2019-03-25 06:30:51 +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 System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
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
|
|
|
|
{
|
2020-03-23 01:01:33 +00:00
|
|
|
public class TestSceneResumeOverlay : OsuManualInputManagerTestScene
|
2019-03-25 06:30:51 +00:00
|
|
|
{
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
{
|
|
|
|
typeof(OsuResumeOverlay),
|
|
|
|
};
|
|
|
|
|
2019-05-14 19:37:25 +00:00
|
|
|
public TestSceneResumeOverlay()
|
2019-03-25 06:30:51 +00:00
|
|
|
{
|
|
|
|
ManualOsuInputManager osuInputManager;
|
|
|
|
CursorContainer cursor;
|
|
|
|
ResumeOverlay resume;
|
|
|
|
|
|
|
|
bool resumeFired = false;
|
|
|
|
|
|
|
|
Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo)
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
cursor = new CursorContainer(),
|
|
|
|
resume = new OsuResumeOverlay
|
|
|
|
{
|
|
|
|
GameplayCursor = cursor
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
resume.ResumeAction = () => resumeFired = true;
|
|
|
|
|
|
|
|
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());
|
2019-06-11 05:28:52 +00:00
|
|
|
AddAssert("not dismissed", () => !resumeFired && resume.State.Value == Visibility.Visible);
|
2019-03-25 06:30:51 +00:00
|
|
|
|
|
|
|
AddStep("move mouse back", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre));
|
|
|
|
AddStep("click", () => osuInputManager.GameClick());
|
2019-06-11 05:28:52 +00:00
|
|
|
AddAssert("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden);
|
2019-03-25 06:30:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class ManualOsuInputManager : OsuInputManager
|
|
|
|
{
|
|
|
|
public ManualOsuInputManager(RulesetInfo ruleset)
|
|
|
|
: base(ruleset)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void GameClick()
|
|
|
|
{
|
|
|
|
KeyBindingContainer.TriggerPressed(OsuAction.LeftButton);
|
|
|
|
KeyBindingContainer.TriggerReleased(OsuAction.LeftButton);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|