2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-07-04 15:53:08 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using NUnit.Framework;
|
2019-07-04 16:32:58 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Timing;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Screens.Play;
|
2019-07-04 18:26:12 +08:00
|
|
|
|
using osuTK;
|
2019-07-04 15:53:08 +08:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-07-04 15:53:08 +08:00
|
|
|
|
public class TestSceneSkipOverlay : ManualInputManagerTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-07-04 15:53:08 +08:00
|
|
|
|
private SkipOverlay skip;
|
|
|
|
|
private int requestCount;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUp() => Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
requestCount = 0;
|
2019-07-04 16:32:58 +08:00
|
|
|
|
Child = new Container
|
2019-07-04 15:53:08 +08:00
|
|
|
|
{
|
2019-07-04 16:32:58 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Clock = new FramedOffsetClock(Clock)
|
|
|
|
|
{
|
|
|
|
|
Offset = -Clock.CurrentTime,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-07-04 17:38:29 +08:00
|
|
|
|
skip = new SkipOverlay(6000)
|
2019-07-04 16:32:58 +08:00
|
|
|
|
{
|
2019-11-21 14:19:06 +08:00
|
|
|
|
RequestSkip = () => requestCount++
|
2019-07-04 16:32:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-07-04 15:53:08 +08:00
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestFadeOnIdle()
|
|
|
|
|
{
|
2019-07-04 18:26:12 +08:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero));
|
2019-07-04 17:38:29 +08:00
|
|
|
|
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1);
|
|
|
|
|
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1);
|
|
|
|
|
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
2019-07-04 17:38:29 +08:00
|
|
|
|
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1);
|
|
|
|
|
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1);
|
2019-07-04 15:53:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickableAfterFade()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
AddUntilStep("wait for fade", () => skip.Children.First().Alpha == 0);
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
checkRequestCount(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDoesntFadeOnMouseDown()
|
|
|
|
|
{
|
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
|
|
|
|
|
AddUntilStep("wait for overlay disapper", () => !skip.IsAlive);
|
|
|
|
|
AddAssert("ensure button didn't disappear", () => skip.Children.First().Alpha > 0);
|
|
|
|
|
AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left));
|
|
|
|
|
checkRequestCount(0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-07-04 15:53:08 +08:00
|
|
|
|
|
|
|
|
|
private void checkRequestCount(int expected) =>
|
|
|
|
|
AddAssert($"request count is {expected}", () => requestCount == expected);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|