1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 03:22:55 +08:00

Add test coverage of flinging

This commit is contained in:
Dean Herbert 2022-09-12 19:06:09 +09:00
parent d92e000fe6
commit f56f6545c0

View File

@ -48,6 +48,40 @@ namespace osu.Game.Tests.Visual.UserInterface
notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; }; notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; };
}); });
[Test]
public void TestDismissWithoutActivationFling()
{
bool activated = false;
SimpleNotification notification = null!;
AddStep("post", () =>
{
activated = false;
notificationOverlay.Post(notification = new SimpleNotification
{
Text = @"Welcome to osu!. Enjoy your stay!",
Activated = () => activated = true,
});
});
AddStep("start drag", () =>
{
InputManager.MoveMouseTo(notification.ChildrenOfType<Notification>().Single());
InputManager.PressButton(MouseButton.Left);
InputManager.MoveMouseTo(notification.ChildrenOfType<Notification>().Single().ScreenSpaceDrawQuad.Centre + new Vector2(-500, 0));
});
AddStep("fling away", () =>
{
InputManager.ReleaseButton(MouseButton.Left);
});
AddUntilStep("wait for closed", () => notification.WasClosed);
AddAssert("was not activated", () => !activated);
AddStep("reset mouse position", () => InputManager.MoveMouseTo(Vector2.Zero));
AddAssert("unread count zero", () => notificationOverlay.UnreadCount.Value == 0);
}
[Test] [Test]
public void TestDismissWithoutActivationCloseButton() public void TestDismissWithoutActivationCloseButton()
{ {
@ -75,6 +109,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddUntilStep("wait for closed", () => notification.WasClosed); AddUntilStep("wait for closed", () => notification.WasClosed);
AddAssert("was not activated", () => !activated); AddAssert("was not activated", () => !activated);
AddStep("reset mouse position", () => InputManager.MoveMouseTo(Vector2.Zero)); AddStep("reset mouse position", () => InputManager.MoveMouseTo(Vector2.Zero));
AddAssert("unread count zero", () => notificationOverlay.UnreadCount.Value == 0);
} }
[Test] [Test]