1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Add test coverage of clicking close button to dismiss

This commit is contained in:
Dean Herbert 2022-09-10 15:18:32 +09:00
parent efe3b1aa7b
commit a9094c6b03
2 changed files with 30 additions and 1 deletions

View File

@ -47,6 +47,35 @@ namespace osu.Game.Tests.Visual.UserInterface
notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; };
});
[Test]
public void TestDismissWithoutActivationCloseButton()
{
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("click to activate", () =>
{
InputManager.MoveMouseTo(notificationOverlay
.ChildrenOfType<Notification>().Single()
.ChildrenOfType<Notification.CloseButton>().Single());
InputManager.Click(MouseButton.Left);
});
AddUntilStep("wait for closed", () => notification.WasClosed);
AddAssert("was not activated", () => !activated);
AddStep("reset mouse position", () => InputManager.MoveMouseTo(Vector2.Zero));
}
[Test]
public void TestDismissWithoutActivationRightClick()
{

View File

@ -218,7 +218,7 @@ namespace osu.Game.Overlays.Notifications
Expire();
}
private class CloseButton : OsuClickableContainer
internal class CloseButton : OsuClickableContainer
{
private SpriteIcon icon = null!;
private Box background = null!;