1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 06:27:27 +08:00
osu-lazer/osu.Game.Tests/Visual/Menus/TestSceneIntroMusicActionHandling.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.8 KiB
C#
Raw Normal View History

2024-01-06 17:29:41 +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.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Input.Bindings;
using osu.Game.Screens.Menu;
namespace osu.Game.Tests.Visual.Menus
{
2024-01-08 19:52:14 +08:00
public partial class TestSceneIntroMusicActionHandling : OsuGameTestScene
2024-01-06 17:29:41 +08:00
{
2024-01-08 19:52:14 +08:00
private GlobalActionContainer globalActionContainer => Game.ChildrenOfType<GlobalActionContainer>().First();
2024-01-06 17:29:41 +08:00
2024-01-08 19:52:14 +08:00
public override void SetUpSteps()
{
CreateNewGame();
// we do not want to progress to main menu immediately, hence the override and lack of `ConfirmAtMainMenu()` call here.
}
2024-01-06 17:29:41 +08:00
[Test]
public void TestPauseDuringIntro()
{
2024-01-08 19:52:14 +08:00
AddUntilStep("Wait for music", () => Game?.MusicController.IsPlaying == true);
2024-01-06 17:29:41 +08:00
2024-01-08 19:52:23 +08:00
// Check that pause doesn't work during intro sequence.
2024-01-06 17:29:41 +08:00
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
2024-01-08 19:52:14 +08:00
AddAssert("Still playing before menu", () => Game?.MusicController.IsPlaying == true);
AddUntilStep("Wait for main menu", () => Game?.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
2024-01-06 17:29:41 +08:00
// Check that toggling after intro still works.
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
2024-01-08 19:52:14 +08:00
AddUntilStep("Music paused", () => Game?.MusicController.IsPlaying == false && Game?.MusicController.UserPauseRequested == true);
2024-01-06 17:29:41 +08:00
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
2024-01-08 19:52:14 +08:00
AddUntilStep("Music resumed", () => Game?.MusicController.IsPlaying == true && Game?.MusicController.UserPauseRequested == false);
2024-01-06 17:29:41 +08:00
}
}
}