mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 01:53:00 +08:00
Add Test
This commit is contained in:
parent
c62952ea3a
commit
78d6f24fca
@ -114,6 +114,51 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
=> AddAssert($"state is {expected}", () => state.Value == expected);
|
=> AddAssert($"state is {expected}", () => state.Value == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestItemRespondsToRightClick()
|
||||||
|
{
|
||||||
|
OsuMenu menu = null;
|
||||||
|
|
||||||
|
Bindable<TernaryState> state = new Bindable<TernaryState>(TernaryState.Indeterminate);
|
||||||
|
|
||||||
|
AddStep("create menu", () =>
|
||||||
|
{
|
||||||
|
state.Value = TernaryState.Indeterminate;
|
||||||
|
|
||||||
|
Child = menu = new OsuMenu(Direction.Vertical, true)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Items = new[]
|
||||||
|
{
|
||||||
|
new TernaryStateToggleMenuItem("First"),
|
||||||
|
new TernaryStateToggleMenuItem("Second") { State = { BindTarget = state } },
|
||||||
|
new TernaryStateToggleMenuItem("Third") { State = { Value = TernaryState.True } },
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
checkState(TernaryState.Indeterminate);
|
||||||
|
|
||||||
|
click();
|
||||||
|
checkState(TernaryState.True);
|
||||||
|
|
||||||
|
click();
|
||||||
|
checkState(TernaryState.False);
|
||||||
|
|
||||||
|
AddStep("change state via bindable", () => state.Value = TernaryState.True);
|
||||||
|
|
||||||
|
void click() =>
|
||||||
|
AddStep("click", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(menu.ScreenSpaceDrawQuad.Centre);
|
||||||
|
InputManager.Click(MouseButton.Right);
|
||||||
|
});
|
||||||
|
|
||||||
|
void checkState(TernaryState expected)
|
||||||
|
=> AddAssert($"state is {expected}", () => state.Value == expected);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCustomState()
|
public void TestCustomState()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user