mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Make TestPlayer
skin assigning logic not flaky
This commit is contained in:
@ -51,7 +51,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
ExposedPlayer player = CreateTestPlayer();
|
||||
|
||||
player.Skin = new TestSkin(userHasCustomColours);
|
||||
player.SetSkin(new TestSkin(userHasCustomColours));
|
||||
|
||||
LoadScreen(player);
|
||||
|
||||
|
@ -79,7 +79,7 @@ namespace osu.Game.Tests.Visual
|
||||
}
|
||||
|
||||
Player = CreatePlayer(ruleset);
|
||||
Player.Skin = GetPlayerSkin();
|
||||
Player.SetSkin(GetPlayerSkin());
|
||||
|
||||
LoadScreen(Player);
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
@ -22,8 +24,6 @@ namespace osu.Game.Tests.Visual
|
||||
/// </summary>
|
||||
public class TestPlayer : Player
|
||||
{
|
||||
public ISkin Skin { get; set; }
|
||||
|
||||
protected override bool PauseOnFocusLost { get; }
|
||||
|
||||
public new DrawableRuleset DrawableRuleset => base.DrawableRuleset;
|
||||
@ -81,8 +81,22 @@ namespace osu.Game.Tests.Visual
|
||||
ScoreProcessor.NewJudgement += r => Results.Add(r);
|
||||
}
|
||||
|
||||
public ISkin Skin { get; private set; }
|
||||
|
||||
private TestSkinProvidingContainer rulesetSkinProvider;
|
||||
|
||||
internal void SetSkin(ISkin skin)
|
||||
{
|
||||
Debug.Assert(rulesetSkinProvider == null);
|
||||
|
||||
if (Skin != null)
|
||||
throw new InvalidOperationException("A skin has already been set.");
|
||||
|
||||
Skin = skin;
|
||||
}
|
||||
|
||||
protected override RulesetSkinProvidingContainer CreateRulesetSkinProvider(Ruleset ruleset, IBeatmap beatmap, ISkin beatmapSkin)
|
||||
=> new TestSkinProvidingContainer(Skin, ruleset, beatmap, beatmapSkin);
|
||||
=> rulesetSkinProvider = new TestSkinProvidingContainer(Skin, ruleset, beatmap, beatmapSkin);
|
||||
|
||||
private class TestSkinProvidingContainer : RulesetSkinProvidingContainer
|
||||
{
|
||||
|
Reference in New Issue
Block a user