|
|
|
@ -15,6 +15,7 @@ using osu.Game.Graphics.Cursor;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osuTK.Input;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
|
|
|
@ -81,25 +82,24 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AddToggleStep("Smooth transitions", b => cursorBoxes.ForEach(box => box.SmoothTransition = b));
|
|
|
|
|
|
|
|
|
|
testUserCursor();
|
|
|
|
|
testLocalCursor();
|
|
|
|
|
testUserCursorOverride();
|
|
|
|
|
testMultipleLocalCursors();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUp() => Schedule(moveOut);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// -- Green Box --
|
|
|
|
|
/// Tests whether hovering in and out of a drawable that provides the user cursor (green)
|
|
|
|
|
/// results in the correct visibility state for that cursor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void testUserCursor()
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestUserCursor()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Move to green area", () => InputManager.MoveMouseTo(cursorBoxes[0]));
|
|
|
|
|
AddAssert("Check green cursor visible", () => checkVisible(cursorBoxes[0].MenuCursor));
|
|
|
|
|
AddAssert("Check green cursor at mouse", () => checkAtMouse(cursorBoxes[0].MenuCursor));
|
|
|
|
|
AddAssert("Check green cursor visible", () => checkVisible(cursorBoxes[0].Cursor));
|
|
|
|
|
AddAssert("Check green cursor at mouse", () => checkAtMouse(cursorBoxes[0].Cursor));
|
|
|
|
|
AddStep("Move out", moveOut);
|
|
|
|
|
AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].MenuCursor));
|
|
|
|
|
AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor));
|
|
|
|
|
AddAssert("Check global cursor visible", () => checkVisible(globalCursorDisplay.MenuCursor));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -108,15 +108,16 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
/// Tests whether hovering in and out of a drawable that provides a local cursor (purple)
|
|
|
|
|
/// results in the correct visibility and state for that cursor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void testLocalCursor()
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestLocalCursor()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Move to purple area", () => InputManager.MoveMouseTo(cursorBoxes[3]));
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].MenuCursor));
|
|
|
|
|
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].MenuCursor));
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
|
|
|
|
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor));
|
|
|
|
|
AddAssert("Check global cursor visible", () => checkVisible(globalCursorDisplay.MenuCursor));
|
|
|
|
|
AddAssert("Check global cursor at mouse", () => checkAtMouse(globalCursorDisplay.MenuCursor));
|
|
|
|
|
AddStep("Move out", moveOut);
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].MenuCursor));
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
|
|
|
|
AddAssert("Check global cursor visible", () => checkVisible(globalCursorDisplay.MenuCursor));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -125,47 +126,96 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
/// Tests whether overriding a user cursor (green) with another user cursor (blue)
|
|
|
|
|
/// results in the correct visibility and states for the cursors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void testUserCursorOverride()
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestUserCursorOverride()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Move to blue-green boundary", () => InputManager.MoveMouseTo(cursorBoxes[1].ScreenSpaceDrawQuad.BottomRight - new Vector2(10)));
|
|
|
|
|
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].MenuCursor));
|
|
|
|
|
AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].MenuCursor));
|
|
|
|
|
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].MenuCursor));
|
|
|
|
|
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor));
|
|
|
|
|
AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor));
|
|
|
|
|
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor));
|
|
|
|
|
AddStep("Move out", moveOut);
|
|
|
|
|
AddAssert("Check blue cursor not visible", () => !checkVisible(cursorBoxes[1].MenuCursor));
|
|
|
|
|
AddAssert("Check green cursor not visible", () => !checkVisible(cursorBoxes[0].MenuCursor));
|
|
|
|
|
AddAssert("Check blue cursor not visible", () => !checkVisible(cursorBoxes[1].Cursor));
|
|
|
|
|
AddAssert("Check green cursor not visible", () => !checkVisible(cursorBoxes[0].Cursor));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// -- Yellow-Purple Box Boundary --
|
|
|
|
|
/// Tests whether multiple local cursors (purple + yellow) may be visible and at the mouse position at the same time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void testMultipleLocalCursors()
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestMultipleLocalCursors()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Move to yellow-purple boundary", () => InputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.BottomRight - new Vector2(10)));
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].MenuCursor));
|
|
|
|
|
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].MenuCursor));
|
|
|
|
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].MenuCursor));
|
|
|
|
|
AddAssert("Check yellow cursor at mouse", () => checkAtMouse(cursorBoxes[5].MenuCursor));
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
|
|
|
|
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor));
|
|
|
|
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
|
|
|
|
AddAssert("Check yellow cursor at mouse", () => checkAtMouse(cursorBoxes[5].Cursor));
|
|
|
|
|
AddStep("Move out", moveOut);
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].MenuCursor));
|
|
|
|
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].MenuCursor));
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
|
|
|
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// -- Yellow-Blue Box Boundary --
|
|
|
|
|
/// Tests whether a local cursor (yellow) may be displayed along with a user cursor override (blue).
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void testUserOverrideWithLocal()
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestUserOverrideWithLocal()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Move to yellow-blue boundary", () => InputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.TopRight - new Vector2(10)));
|
|
|
|
|
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].MenuCursor));
|
|
|
|
|
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].MenuCursor));
|
|
|
|
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].MenuCursor));
|
|
|
|
|
AddAssert("Check yellow cursor at mouse", () => checkAtMouse(cursorBoxes[5].MenuCursor));
|
|
|
|
|
AddStep("Move to yellow-blue boundary", () => InputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.TopRight - new Vector2(10, 0)));
|
|
|
|
|
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor));
|
|
|
|
|
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor));
|
|
|
|
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
|
|
|
|
AddAssert("Check yellow cursor at mouse", () => checkAtMouse(cursorBoxes[5].Cursor));
|
|
|
|
|
AddStep("Move out", moveOut);
|
|
|
|
|
AddAssert("Check blue cursor invisible", () => !checkVisible(cursorBoxes[1].MenuCursor));
|
|
|
|
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].MenuCursor));
|
|
|
|
|
AddAssert("Check blue cursor invisible", () => !checkVisible(cursorBoxes[1].Cursor));
|
|
|
|
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Ensures non-mouse input hides global cursor on a "local cursor" area (which doesn't hide global cursor).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestKeyboardLocalCursor([Values] bool clickToShow)
|
|
|
|
|
{
|
|
|
|
|
AddStep("Move to purple area", () => InputManager.MoveMouseTo(cursorBoxes[3].ScreenSpaceDrawQuad.Centre + new Vector2(10, 0)));
|
|
|
|
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
|
|
|
|
AddAssert("Check global cursor alpha is 1", () => globalCursorDisplay.MenuCursor.Alpha == 1);
|
|
|
|
|
|
|
|
|
|
AddStep("Press key", () => InputManager.Key(Key.A));
|
|
|
|
|
AddAssert("Check purple cursor still visible", () => checkVisible(cursorBoxes[3].Cursor));
|
|
|
|
|
AddUntilStep("Check global cursor alpha is 0", () => globalCursorDisplay.MenuCursor.ActiveCursor.Alpha == 0);
|
|
|
|
|
|
|
|
|
|
if (clickToShow)
|
|
|
|
|
AddStep("Click mouse", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
else
|
|
|
|
|
AddStep("Move mouse", () => InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + Vector2.One));
|
|
|
|
|
|
|
|
|
|
AddAssert("Check purple cursor still visible", () => checkVisible(cursorBoxes[3].Cursor));
|
|
|
|
|
AddUntilStep("Check global cursor alpha is 1", () => globalCursorDisplay.MenuCursor.ActiveCursor.Alpha == 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Ensures mouse input after non-mouse input doesn't show global cursor on a "user cursor" area (which hides global cursor).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestKeyboardUserCursor([Values] bool clickToShow)
|
|
|
|
|
{
|
|
|
|
|
AddStep("Move to green area", () => InputManager.MoveMouseTo(cursorBoxes[0]));
|
|
|
|
|
AddAssert("Check green cursor visible", () => checkVisible(cursorBoxes[0].Cursor));
|
|
|
|
|
AddAssert("Check global cursor alpha is 0", () => !checkVisible(globalCursorDisplay.MenuCursor) && globalCursorDisplay.MenuCursor.ActiveCursor.Alpha == 0);
|
|
|
|
|
|
|
|
|
|
AddStep("Press key", () => InputManager.Key(Key.A));
|
|
|
|
|
AddAssert("Check green cursor still visible", () => checkVisible(cursorBoxes[0].Cursor));
|
|
|
|
|
AddAssert("Check global cursor alpha is still 0", () => !checkVisible(globalCursorDisplay.MenuCursor) && globalCursorDisplay.MenuCursor.ActiveCursor.Alpha == 0);
|
|
|
|
|
|
|
|
|
|
if (clickToShow)
|
|
|
|
|
AddStep("Click mouse", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
else
|
|
|
|
|
AddStep("Move mouse", () => InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + Vector2.One));
|
|
|
|
|
|
|
|
|
|
AddAssert("Check green cursor still visible", () => checkVisible(cursorBoxes[0].Cursor));
|
|
|
|
|
AddAssert("Check global cursor alpha is still 0", () => !checkVisible(globalCursorDisplay.MenuCursor) && globalCursorDisplay.MenuCursor.ActiveCursor.Alpha == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -191,7 +241,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
|
|
|
|
public bool SmoothTransition;
|
|
|
|
|
|
|
|
|
|
public CursorContainer MenuCursor { get; }
|
|
|
|
|
public CursorContainer Cursor { get; }
|
|
|
|
|
public bool ProvidingUserCursor { get; }
|
|
|
|
|
|
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) || (SmoothTransition && !ProvidingUserCursor);
|
|
|
|
@ -218,7 +268,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Text = providesUserCursor ? "User cursor" : "Local cursor"
|
|
|
|
|
},
|
|
|
|
|
MenuCursor = new TestCursorContainer
|
|
|
|
|
Cursor = new TestCursorContainer
|
|
|
|
|
{
|
|
|
|
|
State = { Value = providesUserCursor ? Visibility.Hidden : Visibility.Visible },
|
|
|
|
|
}
|
|
|
|
|