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
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-03-02 14:34:31 +08:00
|
|
|
|
using NUnit.Framework;
|
2019-07-04 16:32:58 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-05-16 01:43:01 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-08-15 16:06:24 +08:00
|
|
|
|
using osu.Framework.Timing;
|
2019-11-21 18:51:22 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2017-09-18 21:32:49 +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
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2018-03-02 14:34:31 +08:00
|
|
|
|
[TestFixture]
|
2020-03-23 09:01:33 +08:00
|
|
|
|
public class TestSceneSkipOverlay : OsuManualInputManagerTestScene
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2020-05-16 01:43:01 +08:00
|
|
|
|
private TestSkipOverlay skip;
|
2019-07-04 15:53:08 +08:00
|
|
|
|
private int requestCount;
|
|
|
|
|
|
2019-11-21 17:57:19 +08:00
|
|
|
|
private double increment;
|
|
|
|
|
|
2019-11-21 18:51:22 +08:00
|
|
|
|
private GameplayClockContainer gameplayClockContainer;
|
2022-08-15 16:06:24 +08:00
|
|
|
|
private IFrameBasedClock gameplayClock;
|
2019-11-21 18:51:22 +08:00
|
|
|
|
|
|
|
|
|
private const double skip_time = 6000;
|
|
|
|
|
|
2022-08-31 12:19:58 +08:00
|
|
|
|
private void createTest(double skipTime = skip_time) => AddStep("create test", () =>
|
2019-07-04 15:53:08 +08:00
|
|
|
|
{
|
|
|
|
|
requestCount = 0;
|
2019-11-21 18:51:22 +08:00
|
|
|
|
increment = skip_time;
|
2019-11-21 17:57:19 +08:00
|
|
|
|
|
2020-08-06 17:31:08 +08:00
|
|
|
|
var working = CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
|
|
|
|
|
|
2021-04-14 16:47:11 +08:00
|
|
|
|
Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0)
|
2019-07-04 15:53:08 +08:00
|
|
|
|
{
|
2019-07-04 16:32:58 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2022-08-31 12:19:58 +08:00
|
|
|
|
skip = new TestSkipOverlay(skipTime)
|
2019-07-04 16:32:58 +08:00
|
|
|
|
{
|
2019-11-21 17:57:19 +08:00
|
|
|
|
RequestSkip = () =>
|
|
|
|
|
{
|
|
|
|
|
requestCount++;
|
2019-11-21 18:51:22 +08:00
|
|
|
|
gameplayClockContainer.Seek(gameplayClock.CurrentTime + increment);
|
2019-11-21 17:57:19 +08:00
|
|
|
|
}
|
2019-07-04 16:32:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-07-04 15:53:08 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-11-21 18:51:22 +08:00
|
|
|
|
gameplayClockContainer.Start();
|
2022-08-15 16:06:24 +08:00
|
|
|
|
gameplayClock = gameplayClockContainer;
|
2019-11-21 18:51:22 +08:00
|
|
|
|
});
|
2019-11-21 17:57:19 +08:00
|
|
|
|
|
2022-08-31 12:19:58 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestSkipTimeZero()
|
|
|
|
|
{
|
|
|
|
|
createTest(0);
|
|
|
|
|
AddUntilStep("wait for skip overlay expired", () => !skip.IsAlive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestSkipTimeEqualToSkip()
|
|
|
|
|
{
|
|
|
|
|
createTest(MasterGameplayClockContainer.MINIMUM_SKIP_TIME);
|
|
|
|
|
AddUntilStep("wait for skip overlay expired", () => !skip.IsAlive);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-04 15:53:08 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestFadeOnIdle()
|
|
|
|
|
{
|
2022-08-31 12:19:58 +08:00
|
|
|
|
createTest();
|
|
|
|
|
|
2019-07-04 18:26:12 +08:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero));
|
2020-05-18 19:01:00 +08:00
|
|
|
|
AddUntilStep("fully visible", () => skip.FadingContent.Alpha == 1);
|
|
|
|
|
AddUntilStep("wait for fade", () => skip.FadingContent.Alpha < 1);
|
2019-07-04 17:38:29 +08:00
|
|
|
|
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
2020-05-18 19:01:00 +08:00
|
|
|
|
AddUntilStep("fully visible", () => skip.FadingContent.Alpha == 1);
|
|
|
|
|
AddUntilStep("wait for fade", () => skip.FadingContent.Alpha < 1);
|
2019-07-04 15:53:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickableAfterFade()
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2022-08-31 12:19:58 +08:00
|
|
|
|
createTest();
|
|
|
|
|
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
2020-05-18 19:01:00 +08:00
|
|
|
|
AddUntilStep("wait for fade", () => skip.FadingContent.Alpha == 0);
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
checkRequestCount(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickOnlyActuatesOnce()
|
|
|
|
|
{
|
2022-08-31 12:19:58 +08:00
|
|
|
|
createTest();
|
|
|
|
|
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
2019-11-21 17:57:19 +08:00
|
|
|
|
AddStep("click", () =>
|
|
|
|
|
{
|
2021-04-14 16:47:11 +08:00
|
|
|
|
increment = skip_time - gameplayClock.CurrentTime - MasterGameplayClockContainer.MINIMUM_SKIP_TIME / 2;
|
2019-11-21 17:57:19 +08:00
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
checkRequestCount(1);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-11-21 17:57:19 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickOnlyActuatesMultipleTimes()
|
|
|
|
|
{
|
2022-08-31 12:19:58 +08:00
|
|
|
|
createTest();
|
|
|
|
|
|
2019-11-21 17:57:19 +08:00
|
|
|
|
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 15:53:08 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDoesntFadeOnMouseDown()
|
|
|
|
|
{
|
2022-08-31 12:19:58 +08:00
|
|
|
|
createTest();
|
|
|
|
|
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
|
2020-05-18 19:01:00 +08:00
|
|
|
|
AddUntilStep("wait for overlay disappear", () => !skip.OverlayContent.IsPresent);
|
|
|
|
|
AddAssert("ensure button didn't disappear", () => skip.FadingContent.Alpha > 0);
|
2019-07-04 15:53:08 +08:00
|
|
|
|
AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left));
|
|
|
|
|
checkRequestCount(0);
|
2017-09-18 21:32:49 +08:00
|
|
|
|
}
|
2019-07-04 15:53:08 +08:00
|
|
|
|
|
|
|
|
|
private void checkRequestCount(int expected) =>
|
|
|
|
|
AddAssert($"request count is {expected}", () => requestCount == expected);
|
2020-05-16 01:43:01 +08:00
|
|
|
|
|
|
|
|
|
private class TestSkipOverlay : SkipOverlay
|
|
|
|
|
{
|
|
|
|
|
public TestSkipOverlay(double startTime)
|
|
|
|
|
: base(startTime)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 19:01:00 +08:00
|
|
|
|
public Drawable OverlayContent => InternalChild;
|
|
|
|
|
|
|
|
|
|
public Drawable FadingContent => (OverlayContent as Container)?.Child;
|
2020-05-16 01:43:01 +08:00
|
|
|
|
}
|
2017-09-18 21:32:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|