2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-09-15 07:25:37 +00:00
|
|
|
|
using System.Linq;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
2020-01-09 04:43:44 +00:00
|
|
|
|
using osu.Framework.Utils;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-03-24 16:02:36 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-03-23 01:01:33 +00:00
|
|
|
|
public class TestSceneKeyCounter : OsuManualInputManagerTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public TestSceneKeyCounter()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-09-12 06:41:53 +00:00
|
|
|
|
KeyCounterKeyboard testCounter;
|
|
|
|
|
|
2019-03-26 02:28:43 +00:00
|
|
|
|
KeyCounterDisplay kc = new KeyCounterDisplay
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new KeyCounter[]
|
|
|
|
|
{
|
2019-09-12 06:41:53 +00:00
|
|
|
|
testCounter = new KeyCounterKeyboard(Key.X),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
new KeyCounterKeyboard(Key.X),
|
|
|
|
|
new KeyCounterMouse(MouseButton.Left),
|
|
|
|
|
new KeyCounterMouse(MouseButton.Right),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AddStep("Add random", () =>
|
|
|
|
|
{
|
|
|
|
|
Key key = (Key)((int)Key.A + RNG.Next(26));
|
|
|
|
|
kc.Add(new KeyCounterKeyboard(key));
|
|
|
|
|
});
|
|
|
|
|
|
2018-09-15 07:25:37 +00:00
|
|
|
|
Key testKey = ((KeyCounterKeyboard)kc.Children.First()).Key;
|
|
|
|
|
|
2020-03-03 00:47:25 +00:00
|
|
|
|
void addPressKeyStep()
|
2018-07-28 20:24:03 +00:00
|
|
|
|
{
|
2020-11-05 14:41:56 +00:00
|
|
|
|
AddStep($"Press {testKey} key", () => InputManager.Key(testKey));
|
2020-03-03 00:47:25 +00:00
|
|
|
|
}
|
2018-07-28 20:24:03 +00:00
|
|
|
|
|
2020-03-03 00:47:25 +00:00
|
|
|
|
addPressKeyStep();
|
2019-09-12 06:41:53 +00:00
|
|
|
|
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses == 1);
|
2020-03-03 00:47:25 +00:00
|
|
|
|
addPressKeyStep();
|
2019-09-12 06:41:53 +00:00
|
|
|
|
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses == 2);
|
2020-03-06 09:00:07 +00:00
|
|
|
|
AddStep("Disable counting", () => testCounter.IsCounting = false);
|
2020-03-03 00:47:25 +00:00
|
|
|
|
addPressKeyStep();
|
|
|
|
|
AddAssert($"Check {testKey} count has not changed", () => testCounter.CountPresses == 2);
|
2018-09-15 07:25:37 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Add(kc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|