2019-07-09 17:15:31 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-07-09 17:15:31 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-01-30 17:51:15 +08:00
|
|
|
using osu.Framework.Threading;
|
|
|
|
using osu.Game.Overlays;
|
2019-07-09 17:15:31 +08:00
|
|
|
using osu.Game.Screens;
|
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Menus
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public abstract partial class IntroTestScene : OsuTestScene
|
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
private OsuLogo logo;
|
|
|
|
|
2022-01-30 17:59:18 +08:00
|
|
|
protected abstract bool IntroReliesOnTrack { get; }
|
|
|
|
|
2020-06-29 08:16:19 +08:00
|
|
|
protected OsuScreenStack IntroStack;
|
|
|
|
|
2021-10-07 17:39:48 +08:00
|
|
|
private IntroScreen intro;
|
|
|
|
|
2022-04-18 18:59:57 +08:00
|
|
|
[Cached(typeof(INotificationOverlay))]
|
2022-01-30 17:51:15 +08:00
|
|
|
private NotificationOverlay notifications;
|
|
|
|
|
|
|
|
private ScheduledDelegate trackResetDelegate;
|
|
|
|
|
2019-07-09 17:15:31 +08:00
|
|
|
protected IntroTestScene()
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Depth = float.MaxValue,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
},
|
|
|
|
logo = new OsuLogo
|
|
|
|
{
|
|
|
|
Alpha = 0,
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
Depth = float.MinValue,
|
|
|
|
Position = new Vector2(0.5f),
|
2022-01-30 17:51:15 +08:00
|
|
|
},
|
|
|
|
notifications = new NotificationOverlay
|
|
|
|
{
|
2022-08-31 11:46:54 +08:00
|
|
|
Depth = float.MinValue,
|
2022-01-30 17:51:15 +08:00
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
2019-07-09 17:15:31 +08:00
|
|
|
}
|
|
|
|
};
|
2021-10-07 17:39:48 +08:00
|
|
|
}
|
2019-07-09 17:15:31 +08:00
|
|
|
|
2021-10-07 17:39:48 +08:00
|
|
|
[Test]
|
2021-10-07 18:58:34 +08:00
|
|
|
public virtual void TestPlayIntro()
|
2021-10-07 17:39:48 +08:00
|
|
|
{
|
2019-07-09 17:15:31 +08:00
|
|
|
AddStep("restart sequence", () =>
|
|
|
|
{
|
2019-07-09 17:51:10 +08:00
|
|
|
logo.FinishTransforms();
|
2019-07-09 17:59:56 +08:00
|
|
|
logo.IsTracking = false;
|
|
|
|
|
2020-06-29 08:16:19 +08:00
|
|
|
IntroStack?.Expire();
|
2019-07-09 17:51:10 +08:00
|
|
|
|
2020-06-29 08:16:19 +08:00
|
|
|
Add(IntroStack = new OsuScreenStack
|
2019-07-09 17:15:31 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
});
|
2020-01-31 18:10:44 +08:00
|
|
|
|
2021-10-07 17:39:48 +08:00
|
|
|
IntroStack.Push(intro = CreateScreen());
|
2019-07-09 17:15:31 +08:00
|
|
|
});
|
2020-03-25 14:12:19 +08:00
|
|
|
|
2021-10-07 17:39:48 +08:00
|
|
|
AddUntilStep("wait for menu", () => intro.DidLoadMenu);
|
2019-07-09 17:15:31 +08:00
|
|
|
}
|
|
|
|
|
2022-01-30 17:51:15 +08:00
|
|
|
[Test]
|
|
|
|
public virtual void TestPlayIntroWithFailingAudioDevice()
|
|
|
|
{
|
2022-08-31 11:46:54 +08:00
|
|
|
AddStep("reset notifications", () =>
|
|
|
|
{
|
|
|
|
notifications.Show();
|
|
|
|
notifications.Hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("wait for no notifications", () => notifications.UnreadCount.Value, () => Is.EqualTo(0));
|
|
|
|
|
2022-01-30 17:51:15 +08:00
|
|
|
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);
|
2022-01-30 17:59:18 +08:00
|
|
|
|
|
|
|
if (IntroReliesOnTrack)
|
|
|
|
AddUntilStep("wait for notification", () => notifications.UnreadCount.Value == 1);
|
2022-01-30 17:51:15 +08:00
|
|
|
|
|
|
|
AddStep("uninstall delegate", () => trackResetDelegate?.Cancel());
|
|
|
|
}
|
|
|
|
|
2021-10-07 17:39:48 +08:00
|
|
|
protected abstract IntroScreen CreateScreen();
|
2019-07-09 17:15:31 +08:00
|
|
|
}
|
|
|
|
}
|