mirror of
https://github.com/ppy/osu
synced 2025-01-25 07:13:22 +00:00
Add test coverage of notification resume flow
This commit is contained in:
parent
02f8367d66
commit
a8d32a2061
@ -12,6 +12,7 @@ using osu.Framework.Screens;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.FirstRunSetup;
|
using osu.Game.Overlays.FirstRunSetup;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -22,20 +23,34 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
private FirstRunSetupOverlay overlay;
|
private FirstRunSetupOverlay overlay;
|
||||||
|
|
||||||
private readonly Mock<IPerformFromScreenRunner> perfomer = new Mock<IPerformFromScreenRunner>();
|
private readonly Mock<IPerformFromScreenRunner> performer = new Mock<IPerformFromScreenRunner>();
|
||||||
|
|
||||||
|
private readonly Mock<INotificationOverlay> notificationOverlay = new Mock<INotificationOverlay>();
|
||||||
|
|
||||||
|
private Notification lastNotification;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Dependencies.CacheAs(perfomer.Object);
|
Dependencies.CacheAs(performer.Object);
|
||||||
|
Dependencies.CacheAs(notificationOverlay.Object);
|
||||||
perfomer.Setup(g => g.PerformFromScreen(It.IsAny<Action<IScreen>>(), It.IsAny<IEnumerable<Type>>()))
|
|
||||||
.Callback((Action<IScreen> action, IEnumerable<Type> types) => action(null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
|
AddStep("setup dependencies", () =>
|
||||||
|
{
|
||||||
|
performer.Reset();
|
||||||
|
notificationOverlay.Reset();
|
||||||
|
|
||||||
|
performer.Setup(g => g.PerformFromScreen(It.IsAny<Action<IScreen>>(), It.IsAny<IEnumerable<Type>>()))
|
||||||
|
.Callback((Action<IScreen> action, IEnumerable<Type> types) => action(null));
|
||||||
|
|
||||||
|
notificationOverlay.Setup(n => n.Post(It.IsAny<Notification>()))
|
||||||
|
.Callback((Notification n) => lastNotification = n);
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("add overlay", () =>
|
AddStep("add overlay", () =>
|
||||||
{
|
{
|
||||||
Child = overlay = new FirstRunSetupOverlay
|
Child = overlay = new FirstRunSetupOverlay
|
||||||
@ -58,6 +73,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddUntilStep("wait for screens removed", () => !overlay.ChildrenOfType<Screen>().Any());
|
AddUntilStep("wait for screens removed", () => !overlay.ChildrenOfType<Screen>().Any());
|
||||||
|
|
||||||
|
AddStep("no notifications", () => notificationOverlay.VerifyNoOtherCalls());
|
||||||
|
|
||||||
AddStep("display again on demand", () => overlay.Show());
|
AddStep("display again on demand", () => overlay.Show());
|
||||||
|
|
||||||
AddUntilStep("back at start", () => overlay.CurrentScreen is ScreenWelcome);
|
AddUntilStep("back at start", () => overlay.CurrentScreen is ScreenWelcome);
|
||||||
@ -108,5 +125,23 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddAssert("overlay dismissed", () => overlay.State.Value == Visibility.Hidden);
|
AddAssert("overlay dismissed", () => overlay.State.Value == Visibility.Hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestResumeViaNotification()
|
||||||
|
{
|
||||||
|
AddStep("step to next", () => overlay.NextButton.TriggerClick());
|
||||||
|
|
||||||
|
AddAssert("is at known screen", () => overlay.CurrentScreen is ScreenUIScale);
|
||||||
|
|
||||||
|
AddStep("hide", () => overlay.Hide());
|
||||||
|
AddAssert("overlay hidden", () => overlay.State.Value == Visibility.Hidden);
|
||||||
|
|
||||||
|
AddStep("notification arrived", () => notificationOverlay.Verify(n => n.Post(It.IsAny<Notification>()), Times.Once));
|
||||||
|
|
||||||
|
AddStep("run notification action", () => lastNotification.Activated());
|
||||||
|
|
||||||
|
AddAssert("overlay shown", () => overlay.State.Value == Visibility.Visible);
|
||||||
|
AddAssert("is resumed", () => overlay.CurrentScreen is ScreenUIScale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user