1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00
osu-lazer/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.4 KiB
C#
Raw Normal View History

2019-03-25 14:30:51 +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.
2023-11-05 11:28:34 +08:00
using NUnit.Framework;
2019-03-25 14:30:51 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Screens.Play;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests
{
public partial class TestSceneResumeOverlay : OsuManualInputManagerTestScene
2019-03-25 14:30:51 +08:00
{
2023-11-05 11:28:34 +08:00
private ManualOsuInputManager osuInputManager = null!;
private CursorContainer cursor = null!;
private ResumeOverlay resume = null!;
2019-03-25 14:30:51 +08:00
2023-11-05 11:28:34 +08:00
private bool resumeFired;
2019-03-25 14:30:51 +08:00
2023-11-05 11:28:34 +08:00
[SetUp]
public void SetUp() => Schedule(() =>
{
2019-03-25 14:30:51 +08:00
Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo)
{
Children = new Drawable[]
{
cursor = new CursorContainer(),
resume = new OsuResumeOverlay
{
GameplayCursor = cursor
},
}
};
2023-11-05 11:28:34 +08:00
resumeFired = false;
2019-03-25 14:30:51 +08:00
resume.ResumeAction = () => resumeFired = true;
2023-11-05 11:28:34 +08:00
});
2019-03-25 14:30:51 +08:00
2023-11-05 11:28:34 +08:00
[Test]
public void TestResume()
{
2019-03-25 14:30:51 +08:00
AddStep("move mouse to center", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre));
AddStep("show", () => resume.Show());
AddStep("move mouse away", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.TopLeft));
AddStep("click", () => osuInputManager.GameClick());
AddAssert("not dismissed", () => !resumeFired && resume.State.Value == Visibility.Visible);
2019-03-25 14:30:51 +08:00
AddStep("move mouse back", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre));
AddStep("click", () => osuInputManager.GameClick());
AddAssert("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden);
2019-03-25 14:30:51 +08:00
}
private partial class ManualOsuInputManager : OsuInputManager
{
public ManualOsuInputManager(RulesetInfo ruleset)
: base(ruleset)
{
}
public void GameClick()
{
KeyBindingContainer.TriggerPressed(OsuAction.LeftButton);
KeyBindingContainer.TriggerReleased(OsuAction.LeftButton);
}
}
}
}