mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Test staying on same difficulty due to unsaved changes
This commit is contained in:
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components.Menus;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
@ -35,8 +36,9 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("set current beatmap", () => Beatmap.Value = beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First()));
|
||||
AddStep("push loader", () => Stack.Push(new EditorLoader()));
|
||||
|
||||
AddUntilStep("wait for editor to load", () => Stack.CurrentScreen is Editor);
|
||||
AddUntilStep("wait for editor push", () => Stack.CurrentScreen is Editor);
|
||||
AddStep("store editor", () => editor = (Editor)Stack.CurrentScreen);
|
||||
AddUntilStep("wait for editor to load", () => editor.IsLoaded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -53,6 +55,39 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("stack empty", () => Stack.CurrentScreen == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPreventSwitchDueToUnsavedChanges()
|
||||
{
|
||||
BeatmapInfo targetDifficulty = null;
|
||||
PromptForSaveDialog saveDialog = null;
|
||||
|
||||
AddStep("remove first hitobject", () =>
|
||||
{
|
||||
var editorBeatmap = editor.ChildrenOfType<EditorBeatmap>().Single();
|
||||
editorBeatmap.RemoveAt(0);
|
||||
});
|
||||
|
||||
AddStep("set target difficulty", () => targetDifficulty = importedBeatmapSet.Beatmaps.Last(beatmap => !beatmap.Equals(Beatmap.Value.BeatmapInfo)));
|
||||
switchToDifficulty(() => targetDifficulty);
|
||||
|
||||
AddUntilStep("prompt for save dialog shown", () =>
|
||||
{
|
||||
saveDialog = this.ChildrenOfType<PromptForSaveDialog>().Single();
|
||||
return saveDialog != null;
|
||||
});
|
||||
AddStep("continue editing", () =>
|
||||
{
|
||||
var continueButton = saveDialog.ChildrenOfType<PopupDialogCancelButton>().Last();
|
||||
continueButton.TriggerClick();
|
||||
});
|
||||
|
||||
confirmEditingBeatmap(() => importedBeatmapSet.Beatmaps.First());
|
||||
|
||||
AddRepeatStep("exit editor forcefully", () => Stack.Exit(), 2);
|
||||
// ensure editor loader didn't resume.
|
||||
AddAssert("stack empty", () => Stack.CurrentScreen == null);
|
||||
}
|
||||
|
||||
private void switchToDifficulty(Func<BeatmapInfo> difficulty)
|
||||
{
|
||||
AddUntilStep("wait for menubar to load", () => editor.ChildrenOfType<EditorMenuBar>().Any());
|
||||
|
Reference in New Issue
Block a user