Fix SessionStaticsTest never working

In headless operation, the test would complete before ever reaching an
idle state. And this test only ran headless..
This commit is contained in:
Dean Herbert 2021-12-21 15:39:04 +09:00
parent 981158ed88
commit 16fe0e4f89

View File

@ -3,7 +3,6 @@
using NUnit.Framework;
using osu.Game.Configuration;
using osu.Game.Input;
namespace osu.Game.Tests.NonVisual
{
@ -11,37 +10,28 @@ namespace osu.Game.Tests.NonVisual
public class SessionStaticsTest
{
private SessionStatics sessionStatics;
private IdleTracker sessionIdleTracker;
[SetUp]
public void SetUp()
[Test]
public void TestSessionStaticsReset()
{
sessionStatics = new SessionStatics();
sessionIdleTracker = new GameIdleTracker(1000);
sessionStatics.SetValue(Static.LoginOverlayDisplayed, true);
sessionStatics.SetValue(Static.MutedAudioNotificationShownOnce, true);
sessionStatics.SetValue(Static.LowBatteryNotificationShownOnce, true);
sessionStatics.SetValue(Static.LastHoverSoundPlaybackTime, (double?)1d);
sessionIdleTracker.IsIdle.BindValueChanged(e =>
{
if (e.NewValue)
sessionStatics.ResetAfterInactivity();
});
}
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.LoginOverlayDisplayed).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce).IsDefault);
Assert.IsFalse(sessionStatics.GetBindable<double?>(Static.LastHoverSoundPlaybackTime).IsDefault);
[Test]
[Timeout(2000)]
public void TestSessionStaticsReset()
{
sessionIdleTracker.IsIdle.BindValueChanged(e =>
{
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.LoginOverlayDisplayed).IsDefault);
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce).IsDefault);
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce).IsDefault);
Assert.IsTrue(sessionStatics.GetBindable<double?>(Static.LastHoverSoundPlaybackTime).IsDefault);
});
sessionStatics.ResetAfterInactivity();
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.LoginOverlayDisplayed).IsDefault);
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce).IsDefault);
Assert.IsTrue(sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce).IsDefault);
Assert.IsTrue(sessionStatics.GetBindable<double?>(Static.LastHoverSoundPlaybackTime).IsDefault);
}
}
}