1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 07:32:55 +08:00

Add test coverage of intro fail scenario

This commit is contained in:
Dean Herbert 2022-01-30 18:51:15 +09:00
parent 4132f67629
commit 1dbcb5ab63

View File

@ -5,6 +5,8 @@ using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Threading;
using osu.Game.Overlays;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osuTK; using osuTK;
@ -22,6 +24,11 @@ namespace osu.Game.Tests.Visual.Menus
private IntroScreen intro; private IntroScreen intro;
[Cached]
private NotificationOverlay notifications;
private ScheduledDelegate trackResetDelegate;
protected IntroTestScene() protected IntroTestScene()
{ {
Children = new Drawable[] Children = new Drawable[]
@ -38,6 +45,11 @@ namespace osu.Game.Tests.Visual.Menus
RelativePositionAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Depth = float.MinValue, Depth = float.MinValue,
Position = new Vector2(0.5f), Position = new Vector2(0.5f),
},
notifications = new NotificationOverlay
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
} }
}; };
} }
@ -63,6 +75,39 @@ namespace osu.Game.Tests.Visual.Menus
AddUntilStep("wait for menu", () => intro.DidLoadMenu); AddUntilStep("wait for menu", () => intro.DidLoadMenu);
} }
[Test]
public virtual void TestPlayIntroWithFailingAudioDevice()
{
AddStep("hide notifications", () => notifications.Hide());
AddStep("restart sequence", () =>
{
logo.FinishTransforms();
logo.IsTracking = false;
IntroStack?.Expire();
Add(IntroStack = new OsuScreenStack
{
RelativeSizeAxes = Axes.Both,
});
IntroStack.Push(intro = CreateScreen());
});
AddStep("trigger failure", () =>
{
trackResetDelegate = Scheduler.AddDelayed(() =>
{
intro.Beatmap.Value.Track.Seek(0);
}, 0, true);
});
AddUntilStep("wait for menu", () => intro.DidLoadMenu);
AddUntilStep("wait for notification", () => notifications.UnreadCount.Value == 1);
AddStep("uninstall delegate", () => trackResetDelegate?.Cancel());
}
protected abstract IntroScreen CreateScreen(); protected abstract IntroScreen CreateScreen();
} }
} }