2021-04-07 09:29:31 +00: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-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2022-11-17 00:57:27 +00:00
|
|
|
using System.Linq;
|
2022-04-29 01:14:09 +00:00
|
|
|
using NUnit.Framework;
|
2021-04-07 09:29:31 +00:00
|
|
|
using osu.Framework.Graphics;
|
2022-11-17 00:57:27 +00:00
|
|
|
using osu.Framework.Testing;
|
2021-04-07 09:29:31 +00:00
|
|
|
using osu.Game.Screens.Select;
|
2022-04-29 07:12:20 +00:00
|
|
|
using osuTK;
|
2022-04-29 01:14:09 +00:00
|
|
|
using osuTK.Input;
|
2021-04-07 09:29:31 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.SongSelect
|
|
|
|
{
|
|
|
|
public partial class TestSceneSongSelectFooter : OsuManualInputManagerTestScene
|
|
|
|
{
|
2022-04-29 01:14:09 +00:00
|
|
|
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);
|
2022-04-29 07:12:20 +00:00
|
|
|
|
|
|
|
InputManager.MoveMouseTo(Vector2.Zero);
|
2022-04-29 01:14:09 +00:00
|
|
|
});
|
|
|
|
|
2022-11-17 00:57:27 +00:00
|
|
|
[Test]
|
|
|
|
public void TestState()
|
|
|
|
{
|
|
|
|
AddRepeatStep("toggle options state", () => this.ChildrenOfType<FooterButton>().Last().Enabled.Toggle(), 20);
|
|
|
|
}
|
|
|
|
|
2022-04-29 01:14:09 +00:00
|
|
|
[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]
|
2022-04-29 07:12:20 +00:00
|
|
|
public void TestFooterRewindViaShiftMouseLeft()
|
2021-04-07 09:29:31 +00:00
|
|
|
{
|
2022-04-29 01:14:09 +00:00
|
|
|
AddStep("shift + click button", () =>
|
2021-04-07 09:29:31 +00:00
|
|
|
{
|
2022-04-29 01:14:09 +00:00
|
|
|
InputManager.PressKey(Key.LShift);
|
|
|
|
InputManager.MoveMouseTo(randomButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
InputManager.ReleaseKey(Key.LShift);
|
2021-04-07 09:29:31 +00:00
|
|
|
});
|
2022-04-29 01:14:09 +00:00
|
|
|
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled);
|
2021-04-07 09:29:31 +00:00
|
|
|
}
|
2022-04-29 07:12:20 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFooterRewindViaMouseRight()
|
|
|
|
{
|
|
|
|
AddStep("right click button", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(randomButton);
|
|
|
|
InputManager.Click(MouseButton.Right);
|
|
|
|
});
|
|
|
|
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled);
|
|
|
|
}
|
2021-04-07 09:29:31 +00:00
|
|
|
}
|
|
|
|
}
|