2022-03-26 07:35:53 +00: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 NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-03-26 08:55:33 +00:00
|
|
|
using osu.Framework.Timing;
|
2022-03-26 07:35:53 +00:00
|
|
|
using osu.Game.Overlays.Toolbar;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Menus
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class TestSceneToolbarClock : OsuManualInputManagerTestScene
|
|
|
|
{
|
2022-03-26 08:55:33 +00:00
|
|
|
private readonly Container mainContainer;
|
2022-04-02 00:35:37 +00:00
|
|
|
private readonly ToolbarClock toolbarClock;
|
2022-03-26 08:55:33 +00:00
|
|
|
|
2022-03-26 07:35:53 +00:00
|
|
|
public TestSceneToolbarClock()
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-03-26 08:55:33 +00:00
|
|
|
mainContainer = new Container
|
2022-03-26 07:35:53 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = Toolbar.HEIGHT,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.Black,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.DarkRed,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Width = 2,
|
|
|
|
},
|
2022-04-02 00:35:37 +00:00
|
|
|
toolbarClock = new ToolbarClock(),
|
2022-03-26 07:35:53 +00:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.DarkRed,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Width = 2,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
2022-03-26 09:56:28 +00:00
|
|
|
|
|
|
|
AddSliderStep("scale", 0.5, 4, 1, scale => mainContainer.Scale = new Vector2((float)scale));
|
2022-03-26 07:35:53 +00:00
|
|
|
}
|
2022-03-26 08:55:33 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestRealGameTime()
|
|
|
|
{
|
|
|
|
AddStep("Set game time real", () => mainContainer.Clock = Clock);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestLongGameTime()
|
|
|
|
{
|
|
|
|
AddStep("Set game time long", () => mainContainer.Clock = new FramedOffsetClock(Clock, false) { Offset = 3600.0 * 24 * 1000 * 98 });
|
|
|
|
}
|
2022-04-02 00:35:37 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestHoverBackground()
|
|
|
|
{
|
|
|
|
Box hoverBackground = null;
|
|
|
|
|
|
|
|
AddStep("Retrieve hover background", () => hoverBackground = (Box)toolbarClock.Children[0]);
|
|
|
|
|
2022-04-02 00:59:07 +00:00
|
|
|
AddStep("Move mouse away from clock", () => InputManager.MoveMouseTo(toolbarClock, new Vector2(0, 200)));
|
2022-04-02 00:35:37 +00:00
|
|
|
AddAssert("Hover background is not visible", () => hoverBackground.Alpha == 0);
|
2022-04-02 00:43:44 +00:00
|
|
|
AddStep("Move mouse on top of clock", () => InputManager.MoveMouseTo(toolbarClock));
|
2022-04-02 00:35:37 +00:00
|
|
|
AddAssert("Hover background is visible", () => hoverBackground.Alpha != 0);
|
2022-04-02 00:59:07 +00:00
|
|
|
AddStep("Move mouse away from clock", () => InputManager.MoveMouseTo(toolbarClock, new Vector2(0, 200)));
|
2022-04-02 00:35:37 +00:00
|
|
|
AddUntilStep("Hover background is not visible", () => hoverBackground.Alpha == 0);
|
|
|
|
}
|
2022-03-26 07:35:53 +00:00
|
|
|
}
|
|
|
|
}
|