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
|
|
|
|
|
2020-06-04 13:17:00 +00:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using NUnit.Framework;
|
2020-06-04 13:17:00 +00:00
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
using osu.Framework.Threading;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2020-06-04 13:17:00 +00:00
|
|
|
|
using osu.Game.Overlays.KeyBinding;
|
|
|
|
|
using osuTK.Input;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-03-24 16:02:36 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.Settings
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-06-04 13:17:00 +00:00
|
|
|
|
public class TestSceneKeyBindingPanel : OsuManualInputManagerTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-05-14 01:45:05 +00:00
|
|
|
|
private readonly KeyBindingPanel panel;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-06-21 04:33:51 +00:00
|
|
|
|
public TestSceneKeyBindingPanel()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-05-14 01:45:05 +00:00
|
|
|
|
Child = panel = new KeyBindingPanel();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2019-05-14 01:45:05 +00:00
|
|
|
|
panel.Show();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
2020-06-04 13:17:00 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickTwiceOnClearButton()
|
|
|
|
|
{
|
|
|
|
|
KeyBindingRow firstRow = null;
|
|
|
|
|
|
|
|
|
|
AddStep("click first row", () =>
|
|
|
|
|
{
|
|
|
|
|
firstRow = panel.ChildrenOfType<KeyBindingRow>().First();
|
|
|
|
|
InputManager.MoveMouseTo(firstRow);
|
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("schedule button clicks", () =>
|
|
|
|
|
{
|
|
|
|
|
var clearButton = firstRow.ChildrenOfType<KeyBindingRow.ClearButton>().Single();
|
|
|
|
|
|
|
|
|
|
InputManager.MoveMouseTo(clearButton);
|
|
|
|
|
|
|
|
|
|
int buttonClicks = 0;
|
|
|
|
|
ScheduledDelegate clickDelegate = null;
|
|
|
|
|
|
|
|
|
|
clickDelegate = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
|
|
|
|
InputManager.ReleaseButton(MouseButton.Left);
|
|
|
|
|
|
|
|
|
|
if (++buttonClicks == 2)
|
|
|
|
|
{
|
|
|
|
|
// ReSharper disable once AccessToModifiedClosure
|
|
|
|
|
Debug.Assert(clickDelegate != null);
|
|
|
|
|
// ReSharper disable once AccessToModifiedClosure
|
|
|
|
|
clickDelegate.Cancel();
|
|
|
|
|
}
|
|
|
|
|
}, 0, true);
|
|
|
|
|
});
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|