1
0
mirror of https://github.com/ppy/osu synced 2025-01-11 08:39:31 +00:00

Fix TestSettingsMigration's usage of RecycleLocalStorage

This commit is contained in:
Dean Herbert 2021-08-18 16:23:02 +09:00
parent dc44cc0eb3
commit 2758a83d55
8 changed files with 37 additions and 23 deletions

View File

@ -8,7 +8,7 @@ using osu.Framework.Input;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Input;
using osu.Game.Tests.Visual.Navigation;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Input
{

View File

@ -10,7 +10,6 @@ using osu.Game.Database;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual.Navigation;
namespace osu.Game.Tests.Visual.Menus
{

View File

@ -4,7 +4,6 @@
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Overlays;
using osu.Game.Tests.Visual.Navigation;
namespace osu.Game.Tests.Visual.Menus
{

View File

@ -62,7 +62,7 @@ namespace osu.Game.Tests.Visual.Navigation
Game.Dispose();
}
RecycleLocalStorage();
RecycleLocalStorage(false);
CreateGame();
});
@ -73,6 +73,13 @@ namespace osu.Game.Tests.Visual.Navigation
ConfirmAtMainMenu();
}
[TearDownSteps]
public void TearDownSteps()
{
AddStep("exit game", () => Game.Exit());
AddUntilStep("wait for game exit", () => Game.Parent == null);
}
protected void CreateGame()
{
Game = new TestOsuGame(LocalStorage, API);

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Textures;
using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
@ -88,25 +89,32 @@ namespace osu.Game.Tests.Visual.Navigation
[Resolved]
private OsuGameBase gameBase { get; set; }
[BackgroundDependencyLoader]
private void load(GameHost host)
{
game = new OsuGame();
game.SetHost(host);
[Resolved]
private GameHost host { get; set; }
Children = new Drawable[]
[SetUpSteps]
public void SetUpSteps()
{
AddStep("create game", () =>
{
new Box
game = new OsuGame();
game.SetHost(host);
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
game
};
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
game
};
});
AddUntilStep("wait for load", () => game.IsLoaded);
}
[Test]
public void TestNullRulesetHandled()
{

View File

@ -9,9 +9,12 @@ namespace osu.Game.Tests.Visual.Navigation
{
public class TestSettingsMigration : OsuGameTestScene
{
public override void RecycleLocalStorage()
public override void RecycleLocalStorage(bool isDisposing)
{
base.RecycleLocalStorage();
base.RecycleLocalStorage(isDisposing);
if (isDisposing)
return;
using (var config = new OsuConfigManager(LocalStorage))
{

View File

@ -14,7 +14,6 @@ using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Taiko;
using osu.Game.Tests.Visual.Navigation;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.SongSelect

View File

@ -7,7 +7,6 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
@ -100,7 +99,7 @@ namespace osu.Game.Tests.Visual
return factory;
});
RecycleLocalStorage();
RecycleLocalStorage(false);
var baseDependencies = base.CreateChildDependencies(parent);
@ -140,7 +139,7 @@ namespace osu.Game.Tests.Visual
protected virtual bool UseFreshStoragePerRun => false;
public virtual void RecycleLocalStorage()
public virtual void RecycleLocalStorage(bool isDisposing)
{
if (localStorage?.IsValueCreated == true)
{
@ -199,7 +198,7 @@ namespace osu.Game.Tests.Visual
if (contextFactory?.IsValueCreated == true)
contextFactory.Value.ResetDatabase();
RecycleLocalStorage();
RecycleLocalStorage(true);
}
protected override ITestSceneTestRunner CreateRunner() => new OsuTestSceneTestRunner();