1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 04:42:55 +08:00
osu-lazer/osu.Game.Tests/Visual/Settings/TestSceneMigrationScreens.cs

76 lines
2.1 KiB
C#
Raw Normal View History

2020-05-14 18:05:35 +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-05-14 18:05:35 +08:00
using System.IO;
using System.Threading;
2022-02-10 18:21:17 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2020-05-14 18:05:35 +08:00
using osu.Framework.Screens;
2022-02-10 18:21:17 +08:00
using osu.Game.Overlays;
2020-05-14 18:05:35 +08:00
using osu.Game.Overlays.Settings.Sections.Maintenance;
namespace osu.Game.Tests.Visual.Settings
{
public class TestSceneMigrationScreens : ScreenTestScene
{
[Cached(typeof(INotificationOverlay))]
2022-02-10 18:21:17 +08:00
private readonly NotificationOverlay notifications;
2020-05-14 18:05:35 +08:00
public TestSceneMigrationScreens()
{
2022-02-10 18:21:17 +08: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 18:05:35 +08:00
}
private class TestMigrationSelectScreen : MigrationSelectScreen
{
2022-02-10 18:21:17 +08: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 18:05:35 +08:00
private class TestMigrationRunScreen : MigrationRunScreen
{
2022-02-10 18:21:17 +08:00
private readonly bool success;
public TestMigrationRunScreen(bool success)
: base(null)
2020-05-14 18:05:35 +08:00
{
2022-02-10 18:21:17 +08:00
this.success = success;
2020-05-14 18:05:35 +08:00
}
2022-02-10 18:21:17 +08:00
protected override bool PerformMigration()
2020-05-14 18:05:35 +08:00
{
2022-02-10 18:21:17 +08:00
Thread.Sleep(3000);
return success;
2020-05-14 18:05:35 +08:00
}
}
}
}
}