mirror of
https://github.com/osukey/osukey.git
synced 2025-05-02 12:17:27 +09:00
This test scene passes at e58e1151f3c610d8019e1f1e408a1cb55d204c24 and fails at current master, due to an inadvertent regression caused by e72f103c1759e61c3afa7080f962c639265996c3. 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.
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
// 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 System.Net;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Extensions;
|
|
using osu.Game.Database;
|
|
using osu.Game.Online.API;
|
|
using osu.Game.Online.API.Requests;
|
|
using osu.Game.Tests.Resources;
|
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
|
{
|
|
public partial class TestSceneLocallyModifyingOnlineBeatmaps : EditorSavingTestScene
|
|
{
|
|
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
|
|
|
public override void SetUpSteps()
|
|
{
|
|
CreateInitialBeatmap = () =>
|
|
{
|
|
var importedSet = Game.BeatmapManager.Import(new ImportTask(TestResources.GetTestBeatmapForImport())).GetResultSafely();
|
|
return Game.BeatmapManager.GetWorkingBeatmap(importedSet!.Value.Beatmaps.First());
|
|
};
|
|
|
|
base.SetUpSteps();
|
|
}
|
|
|
|
[Test]
|
|
public void TestLocallyModifyingOnlineBeatmap()
|
|
{
|
|
AddAssert("editor beatmap has online ID", () => EditorBeatmap.BeatmapInfo.OnlineID, () => Is.GreaterThan(0));
|
|
|
|
AddStep("delete first hitobject", () => EditorBeatmap.RemoveAt(0));
|
|
|
|
AddStep("mock online lookup failure", () =>
|
|
{
|
|
dummyAPI.HandleRequest = req =>
|
|
{
|
|
if (req is GetBeatmapRequest)
|
|
{
|
|
req.TriggerFailure(new APIException("Beatmap not found", new WebException("NotFound")));
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
});
|
|
SaveEditor();
|
|
|
|
ReloadEditorToSameBeatmap();
|
|
AddAssert("editor beatmap online ID reset", () => EditorBeatmap.BeatmapInfo.OnlineID, () => Is.EqualTo(-1));
|
|
}
|
|
}
|
|
}
|