mirror of https://github.com/ppy/osu
Fix unobserved exceptions due to using unconverted beatmap
`TestSceneBeatmapSkinFallbacks` was locally caching a `GameplayState` instance to fulfill dependencies of a `SkinnableTargetComponentsContainer`. However, it was doing so using `new TestBeatmap()`, which is a raw decoded beatmap that hasn't been converted to any ruleset yet, which was causing failures in `BeatmapDifficultyCache.GetTimedDifficultyAttributesAsync()` as that method is expecting to receive a post-conversion, ready-for-gameplay beatmap. Resolve by proxying forward dependency instances from the already-known-to-be-working `actualComponentsContainer`.
This commit is contained in:
parent
1641918c51
commit
dcf3d76954
|
@ -6,7 +6,6 @@
|
|||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
|
@ -22,7 +21,6 @@
|
|||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
|
@ -33,18 +31,6 @@ public class TestSceneBeatmapSkinFallbacks : OsuPlayerTestScene
|
|||
[Resolved]
|
||||
private SkinManager skinManager { get; set; }
|
||||
|
||||
[Cached]
|
||||
private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset());
|
||||
|
||||
[Cached(typeof(HealthProcessor))]
|
||||
private HealthProcessor healthProcessor = new DrainingHealthProcessor(0);
|
||||
|
||||
[Cached]
|
||||
private GameplayState gameplayState = new GameplayState(new TestBeatmap(new OsuRuleset().RulesetInfo), new OsuRuleset());
|
||||
|
||||
[Cached]
|
||||
private readonly GameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
||||
|
||||
protected override bool HasCustomSteps => true;
|
||||
|
||||
[Test]
|
||||
|
@ -81,11 +67,19 @@ protected bool AssertComponentsFromExpectedSource(SkinnableTarget target, ISkin
|
|||
if (expectedComponentsContainer == null)
|
||||
return false;
|
||||
|
||||
var expectedComponentsAdjustmentContainer = new Container
|
||||
var expectedComponentsAdjustmentContainer = new DependencyProvidingContainer
|
||||
{
|
||||
Position = actualComponentsContainer.Parent.ToSpaceOfOtherDrawable(actualComponentsContainer.DrawPosition, Content),
|
||||
Size = actualComponentsContainer.DrawSize,
|
||||
Child = expectedComponentsContainer,
|
||||
// proxy the same required dependencies that `actualComponentsContainer` is using.
|
||||
CachedDependencies = new (Type, object)[]
|
||||
{
|
||||
(typeof(ScoreProcessor), actualComponentsContainer.Dependencies.Get<ScoreProcessor>()),
|
||||
(typeof(HealthProcessor), actualComponentsContainer.Dependencies.Get<HealthProcessor>()),
|
||||
(typeof(GameplayState), actualComponentsContainer.Dependencies.Get<GameplayState>()),
|
||||
(typeof(GameplayClock), actualComponentsContainer.Dependencies.Get<GameplayClock>())
|
||||
},
|
||||
};
|
||||
|
||||
Add(expectedComponentsAdjustmentContainer);
|
||||
|
|
Loading…
Reference in New Issue