1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 13:32:54 +08:00

Fix unobserved exceptions due to unimplemented beatmap converter

`TestSceneStatisticsPanel` intends to check the operation of statistics
panels using dummy ruleset classes. However, `StatisticsPanel` relies on
being able to retrieve the playable beatmap, which requires a converter.
One was not provided by the dummy rulesets, therefore the retrieval
would fail with an unobserved exception.

To fix, add a barebones converter implementation that is enough for the
test to pass.
This commit is contained in:
Bartłomiej Dach 2022-05-28 13:59:10 +02:00
parent 62266c72ea
commit e18fec3d89
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -13,6 +14,7 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics;
using osu.Game.Rulesets.Osu.Objects;
@ -114,10 +116,7 @@ namespace osu.Game.Tests.Visual.Ranking
throw new NotImplementedException();
}
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap)
{
throw new NotImplementedException();
}
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TestBeatmapConverter(beatmap);
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap)
{
@ -151,6 +150,24 @@ namespace osu.Game.Tests.Visual.Ranking
}
}
};
private class TestBeatmapConverter : IBeatmapConverter
{
#pragma warning disable CS0067 // The event is never used
public event Action<HitObject, IEnumerable<HitObject>> ObjectConverted;
#pragma warning restore CS0067
public IBeatmap Beatmap { get; }
public TestBeatmapConverter(IBeatmap beatmap)
{
Beatmap = beatmap;
}
public bool CanConvert() => true;
public IBeatmap Convert(CancellationToken cancellationToken = default) => Beatmap.Clone();
}
}
private class TestRulesetAllStatsRequireHitEvents : TestRuleset