Add failing test case covering online ID reset on save

This test scene passes at e58e1151f3 and
fails at current master, due to an inadvertent regression caused by
e72f103c17.

As it turns out, the online lookup flow that was causing UI thread
freezes when saving beatmaps in the editor, was also responsible for
resetting the online ID of locally-modified beatmaps if online lookup
failed.
This commit is contained in:
Bartłomiej Dach
2023-05-01 17:13:09 +02:00
parent 5c066c40b1
commit 8ab3a87b13
2 changed files with 80 additions and 3 deletions

View File

@ -3,9 +3,12 @@
#nullable disable
using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Input;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Setup;
@ -24,18 +27,27 @@ namespace osu.Game.Tests.Visual
protected EditorBeatmap EditorBeatmap => (EditorBeatmap)Editor.Dependencies.Get(typeof(EditorBeatmap));
[CanBeNull]
protected Func<WorkingBeatmap> CreateInitialBeatmap { get; set; }
[SetUpSteps]
public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("set default beatmap", () => Game.Beatmap.SetDefault());
if (CreateInitialBeatmap == null)
AddStep("set default beatmap", () => Game.Beatmap.SetDefault());
else
{
AddStep("set test beatmap", () => Game.Beatmap.Value = CreateInitialBeatmap?.Invoke());
}
PushAndConfirm(() => new EditorLoader());
AddUntilStep("wait for editor load", () => Editor?.IsLoaded == true);
AddUntilStep("wait for metadata screen load", () => Editor.ChildrenOfType<MetadataSection>().FirstOrDefault()?.IsLoaded == true);
if (CreateInitialBeatmap == null)
AddUntilStep("wait for metadata screen load", () => Editor.ChildrenOfType<MetadataSection>().FirstOrDefault()?.IsLoaded == true);
// We intentionally switch away from the metadata screen, else there is a feedback loop with the textbox handling which causes metadata changes below to get overwritten.
@ -50,6 +62,14 @@ namespace osu.Game.Tests.Visual
protected void ReloadEditorToSameBeatmap()
{
Guid beatmapSetGuid = Guid.Empty;
Guid beatmapGuid = Guid.Empty;
AddStep("Store beatmap GUIDs", () =>
{
beatmapSetGuid = EditorBeatmap.BeatmapInfo.BeatmapSet!.ID;
beatmapGuid = EditorBeatmap.BeatmapInfo.ID;
});
AddStep("Exit", () => InputManager.Key(Key.Escape));
AddUntilStep("Wait for main menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
@ -59,7 +79,8 @@ namespace osu.Game.Tests.Visual
PushAndConfirm(() => songSelect = new PlaySongSelect());
AddUntilStep("wait for carousel load", () => songSelect.BeatmapSetsLoaded);
AddUntilStep("Wait for beatmap selected", () => !Game.Beatmap.IsDefault);
AddStep("Present same beatmap", () => Game.PresentBeatmap(Game.BeatmapManager.QueryBeatmapSet(set => set.ID == beatmapSetGuid)!.Value, beatmap => beatmap.ID == beatmapGuid));
AddUntilStep("Wait for beatmap selected", () => Game.Beatmap.Value.BeatmapInfo.ID == beatmapGuid);
AddStep("Open options", () => InputManager.Key(Key.F3));
AddStep("Enter editor", () => InputManager.Key(Key.Number5));