mirror of
https://github.com/ppy/osu.git
synced 2024-11-07 16:07:25 +08:00
11d0e185b8
This allows for different layouts of display. Idk, maybe someone would want to mix both variants? (don't do this please). This commit is mostly prep for further changes.
60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
// 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.
|
|
|
|
#nullable disable
|
|
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Utils;
|
|
using osu.Game.Screens.Play;
|
|
using osuTK.Input;
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
{
|
|
[TestFixture]
|
|
public partial class TestSceneKeyCounter : OsuManualInputManagerTestScene
|
|
{
|
|
public TestSceneKeyCounter()
|
|
{
|
|
DefaultKeyCounter testCounter;
|
|
|
|
KeyCounterDisplay kc = new DefaultKeyCounterDisplay
|
|
{
|
|
Origin = Anchor.Centre,
|
|
Anchor = Anchor.Centre,
|
|
Children = new[]
|
|
{
|
|
testCounter = new DefaultKeyCounter(new KeyCounterKeyboard(Key.X)),
|
|
new DefaultKeyCounter(new KeyCounterKeyboard(Key.X)),
|
|
new DefaultKeyCounter(new KeyCounterMouse(MouseButton.Left)),
|
|
new DefaultKeyCounter(new KeyCounterMouse(MouseButton.Right)),
|
|
},
|
|
};
|
|
|
|
AddStep("Add random", () =>
|
|
{
|
|
Key key = (Key)((int)Key.A + RNG.Next(26));
|
|
kc.Add(kc.CreateKeyCounter(new KeyCounterKeyboard(key)));
|
|
});
|
|
|
|
Key testKey = ((KeyCounterKeyboard)kc.Children.First().CounterTrigger).Key;
|
|
|
|
void addPressKeyStep()
|
|
{
|
|
AddStep($"Press {testKey} key", () => InputManager.Key(testKey));
|
|
}
|
|
|
|
addPressKeyStep();
|
|
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses == 1);
|
|
addPressKeyStep();
|
|
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses == 2);
|
|
AddStep("Disable counting", () => testCounter.IsCounting = false);
|
|
addPressKeyStep();
|
|
AddAssert($"Check {testKey} count has not changed", () => testCounter.CountPresses == 2);
|
|
|
|
Add(kc);
|
|
}
|
|
}
|
|
}
|