mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Fix incorrect count tracking when notification is manually disposed
This commit is contained in:
parent
229e1a8ef7
commit
0514c96191
@ -57,6 +57,19 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddUntilStep("wait overlay not present", () => !notificationOverlay.IsPresent);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPresenceWithManualDismiss()
|
||||
{
|
||||
AddAssert("tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
|
||||
AddAssert("overlay not present", () => !notificationOverlay.IsPresent);
|
||||
|
||||
AddStep(@"post notification", sendBackgroundNotification);
|
||||
AddStep("click notification", () => notificationOverlay.ChildrenOfType<Notification>().Single().TriggerClick());
|
||||
|
||||
AddUntilStep("wait tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
|
||||
AddUntilStep("wait overlay not present", () => !notificationOverlay.IsPresent);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCompleteProgress()
|
||||
{
|
||||
|
@ -97,6 +97,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
public void Post(Notification notification)
|
||||
{
|
||||
notification.Closed += stopTrackingNotification;
|
||||
|
||||
++runningDepth;
|
||||
displayedCount++;
|
||||
|
||||
@ -139,14 +141,23 @@ namespace osu.Game.Overlays
|
||||
notification.MoveToOffset(new Vector2(400, 0), NotificationOverlay.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
notification.FadeOut(NotificationOverlay.TRANSITION_LENGTH, Easing.OutQuint).OnComplete(_ =>
|
||||
{
|
||||
notification.Closed -= stopTrackingNotification;
|
||||
if (!notification.WasClosed)
|
||||
stopTrackingNotification();
|
||||
|
||||
RemoveInternal(notification, false);
|
||||
displayedCount--;
|
||||
ForwardNotificationToPermanentStore?.Invoke(notification);
|
||||
|
||||
notification.FadeIn(300, Easing.OutQuint);
|
||||
});
|
||||
}
|
||||
|
||||
private void stopTrackingNotification()
|
||||
{
|
||||
Debug.Assert(displayedCount > 0);
|
||||
displayedCount--;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
Loading…
Reference in New Issue
Block a user