mirror of
https://github.com/ppy/osu
synced 2025-01-11 08:39:31 +00:00
Add test coverage of startup import sequence
This commit is contained in:
parent
94de24075e
commit
f69a56a26a
31
osu.Game.Tests/Visual/Navigation/TestSceneStartupImport.cs
Normal file
31
osu.Game.Tests/Visual/Navigation/TestSceneStartupImport.cs
Normal file
@ -0,0 +1,31 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
public class TestSceneStartupImport : OsuGameTestScene
|
||||
{
|
||||
private string importFilename;
|
||||
|
||||
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { importFilename });
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
AddStep("Prepare import beatmap", () => importFilename = TestResources.GetTestBeatmapForImport());
|
||||
|
||||
base.SetUpSteps();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportCreatedNotification()
|
||||
{
|
||||
AddUntilStep("Import notification was presented", () => Game.Notifications.ChildrenOfType<ImportProgressNotification>().Count() == 1);
|
||||
}
|
||||
}
|
||||
}
|
@ -116,7 +116,7 @@ namespace osu.Game.Database
|
||||
/// <param name="paths">One or more archive locations on disk.</param>
|
||||
public Task Import(params string[] paths)
|
||||
{
|
||||
var notification = new ProgressNotification { State = ProgressNotificationState.Active };
|
||||
var notification = new ImportProgressNotification();
|
||||
|
||||
PostNotification?.Invoke(notification);
|
||||
|
||||
@ -125,7 +125,7 @@ namespace osu.Game.Database
|
||||
|
||||
public Task Import(params ImportTask[] tasks)
|
||||
{
|
||||
var notification = new ProgressNotification { State = ProgressNotificationState.Active };
|
||||
var notification = new ImportProgressNotification();
|
||||
|
||||
PostNotification?.Invoke(notification);
|
||||
|
||||
|
15
osu.Game/Database/ImportProgressNotification.cs
Normal file
15
osu.Game/Database/ImportProgressNotification.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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 osu.Game.Overlays.Notifications;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class ImportProgressNotification : ProgressNotification
|
||||
{
|
||||
public ImportProgressNotification()
|
||||
{
|
||||
State = ProgressNotificationState.Active;
|
||||
}
|
||||
}
|
||||
}
|
@ -78,9 +78,11 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected void CreateGame()
|
||||
{
|
||||
AddGame(Game = new TestOsuGame(LocalStorage, API));
|
||||
AddGame(Game = CreateTestGame());
|
||||
}
|
||||
|
||||
protected virtual TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API);
|
||||
|
||||
protected void PushAndConfirm(Func<Screen> newScreen)
|
||||
{
|
||||
Screen screen = null;
|
||||
@ -135,7 +137,8 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
public new void PerformFromScreen(Action<IScreen> action, IEnumerable<Type> validScreens = null) => base.PerformFromScreen(action, validScreens);
|
||||
|
||||
public TestOsuGame(Storage storage, IAPIProvider api)
|
||||
public TestOsuGame(Storage storage, IAPIProvider api, string[] args = null)
|
||||
: base(args)
|
||||
{
|
||||
Storage = storage;
|
||||
API = api;
|
||||
|
Loading…
Reference in New Issue
Block a user