1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00

Add failing case for two bindings of single action bound to same key

This commit is contained in:
Bartłomiej Dach 2023-10-16 21:28:11 +02:00
parent 9c6166ec3d
commit 3aae07d1ca
No known key found for this signature in database

View File

@ -86,5 +86,32 @@ namespace osu.Game.Tests.Input
Assert.That(bindings[6].KeyCombination, Is.EqualTo(new KeyCombination(InputKey.PrintScreen)));
});
}
[Test]
public void TestDuplicateBindingsAllowedIfBoundToSameAction()
{
var bindings = new List<RealmKeyBinding>
{
new RealmKeyBinding(GlobalAction.Back, KeyCombination.FromKey(Key.Escape)),
new RealmKeyBinding(GlobalAction.Back, KeyCombination.FromKey(Key.Escape)),
new RealmKeyBinding(GlobalAction.MusicPrev, KeyCombination.FromKey(Key.F1)),
};
int countCleared = RealmKeyBindingStore.ClearDuplicateBindings(bindings);
Assert.Multiple(() =>
{
Assert.That(countCleared, Is.EqualTo(0));
Assert.That(bindings[0].Action, Is.EqualTo((int)GlobalAction.Back));
Assert.That(bindings[0].KeyCombination, Is.EqualTo(new KeyCombination(InputKey.Escape)));
Assert.That(bindings[1].Action, Is.EqualTo((int)GlobalAction.Back));
Assert.That(bindings[1].KeyCombination, Is.EqualTo(new KeyCombination(InputKey.Escape)));
Assert.That(bindings[2].Action, Is.EqualTo((int)GlobalAction.MusicPrev));
Assert.That(bindings[2].KeyCombination, Is.EqualTo(new KeyCombination(InputKey.F1)));
});
}
}
}