From d009cd8422780247f035bb586851790bac37f6b5 Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Thu, 9 Mar 2023 22:45:33 +0900 Subject: [PATCH] test --- .../UserInterface/TestSceneModPresetColumn.cs | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModPresetColumn.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModPresetColumn.cs index d6065374ac..b67f67db2b 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModPresetColumn.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModPresetColumn.cs @@ -327,6 +327,32 @@ namespace osu.Game.Tests.Visual.UserInterface }); AddUntilStep("items loaded", () => modPresetColumn.IsLoaded && modPresetColumn.ItemsLoaded); + + AddStep("right click first panel", () => + { + var panel = this.ChildrenOfType().First(); + InputManager.MoveMouseTo(panel); + InputManager.Click(MouseButton.Right); + }); + AddUntilStep("wait for context menu", () => this.ChildrenOfType().Any()); + AddStep("click edit", () => + { + var editItem = this.ChildrenOfType().ElementAt(0); + InputManager.MoveMouseTo(editItem); + InputManager.Click(MouseButton.Left); + }); + + OsuPopover? popover = null; + AddUntilStep("wait for popover", () => (popover = this.ChildrenOfType().FirstOrDefault()) != null); + AddStep("click use current mods", () => + { + InputManager.MoveMouseTo(popover.ChildrenOfType().ElementAt(0)); + InputManager.Click(MouseButton.Left); + }); + AddWaitStep("wait some", 3); + AddUntilStep("popover not closed", () => this.ChildrenOfType().Any()); + AddAssert("present mod not changed", () => this.ChildrenOfType().First().Preset.Value.Mods.Count == 1); + AddStep("select mods", () => SelectedMods.Value = mods); AddStep("right click first panel", () => { @@ -343,14 +369,57 @@ namespace osu.Game.Tests.Visual.UserInterface InputManager.Click(MouseButton.Left); }); - OsuPopover? popover = null; AddUntilStep("wait for popover", () => (popover = this.ChildrenOfType().FirstOrDefault()) != null); AddStep("click use current mods", () => { InputManager.MoveMouseTo(popover.ChildrenOfType().ElementAt(0)); InputManager.Click(MouseButton.Left); }); - AddUntilStep("popover not closed", () => this.ChildrenOfType().Any()); + AddWaitStep("wait some", 3); + AddUntilStep("popover closed", () => !this.ChildrenOfType().Any()); + AddAssert("present mod is changed", () => this.ChildrenOfType().First().Preset.Value.Mods.Count == 2); + } + + [Test] + public void TestEditPresetModInContextMenu() + { + ModPresetColumn modPresetColumn = null!; + var mods = new Mod[] { new OsuModHidden(), new OsuModHardRock() }; + + AddStep("clear mods", () => SelectedMods.Value = Array.Empty()); + AddStep("create content", () => Child = modPresetColumn = new ModPresetColumn + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }); + + AddUntilStep("items loaded", () => modPresetColumn.IsLoaded && modPresetColumn.ItemsLoaded); + + AddStep("right click first panel", () => + { + var panel = this.ChildrenOfType().First(); + InputManager.MoveMouseTo(panel); + InputManager.Click(MouseButton.Right); + }); + AddUntilStep("wait for context menu", () => this.ChildrenOfType().Any()); + AddAssert("No Use Current Mods", () => this.ChildrenOfType().Count() == 2); + + AddStep("select mods", () => SelectedMods.Value = mods); + AddStep("right click first panel", () => + { + var panel = this.ChildrenOfType().First(); + InputManager.MoveMouseTo(panel); + InputManager.Click(MouseButton.Right); + }); + + AddUntilStep("wait for context menu", () => this.ChildrenOfType().Any()); + AddAssert("Have Use Current Mods", () => this.ChildrenOfType().Count() == 3); + AddStep("Click Use Current Mods", () => + { + var editItem = this.ChildrenOfType().ElementAt(1); + InputManager.MoveMouseTo(editItem); + InputManager.Click(MouseButton.Left); + }); AddAssert("present mod is changed", () => this.ChildrenOfType().First().Preset.Value.Mods.Count == 2); }