1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 15:27:26 +08:00

Move initialisation logic to [SetUp]

This commit is contained in:
Bartłomiej Dach 2020-02-13 20:44:02 +01:00
parent c391a464a5
commit cc625e3b89

View File

@ -31,73 +31,13 @@ namespace osu.Game.Tests.Visual.UserInterface
private string commitText; private string commitText;
private bool cancelActionFired; private bool cancelActionFired;
[Test] [SetUp]
public void TestCommitViaKeyboard() public void SetUp()
{ {
AddStep("Create", createEditors);
AddStep("Click on textbox", () =>
{
InputManager.MoveMouseTo(commentEditor);
InputManager.Click(MouseButton.Left);
});
AddStep("Write something", () => commentEditor.Current.Value = "text");
AddStep("Click Enter", () => press(Key.Enter));
AddAssert("Text has been invoked", () => !string.IsNullOrEmpty(commitText));
AddAssert("Button is loading", () => commentEditor.IsLoading);
}
[Test]
public void TestCommitViaKeyboardWhenEmpty()
{
AddStep("Create", createEditors);
AddStep("Click on textbox", () =>
{
InputManager.MoveMouseTo(commentEditor);
InputManager.Click(MouseButton.Left);
});
AddStep("Click Enter", () => press(Key.Enter));
AddAssert("Text not invoked", () => string.IsNullOrEmpty(commitText));
AddAssert("Button is not loading", () => !commentEditor.IsLoading);
}
[Test]
public void TestCommitViaButton()
{
AddStep("Create", createEditors);
AddStep("Click on textbox", () =>
{
InputManager.MoveMouseTo(commentEditor);
InputManager.Click(MouseButton.Left);
});
AddStep("Write something", () => commentEditor.Current.Value = "text");
AddStep("Click on button", () =>
{
InputManager.MoveMouseTo(commentEditor.ButtonsContainer);
InputManager.Click(MouseButton.Left);
});
AddAssert("Text has been invoked", () => !string.IsNullOrEmpty(commitText));
AddAssert("Button is loading", () => commentEditor.IsLoading);
}
[Test]
public void TestCancelAction()
{
AddStep("Create", createEditors);
AddStep("Click on cancel button", () =>
{
InputManager.MoveMouseTo(cancellableCommentEditor.ButtonsContainer);
InputManager.Click(MouseButton.Left);
});
AddAssert("Cancel action is fired", () => cancelActionFired);
}
private void createEditors()
{
Clear();
commitText = string.Empty; commitText = string.Empty;
cancelActionFired = false; cancelActionFired = false;
Add(new FillFlowContainer Schedule(() => Add(new FillFlowContainer
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -117,7 +57,63 @@ namespace osu.Game.Tests.Visual.UserInterface
OnCancel = onCancel OnCancel = onCancel
} }
} }
}));
}
[Test]
public void TestCommitViaKeyboard()
{
AddStep("Click on textbox", () =>
{
InputManager.MoveMouseTo(commentEditor);
InputManager.Click(MouseButton.Left);
}); });
AddStep("Write something", () => commentEditor.Current.Value = "text");
AddStep("Click Enter", () => press(Key.Enter));
AddAssert("Text has been invoked", () => !string.IsNullOrEmpty(commitText));
AddAssert("Button is loading", () => commentEditor.IsLoading);
}
[Test]
public void TestCommitViaKeyboardWhenEmpty()
{
AddStep("Click on textbox", () =>
{
InputManager.MoveMouseTo(commentEditor);
InputManager.Click(MouseButton.Left);
});
AddStep("Click Enter", () => press(Key.Enter));
AddAssert("Text not invoked", () => string.IsNullOrEmpty(commitText));
AddAssert("Button is not loading", () => !commentEditor.IsLoading);
}
[Test]
public void TestCommitViaButton()
{
AddStep("Click on textbox", () =>
{
InputManager.MoveMouseTo(commentEditor);
InputManager.Click(MouseButton.Left);
});
AddStep("Write something", () => commentEditor.Current.Value = "text");
AddStep("Click on button", () =>
{
InputManager.MoveMouseTo(commentEditor.ButtonsContainer);
InputManager.Click(MouseButton.Left);
});
AddAssert("Text has been invoked", () => !string.IsNullOrEmpty(commitText));
AddAssert("Button is loading", () => commentEditor.IsLoading);
}
[Test]
public void TestCancelAction()
{
AddStep("Click on cancel button", () =>
{
InputManager.MoveMouseTo(cancellableCommentEditor.ButtonsContainer);
InputManager.Click(MouseButton.Left);
});
AddAssert("Cancel action is fired", () => cancelActionFired);
} }
private void onCommit(string value) private void onCommit(string value)