Add display mode changing test

Yup this is gonna fail horribly
This commit is contained in:
CenTdemeern1 2022-04-02 04:26:16 +02:00
parent 9350f6f5f8
commit 95ccac50d4
1 changed files with 28 additions and 0 deletions

View File

@ -2,10 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Game.Configuration;
using osu.Game.Overlays.Toolbar;
using osuTK;
using osuTK.Graphics;
@ -15,6 +18,8 @@ namespace osu.Game.Tests.Visual.Menus
[TestFixture]
public class TestSceneToolbarClock : OsuManualInputManagerTestScene
{
private Bindable<ToolbarClockDisplayMode> clockDisplayMode;
private readonly Container mainContainer;
private readonly ToolbarClock toolbarClock;
@ -66,6 +71,12 @@ public TestSceneToolbarClock()
AddSliderStep("scale", 0.5, 4, 1, scale => mainContainer.Scale = new Vector2((float)scale));
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
clockDisplayMode = config.GetBindable<ToolbarClockDisplayMode>(OsuSetting.ToolbarClockDisplayMode);
}
[Test]
public void TestRealGameTime()
{
@ -92,5 +103,22 @@ public void TestHoverBackground()
AddStep("Move mouse away from clock", () => InputManager.MoveMouseTo(toolbarClock, new Vector2(0, 200)));
AddUntilStep("Hover background is not visible", () => hoverBackground.Alpha == 0);
}
[Test]
public void TestDisplayModeChange()
{
ToolbarClockDisplayMode initialDisplayMode = 0;
AddStep("Retrieve current state", () => initialDisplayMode = (ToolbarClockDisplayMode)clockDisplayMode.Value);
AddStep("Trigger click", () => toolbarClock.TriggerClick());
AddAssert("State changed from initial", () => clockDisplayMode.Value != initialDisplayMode);
AddStep("Trigger click", () => toolbarClock.TriggerClick());
AddAssert("State changed from initial", () => clockDisplayMode.Value != initialDisplayMode);
AddStep("Trigger click", () => toolbarClock.TriggerClick());
AddAssert("State changed from initial", () => clockDisplayMode.Value != initialDisplayMode);
AddStep("Trigger click", () => toolbarClock.TriggerClick());
AddAssert("State is equal to initial", () => clockDisplayMode.Value == initialDisplayMode);
}
}
}