diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs index d0fc66252e5c..8b05fa8f7a0a 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs @@ -13,13 +13,14 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Framework.Logging; using osu.Framework.Testing; using osu.Game.Configuration; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; @@ -40,6 +41,7 @@ namespace osu.Game.Tests.Visual.Online public partial class TestSceneChatOverlay : OsuManualInputManagerTestScene { private TestChatOverlay chatOverlay; + private DialogOverlay dialogOverlay; private ChannelManager channelManager; private readonly APIUser testUser = new APIUser { Username = "test user", Id = 5071479 }; @@ -72,11 +74,13 @@ public void SetUp() => Schedule(() => CachedDependencies = new (Type, object)[] { (typeof(ChannelManager), channelManager = new ChannelManager(API)), + (typeof(IDialogOverlay), dialogOverlay = new DialogOverlay()) }, Children = new Drawable[] { channelManager, chatOverlay = new TestChatOverlay(), + dialogOverlay, }, }; }); @@ -694,36 +698,46 @@ public void TestChatReport() }; }); - AddStep("Show report popover", () => this.ChildrenOfType().First().ShowPopover()); + AddStep("Open context menu", () => + { + var username = this.ChildrenOfType().First().ChildrenOfType().First(); + InputManager.MoveMouseTo(username); + InputManager.Click(MouseButton.Right); + }); + AddStep("Select report option", () => + { + InputManager.MoveMouseTo(this.ChildrenOfType().First(m => m.Item.Text.ToString() == "Report")); + InputManager.Click(MouseButton.Left); + }); AddStep("Set report reason to other", () => { - var reason = this.ChildrenOfType>().Single(); + var reason = this.ChildrenOfType>().Single(); reason.Current.Value = ChatReportReason.Other; }); AddStep("Try to report", () => { - var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); + var btn = this.ChildrenOfType().Single(); InputManager.MoveMouseTo(btn); InputManager.Click(MouseButton.Left); }); - AddAssert("Nothing happened", () => this.ChildrenOfType().Any()); + AddAssert("Nothing happened", () => this.ChildrenOfType().Any()); AddStep("Set report data", () => { - var field = this.ChildrenOfType().Single().ChildrenOfType().First(); + var field = this.ChildrenOfType().Single().ChildrenOfType().First(); field.Current.Value = "test other"; }); AddStep("Try to report", () => { - var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); + var btn = this.ChildrenOfType().Single(); InputManager.MoveMouseTo(btn); InputManager.Click(MouseButton.Left); }); - AddUntilStep("Overlay closed", () => !this.ChildrenOfType().Any()); + AddUntilStep("Overlay closed", () => !this.ChildrenOfType().Any()); AddStep("Complete request", () => requestLock.Set()); AddUntilStep("Request sent", () => request != null); AddUntilStep("Info message displayed", () => channelManager.CurrentChannel.Value.Messages.Last(), () => Is.InstanceOf(typeof(InfoMessage))); diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs index 56b161db2a2a..30da8be4361b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs @@ -255,30 +255,30 @@ public void TestReport() }); AddStep("Set reason to other", () => { - var reason = this.ChildrenOfType>().Single(); + var reason = this.ChildrenOfType>().Single(); reason.Current.Value = CommentReportReason.Other; }); AddStep("Try to report", () => { - var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); + var btn = this.ChildrenOfType().First(); InputManager.MoveMouseTo(btn); InputManager.Click(MouseButton.Left); }); AddWaitStep("Wait", 3); - AddAssert("Nothing happened", () => this.ChildrenOfType().Any()); + AddAssert("Nothing happened", () => this.ChildrenOfType().Any()); AddStep("Add comment", () => { - var field = this.ChildrenOfType().Single().ChildrenOfType().First(); + var field = this.ChildrenOfType().Single().ChildrenOfType().First(); field.Current.Value = report_text; }); AddStep("Try to report", () => { - var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); + var btn = this.ChildrenOfType().First(); InputManager.MoveMouseTo(btn); InputManager.Click(MouseButton.Left); }); AddWaitStep("Wait", 3); - AddAssert("Overlay closed", () => !this.ChildrenOfType().Any()); + AddAssert("Overlay closed", () => !this.ChildrenOfType().Any()); AddAssert("Loading spinner shown", () => targetComment.ChildrenOfType().Any(d => d.IsPresent)); AddStep("Complete request", () => requestLock.Set()); AddUntilStep("Request sent", () => request != null); diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentReportButton.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentReportButton.cs index d2e73b8673aa..5200c6967ab0 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentReportButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentReportButton.cs @@ -1,21 +1,30 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Extensions; +using System; +using System.Linq; using osu.Framework.Graphics; -using osu.Framework.Graphics.Cursor; using osu.Framework.Testing; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Overlays; using osu.Game.Overlays.Comments; using osu.Game.Tests.Visual.UserInterface; using osuTK; +using osuTK.Input; namespace osu.Game.Tests.Visual.Online { public partial class TestSceneCommentReportButton : ThemeComparisonTestScene { + private DialogOverlay dialogOverlay = null!; + + public TestSceneCommentReportButton() + : base(false) + { + } + [SetUpSteps] public void SetUpSteps() { @@ -32,15 +41,27 @@ public void SetUpSteps() }); } - protected override Drawable CreateContent() => new PopoverContainer + protected override Drawable CreateContent() => new DependencyProvidingContainer { RelativeSizeAxes = Axes.Both, - Child = new CommentReportButton(new Comment { User = new APIUser { Username = "Someone" } }) + CachedDependencies = new (Type, object)[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Scale = new Vector2(2f), - }.With(b => Schedule(b.ShowPopover)), - }; + (typeof(IDialogOverlay), dialogOverlay = new DialogOverlay()), + }, + Children = new Drawable[] + { + new CommentReportButton(new Comment { User = new APIUser { Username = "Someone" } }) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(2f), + }, + dialogOverlay, + } + }.With(c => c.OnLoadComplete += _ => + { + InputManager.MoveMouseTo(c.ChildrenOfType().First()); + InputManager.Click(MouseButton.Left); + }); } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs b/osu.Game.Tests/Visual/Online/TestSceneReportDialog.cs similarity index 59% rename from osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs rename to osu.Game.Tests/Visual/Online/TestSceneReportDialog.cs index e2e90535d02c..5d31b896419b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneReportDialog.cs @@ -4,37 +4,32 @@ using System.Linq; using System.Net.Http; using NUnit.Framework; -using osu.Framework.Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Overlays; using osu.Game.Overlays.Chat; +using osu.Game.Overlays.Settings; +using osu.Game.Resources.Localisation.Web; namespace osu.Game.Tests.Visual.Online { - public partial class TestSceneReportPopover : OsuTestScene + public partial class TestSceneReportDialog : OsuTestScene { - private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; + private DialogOverlay dialogOverlay = null!; - private ReportPopoverContainer popover = null!; + private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; [SetUpSteps] public void SetUp() { - AddStep("create popover", () => + AddStep("create dialog overlay", () => { - Child = new PopoverContainer - { - RelativeSizeAxes = Axes.Both, - Child = popover = new ReportPopoverContainer(), - }; + Child = dialogOverlay = new DialogOverlay(); }); } @@ -56,16 +51,23 @@ public void TestSuccess() return false; }; }); - AddStep("show popover", () => popover.ShowPopover()); + AddStep("push dialog", () => dialogOverlay.Push(new TestReportDialog("test"))); + + AddStep("try to report", () => dialogOverlay.CurrentDialog!.PerformAction()); + AddWaitStep("wait", 3); + AddAssert("nothing happened", () => dialogOverlay.CurrentDialog!.ChildrenOfType().First().IsReadOnly, () => Is.False); + AddStep("input reason", () => this.ChildrenOfType().First().Text = "reason"); - AddStep("send report", () => this.ChildrenOfType