diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs index 49a8254f53..25d0b0a3d3 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs @@ -1,16 +1,20 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; +using osu.Framework.Testing; using osu.Game.Configuration; using osu.Game.Rulesets.Osu.UI; +using osu.Game.Rulesets.Osu.UI.Cursor; using osu.Game.Screens.Play; using osu.Game.Tests.Gameplay; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Rulesets.Osu.Tests { @@ -54,9 +58,13 @@ namespace osu.Game.Rulesets.Osu.Tests [SetUp] public void SetUp() => Schedule(loadContent); - [Test] - public void TestResume() + [TestCase(1)] + [TestCase(0.5f)] + [TestCase(2)] + public void TestResume(float cursorSize) { + AddStep($"set cursor size to {cursorSize}", () => localConfig.SetValue(OsuSetting.GameplayCursorSize, cursorSize)); + AddStep("move mouse to center", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre)); AddStep("show", () => resume.Show()); @@ -64,7 +72,27 @@ namespace osu.Game.Rulesets.Osu.Tests AddStep("click", () => osuInputManager.GameClick()); AddAssert("not dismissed", () => !resumeFired && resume.State.Value == Visibility.Visible); - AddStep("move mouse back", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre)); + AddStep("move mouse just out of range", () => + { + var resumeOverlay = this.ChildrenOfType().Single(); + var resumeOverlayCursor = resumeOverlay.ChildrenOfType().Single(); + + Vector2 offset = resumeOverlay.ToScreenSpace(new Vector2(OsuCursor.SIZE / 2)) - resumeOverlay.ToScreenSpace(Vector2.Zero); + InputManager.MoveMouseTo(resumeOverlayCursor.ScreenSpaceDrawQuad.Centre - offset - new Vector2(1)); + }); + + AddStep("click", () => osuInputManager.GameClick()); + AddAssert("not dismissed", () => !resumeFired && resume.State.Value == Visibility.Visible); + + AddStep("move mouse just within range", () => + { + var resumeOverlay = this.ChildrenOfType().Single(); + var resumeOverlayCursor = resumeOverlay.ChildrenOfType().Single(); + + Vector2 offset = resumeOverlay.ToScreenSpace(new Vector2(OsuCursor.SIZE / 2)) - resumeOverlay.ToScreenSpace(Vector2.Zero); + InputManager.MoveMouseTo(resumeOverlayCursor.ScreenSpaceDrawQuad.Centre - offset + new Vector2(1)); + }); + AddStep("click", () => osuInputManager.GameClick()); AddAssert("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden); } diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs index ab1bb0cf5a..8215201d43 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs @@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { public partial class OsuCursor : SkinReloadableDrawable { - private const float size = 28; + public const float SIZE = 28; private const float pressed_scale = 1.2f; private const float released_scale = 1f; @@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { Origin = Anchor.Centre; - Size = new Vector2(size); + Size = new Vector2(SIZE); } [BackgroundDependencyLoader] @@ -134,7 +134,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Masking = true, - BorderThickness = size / 6, + BorderThickness = SIZE / 6, BorderColour = Color4.White, EdgeEffect = new EdgeEffectParameters { @@ -156,7 +156,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor Anchor = Anchor.Centre, RelativeSizeAxes = Axes.Both, Masking = true, - BorderThickness = size / 3, + BorderThickness = SIZE / 3, BorderColour = Color4.White.Opacity(0.5f), Children = new Drawable[] {