1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 18:43:04 +08:00

Add test coverage of user deleting intro files

This commit is contained in:
Dean Herbert 2025-01-04 15:26:42 +09:00
parent b4698851a3
commit e15978cc65
No known key found for this signature in database
3 changed files with 67 additions and 19 deletions

View File

@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Menus
protected OsuScreenStack IntroStack;
private IntroScreen intro;
protected IntroScreen Intro { get; private set; }
[Cached(typeof(INotificationOverlay))]
private NotificationOverlay notifications;
@ -62,22 +62,9 @@ namespace osu.Game.Tests.Visual.Menus
[Test]
public virtual void TestPlayIntro()
{
AddStep("restart sequence", () =>
{
logo.FinishTransforms();
logo.IsTracking = false;
RestartIntro();
IntroStack?.Expire();
Add(IntroStack = new OsuScreenStack
{
RelativeSizeAxes = Axes.Both,
});
IntroStack.Push(intro = CreateScreen());
});
AddUntilStep("wait for menu", () => intro.DidLoadMenu);
WaitForMenu();
}
[Test]
@ -103,18 +90,18 @@ namespace osu.Game.Tests.Visual.Menus
RelativeSizeAxes = Axes.Both,
});
IntroStack.Push(intro = CreateScreen());
IntroStack.Push(Intro = CreateScreen());
});
AddStep("trigger failure", () =>
{
trackResetDelegate = Scheduler.AddDelayed(() =>
{
intro.Beatmap.Value.Track.Seek(0);
Intro.Beatmap.Value.Track.Seek(0);
}, 0, true);
});
AddUntilStep("wait for menu", () => intro.DidLoadMenu);
WaitForMenu();
if (IntroReliesOnTrack)
AddUntilStep("wait for notification", () => notifications.UnreadCount.Value == 1);
@ -122,6 +109,29 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("uninstall delegate", () => trackResetDelegate?.Cancel());
}
protected void RestartIntro()
{
AddStep("restart sequence", () =>
{
logo.FinishTransforms();
logo.IsTracking = false;
IntroStack?.Expire();
Add(IntroStack = new OsuScreenStack
{
RelativeSizeAxes = Axes.Both,
});
IntroStack.Push(Intro = CreateScreen());
});
}
protected void WaitForMenu()
{
AddUntilStep("wait for menu", () => Intro.DidLoadMenu);
}
protected abstract IntroScreen CreateScreen();
}
}

View File

@ -0,0 +1,37 @@
// 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 NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Screens.Menu;
namespace osu.Game.Tests.Visual.Menus
{
[HeadlessTest]
[TestFixture]
public partial class TestSceneIntroIntegrity : IntroTestScene
{
[Test]
public virtual void TestDeletedFilesRestored()
{
RestartIntro();
WaitForMenu();
AddStep("delete game files unexpectedly", () => LocalStorage.DeleteDirectory("files"));
AddStep("reset game beatmap", () => Dependencies.Get<Bindable<WorkingBeatmap>>().Value = new DummyWorkingBeatmap(Audio, null));
AddStep("invalidate beatmap from cache", () => Dependencies.Get<IWorkingBeatmapCache>().Invalidate(Intro.Beatmap.Value.BeatmapSetInfo));
RestartIntro();
WaitForMenu();
AddUntilStep("wait for track playing", () => Intro.Beatmap.Value.Track is TrackBass trackBass && trackBass.IsRunning);
}
protected override bool IntroReliesOnTrack => true;
protected override IntroScreen CreateScreen() => new IntroTriangles();
}
}

View File

@ -315,6 +315,7 @@ namespace osu.Game
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, API, LocalConfig));
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, realm, API, Audio, Resources, Host, defaultBeatmap, difficultyCache, performOnlineLookups: true));
dependencies.CacheAs<IWorkingBeatmapCache>(BeatmapManager);
dependencies.Cache(BeatmapDownloader = new BeatmapModelDownloader(BeatmapManager, API));
dependencies.Cache(ScoreDownloader = new ScoreModelDownloader(ScoreManager, API));