diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
index ab519360ac..eb54eca0cb 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
@@ -7,10 +7,15 @@ using System.Linq;
using System.Threading;
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Screens;
+using osu.Game.Graphics.Containers;
+using osu.Game.Overlays;
+using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring;
@@ -18,25 +23,41 @@ using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.PlayerSettings;
+using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestScenePlayerLoader : ManualInputManagerTestScene
{
private TestPlayerLoader loader;
- private OsuScreenStack stack;
+ private TestPlayerLoaderContainer container;
+ private TestPlayer player;
- [SetUp]
- public void Setup() => Schedule(() =>
+ [Resolved]
+ private AudioManager audioManager { get; set; }
+
+ ///
+ /// Sets the input manager child to a new test player loader container instance.
+ ///
+ /// If the test player should behave like the production one.
+ /// An action to run before player load but after bindable leases are returned.
+ public void ResetPlayer(bool interactive, Action beforeLoadAction = null)
{
- InputManager.Child = stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both };
+ audioManager.Volume.SetDefault();
+
+ InputManager.Clear();
+
+ beforeLoadAction?.Invoke();
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
- });
+
+ InputManager.Child = container = new TestPlayerLoaderContainer(
+ loader = new TestPlayerLoader(() => player = new TestPlayer(interactive, interactive)));
+ }
[Test]
public void TestBlockLoadViaMouseMovement()
{
- AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => new TestPlayer(false, false))));
+ AddStep("load dummy beatmap", () => ResetPlayer(false));
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddRepeatStep("move mouse", () => InputManager.MoveMouseTo(loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft + (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft) * RNG.NextSingle()), 20);
AddAssert("loader still active", () => loader.IsCurrentScreen());
@@ -46,16 +67,17 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestLoadContinuation()
{
- Player player = null;
SlowLoadPlayer slowPlayer = null;
- AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer(false, false))));
+ AddStep("load dummy beatmap", () => ResetPlayer(false));
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
AddStep("load slow dummy beatmap", () =>
{
- stack.Push(loader = new TestPlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
+ InputManager.Child = container = new TestPlayerLoaderContainer(
+ loader = new TestPlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
+
Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000);
});
@@ -65,16 +87,11 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestModReinstantiation()
{
- TestPlayer player = null;
TestMod gameMod = null;
TestMod playerMod1 = null;
TestMod playerMod2 = null;
- AddStep("load player", () =>
- {
- Mods.Value = new[] { gameMod = new TestMod() };
- stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer()));
- });
+ AddStep("load player", () => { ResetPlayer(true, () => Mods.Value = new[] { gameMod = new TestMod() }); });
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
@@ -97,6 +114,66 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("player mods applied", () => playerMod2.Applied);
}
+ [Test]
+ public void TestMutedNotification()
+ {
+ AddStep("reset notification", PlayerLoader.ResetNotificationLock);
+
+ AddStep("load player", () => ResetPlayer(false, () => audioManager.Volume.Value = 0));
+ AddUntilStep("wait for player", () => player.IsLoaded);
+
+ AddAssert("check for notification", () => container.NotificationOverlay.UnreadCount.Value == 1);
+ AddStep("click notification", () =>
+ {
+ var scrollContainer = (OsuScrollContainer)container.NotificationOverlay.Children.Last();
+ var flowContainer = scrollContainer.Children.OfType>().First();
+ var notification = flowContainer.First();
+
+ InputManager.MoveMouseTo(notification);
+ InputManager.Click(MouseButton.Left);
+ });
+ AddAssert("check master volume", () => audioManager.Volume.IsDefault);
+
+ AddStep("restart player", () =>
+ {
+ var lastPlayer = player;
+ player = null;
+ lastPlayer.Restart();
+ });
+ }
+
+ private class TestPlayerLoaderContainer : Container
+ {
+ [Cached]
+ public readonly NotificationOverlay NotificationOverlay;
+
+ [Cached]
+ public readonly VolumeOverlay VolumeOverlay;
+
+ public TestPlayerLoaderContainer(IScreen screen)
+ {
+ RelativeSizeAxes = Axes.Both;
+
+ InternalChildren = new Drawable[]
+ {
+ new OsuScreenStack(screen)
+ {
+ RelativeSizeAxes = Axes.Both,
+ },
+ NotificationOverlay = new NotificationOverlay
+ {
+ Anchor = Anchor.TopRight,
+ Origin = Anchor.TopRight,
+ },
+ VolumeOverlay = new VolumeOverlay
+ {
+ Anchor = Anchor.TopLeft,
+ Origin = Anchor.TopLeft,
+ }
+ };
+ }
+ }
+
private class TestPlayerLoader : PlayerLoader
{
public new VisualSettings VisualSettings => base.VisualSettings;
diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs
index 8f2435d2f7..053e11104f 100644
--- a/osu.Game/Screens/Play/PlayerLoader.cs
+++ b/osu.Game/Screens/Play/PlayerLoader.cs
@@ -530,7 +530,7 @@ namespace osu.Game.Screens.Play
}
///
- /// Sets to , reserved for testing.
+ /// Sets to false, reserved for testing.
///
public static void ResetNotificationLock()
{