mirror of
https://github.com/ppy/osu
synced 2025-01-30 09:52:23 +00:00
Add test coverage for keyboard selection
This commit is contained in:
parent
3b04daddaa
commit
ec27fa8e85
@ -147,6 +147,40 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("item 1 is selected", () => playlist.SelectedItem.Value == playlist.Items[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void KeyboardSelection()
|
||||
{
|
||||
createPlaylist(p => p.AllowSelection = true);
|
||||
|
||||
AddStep("press down", () => InputManager.Key(Key.Down));
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
|
||||
AddStep("press down", () => InputManager.Key(Key.Down));
|
||||
AddAssert("item 1 is selected", () => playlist.SelectedItem.Value == playlist.Items[1]);
|
||||
|
||||
AddStep("press up", () => InputManager.Key(Key.Up));
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
|
||||
AddUntilStep("navigate to last item via keyboard", () =>
|
||||
{
|
||||
InputManager.Key(Key.Down);
|
||||
return playlist.SelectedItem.Value == playlist.Items.Last();
|
||||
});
|
||||
AddAssert("last item is selected", () => playlist.SelectedItem.Value == playlist.Items.Last());
|
||||
AddUntilStep("last item is scrolled into view", () =>
|
||||
{
|
||||
var drawableItem = playlist.ItemMap[playlist.Items.Last()];
|
||||
return playlist.ScreenSpaceDrawQuad.Contains(drawableItem.ScreenSpaceDrawQuad.TopLeft)
|
||||
&& playlist.ScreenSpaceDrawQuad.Contains(drawableItem.ScreenSpaceDrawQuad.BottomRight);
|
||||
});
|
||||
|
||||
AddStep("press down", () => InputManager.Key(Key.Down));
|
||||
AddAssert("last item is selected", () => playlist.SelectedItem.Value == playlist.Items.Last());
|
||||
|
||||
AddStep("press up", () => InputManager.Key(Key.Up));
|
||||
AddAssert("second last item is selected", () => playlist.SelectedItem.Value == playlist.Items.Reverse().ElementAt(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDownloadButtonHiddenWhenBeatmapExists()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user