2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-11-28 13:41:29 +00:00
|
|
|
|
using System;
|
2019-07-04 07:53:08 +00:00
|
|
|
|
using System.Linq;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using NUnit.Framework;
|
2019-07-04 08:32:58 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-11-21 10:51:22 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2019-07-04 10:26:12 +00:00
|
|
|
|
using osuTK;
|
2019-07-04 07:53:08 +00:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-03-24 16:02:36 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-03-23 01:01:33 +00:00
|
|
|
|
public class TestSceneSkipOverlay : OsuManualInputManagerTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-07-04 07:53:08 +00:00
|
|
|
|
private SkipOverlay skip;
|
|
|
|
|
private int requestCount;
|
|
|
|
|
|
2019-11-21 09:57:19 +00:00
|
|
|
|
private double increment;
|
|
|
|
|
|
2019-11-21 10:51:22 +00:00
|
|
|
|
private GameplayClockContainer gameplayClockContainer;
|
|
|
|
|
private GameplayClock gameplayClock;
|
|
|
|
|
|
|
|
|
|
private const double skip_time = 6000;
|
|
|
|
|
|
2019-07-04 07:53:08 +00:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUp() => Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
requestCount = 0;
|
2019-11-21 10:51:22 +00:00
|
|
|
|
increment = skip_time;
|
2019-11-21 09:57:19 +00:00
|
|
|
|
|
2019-11-28 13:41:29 +00:00
|
|
|
|
Child = gameplayClockContainer = new GameplayClockContainer(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), Array.Empty<Mod>(), 0)
|
2019-07-04 07:53:08 +00:00
|
|
|
|
{
|
2019-07-04 08:32:58 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-11-21 10:51:22 +00:00
|
|
|
|
skip = new SkipOverlay(skip_time)
|
2019-07-04 08:32:58 +00:00
|
|
|
|
{
|
2019-11-21 09:57:19 +00:00
|
|
|
|
RequestSkip = () =>
|
|
|
|
|
{
|
|
|
|
|
requestCount++;
|
2019-11-21 10:51:22 +00:00
|
|
|
|
gameplayClockContainer.Seek(gameplayClock.CurrentTime + increment);
|
2019-11-21 09:57:19 +00:00
|
|
|
|
}
|
2019-07-04 08:32:58 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-07-04 07:53:08 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-11-21 10:51:22 +00:00
|
|
|
|
gameplayClockContainer.Start();
|
|
|
|
|
gameplayClock = gameplayClockContainer.GameplayClock;
|
|
|
|
|
});
|
2019-11-21 09:57:19 +00:00
|
|
|
|
|
2019-07-04 07:53:08 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestFadeOnIdle()
|
|
|
|
|
{
|
2019-07-04 10:26:12 +00:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero));
|
2019-07-04 09:38:29 +00:00
|
|
|
|
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1);
|
|
|
|
|
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1);
|
|
|
|
|
|
2019-07-04 07:53:08 +00:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
2019-07-04 09:38:29 +00:00
|
|
|
|
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1);
|
|
|
|
|
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1);
|
2019-07-04 07:53:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickableAfterFade()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-07-04 07:53:08 +00: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 TestClickOnlyActuatesOnce()
|
|
|
|
|
{
|
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
2019-11-21 09:57:19 +00:00
|
|
|
|
AddStep("click", () =>
|
|
|
|
|
{
|
2019-11-21 10:51:22 +00:00
|
|
|
|
increment = skip_time - gameplayClock.CurrentTime - GameplayClockContainer.MINIMUM_SKIP_TIME / 2;
|
2019-11-21 09:57:19 +00:00
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
2019-07-04 07:53:08 +00:00
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
checkRequestCount(1);
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-11-21 09:57:19 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickOnlyActuatesMultipleTimes()
|
|
|
|
|
{
|
|
|
|
|
AddStep("set increment lower", () => increment = 3000);
|
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
checkRequestCount(2);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-04 07:53:08 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDoesntFadeOnMouseDown()
|
|
|
|
|
{
|
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
|
2019-11-21 13:07:37 +00:00
|
|
|
|
AddUntilStep("wait for overlay disappear", () => !skip.IsPresent);
|
2019-07-04 07:53:08 +00:00
|
|
|
|
AddAssert("ensure button didn't disappear", () => skip.Children.First().Alpha > 0);
|
|
|
|
|
AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left));
|
|
|
|
|
checkRequestCount(0);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
2019-07-04 07:53:08 +00:00
|
|
|
|
|
|
|
|
|
private void checkRequestCount(int expected) =>
|
|
|
|
|
AddAssert($"request count is {expected}", () => requestCount == expected);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|