2020-12-01 00:49:04 +00: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.
|
|
|
|
|
2021-06-16 10:52:58 +00:00
|
|
|
using System.Linq;
|
2020-12-01 00:49:04 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2021-05-30 21:02:55 +00:00
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
using osu.Framework.Testing;
|
2020-12-01 00:49:04 +00:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public abstract class LegacySkinPlayerTestScene : PlayerTestScene
|
|
|
|
{
|
2021-05-19 21:03:10 +00:00
|
|
|
protected LegacySkin LegacySkin { get; private set; }
|
|
|
|
|
2020-12-01 00:49:04 +00:00
|
|
|
private ISkinSource legacySkinSource;
|
|
|
|
|
|
|
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(legacySkinSource);
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-05-31 09:58:40 +00:00
|
|
|
private void load(SkinManager skins)
|
2020-12-01 00:49:04 +00:00
|
|
|
{
|
2021-05-31 10:35:54 +00:00
|
|
|
LegacySkin = new DefaultLegacySkin(skins);
|
2021-05-19 21:03:10 +00:00
|
|
|
legacySkinSource = new SkinProvidingContainer(LegacySkin);
|
2020-12-01 00:49:04 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 21:02:55 +00:00
|
|
|
[SetUpSteps]
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
addResetTargetsStep();
|
|
|
|
}
|
|
|
|
|
|
|
|
[TearDownSteps]
|
|
|
|
public override void TearDownSteps()
|
|
|
|
{
|
|
|
|
addResetTargetsStep();
|
|
|
|
base.TearDownSteps();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addResetTargetsStep()
|
|
|
|
{
|
|
|
|
AddStep("reset targets", () => this.ChildrenOfType<SkinnableTargetContainer>().ForEach(t =>
|
|
|
|
{
|
|
|
|
LegacySkin.ResetDrawableTarget(t);
|
|
|
|
t.Reload();
|
|
|
|
}));
|
2021-06-16 10:52:58 +00:00
|
|
|
|
|
|
|
AddUntilStep("wait for components to load", () => this.ChildrenOfType<SkinnableTargetContainer>().All(t => t.ComponentsLoaded));
|
2020-12-01 00:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public class SkinProvidingPlayer : TestPlayer
|
|
|
|
{
|
|
|
|
[Cached(typeof(ISkinSource))]
|
|
|
|
private readonly ISkinSource skinSource;
|
|
|
|
|
|
|
|
public SkinProvidingPlayer(ISkinSource skinSource)
|
|
|
|
{
|
|
|
|
this.skinSource = skinSource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|