1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 03:52:55 +08:00
osu-lazer/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

108 lines
3.4 KiB
C#
Raw Normal View History

2022-12-01 18:57:50 +08: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.
2022-12-01 23:29:52 +08:00
using System.Linq;
2022-12-01 18:57:50 +08:00
using NUnit.Framework;
using osu.Framework.Graphics;
2022-12-01 23:29:52 +08:00
using osu.Framework.Testing;
2022-12-01 18:57:50 +08:00
using osu.Game.Screens.Select.FooterV2;
2022-12-01 23:29:52 +08:00
using osuTK;
using osuTK.Input;
2022-12-01 18:57:50 +08:00
namespace osu.Game.Tests.Visual.SongSelect
{
public partial class TestSceneSongSelectFooterV2 : OsuManualInputManagerTestScene
{
2022-12-01 23:29:52 +08:00
private FooterButtonRandomV2 randomButton = null!;
private bool nextRandomCalled;
private bool previousRandomCalled;
2022-12-01 18:57:50 +08:00
[SetUp]
public void SetUp() => Schedule(() =>
{
2022-12-01 23:29:52 +08:00
nextRandomCalled = false;
previousRandomCalled = false;
2022-12-01 18:57:50 +08:00
FooterV2 footer;
Child = footer = new FooterV2
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
};
footer.AddButton(new FooterButtonModsV2());
2022-12-01 23:29:52 +08:00
footer.AddButton(randomButton = new FooterButtonRandomV2
{
NextRandom = () => nextRandomCalled = true,
PreviousRandom = () => previousRandomCalled = true
});
footer.AddButton(new FooterButtonOptionsV2());
2022-12-01 23:29:52 +08:00
InputManager.MoveMouseTo(Vector2.Zero);
2022-12-01 18:57:50 +08:00
});
[Test]
2022-12-01 23:29:52 +08:00
public void TestState()
2022-12-01 18:57:50 +08:00
{
2022-12-01 23:29:52 +08:00
AddRepeatStep("toggle options state", () => this.ChildrenOfType<FooterButtonV2>().Last().Enabled.Toggle(), 20);
}
[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("right click button", () =>
{
InputManager.MoveMouseTo(randomButton);
InputManager.Click(MouseButton.Right);
});
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled);
2022-12-01 18:57:50 +08:00
}
}
}