Fix beatmap carousel test failures

This commit is contained in:
Dean Herbert 2022-01-10 14:52:59 +09:00
parent a0f8debafe
commit 41d90cd0b5
2 changed files with 12 additions and 3 deletions

View File

@ -698,10 +698,9 @@ namespace osu.Game.Tests.Visual.SongSelect
for (int i = 1; i <= 15; i++) for (int i = 1; i <= 15; i++)
{ {
set.Beatmaps.Add(new BeatmapInfo set.Beatmaps.Add(new BeatmapInfo(new OsuRuleset().RulesetInfo, new BeatmapDifficulty(), new BeatmapMetadata())
{ {
DifficultyName = $"Stars: {i}", DifficultyName = $"Stars: {i}",
Ruleset = new OsuRuleset().RulesetInfo,
StarRating = i, StarRating = i,
}); });
} }

View File

@ -98,10 +98,16 @@ namespace osu.Game.Screens.Select
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>(); private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>();
// todo: only used for testing, maybe remove. // todo: only used for testing, maybe remove.
private bool loadedTestBeatmaps;
public IEnumerable<BeatmapSetInfo> BeatmapSets public IEnumerable<BeatmapSetInfo> BeatmapSets
{ {
get => beatmapSets.Select(g => g.BeatmapSet); get => beatmapSets.Select(g => g.BeatmapSet);
set => loadBeatmapSets(value); set
{
loadedTestBeatmaps = true;
loadBeatmapSets(value);
}
} }
private void loadBeatmapSets(IEnumerable<BeatmapSetInfo> beatmapSets) private void loadBeatmapSets(IEnumerable<BeatmapSetInfo> beatmapSets)
@ -190,6 +196,10 @@ namespace osu.Game.Screens.Select
private void beatmapSetsChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet changes, Exception error) private void beatmapSetsChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet changes, Exception error)
{ {
// If loading test beatmaps, avoid overwriting with realm subscription callbacks.
if (loadedTestBeatmaps)
return;
if (changes == null) if (changes == null)
{ {
// initial load // initial load