1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +08:00

Add test coverage

This commit is contained in:
Bartłomiej Dach 2024-11-01 19:26:56 +01:00
parent 0f61e19857
commit 0a33d71671
No known key found for this signature in database

View File

@ -414,11 +414,7 @@ namespace osu.Game.Tests.Visual.Settings
});
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();
});
clearBinding();
scrollToAndStartBinding("Left (rim)");
AddStep("bind M1", () => InputManager.Click(MouseButton.Left));
@ -431,6 +427,45 @@ namespace osu.Game.Tests.Visual.Settings
AddUntilStep("conflict popover not shown", () => panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Null);
}
[Test]
public void TestResettingRowCannotConflictWithItself()
{
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)");
clearBinding();
scrollToAndStartBinding("Left (centre)", 1);
clearBinding();
scrollToAndStartBinding("Left (centre)");
AddStep("bind F", () => InputManager.Key(Key.F));
scrollToAndStartBinding("Left (centre)", 1);
AddStep("bind M1", () => InputManager.Click(MouseButton.Left));
AddStep("revert row to default", () =>
{
var row = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == "Left (centre)"));
InputManager.MoveMouseTo(row.ChildrenOfType<RevertToDefaultButton<bool>>().Single());
InputManager.Click(MouseButton.Left);
});
AddWaitStep("wait a bit", 3);
AddUntilStep("conflict popover not shown", () => panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Null);
}
private void clearBinding()
{
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();
});
}
private void checkBinding(string name, string keyName)
{
AddAssert($"Check {name} is bound to {keyName}", () =>
@ -442,23 +477,23 @@ namespace osu.Game.Tests.Visual.Settings
}, () => Is.EqualTo(keyName));
}
private void scrollToAndStartBinding(string name)
private void scrollToAndStartBinding(string name, int bindingIndex = 0)
{
KeyBindingRow.KeyButton firstButton = null;
KeyBindingRow.KeyButton targetButton = null;
AddStep($"Scroll to {name}", () =>
{
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == name));
firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First();
targetButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(bindingIndex);
panel.ChildrenOfType<SettingsPanel.SettingsSectionsContainer>().First().ScrollTo(firstButton);
panel.ChildrenOfType<SettingsPanel.SettingsSectionsContainer>().First().ScrollTo(targetButton);
});
AddWaitStep("wait for scroll", 5);
AddStep("click to bind", () =>
{
InputManager.MoveMouseTo(firstButton);
InputManager.MoveMouseTo(targetButton);
InputManager.Click(MouseButton.Left);
});
}