1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00
osu-lazer/osu.Game/Tests/Visual/LegacySkinPlayerTestScene.cs
Dean Herbert a92e42bb84 Rename SkinnableTargetContainer to SkinComponentsContainer
Also use full `SkinComponentsContainerLookup` instead of the sub-type.
This will potentially be useful once we bring in per-ruleset targets.
2023-02-15 18:37:41 +09:00

69 lines
2.0 KiB
C#

// 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.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Skinning;
namespace osu.Game.Tests.Visual
{
[TestFixture]
public abstract partial class LegacySkinPlayerTestScene : PlayerTestScene
{
protected LegacySkin LegacySkin { get; private set; }
private ISkinSource legacySkinSource;
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(legacySkinSource);
[BackgroundDependencyLoader]
private void load(SkinManager skins)
{
LegacySkin = new DefaultLegacySkin(skins);
legacySkinSource = new SkinProvidingContainer(LegacySkin);
}
[SetUpSteps]
public override void SetUpSteps()
{
base.SetUpSteps();
addResetTargetsStep();
}
[TearDownSteps]
public override void TearDownSteps()
{
addResetTargetsStep();
base.TearDownSteps();
}
private void addResetTargetsStep()
{
AddStep("reset targets", () => this.ChildrenOfType<SkinComponentsContainer>().ForEach(t =>
{
LegacySkin.ResetDrawableTarget(t);
t.Reload();
}));
AddUntilStep("wait for components to load", () => this.ChildrenOfType<SkinComponentsContainer>().All(t => t.ComponentsLoaded));
}
public partial class SkinProvidingPlayer : TestPlayer
{
[Cached(typeof(ISkinSource))]
private readonly ISkinSource skinSource;
public SkinProvidingPlayer(ISkinSource skinSource)
{
this.skinSource = skinSource;
}
}
}
}