2019-01-24 17:43:03 +09: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.
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-09-15 16:25:37 +09:00
|
|
|
|
using System.Linq;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
2020-01-09 13:43:44 +09:00
|
|
|
|
using osu.Framework.Utils;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Game.Screens.Play;
|
2023-03-07 16:28:54 +09:00
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
2023-02-15 22:18:02 +00:00
|
|
|
|
using osuTK;
|
2018-11-20 16:51:59 +09:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-03-25 01:02:36 +09:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2022-11-24 14:32:20 +09:00
|
|
|
|
public partial class TestSceneKeyCounter : OsuManualInputManagerTestScene
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2019-05-14 22:37:25 +03:00
|
|
|
|
public TestSceneKeyCounter()
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2023-04-25 21:37:17 +09:00
|
|
|
|
KeyCounterDisplay defaultDisplay = new DefaultKeyCounterDisplay
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
2023-04-05 21:34:36 +02:00
|
|
|
|
Position = new Vector2(0, 72.7f)
|
|
|
|
|
};
|
2019-09-12 15:41:53 +09:00
|
|
|
|
|
2023-04-25 21:37:17 +09:00
|
|
|
|
KeyCounterDisplay argonDisplay = new ArgonKeyCounterDisplay
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2023-04-05 21:34:36 +02:00
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Position = new Vector2(0, -72.7f)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
};
|
|
|
|
|
|
2023-04-25 21:37:17 +09:00
|
|
|
|
defaultDisplay.AddRange(new InputTrigger[]
|
2023-03-07 16:21:57 +09:00
|
|
|
|
{
|
|
|
|
|
new KeyCounterKeyboardTrigger(Key.X),
|
|
|
|
|
new KeyCounterKeyboardTrigger(Key.X),
|
|
|
|
|
new KeyCounterMouseTrigger(MouseButton.Left),
|
|
|
|
|
new KeyCounterMouseTrigger(MouseButton.Right),
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-25 21:37:17 +09:00
|
|
|
|
argonDisplay.AddRange(new InputTrigger[]
|
2023-04-05 21:34:36 +02:00
|
|
|
|
{
|
|
|
|
|
new KeyCounterKeyboardTrigger(Key.X),
|
|
|
|
|
new KeyCounterKeyboardTrigger(Key.X),
|
|
|
|
|
new KeyCounterMouseTrigger(MouseButton.Left),
|
|
|
|
|
new KeyCounterMouseTrigger(MouseButton.Right),
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-25 21:37:17 +09:00
|
|
|
|
var testCounter = (DefaultKeyCounter)defaultDisplay.Counters.First();
|
2023-02-22 17:59:39 +00:00
|
|
|
|
|
2018-04-13 18:19:50 +09:00
|
|
|
|
AddStep("Add random", () =>
|
|
|
|
|
{
|
|
|
|
|
Key key = (Key)((int)Key.A + RNG.Next(26));
|
2023-04-25 21:37:17 +09:00
|
|
|
|
defaultDisplay.Add(new KeyCounterKeyboardTrigger(key));
|
|
|
|
|
argonDisplay.Add(new KeyCounterKeyboardTrigger(key));
|
2018-04-13 18:19:50 +09:00
|
|
|
|
});
|
|
|
|
|
|
2023-04-25 21:37:17 +09:00
|
|
|
|
Key testKey = ((KeyCounterKeyboardTrigger)defaultDisplay.Counters.First().Trigger).Key;
|
2018-07-28 23:24:03 +03:00
|
|
|
|
|
2020-03-03 06:17:25 +05:30
|
|
|
|
addPressKeyStep();
|
2023-02-16 22:20:34 +00:00
|
|
|
|
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses.Value == 1);
|
2020-03-03 06:17:25 +05:30
|
|
|
|
addPressKeyStep();
|
2023-02-16 22:20:34 +00:00
|
|
|
|
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses.Value == 2);
|
2023-04-25 20:17:52 +02:00
|
|
|
|
AddStep("Disable counting", () =>
|
|
|
|
|
{
|
|
|
|
|
argonDisplay.IsCounting.Value = false;
|
|
|
|
|
defaultDisplay.IsCounting.Value = false;
|
|
|
|
|
});
|
2020-03-03 06:17:25 +05:30
|
|
|
|
addPressKeyStep();
|
2023-02-16 22:20:34 +00:00
|
|
|
|
AddAssert($"Check {testKey} count has not changed", () => testCounter.CountPresses.Value == 2);
|
2018-09-15 16:25:37 +09:00
|
|
|
|
|
2023-04-25 21:37:17 +09:00
|
|
|
|
Add(defaultDisplay);
|
|
|
|
|
Add(argonDisplay);
|
|
|
|
|
|
|
|
|
|
void addPressKeyStep() => AddStep($"Press {testKey} key", () => InputManager.Key(testKey));
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|