Merge branch 'master' into fix_progress_bar_info

This commit is contained in:
Dean Herbert
2022-09-09 17:34:13 +09:00
committed by GitHub
183 changed files with 2708 additions and 1041 deletions

View File

@ -259,7 +259,7 @@ namespace osu.Game.Tests.Visual.UserInterface
private void removeFacade()
{
trackingContainer.Remove(logoFacade);
trackingContainer.Remove(logoFacade, false);
visualBox.Colour = Color4.White;
moveLogoFacade();
}

View File

@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
@ -23,9 +24,12 @@ namespace osu.Game.Tests.Visual.UserInterface
private SpriteText displayedCount = null!;
public double TimeToCompleteProgress { get; set; } = 2000;
[SetUp]
public void SetUp() => Schedule(() =>
{
TimeToCompleteProgress = 2000;
progressingNotifications.Clear();
Content.Children = new Drawable[]
@ -41,10 +45,36 @@ namespace osu.Game.Tests.Visual.UserInterface
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]
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()
{
ProgressNotification notification = null!;
AddStep("add progress notification", () =>
{
notification = new ProgressNotification
@ -57,6 +87,31 @@ namespace osu.Game.Tests.Visual.UserInterface
});
AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed);
AddAssert("Completion toast shown", () => notificationOverlay.ToastCount == 1);
AddUntilStep("wait forwarded", () => notificationOverlay.ToastCount == 0);
}
[Test]
public void TestCompleteProgressSlow()
{
ProgressNotification notification = null!;
AddStep("Set progress slow", () => TimeToCompleteProgress *= 2);
AddStep("add progress notification", () =>
{
notification = new ProgressNotification
{
Text = @"Uploading to BSS...",
CompletionText = "Uploaded to BSS!",
};
notificationOverlay.Post(notification);
progressingNotifications.Add(notification);
});
AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed);
AddAssert("Completion toast shown", () => notificationOverlay.ToastCount == 1);
}
[Test]
@ -177,7 +232,7 @@ namespace osu.Game.Tests.Visual.UserInterface
foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active))
{
if (n.Progress < 1)
n.Progress += (float)(Time.Elapsed / 2000);
n.Progress += (float)(Time.Elapsed / TimeToCompleteProgress);
else
n.State = ProgressNotificationState.Completed;
}