2020-05-14 10:05:35 +00: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.
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
using System.Threading;
|
2022-02-10 10:21:17 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
2020-05-14 10:05:35 +00:00
|
|
|
using osu.Framework.Screens;
|
2022-02-10 10:21:17 +00:00
|
|
|
using osu.Game.Overlays;
|
2020-05-14 10:05:35 +00:00
|
|
|
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Settings
|
|
|
|
{
|
|
|
|
public class TestSceneMigrationScreens : ScreenTestScene
|
|
|
|
{
|
2022-04-18 21:18:10 +00:00
|
|
|
[Cached(typeof(INotificationOverlay))]
|
2022-02-10 10:21:17 +00:00
|
|
|
private readonly NotificationOverlay notifications;
|
|
|
|
|
2020-05-14 10:05:35 +00:00
|
|
|
public TestSceneMigrationScreens()
|
|
|
|
{
|
2022-02-10 10:21:17 +00:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
notifications = new NotificationOverlay
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestDeleteSuccess()
|
|
|
|
{
|
|
|
|
AddStep("Push screen", () => Stack.Push(new TestMigrationSelectScreen(true)));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestDeleteFails()
|
|
|
|
{
|
|
|
|
AddStep("Push screen", () => Stack.Push(new TestMigrationSelectScreen(false)));
|
2020-05-14 10:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class TestMigrationSelectScreen : MigrationSelectScreen
|
|
|
|
{
|
2022-02-10 10:21:17 +00:00
|
|
|
private readonly bool deleteSuccess;
|
|
|
|
|
|
|
|
public TestMigrationSelectScreen(bool deleteSuccess)
|
|
|
|
{
|
|
|
|
this.deleteSuccess = deleteSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void BeginMigration(DirectoryInfo target) => this.Push(new TestMigrationRunScreen(deleteSuccess));
|
2020-05-14 10:05:35 +00:00
|
|
|
|
|
|
|
private class TestMigrationRunScreen : MigrationRunScreen
|
|
|
|
{
|
2022-02-10 10:21:17 +00:00
|
|
|
private readonly bool success;
|
|
|
|
|
|
|
|
public TestMigrationRunScreen(bool success)
|
|
|
|
: base(null)
|
2020-05-14 10:05:35 +00:00
|
|
|
{
|
2022-02-10 10:21:17 +00:00
|
|
|
this.success = success;
|
2020-05-14 10:05:35 +00:00
|
|
|
}
|
|
|
|
|
2022-02-10 10:21:17 +00:00
|
|
|
protected override bool PerformMigration()
|
2020-05-14 10:05:35 +00:00
|
|
|
{
|
2022-02-10 10:21:17 +00:00
|
|
|
Thread.Sleep(3000);
|
|
|
|
return success;
|
2020-05-14 10:05:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|