mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Fix remaining test failures by strengthening PlayerLoader
tests
- Click using `TriggerClick` as notifications move around quite a bit. - Ensure any notifications from a previous test method are cleaned up.
This commit is contained in:
parent
31a9980686
commit
9eb615f942
@ -14,11 +14,10 @@ using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -30,7 +29,6 @@ using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Utils;
|
||||
using osuTK.Input;
|
||||
using SkipOverlay = osu.Game.Screens.Play.SkipOverlay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
@ -83,6 +81,20 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() => player = null);
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("read all notifications", () =>
|
||||
{
|
||||
notificationOverlay.Show();
|
||||
notificationOverlay.Hide();
|
||||
});
|
||||
|
||||
AddUntilStep("wait for no notifications", () => notificationOverlay.UnreadCount.Value, () => Is.EqualTo(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the input manager child to a new test player loader container instance.
|
||||
/// </summary>
|
||||
@ -287,16 +299,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
saveVolumes();
|
||||
|
||||
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value == 1);
|
||||
AddStep("click notification", () =>
|
||||
{
|
||||
var scrollContainer = (OsuScrollContainer)notificationOverlay.Children.Last();
|
||||
var flowContainer = scrollContainer.Children.OfType<FillFlowContainer<NotificationSection>>().First();
|
||||
var notification = flowContainer.First();
|
||||
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value, () => Is.EqualTo(1));
|
||||
|
||||
InputManager.MoveMouseTo(notification);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
clickNotificationIfAny();
|
||||
|
||||
AddAssert("check " + volumeName, assert);
|
||||
|
||||
@ -366,15 +371,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}));
|
||||
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
|
||||
AddAssert($"notification {(shouldWarn ? "triggered" : "not triggered")}", () => notificationOverlay.UnreadCount.Value == (shouldWarn ? 1 : 0));
|
||||
AddStep("click notification", () =>
|
||||
{
|
||||
var scrollContainer = (OsuScrollContainer)notificationOverlay.Children.Last();
|
||||
var flowContainer = scrollContainer.Children.OfType<FillFlowContainer<NotificationSection>>().First();
|
||||
var notification = flowContainer.First();
|
||||
|
||||
InputManager.MoveMouseTo(notification);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
clickNotificationIfAny();
|
||||
AddUntilStep("wait for player load", () => player.IsLoaded);
|
||||
}
|
||||
|
||||
@ -439,6 +436,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddUntilStep("skip button not visible", () => !checkSkipButtonVisible());
|
||||
}
|
||||
|
||||
private void clickNotificationIfAny()
|
||||
{
|
||||
AddStep("click notification", () => notificationOverlay.ChildrenOfType<Notification>().FirstOrDefault()?.TriggerClick());
|
||||
}
|
||||
|
||||
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();
|
||||
|
||||
private class TestPlayerLoader : PlayerLoader
|
||||
|
@ -157,12 +157,11 @@ namespace osu.Game.Overlays
|
||||
playDebouncedSample(notification.PopInSampleName);
|
||||
|
||||
if (State.Value == Visibility.Hidden)
|
||||
{
|
||||
toastTray.Post(notification);
|
||||
updateCounts();
|
||||
}
|
||||
else
|
||||
addPermanently(notification);
|
||||
|
||||
updateCounts();
|
||||
});
|
||||
|
||||
private void addPermanently(Notification notification)
|
||||
@ -231,7 +230,6 @@ namespace osu.Game.Overlays
|
||||
private void markAllRead()
|
||||
{
|
||||
sections.Children.ForEach(s => s.MarkAllRead());
|
||||
|
||||
updateCounts();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user