mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 07:22:54 +08:00
Add failing test case showing editor save then delete failure
This commit is contained in:
parent
920c0e4d25
commit
0e2e44a2f5
@ -29,6 +29,35 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
{
|
{
|
||||||
public partial class TestSceneBeatmapEditorNavigation : OsuGameTestScene
|
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<Editor>().Single().Save());
|
||||||
|
|
||||||
|
AddStep("delete beatmap", () => Game.BeatmapManager.Delete(beatmapSet));
|
||||||
|
|
||||||
|
AddStep("exit", () => Game.ChildrenOfType<Editor>().Single().Exit());
|
||||||
|
|
||||||
|
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect
|
||||||
|
&& songSelect.Beatmap.Value is DummyWorkingBeatmap);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestChangeMetadataExitWhileTextboxFocusedPromptsSave()
|
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)));
|
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);
|
AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse);
|
||||||
|
|
||||||
|
makeMetadataChange(commit: false);
|
||||||
|
|
||||||
|
AddStep("exit", () => Game.ChildrenOfType<Editor>().Single().Exit());
|
||||||
|
|
||||||
|
AddUntilStep("save dialog displayed", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault()?.CurrentDialog is PromptForSaveDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeMetadataChange(bool commit = true)
|
||||||
|
{
|
||||||
AddStep("change to song setup", () => InputManager.Key(Key.F4));
|
AddStep("change to song setup", () => InputManager.Key(Key.F4));
|
||||||
|
|
||||||
TextBox textbox = null!;
|
TextBox textbox = null!;
|
||||||
@ -77,9 +115,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
InputManager.Keys(PlatformAction.Paste);
|
InputManager.Keys(PlatformAction.Paste);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("exit", () => Game.ChildrenOfType<Editor>().Single().Exit());
|
if (commit) AddStep("commit", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
AddUntilStep("save dialog displayed", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault()?.CurrentDialog is PromptForSaveDialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -521,7 +521,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// Saves the currently edited beatmap.
|
/// Saves the currently edited beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Whether the save was successful.</returns>
|
/// <returns>Whether the save was successful.</returns>
|
||||||
protected bool Save()
|
internal bool Save()
|
||||||
{
|
{
|
||||||
if (!canSave)
|
if (!canSave)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user