2020-03-05 13:46:07 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-03-05 13:46:07 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Navigation
|
|
|
|
{
|
|
|
|
public class TestSettingsMigration : OsuGameTestScene
|
|
|
|
{
|
2021-08-18 15:23:02 +08:00
|
|
|
public override void RecycleLocalStorage(bool isDisposing)
|
2020-03-05 13:46:07 +08:00
|
|
|
{
|
2021-08-18 15:23:02 +08:00
|
|
|
base.RecycleLocalStorage(isDisposing);
|
|
|
|
|
|
|
|
if (isDisposing)
|
|
|
|
return;
|
2020-03-05 13:46:07 +08:00
|
|
|
|
|
|
|
using (var config = new OsuConfigManager(LocalStorage))
|
|
|
|
{
|
2021-03-17 15:10:16 +08:00
|
|
|
config.SetValue(OsuSetting.Version, "2020.101.0");
|
|
|
|
config.SetValue(OsuSetting.DisplayStarsMaximum, 10.0);
|
2020-03-05 13:46:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestDisplayStarsMigration()
|
|
|
|
{
|
|
|
|
AddAssert("config has migrated value", () => Precision.AlmostEquals(Game.LocalConfig.Get<double>(OsuSetting.DisplayStarsMaximum), 10.1));
|
|
|
|
|
2021-03-17 18:02:25 +08:00
|
|
|
AddStep("set value again", () => Game.LocalConfig.SetValue(OsuSetting.DisplayStarsMaximum, 10.0));
|
2020-03-05 13:46:07 +08:00
|
|
|
|
|
|
|
AddStep("force save config", () => Game.LocalConfig.Save());
|
|
|
|
|
2022-08-26 14:19:05 +08:00
|
|
|
AddStep("remove game", () => Remove(Game, true));
|
2020-03-05 13:46:07 +08:00
|
|
|
|
|
|
|
AddStep("create game again", CreateGame);
|
|
|
|
|
|
|
|
AddUntilStep("Wait for load", () => Game.IsLoaded);
|
|
|
|
|
|
|
|
AddAssert("config did not migrate value", () => Precision.AlmostEquals(Game.LocalConfig.Get<double>(OsuSetting.DisplayStarsMaximum), 10));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|