mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add basic test coverage of new screen
This commit is contained in:
@ -0,0 +1,48 @@
|
|||||||
|
// 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.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Moq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.FirstRunSetup;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
|
{
|
||||||
|
public class TestSceneFirstRunScreenImportFromStable : OsuManualInputManagerTestScene
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||||
|
|
||||||
|
private readonly Mock<LegacyImportManager> legacyImportManager = new Mock<LegacyImportManager>();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
legacyImportManager.Setup(m => m.GetImportCount(It.IsAny<StableContent>(), It.IsAny<CancellationToken>())).Returns(() => Task.FromResult(RNG.Next(0, 256)));
|
||||||
|
|
||||||
|
Dependencies.CacheAs(legacyImportManager.Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestSceneFirstRunScreenImportFromStable()
|
||||||
|
{
|
||||||
|
AddStep("load screen", () =>
|
||||||
|
{
|
||||||
|
Child = new PopoverContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new ScreenStack(new ScreenImportFromStable())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -37,13 +37,13 @@ namespace osu.Game.Database
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private CollectionManager collections { get; set; }
|
private CollectionManager collections { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved(canBeNull: true)]
|
||||||
private OsuGame game { get; set; }
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IDialogOverlay dialogOverlay { get; set; }
|
private IDialogOverlay dialogOverlay { get; set; }
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(canBeNull: true)]
|
||||||
private DesktopGameHost desktopGameHost { get; set; }
|
private DesktopGameHost desktopGameHost { get; set; }
|
||||||
|
|
||||||
private StableStorage cachedStorage;
|
private StableStorage cachedStorage;
|
||||||
@ -52,7 +52,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
public void UpdateStorage(string stablePath) => cachedStorage = new StableStorage(stablePath, desktopGameHost);
|
public void UpdateStorage(string stablePath) => cachedStorage = new StableStorage(stablePath, desktopGameHost);
|
||||||
|
|
||||||
public async Task<int> GetImportCount(StableContent content, CancellationToken cancellationToken)
|
public virtual async Task<int> GetImportCount(StableContent content, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var stableStorage = GetCurrentStableStorage();
|
var stableStorage = GetCurrentStableStorage();
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ namespace osu.Game.Database
|
|||||||
if (cachedStorage != null)
|
if (cachedStorage != null)
|
||||||
return cachedStorage;
|
return cachedStorage;
|
||||||
|
|
||||||
var stableStorage = game.GetStorageForStableInstall();
|
var stableStorage = game?.GetStorageForStableInstall();
|
||||||
if (stableStorage != null)
|
if (stableStorage != null)
|
||||||
return cachedStorage = stableStorage;
|
return cachedStorage = stableStorage;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user