mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Add full editor save test coverage
This commit is contained in:
parent
a77db5d837
commit
e54502eef1
@ -7,6 +7,7 @@ using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -17,6 +18,7 @@ using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.GameplayTest;
|
||||
using osu.Game.Screens.Edit.Setup;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
@ -27,6 +29,59 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
public partial class TestSceneBeatmapEditorNavigation : OsuGameTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestChangeMetadataExitWhileTextboxFocusedPromptsSave()
|
||||
{
|
||||
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("switch ruleset", () => Game.Ruleset.Value = new ManiaRuleset().RulesetInfo);
|
||||
|
||||
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);
|
||||
|
||||
AddStep("change to song setup", () => InputManager.Key(Key.F4));
|
||||
|
||||
TextBox textbox = null!;
|
||||
|
||||
AddUntilStep("wait for metadata section", () =>
|
||||
{
|
||||
var t = Game.ChildrenOfType<MetadataSection>().SingleOrDefault().ChildrenOfType<TextBox>().FirstOrDefault();
|
||||
|
||||
if (t == null)
|
||||
return false;
|
||||
|
||||
textbox = t;
|
||||
return true;
|
||||
});
|
||||
|
||||
AddStep("focus textbox", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(textbox);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("simulate changing textbox", () =>
|
||||
{
|
||||
// Can't simulate text input but this should work.
|
||||
InputManager.Keys(PlatformAction.SelectAll);
|
||||
InputManager.Keys(PlatformAction.Copy);
|
||||
InputManager.Keys(PlatformAction.Paste);
|
||||
InputManager.Keys(PlatformAction.Paste);
|
||||
});
|
||||
|
||||
AddStep("exit", () => Game.ChildrenOfType<Editor>().Single().Exit());
|
||||
|
||||
AddAssert("save dialog displayed", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is PromptForSaveDialog);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEditorGameplayTestAlwaysUsesOriginalRuleset()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user