From 0e2e44a2f50349e45d370a043fe1b5d4f493bb74 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 9 Jul 2024 20:34:44 +0900 Subject: [PATCH] Add failing test case showing editor save then delete failure --- .../TestSceneBeatmapEditorNavigation.cs | 42 +++++++++++++++++-- osu.Game/Screens/Edit/Editor.cs | 2 +- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs index e3a8e575f8..1ac4bb347b 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs @@ -29,6 +29,35 @@ namespace osu.Game.Tests.Visual.Navigation { public partial class TestSceneBeatmapEditorNavigation : OsuGameTestScene { + [Test] + public void TestSaveThenDeleteActuallyDeletesAtSongSelect() + { + BeatmapSetInfo beatmapSet = null!; + + AddStep("import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely()); + AddStep("retrieve beatmap", () => beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach()); + + AddStep("present beatmap", () => Game.PresentBeatmap(beatmapSet)); + AddUntilStep("wait for song select", + () => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet) + && Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect + && songSelect.IsLoaded); + + AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0))); + AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse); + + makeMetadataChange(); + + AddAssert("save", () => Game.ChildrenOfType().Single().Save()); + + AddStep("delete beatmap", () => Game.BeatmapManager.Delete(beatmapSet)); + + AddStep("exit", () => Game.ChildrenOfType().Single().Exit()); + + AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect + && songSelect.Beatmap.Value is DummyWorkingBeatmap); + } + [Test] public void TestChangeMetadataExitWhileTextboxFocusedPromptsSave() { @@ -47,6 +76,15 @@ namespace osu.Game.Tests.Visual.Navigation AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0))); AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse); + makeMetadataChange(commit: false); + + AddStep("exit", () => Game.ChildrenOfType().Single().Exit()); + + AddUntilStep("save dialog displayed", () => Game.ChildrenOfType().SingleOrDefault()?.CurrentDialog is PromptForSaveDialog); + } + + private void makeMetadataChange(bool commit = true) + { AddStep("change to song setup", () => InputManager.Key(Key.F4)); TextBox textbox = null!; @@ -77,9 +115,7 @@ namespace osu.Game.Tests.Visual.Navigation InputManager.Keys(PlatformAction.Paste); }); - AddStep("exit", () => Game.ChildrenOfType().Single().Exit()); - - AddUntilStep("save dialog displayed", () => Game.ChildrenOfType().SingleOrDefault()?.CurrentDialog is PromptForSaveDialog); + if (commit) AddStep("commit", () => InputManager.Key(Key.Enter)); } [Test] diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index a8a28ef0b8..27d0392b1e 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -521,7 +521,7 @@ namespace osu.Game.Screens.Edit /// Saves the currently edited beatmap. /// /// Whether the save was successful. - protected bool Save() + internal bool Save() { if (!canSave) {