2023-04-29 01:36:31 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Screens.Edit;
|
|
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Navigation
|
|
|
|
|
{
|
2023-04-29 09:34:50 +08:00
|
|
|
|
public partial class TestSceneBeatmapEditorNavigation : OsuGameTestScene
|
2023-04-29 01:36:31 +08:00
|
|
|
|
{
|
2023-04-29 10:05:10 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// When entering the editor, a new beatmap is created as part of the asynchronous load process.
|
|
|
|
|
/// This test ensures that in the case of an early exit from the editor (ie. while it's still loading)
|
|
|
|
|
/// doesn't leave a dangling beatmap behind.
|
|
|
|
|
///
|
|
|
|
|
/// This may not fail 100% due to timing, but has a pretty high chance of hitting a failure so works well enough
|
|
|
|
|
/// as a test.
|
|
|
|
|
/// </summary>
|
2023-04-29 01:36:31 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestCancelNavigationToEditor()
|
|
|
|
|
{
|
2023-04-29 09:49:25 +08:00
|
|
|
|
BeatmapSetInfo[] beatmapSets = null!;
|
2023-04-29 01:36:31 +08:00
|
|
|
|
|
2023-04-29 10:01:29 +08:00
|
|
|
|
AddStep("Fetch initial beatmaps", () => beatmapSets = allBeatmapSets());
|
2023-04-29 01:36:31 +08:00
|
|
|
|
|
2023-04-29 09:49:25 +08:00
|
|
|
|
AddStep("Set current beatmap to default", () => Game.Beatmap.SetDefault());
|
2023-04-29 01:36:31 +08:00
|
|
|
|
|
2023-04-29 09:49:25 +08:00
|
|
|
|
AddStep("Push editor loader", () => Game.ScreenStack.Push(new EditorLoader()));
|
|
|
|
|
AddUntilStep("Wait for loader current", () => Game.ScreenStack.CurrentScreen is EditorLoader);
|
|
|
|
|
AddStep("Close editor while loading", () => Game.ScreenStack.CurrentScreen.Exit());
|
2023-04-29 02:23:00 +08:00
|
|
|
|
|
2023-04-29 09:49:25 +08:00
|
|
|
|
AddUntilStep("Wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
|
2023-04-29 10:01:29 +08:00
|
|
|
|
AddAssert("Check no new beatmaps were made", () => allBeatmapSets().SequenceEqual(beatmapSets));
|
2023-04-29 01:36:31 +08:00
|
|
|
|
|
2023-04-29 10:01:29 +08:00
|
|
|
|
BeatmapSetInfo[] allBeatmapSets() => Game.Realm.Run(realm => realm.All<BeatmapSetInfo>().Where(x => !x.DeletePending).ToArray());
|
2023-04-29 01:36:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|