1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-01 02:22:55 +08:00

Fix notification overlay being present when it doesn't need to

This commit is contained in:
Dean Herbert 2022-09-05 18:42:37 +09:00
parent f754686521
commit 229e1a8ef7
2 changed files with 16 additions and 0 deletions

View File

@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays; using osu.Game.Overlays;
@ -44,6 +45,18 @@ 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 TestPresence()
{
AddAssert("tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddAssert("overlay not present", () => !notificationOverlay.IsPresent);
AddStep(@"post notification", sendBackgroundNotification);
AddUntilStep("wait tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddUntilStep("wait overlay not present", () => !notificationOverlay.IsPresent);
}
[Test] [Test]
public void TestCompleteProgress() public void TestCompleteProgress()
{ {
@ -63,6 +76,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed); AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed);
AddAssert("Completion toast shown", () => notificationOverlay.ToastCount == 1); AddAssert("Completion toast shown", () => notificationOverlay.ToastCount == 1);
AddUntilStep("wait forwarded", () => notificationOverlay.ToastCount == 0);
} }
[Test] [Test]

View File

@ -24,6 +24,8 @@ namespace osu.Game.Overlays
/// </summary> /// </summary>
public class NotificationOverlayToastTray : CompositeDrawable public class NotificationOverlayToastTray : CompositeDrawable
{ {
public override bool IsPresent => IsDisplayingToasts;
public bool IsDisplayingToasts => displayedCount > 0; public bool IsDisplayingToasts => displayedCount > 0;
private FillFlowContainer<Notification> toastFlow = null!; private FillFlowContainer<Notification> toastFlow = null!;