diff --git a/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoEditorTestGameplay.cs b/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoEditorTestGameplay.cs index 2422e62571a1..0a7c2e89bca9 100644 --- a/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoEditorTestGameplay.cs +++ b/osu.Game.Rulesets.Taiko.Tests/Editor/TestSceneTaikoEditorTestGameplay.cs @@ -62,7 +62,7 @@ public void TestBasicGameplayTest() }); AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog); - AddStep("save changes", () => DialogOverlay.CurrentDialog!.PerformOkAction()); + AddStep("save changes", () => (DialogOverlay.CurrentDialog as SaveRequiredPopupDialog)!.PerformOkAction()); AddUntilStep("player pushed", () => Stack.CurrentScreen is EditorPlayer); AddUntilStep("wait for return to editor", () => Stack.CurrentScreen is Screens.Edit.Editor); } diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs index ed91fe848ab3..5d008ed278c7 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs @@ -165,7 +165,7 @@ public void TestCreateNewDifficulty([Values] bool sameRuleset) if (sameRuleset) { AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); - AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction()); + AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction()); } AddUntilStep("wait for created", () => @@ -240,7 +240,7 @@ public void TestCreateNewDifficultyWithScrollSpeed_SameRuleset() AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new ManiaRuleset().RulesetInfo)); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); - AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction()); + AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction()); AddUntilStep("wait for created", () => { @@ -386,7 +386,7 @@ public void TestCopyDifficulty() AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo)); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); - AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog!.Buttons.ElementAt(1).TriggerClick()); + AddStep("confirm creation as a copy", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.Buttons.ElementAt(1).TriggerClick()); AddUntilStep("wait for created", () => { @@ -464,7 +464,7 @@ public void TestCopyDifficultyDoesNotChangeCollections() AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo)); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); - AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog!.Buttons.ElementAt(1).TriggerClick()); + AddStep("confirm creation as a copy", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.Buttons.ElementAt(1).TriggerClick()); AddUntilStep("wait for created", () => { @@ -504,7 +504,7 @@ public void TestCreateMultipleNewDifficultiesSucceeds() AddStep("try to create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo)); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); - AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction()); + AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction()); AddUntilStep("wait for created", () => { @@ -542,7 +542,7 @@ public void TestSavingBeatmapFailsWithSameNamedDifficulties([Values] bool sameRu if (sameRuleset) { AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); - AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction()); + AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction()); } AddUntilStep("wait for created", () => @@ -608,7 +608,7 @@ public void TestExitBlockedWhenSavingBeatmapWithSameNamedDifficulties() AddStep("exit", () => Editor.Exit()); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is PromptForSaveDialog); - AddStep("attempt to save", () => DialogOverlay.CurrentDialog!.PerformOkAction()); + AddStep("attempt to save", () => (DialogOverlay.CurrentDialog as PromptForSaveDialog)!.PerformOkAction()); AddAssert("editor is still current", () => Editor.IsCurrentScreen()); } @@ -799,7 +799,7 @@ private void createNewDifficulty() }); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); - AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction()); + AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction()); AddUntilStep("wait for created", () => { diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs index f65a3e67e85b..bb242d44b83e 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs @@ -166,7 +166,7 @@ public void TestCancelGameplayTestWithUnsavedChanges() AddStep("dismiss prompt", () => { - var button = DialogOverlay.CurrentDialog!.Buttons.Last(); + var button = (DialogOverlay.CurrentDialog as SaveRequiredPopupDialog)!.Buttons.Last(); InputManager.MoveMouseTo(button); InputManager.Click(MouseButton.Left); }); @@ -193,7 +193,7 @@ public void TestSaveChangesBeforeGameplayTest() AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog); AddAssert("track stopped", () => !Beatmap.Value.Track.IsRunning); - AddStep("save changes", () => DialogOverlay.CurrentDialog!.PerformOkAction()); + AddStep("save changes", () => (DialogOverlay.CurrentDialog as SaveRequiredPopupDialog)!.PerformOkAction()); EditorPlayer editorPlayer = null; AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null); diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs index 09e8253080be..4c0903c1bf70 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs @@ -339,7 +339,7 @@ public void TestCreateNewDifficultyOnNonExistentBeatmap() }); AddAssert("save dialog displayed", () => Game.ChildrenOfType().Single().CurrentDialog is SaveRequiredPopupDialog); - AddStep("press save", () => Game.ChildrenOfType().Single().CurrentDialog!.PerformOkAction()); + AddStep("press save", () => (Game.ChildrenOfType().Single().CurrentDialog as SaveRequiredPopupDialog)!.PerformOkAction()); AddUntilStep("wait for editor", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.IsLoaded); AddAssert("editor beatmap uses catch ruleset", () => getEditorBeatmap().BeatmapInfo.Ruleset.ShortName == "fruits"); } diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs index d0fc66252e5c..4555d4f597dd 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,7 +698,17 @@ 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", () => { @@ -704,26 +718,26 @@ public void TestChatReport() AddStep("Try to report", () => { - var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); + var btn = this.ChildrenOfType().Single().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().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..c16827c7ff1c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs @@ -260,25 +260,25 @@ public void TestReport() }); AddStep("Try to report", () => { - var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); + var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); 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().Single().ChildrenOfType().Single(); 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 68% rename from osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs rename to osu.Game.Tests/Visual/Online/TestSceneReportDialog.cs index e2e90535d02c..cb0e92c3511a 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneReportDialog.cs @@ -4,9 +4,7 @@ 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; @@ -15,26 +13,23 @@ 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; 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.ChildrenOfType