2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-06-04 21:17:00 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
2018-03-02 14:34:31 +08:00
|
|
|
|
using NUnit.Framework;
|
2020-06-04 21:17:00 +08:00
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
using osu.Framework.Threading;
|
2021-05-24 20:56:47 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-10-03 19:53:26 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2023-10-11 14:38:51 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2023-10-13 21:03:41 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2017-09-18 21:32:49 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2021-07-21 12:18:24 +08:00
|
|
|
|
using osu.Game.Overlays.Settings.Sections.Input;
|
2023-10-11 14:38:51 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko;
|
2020-06-04 21:17:00 +08:00
|
|
|
|
using osuTK.Input;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Settings
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2018-03-02 14:34:31 +08:00
|
|
|
|
[TestFixture]
|
2020-06-04 21:17:00 +08:00
|
|
|
|
public partial class TestSceneKeyBindingPanel : OsuManualInputManagerTestScene
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2019-05-14 09:45:05 +08:00
|
|
|
|
private readonly KeyBindingPanel panel;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-21 12:33:51 +08:00
|
|
|
|
public TestSceneKeyBindingPanel()
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2019-05-14 09:45:05 +08:00
|
|
|
|
Child = panel = new KeyBindingPanel();
|
2017-09-18 21:32:49 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-18 21:32:49 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2019-05-14 09:45:05 +08:00
|
|
|
|
panel.Show();
|
2017-09-18 21:32:49 +08:00
|
|
|
|
}
|
2020-06-04 21:17:00 +08:00
|
|
|
|
|
2021-05-24 20:56:47 +08:00
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUpSteps()
|
|
|
|
|
{
|
2021-08-17 15:37:18 +08:00
|
|
|
|
AddUntilStep("wait for load", () => panel.ChildrenOfType<GlobalKeyBindingsSection>().Any());
|
2021-05-24 20:56:47 +08:00
|
|
|
|
AddStep("Scroll to top", () => panel.ChildrenOfType<SettingsPanel.SettingsSectionsContainer>().First().ScrollToTop());
|
|
|
|
|
AddWaitStep("wait for scroll", 5);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-18 14:34:26 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingTwoNonModifiers()
|
|
|
|
|
{
|
|
|
|
|
AddStep("press j", () => InputManager.PressKey(Key.J));
|
|
|
|
|
scrollToAndStartBinding("Increase volume");
|
|
|
|
|
AddStep("press k", () => InputManager.Key(Key.K));
|
|
|
|
|
AddStep("release j", () => InputManager.ReleaseKey(Key.J));
|
|
|
|
|
checkBinding("Increase volume", "K");
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-18 14:33:13 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingSingleKey()
|
|
|
|
|
{
|
|
|
|
|
scrollToAndStartBinding("Increase volume");
|
|
|
|
|
AddStep("press k", () => InputManager.Key(Key.K));
|
|
|
|
|
checkBinding("Increase volume", "K");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingSingleModifier()
|
|
|
|
|
{
|
|
|
|
|
scrollToAndStartBinding("Increase volume");
|
|
|
|
|
AddStep("press shift", () => InputManager.PressKey(Key.ShiftLeft));
|
|
|
|
|
AddStep("release shift", () => InputManager.ReleaseKey(Key.ShiftLeft));
|
|
|
|
|
checkBinding("Increase volume", "LShift");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingSingleKeyWithModifier()
|
|
|
|
|
{
|
|
|
|
|
scrollToAndStartBinding("Increase volume");
|
|
|
|
|
AddStep("press shift", () => InputManager.PressKey(Key.ShiftLeft));
|
|
|
|
|
AddStep("press k", () => InputManager.Key(Key.K));
|
|
|
|
|
AddStep("release shift", () => InputManager.ReleaseKey(Key.ShiftLeft));
|
|
|
|
|
checkBinding("Increase volume", "LShift-K");
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-24 20:56:47 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingMouseWheelToNonGameplay()
|
|
|
|
|
{
|
|
|
|
|
scrollToAndStartBinding("Increase volume");
|
|
|
|
|
AddStep("press k", () => InputManager.Key(Key.K));
|
|
|
|
|
checkBinding("Increase volume", "K");
|
|
|
|
|
|
|
|
|
|
AddStep("click again", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("scroll mouse wheel", () => InputManager.ScrollVerticalBy(1));
|
|
|
|
|
|
|
|
|
|
checkBinding("Increase volume", "Wheel Up");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingMouseWheelToGameplay()
|
|
|
|
|
{
|
|
|
|
|
scrollToAndStartBinding("Left button");
|
|
|
|
|
AddStep("press k", () => InputManager.Key(Key.Z));
|
|
|
|
|
checkBinding("Left button", "Z");
|
|
|
|
|
|
|
|
|
|
AddStep("click again", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
AddStep("scroll mouse wheel", () => InputManager.ScrollVerticalBy(1));
|
|
|
|
|
|
|
|
|
|
checkBinding("Left button", "Z");
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-04 21:17:00 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickTwiceOnClearButton()
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
KeyBindingRow firstRow = null;
|
2020-06-04 21:17:00 +08:00
|
|
|
|
|
|
|
|
|
AddStep("click first row", () =>
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
firstRow = panel.ChildrenOfType<KeyBindingRow>().First();
|
2021-05-14 23:01:17 +08:00
|
|
|
|
|
2021-05-15 09:24:08 +08:00
|
|
|
|
InputManager.MoveMouseTo(firstRow);
|
|
|
|
|
InputManager.Click(MouseButton.Left);
|
2020-06-04 21:17:00 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("schedule button clicks", () =>
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
var clearButton = firstRow.ChildrenOfType<KeyBindingRow.ClearButton>().Single();
|
2020-06-04 21:17:00 +08:00
|
|
|
|
|
|
|
|
|
InputManager.MoveMouseTo(clearButton);
|
|
|
|
|
|
|
|
|
|
int buttonClicks = 0;
|
|
|
|
|
ScheduledDelegate clickDelegate = null;
|
|
|
|
|
|
|
|
|
|
clickDelegate = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
2020-11-05 22:41:56 +08:00
|
|
|
|
InputManager.Click(MouseButton.Left);
|
2020-06-04 21:17:00 +08:00
|
|
|
|
|
|
|
|
|
if (++buttonClicks == 2)
|
|
|
|
|
{
|
|
|
|
|
// ReSharper disable once AccessToModifiedClosure
|
|
|
|
|
Debug.Assert(clickDelegate != null);
|
|
|
|
|
// ReSharper disable once AccessToModifiedClosure
|
|
|
|
|
clickDelegate.Cancel();
|
|
|
|
|
}
|
|
|
|
|
}, 0, true);
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-08-03 03:41:35 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestClearButtonOnBindings()
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
KeyBindingRow multiBindingRow = null;
|
2020-08-03 03:41:35 +08:00
|
|
|
|
|
2020-08-22 05:05:19 +08:00
|
|
|
|
AddStep("click first row with two bindings", () =>
|
2020-08-03 03:41:35 +08:00
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().First(row => row.Defaults.Count() > 1);
|
2023-12-27 03:36:12 +08:00
|
|
|
|
InputManager.MoveMouseTo(multiBindingRow.ChildrenOfType<OsuSpriteText>().First());
|
2020-08-03 03:41:35 +08:00
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
clickClearButton();
|
|
|
|
|
|
2023-10-13 21:03:41 +08:00
|
|
|
|
AddAssert("first binding cleared",
|
|
|
|
|
() => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().Text.Text,
|
|
|
|
|
() => Is.EqualTo(InputSettingsStrings.ActionHasNoKeyBinding));
|
2020-08-03 03:41:35 +08:00
|
|
|
|
|
|
|
|
|
AddStep("click second binding", () =>
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
var target = multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1);
|
2020-08-03 03:41:35 +08:00
|
|
|
|
|
|
|
|
|
InputManager.MoveMouseTo(target);
|
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
clickClearButton();
|
|
|
|
|
|
2023-10-13 21:03:41 +08:00
|
|
|
|
AddAssert("second binding cleared",
|
|
|
|
|
() => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1).Text.Text,
|
|
|
|
|
() => Is.EqualTo(InputSettingsStrings.ActionHasNoKeyBinding));
|
2020-08-03 03:41:35 +08:00
|
|
|
|
|
|
|
|
|
void clickClearButton()
|
|
|
|
|
{
|
|
|
|
|
AddStep("click clear button", () =>
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
var clearButton = multiBindingRow.ChildrenOfType<KeyBindingRow.ClearButton>().Single();
|
2020-08-03 03:41:35 +08:00
|
|
|
|
|
|
|
|
|
InputManager.MoveMouseTo(clearButton);
|
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-03 03:47:23 +08:00
|
|
|
|
|
2021-05-09 13:51:17 +08:00
|
|
|
|
[Test]
|
2021-05-15 17:42:33 +08:00
|
|
|
|
public void TestSingleBindingResetButton()
|
2021-05-09 13:51:17 +08:00
|
|
|
|
{
|
2021-05-26 17:03:15 +08:00
|
|
|
|
KeyBindingRow settingsKeyBindingRow = null;
|
2021-05-09 13:51:17 +08:00
|
|
|
|
|
2021-05-15 17:42:33 +08:00
|
|
|
|
AddStep("click first row", () =>
|
2021-05-09 13:51:17 +08:00
|
|
|
|
{
|
2021-05-26 17:03:15 +08:00
|
|
|
|
settingsKeyBindingRow = panel.ChildrenOfType<KeyBindingRow>().First();
|
2021-05-15 17:42:33 +08:00
|
|
|
|
|
|
|
|
|
InputManager.MoveMouseTo(settingsKeyBindingRow);
|
2021-05-09 13:51:17 +08:00
|
|
|
|
InputManager.Click(MouseButton.Left);
|
2021-05-14 23:01:17 +08:00
|
|
|
|
InputManager.PressKey(Key.P);
|
|
|
|
|
InputManager.ReleaseKey(Key.P);
|
2021-05-09 13:51:17 +08:00
|
|
|
|
});
|
|
|
|
|
|
2023-07-13 12:46:50 +08:00
|
|
|
|
AddUntilStep("restore button shown", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha > 0);
|
2021-05-14 23:01:17 +08:00
|
|
|
|
|
2021-05-15 09:24:08 +08:00
|
|
|
|
AddStep("click reset button for bindings", () =>
|
|
|
|
|
{
|
2023-07-13 12:46:50 +08:00
|
|
|
|
var resetButton = settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First();
|
2021-05-09 13:51:17 +08:00
|
|
|
|
|
2021-08-04 16:27:44 +08:00
|
|
|
|
resetButton.TriggerClick();
|
2021-05-15 09:24:08 +08:00
|
|
|
|
});
|
2021-05-14 23:01:17 +08:00
|
|
|
|
|
2023-07-13 12:46:50 +08:00
|
|
|
|
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha == 0);
|
2021-05-09 13:51:17 +08:00
|
|
|
|
|
2022-11-18 14:33:13 +08:00
|
|
|
|
AddAssert("binding cleared",
|
2023-10-11 17:08:10 +08:00
|
|
|
|
() => settingsKeyBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.Value.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));
|
2021-05-14 23:01:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestResetAllBindingsButton()
|
|
|
|
|
{
|
2021-05-26 17:03:15 +08:00
|
|
|
|
KeyBindingRow settingsKeyBindingRow = null;
|
2021-05-14 23:01:17 +08:00
|
|
|
|
|
2021-05-15 17:42:33 +08:00
|
|
|
|
AddStep("click first row", () =>
|
2021-05-14 23:01:17 +08:00
|
|
|
|
{
|
2021-05-26 17:03:15 +08:00
|
|
|
|
settingsKeyBindingRow = panel.ChildrenOfType<KeyBindingRow>().First();
|
2021-05-15 17:42:33 +08:00
|
|
|
|
|
|
|
|
|
InputManager.MoveMouseTo(settingsKeyBindingRow);
|
2021-05-09 13:51:17 +08:00
|
|
|
|
InputManager.Click(MouseButton.Left);
|
2021-05-14 23:01:17 +08:00
|
|
|
|
InputManager.PressKey(Key.P);
|
|
|
|
|
InputManager.ReleaseKey(Key.P);
|
2021-05-09 13:51:17 +08:00
|
|
|
|
});
|
2021-05-15 17:42:33 +08:00
|
|
|
|
|
2023-07-13 12:46:50 +08:00
|
|
|
|
AddUntilStep("restore button shown", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha > 0);
|
2021-05-15 17:42:33 +08:00
|
|
|
|
|
|
|
|
|
AddStep("click reset button for bindings", () =>
|
2021-05-09 13:51:17 +08:00
|
|
|
|
{
|
2021-05-15 17:42:33 +08:00
|
|
|
|
var resetButton = panel.ChildrenOfType<ResetButton>().First();
|
2021-05-09 13:51:17 +08:00
|
|
|
|
|
2021-08-04 16:27:44 +08:00
|
|
|
|
resetButton.TriggerClick();
|
2021-05-15 09:24:08 +08:00
|
|
|
|
});
|
|
|
|
|
|
2023-07-13 12:46:50 +08:00
|
|
|
|
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha == 0);
|
2021-05-15 17:42:33 +08:00
|
|
|
|
|
2022-11-18 14:33:13 +08:00
|
|
|
|
AddAssert("binding cleared",
|
2023-10-11 17:08:10 +08:00
|
|
|
|
() => settingsKeyBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.Value.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));
|
2021-05-09 13:51:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-03 03:47:23 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestClickRowSelectsFirstBinding()
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
KeyBindingRow multiBindingRow = null;
|
2020-08-03 03:47:23 +08:00
|
|
|
|
|
2020-08-22 05:05:19 +08:00
|
|
|
|
AddStep("click first row with two bindings", () =>
|
2020-08-03 03:47:23 +08:00
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().First(row => row.Defaults.Count() > 1);
|
2023-12-27 03:36:12 +08:00
|
|
|
|
InputManager.MoveMouseTo(multiBindingRow.ChildrenOfType<OsuSpriteText>().First());
|
2020-08-03 03:47:23 +08:00
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-25 19:08:40 +08:00
|
|
|
|
AddAssert("first binding selected", () => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().IsBinding);
|
2020-08-03 03:47:23 +08:00
|
|
|
|
|
|
|
|
|
AddStep("click second binding", () =>
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
var target = multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1);
|
2020-08-03 03:47:23 +08:00
|
|
|
|
|
|
|
|
|
InputManager.MoveMouseTo(target);
|
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("click back binding row", () =>
|
|
|
|
|
{
|
2021-05-25 19:08:40 +08:00
|
|
|
|
multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().ElementAt(10);
|
2020-08-22 05:05:19 +08:00
|
|
|
|
InputManager.MoveMouseTo(multiBindingRow);
|
2020-08-03 03:47:23 +08:00
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-25 19:08:40 +08:00
|
|
|
|
AddAssert("first binding selected", () => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().IsBinding);
|
2020-08-03 03:47:23 +08:00
|
|
|
|
}
|
2021-05-24 20:56:47 +08:00
|
|
|
|
|
2021-10-03 19:53:26 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestFilteringHidesResetSectionButtons()
|
|
|
|
|
{
|
|
|
|
|
SearchTextBox searchTextBox = null;
|
|
|
|
|
|
|
|
|
|
AddStep("add any search term", () =>
|
|
|
|
|
{
|
|
|
|
|
searchTextBox = panel.ChildrenOfType<SearchTextBox>().Single();
|
|
|
|
|
searchTextBox.Current.Value = "chat";
|
|
|
|
|
});
|
|
|
|
|
AddUntilStep("all reset section bindings buttons hidden", () => panel.ChildrenOfType<ResetButton>().All(button => button.Alpha == 0));
|
|
|
|
|
|
|
|
|
|
AddStep("clear search term", () => searchTextBox.Current.Value = string.Empty);
|
|
|
|
|
AddUntilStep("all reset section bindings buttons shown", () => panel.ChildrenOfType<ResetButton>().All(button => button.Alpha == 1));
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-11 14:38:51 +08:00
|
|
|
|
[Test]
|
2024-04-23 18:32:52 +08:00
|
|
|
|
public void TestBindingConflictResolvedByRollbackViaMouse()
|
2023-10-11 14:38:51 +08:00
|
|
|
|
{
|
|
|
|
|
AddStep("reset taiko section to default", () =>
|
|
|
|
|
{
|
|
|
|
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
|
|
|
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
scrollToAndStartBinding("Left (rim)");
|
|
|
|
|
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
|
|
|
|
|
KeyBindingConflictPopover popover = null;
|
|
|
|
|
AddUntilStep("wait for popover", () => popover = panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
|
|
|
|
|
AddStep("click first button", () => popover.ChildrenOfType<RoundedButton>().First().TriggerClick());
|
|
|
|
|
checkBinding("Left (centre)", "M1");
|
|
|
|
|
checkBinding("Left (rim)", "M2");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2024-04-23 18:32:52 +08:00
|
|
|
|
public void TestBindingConflictResolvedByOverwriteViaMouse()
|
2023-10-11 14:38:51 +08:00
|
|
|
|
{
|
|
|
|
|
AddStep("reset taiko section to default", () =>
|
|
|
|
|
{
|
|
|
|
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
|
|
|
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
scrollToAndStartBinding("Left (rim)");
|
|
|
|
|
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
|
|
|
|
|
KeyBindingConflictPopover popover = null;
|
|
|
|
|
AddUntilStep("wait for popover", () => popover = panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
|
|
|
|
|
AddStep("click second button", () => popover.ChildrenOfType<RoundedButton>().ElementAt(1).TriggerClick());
|
2023-10-13 21:03:41 +08:00
|
|
|
|
checkBinding("Left (centre)", InputSettingsStrings.ActionHasNoKeyBinding.ToString());
|
2023-10-11 14:38:51 +08:00
|
|
|
|
checkBinding("Left (rim)", "M1");
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-23 18:32:52 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingConflictResolvedByRollbackViaKeyboard()
|
|
|
|
|
{
|
|
|
|
|
AddStep("reset taiko & global sections to default", () =>
|
|
|
|
|
{
|
|
|
|
|
panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset))
|
|
|
|
|
.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
|
|
|
|
|
|
|
|
|
panel.ChildrenOfType<ResetButton>().First().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
scrollToAndStartBinding("Left (rim)");
|
|
|
|
|
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
|
|
|
|
|
AddUntilStep("wait for popover", () => panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
|
|
|
|
|
AddStep("press Esc", () => InputManager.Key(Key.Escape));
|
|
|
|
|
checkBinding("Left (centre)", "M1");
|
|
|
|
|
checkBinding("Left (rim)", "M2");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingConflictResolvedByOverwriteViaKeyboard()
|
|
|
|
|
{
|
|
|
|
|
AddStep("reset taiko & global sections to default", () =>
|
|
|
|
|
{
|
|
|
|
|
panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset))
|
|
|
|
|
.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
|
|
|
|
|
|
|
|
|
panel.ChildrenOfType<ResetButton>().First().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
scrollToAndStartBinding("Left (rim)");
|
|
|
|
|
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
|
|
|
|
|
AddUntilStep("wait for popover", () => panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
|
|
|
|
|
AddStep("press Enter", () => InputManager.Key(Key.Enter));
|
|
|
|
|
checkBinding("Left (centre)", InputSettingsStrings.ActionHasNoKeyBinding.ToString());
|
|
|
|
|
checkBinding("Left (rim)", "M1");
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-11 14:38:51 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestBindingConflictCausedByResetToDefaultOfSingleRow()
|
|
|
|
|
{
|
|
|
|
|
AddStep("reset taiko section to default", () =>
|
|
|
|
|
{
|
|
|
|
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
|
|
|
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
scrollToAndStartBinding("Left (centre)");
|
|
|
|
|
AddStep("clear binding", () =>
|
|
|
|
|
{
|
|
|
|
|
var row = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == "Left (centre)"));
|
|
|
|
|
row.ChildrenOfType<KeyBindingRow.ClearButton>().Single().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
scrollToAndStartBinding("Left (rim)");
|
|
|
|
|
AddStep("bind M1", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
|
|
|
|
|
AddStep("reset Left (centre) to default", () =>
|
|
|
|
|
{
|
|
|
|
|
var row = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == "Left (centre)"));
|
|
|
|
|
row.ChildrenOfType<RevertToDefaultButton<bool>>().Single().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
KeyBindingConflictPopover popover = null;
|
|
|
|
|
AddUntilStep("wait for popover", () => popover = panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
|
|
|
|
|
AddStep("click second button", () => popover.ChildrenOfType<RoundedButton>().ElementAt(1).TriggerClick());
|
|
|
|
|
checkBinding("Left (centre)", "M1");
|
2023-10-13 21:03:41 +08:00
|
|
|
|
checkBinding("Left (rim)", InputSettingsStrings.ActionHasNoKeyBinding.ToString());
|
2023-10-11 14:38:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestResettingEntireSectionDoesNotCauseBindingConflicts()
|
|
|
|
|
{
|
|
|
|
|
AddStep("reset taiko section to default", () =>
|
|
|
|
|
{
|
|
|
|
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
|
|
|
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
scrollToAndStartBinding("Left (centre)");
|
|
|
|
|
AddStep("clear binding", () =>
|
|
|
|
|
{
|
|
|
|
|
var row = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == "Left (centre)"));
|
|
|
|
|
row.ChildrenOfType<KeyBindingRow.ClearButton>().Single().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
scrollToAndStartBinding("Left (rim)");
|
|
|
|
|
AddStep("bind M1", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
|
|
|
|
|
AddStep("reset taiko section to default", () =>
|
|
|
|
|
{
|
|
|
|
|
var section = panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset));
|
|
|
|
|
section.ChildrenOfType<ResetButton>().Single().TriggerClick();
|
|
|
|
|
});
|
|
|
|
|
AddWaitStep("wait a bit", 3);
|
|
|
|
|
AddUntilStep("conflict popover not shown", () => panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Null);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-24 20:56:47 +08:00
|
|
|
|
private void checkBinding(string name, string keyName)
|
|
|
|
|
{
|
|
|
|
|
AddAssert($"Check {name} is bound to {keyName}", () =>
|
|
|
|
|
{
|
2021-09-16 17:08:19 +08:00
|
|
|
|
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == name));
|
2021-05-24 20:56:47 +08:00
|
|
|
|
var firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First();
|
|
|
|
|
|
2022-11-18 14:33:13 +08:00
|
|
|
|
return firstButton.Text.Text.ToString();
|
|
|
|
|
}, () => Is.EqualTo(keyName));
|
2021-05-24 20:56:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void scrollToAndStartBinding(string name)
|
|
|
|
|
{
|
|
|
|
|
KeyBindingRow.KeyButton firstButton = null;
|
|
|
|
|
|
|
|
|
|
AddStep($"Scroll to {name}", () =>
|
|
|
|
|
{
|
2021-09-16 17:08:19 +08:00
|
|
|
|
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == name));
|
2021-05-24 20:56:47 +08:00
|
|
|
|
firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First();
|
|
|
|
|
|
|
|
|
|
panel.ChildrenOfType<SettingsPanel.SettingsSectionsContainer>().First().ScrollTo(firstButton);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddWaitStep("wait for scroll", 5);
|
|
|
|
|
|
|
|
|
|
AddStep("click to bind", () =>
|
|
|
|
|
{
|
|
|
|
|
InputManager.MoveMouseTo(firstButton);
|
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-09-18 21:32:49 +08:00
|
|
|
|
}
|
2021-05-26 17:03:15 +08:00
|
|
|
|
}
|