mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add test coverage
This commit is contained in:
36
osu.Game.Tests/Visual/Settings/TestSceneMigrationScreens.cs
Normal file
36
osu.Game.Tests/Visual/Settings/TestSceneMigrationScreens.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Settings
|
||||||
|
{
|
||||||
|
public class TestSceneMigrationScreens : ScreenTestScene
|
||||||
|
{
|
||||||
|
public TestSceneMigrationScreens()
|
||||||
|
{
|
||||||
|
AddStep("Push screen", () => Stack.Push(new TestMigrationSelectScreen()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestMigrationSelectScreen : MigrationSelectScreen
|
||||||
|
{
|
||||||
|
protected override void BeginMigration(DirectoryInfo target) => this.Push(new TestMigrationRunScreen());
|
||||||
|
|
||||||
|
private class TestMigrationRunScreen : MigrationRunScreen
|
||||||
|
{
|
||||||
|
protected override void PerformMigration()
|
||||||
|
{
|
||||||
|
Thread.Sleep(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestMigrationRunScreen()
|
||||||
|
: base(null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
{
|
{
|
||||||
private readonly DirectoryInfo destination;
|
private readonly DirectoryInfo destination;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved(canBeNull: true)]
|
||||||
private OsuGame game { get; set; }
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowBackButton => false;
|
||||||
@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
|
|
||||||
Beatmap.Value = Beatmap.Default;
|
Beatmap.Value = Beatmap.Default;
|
||||||
|
|
||||||
migrationTask = Task.Run(() => game.Migrate(destination.FullName))
|
migrationTask = Task.Run(PerformMigration)
|
||||||
.ContinueWith(t =>
|
.ContinueWith(t =>
|
||||||
{
|
{
|
||||||
if (t.IsFaulted)
|
if (t.IsFaulted)
|
||||||
@ -94,6 +94,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void PerformMigration() => game?.Migrate(destination.FullName);
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
|
@ -29,10 +29,10 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
|
|
||||||
public override bool HideOverlaysOnEnter => true;
|
public override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuGame game, Storage storage, OsuColour colours)
|
private void load(OsuGame game, Storage storage, OsuColour colours)
|
||||||
{
|
{
|
||||||
game.Toolbar.Hide();
|
game?.Toolbar.Hide();
|
||||||
|
|
||||||
// begin selection in the parent directory of the current storage location
|
// begin selection in the parent directory of the current storage location
|
||||||
var initialPath = new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent?.FullName;
|
var initialPath = new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent?.FullName;
|
||||||
@ -115,12 +115,14 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Log($"Error during migration: {e?.Message}", level: LogLevel.Error);
|
Logger.Log($"Error during migration: {e.Message}", level: LogLevel.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
this.Push(new MigrationRunScreen(target));
|
BeginMigration(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void BeginMigration(DirectoryInfo target) => this.Push(new MigrationRunScreen(target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user