mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 23:23:52 +08:00
Add test coverage of user deleting intro files
This commit is contained in:
parent
b4698851a3
commit
e15978cc65
@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
|
|
||||||
protected OsuScreenStack IntroStack;
|
protected OsuScreenStack IntroStack;
|
||||||
|
|
||||||
private IntroScreen intro;
|
protected IntroScreen Intro { get; private set; }
|
||||||
|
|
||||||
[Cached(typeof(INotificationOverlay))]
|
[Cached(typeof(INotificationOverlay))]
|
||||||
private NotificationOverlay notifications;
|
private NotificationOverlay notifications;
|
||||||
@ -62,22 +62,9 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[Test]
|
[Test]
|
||||||
public virtual void TestPlayIntro()
|
public virtual void TestPlayIntro()
|
||||||
{
|
{
|
||||||
AddStep("restart sequence", () =>
|
RestartIntro();
|
||||||
{
|
|
||||||
logo.FinishTransforms();
|
|
||||||
logo.IsTracking = false;
|
|
||||||
|
|
||||||
IntroStack?.Expire();
|
WaitForMenu();
|
||||||
|
|
||||||
Add(IntroStack = new OsuScreenStack
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
});
|
|
||||||
|
|
||||||
IntroStack.Push(intro = CreateScreen());
|
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep("wait for menu", () => intro.DidLoadMenu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -103,18 +90,18 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
});
|
});
|
||||||
|
|
||||||
IntroStack.Push(intro = CreateScreen());
|
IntroStack.Push(Intro = CreateScreen());
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("trigger failure", () =>
|
AddStep("trigger failure", () =>
|
||||||
{
|
{
|
||||||
trackResetDelegate = Scheduler.AddDelayed(() =>
|
trackResetDelegate = Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
intro.Beatmap.Value.Track.Seek(0);
|
Intro.Beatmap.Value.Track.Seek(0);
|
||||||
}, 0, true);
|
}, 0, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for menu", () => intro.DidLoadMenu);
|
WaitForMenu();
|
||||||
|
|
||||||
if (IntroReliesOnTrack)
|
if (IntroReliesOnTrack)
|
||||||
AddUntilStep("wait for notification", () => notifications.UnreadCount.Value == 1);
|
AddUntilStep("wait for notification", () => notifications.UnreadCount.Value == 1);
|
||||||
@ -122,6 +109,29 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
AddStep("uninstall delegate", () => trackResetDelegate?.Cancel());
|
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();
|
protected abstract IntroScreen CreateScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
osu.Game.Tests/Visual/Menus/TestSceneIntroIntegrity.cs
Normal file
37
osu.Game.Tests/Visual/Menus/TestSceneIntroIntegrity.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
@ -315,6 +315,7 @@ namespace osu.Game
|
|||||||
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, API, LocalConfig));
|
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.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(BeatmapDownloader = new BeatmapModelDownloader(BeatmapManager, API));
|
||||||
dependencies.Cache(ScoreDownloader = new ScoreModelDownloader(ScoreManager, API));
|
dependencies.Cache(ScoreDownloader = new ScoreModelDownloader(ScoreManager, API));
|
||||||
|
Loading…
Reference in New Issue
Block a user