1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Improve test coverage to ensure volume is unaffected when mouse is away

This commit is contained in:
Salman Ahmed 2022-06-16 20:22:56 +03:00
parent c7287556e5
commit 42378dbb88

View File

@ -17,6 +17,7 @@ using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Overlays.Toolbar;
using osu.Game.Rulesets;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;
@ -153,11 +154,23 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
AddStep("reset volume", () => Audio.Volume.Value = 1);
AddStep("hide volume overlay", () => volumeOverlay.Hide());
AddRepeatStep("scroll down", () => InputManager.ScrollVerticalBy(-10), 5);
AddAssert("volume lowered down", () => Audio.Volume.Value < 1);
AddRepeatStep("scroll up", () => InputManager.ScrollVerticalBy(10), 5);
AddAssert("volume raised up", () => Audio.Volume.Value == 1);
AddStep("move mouse away", () => InputManager.MoveMouseTo(Vector2.Zero));
AddAssert("button not hovered", () => !this.ChildrenOfType<ToolbarMusicButton>().Single().IsHovered);
AddStep("set volume to 0.5", () => Audio.Volume.Value = 0.5);
AddStep("hide volume overlay", () => volumeOverlay.Hide());
AddRepeatStep("scroll down", () => InputManager.ScrollVerticalBy(-10), 5);
AddAssert("volume not changed", () => Audio.Volume.Value == 0.5);
AddRepeatStep("scroll up", () => InputManager.ScrollVerticalBy(10), 5);
AddAssert("volume not changed", () => Audio.Volume.Value == 0.5);
}
[Test]
@ -166,11 +179,24 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
AddStep("reset volume", () => Audio.Volume.Value = 1);
AddStep("hide volume overlay", () => volumeOverlay.Hide());
AddRepeatStep("arrow down", () => InputManager.Key(Key.Down), 5);
AddAssert("volume lowered down", () => Audio.Volume.Value < 1);
AddRepeatStep("arrow up", () => InputManager.Key(Key.Up), 5);
AddAssert("volume raised up", () => Audio.Volume.Value == 1);
AddStep("hide volume overlay", () => volumeOverlay.Hide());
AddStep("move mouse away", () => InputManager.MoveMouseTo(Vector2.Zero));
AddAssert("button not hovered", () => !this.ChildrenOfType<ToolbarMusicButton>().Single().IsHovered);
AddStep("set volume", () => Audio.Volume.Value = 0.5);
AddStep("hide volume overlay", () => volumeOverlay.Hide());
AddRepeatStep("arrow down", () => InputManager.Key(Key.Down), 5);
AddAssert("volume not changed", () => Audio.Volume.Value == 0.5);
AddRepeatStep("arrow up", () => InputManager.Key(Key.Up), 5);
AddAssert("volume not changed", () => Audio.Volume.Value == 0.5);
}
public class TestToolbar : Toolbar