Add migration test

This commit is contained in:
Dean Herbert 2020-03-05 14:46:07 +09:00
parent 1e6710020e
commit a311ace626
4 changed files with 58 additions and 10 deletions

View File

@ -62,14 +62,7 @@ public void SetUpSteps()
var frameworkConfig = host.Dependencies.Get<FrameworkConfigManager>();
frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity).Disabled = false;
Game = new TestOsuGame(LocalStorage, API);
Game.SetHost(host);
// todo: this can be removed once we can run audio tracks without a device present
// see https://github.com/ppy/osu/issues/1302
Game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
Add(Game);
CreateGame();
});
AddUntilStep("Wait for load", () => Game.IsLoaded);
@ -78,6 +71,18 @@ public void SetUpSteps()
ConfirmAtMainMenu();
}
protected void CreateGame()
{
Game = new TestOsuGame(LocalStorage, API);
Game.SetHost(host);
// todo: this can be removed once we can run audio tracks without a device present
// see https://github.com/ppy/osu/issues/1302
Game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
Add(Game);
}
protected void PushAndConfirm(Func<Screen> newScreen)
{
Screen screen = null;
@ -103,6 +108,8 @@ public class TestOsuGame : OsuGame
public new Bindable<RulesetInfo> Ruleset => base.Ruleset;
public override string Version => "test game";
protected override Loader CreateLoader() => new TestLoader();
public new void PerformFromScreen(Action<IScreen> action, IEnumerable<Type> validScreens = null) => base.PerformFromScreen(action, validScreens);

View File

@ -0,0 +1,41 @@
// 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.
using NUnit.Framework;
using osu.Framework.Utils;
using osu.Game.Configuration;
namespace osu.Game.Tests.Visual.Navigation
{
public class TestSettingsMigration : OsuGameTestScene
{
public override void RecycleLocalStorage()
{
base.RecycleLocalStorage();
using (var config = new OsuConfigManager(LocalStorage))
{
config.Set(OsuSetting.Version, "2020.101.0");
config.Set(OsuSetting.DisplayStarsMaximum, 10.0);
}
}
[Test]
public void TestDisplayStarsMigration()
{
AddAssert("config has migrated value", () => Precision.AlmostEquals(Game.LocalConfig.Get<double>(OsuSetting.DisplayStarsMaximum), 10.1));
AddStep("set value again", () => Game.LocalConfig.Set<double>(OsuSetting.DisplayStarsMaximum, 10));
AddStep("force save config", () => Game.LocalConfig.Save());
AddStep("remove game", () => Remove(Game));
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));
}
}
}

View File

@ -97,7 +97,7 @@ public class OsuGameBase : Framework.Game, ICanAcceptFiles
public bool IsDeployedBuild => AssemblyVersion.Major > 0;
public string Version
public virtual string Version
{
get
{

View File

@ -104,7 +104,7 @@ protected OsuTestScene()
base.Content.Add(content = new DrawSizePreservingFillContainer());
}
public void RecycleLocalStorage()
public virtual void RecycleLocalStorage()
{
if (localStorage?.IsValueCreated == true)
{