-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18011 from frenzibyte/rewind-shift-click
Allow rewinding random in song select with "Shift + Left Click"
- Loading branch information
Showing
2 changed files
with
125 additions
and
20 deletions.
There are no files selected for viewing
102 changes: 83 additions & 19 deletions
102
osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,99 @@ | ||
// 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 NUnit.Framework; | ||
using osu.Framework.Graphics; | ||
using osu.Game.Screens.Select; | ||
using osuTK; | ||
using osuTK.Input; | ||
|
||
namespace osu.Game.Tests.Visual.SongSelect | ||
{ | ||
public class TestSceneSongSelectFooter : OsuManualInputManagerTestScene | ||
{ | ||
public TestSceneSongSelectFooter() | ||
private FooterButtonRandom randomButton; | ||
|
||
private bool nextRandomCalled; | ||
private bool previousRandomCalled; | ||
|
||
[SetUp] | ||
public void SetUp() => Schedule(() => | ||
{ | ||
nextRandomCalled = false; | ||
previousRandomCalled = false; | ||
|
||
Footer footer; | ||
|
||
Child = footer = new Footer | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
}; | ||
|
||
footer.AddButton(new FooterButtonMods(), null); | ||
footer.AddButton(randomButton = new FooterButtonRandom | ||
{ | ||
NextRandom = () => nextRandomCalled = true, | ||
PreviousRandom = () => previousRandomCalled = true, | ||
}, null); | ||
footer.AddButton(new FooterButtonOptions(), null); | ||
|
||
InputManager.MoveMouseTo(Vector2.Zero); | ||
}); | ||
|
||
[Test] | ||
public void TestFooterRandom() | ||
{ | ||
AddStep("press F2", () => InputManager.Key(Key.F2)); | ||
AddAssert("next random invoked", () => nextRandomCalled && !previousRandomCalled); | ||
} | ||
|
||
[Test] | ||
public void TestFooterRandomViaMouse() | ||
{ | ||
AddStep("click button", () => | ||
{ | ||
InputManager.MoveMouseTo(randomButton); | ||
InputManager.Click(MouseButton.Left); | ||
}); | ||
AddAssert("next random invoked", () => nextRandomCalled && !previousRandomCalled); | ||
} | ||
|
||
[Test] | ||
public void TestFooterRewind() | ||
{ | ||
AddStep("press Shift+F2", () => | ||
{ | ||
InputManager.PressKey(Key.LShift); | ||
InputManager.PressKey(Key.F2); | ||
InputManager.ReleaseKey(Key.F2); | ||
InputManager.ReleaseKey(Key.LShift); | ||
}); | ||
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled); | ||
} | ||
|
||
[Test] | ||
public void TestFooterRewindViaShiftMouseLeft() | ||
{ | ||
AddStep("shift + click button", () => | ||
{ | ||
InputManager.PressKey(Key.LShift); | ||
InputManager.MoveMouseTo(randomButton); | ||
InputManager.Click(MouseButton.Left); | ||
InputManager.ReleaseKey(Key.LShift); | ||
}); | ||
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled); | ||
} | ||
|
||
[Test] | ||
public void TestFooterRewindViaMouseRight() | ||
{ | ||
AddStep("Create footer", () => | ||
AddStep("right click button", () => | ||
{ | ||
Footer footer; | ||
AddRange(new Drawable[] | ||
{ | ||
footer = new Footer | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
} | ||
}); | ||
|
||
footer.AddButton(new FooterButtonMods(), null); | ||
footer.AddButton(new FooterButtonRandom | ||
{ | ||
NextRandom = () => { }, | ||
PreviousRandom = () => { }, | ||
}, null); | ||
footer.AddButton(new FooterButtonOptions(), null); | ||
InputManager.MoveMouseTo(randomButton); | ||
InputManager.Click(MouseButton.Right); | ||
}); | ||
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters