2021-04-19 11:04:28 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2021-12-21 15:50:25 +08:00
|
|
|
using System;
|
2021-04-19 11:04:28 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Game.Configuration;
|
2021-12-21 15:50:25 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-04-19 11:04:28 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.NonVisual
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class SessionStaticsTest
|
|
|
|
{
|
|
|
|
private SessionStatics sessionStatics;
|
|
|
|
|
2021-12-21 14:39:04 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSessionStaticsReset()
|
2021-04-19 11:04:28 +08:00
|
|
|
{
|
|
|
|
sessionStatics = new SessionStatics();
|
|
|
|
|
|
|
|
sessionStatics.SetValue(Static.LoginOverlayDisplayed, true);
|
|
|
|
sessionStatics.SetValue(Static.MutedAudioNotificationShownOnce, true);
|
|
|
|
sessionStatics.SetValue(Static.LowBatteryNotificationShownOnce, true);
|
|
|
|
sessionStatics.SetValue(Static.LastHoverSoundPlaybackTime, (double?)1d);
|
2021-12-21 15:50:25 +08:00
|
|
|
sessionStatics.SetValue(Static.SeasonalBackgrounds, new APISeasonalBackgrounds { EndDate = new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero) });
|
2021-04-19 11:04:28 +08:00
|
|
|
|
2021-12-21 14:39:04 +08:00
|
|
|
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);
|
2021-12-21 15:50:25 +08:00
|
|
|
Assert.IsFalse(sessionStatics.GetBindable<APISeasonalBackgrounds>(Static.SeasonalBackgrounds).IsDefault);
|
2021-04-19 11:04:28 +08:00
|
|
|
|
2021-12-21 14:39:04 +08:00
|
|
|
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);
|
2021-12-21 15:47:41 +08:00
|
|
|
// some statics should not reset despite inactivity.
|
|
|
|
Assert.IsFalse(sessionStatics.GetBindable<double?>(Static.LastHoverSoundPlaybackTime).IsDefault);
|
2021-12-21 15:50:25 +08:00
|
|
|
Assert.IsFalse(sessionStatics.GetBindable<APISeasonalBackgrounds>(Static.SeasonalBackgrounds).IsDefault);
|
2021-04-19 11:04:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|