1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 10:07:36 +08:00
osu-lazer/osu.Game.Tests/Visual/Settings/TestSceneMigrationScreens.cs

74 lines
2.1 KiB
C#
Raw Normal View History

2023-06-23 00:37:25 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2020-05-14 18:05:35 +08:00
// See the LICENCE file in the repository root for full licence text.
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
{
2022-11-24 13:32:20 +08:00
public partial class TestSceneMigrationScreens : ScreenTestScene
2020-05-14 18:05:35 +08:00
{
[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
}
2022-11-24 13:32:20 +08:00
private partial class TestMigrationSelectScreen : MigrationSelectScreen
2020-05-14 18:05:35 +08:00
{
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
2022-11-24 13:32:20 +08:00
private partial class TestMigrationRunScreen : MigrationRunScreen
2020-05-14 18:05:35 +08:00
{
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
}
}
}
}
}