From b07152a119d3df101600ff18356c476ffdce9326 Mon Sep 17 00:00:00 2001 From: CenTdemeern1 Date: Sat, 2 Apr 2022 02:35:37 +0200 Subject: [PATCH] Initial attempt at writing a test for the toolbarClock I'll add more once I know if this code passes review or not --- .../Visual/Menus/TestSceneToolbarClock.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneToolbarClock.cs b/osu.Game.Tests/Visual/Menus/TestSceneToolbarClock.cs index 064d6f82fd..0b5904aa2b 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneToolbarClock.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneToolbarClock.cs @@ -16,6 +16,7 @@ namespace osu.Game.Tests.Visual.Menus public class TestSceneToolbarClock : OsuManualInputManagerTestScene { private readonly Container mainContainer; + private readonly ToolbarClock toolbarClock; public TestSceneToolbarClock() { @@ -49,7 +50,7 @@ namespace osu.Game.Tests.Visual.Menus RelativeSizeAxes = Axes.Y, Width = 2, }, - new ToolbarClock(), + toolbarClock = new ToolbarClock(), new Box { Colour = Color4.DarkRed, @@ -76,5 +77,22 @@ namespace osu.Game.Tests.Visual.Menus { AddStep("Set game time long", () => mainContainer.Clock = new FramedOffsetClock(Clock, false) { Offset = 3600.0 * 24 * 1000 * 98 }); } + + [Test] + public void TestHoverBackground() + { + Box hoverBackground = null; + + AddStep("Retrieve hover background", () => hoverBackground = (Box)toolbarClock.Children[0]); + + AddStep("Move mouse away from clock", () => InputManager.MoveMouseTo(mainContainer, new Vector2(0,200))); + AddAssert("Hover background is not visible", () => hoverBackground.Alpha == 0); + + AddStep("Move mouse on top of clock", () => InputManager.MoveMouseTo(mainContainer)); + AddAssert("Hover background is visible", () => hoverBackground.Alpha != 0); + + AddStep("Move mouse away from clock", () => InputManager.MoveMouseTo(mainContainer, new Vector2(0,200))); + AddUntilStep("Hover background is not visible", () => hoverBackground.Alpha == 0); + } } }