mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:42:57 +08:00
Merge pull request #22181 from frenzibyte/attempt-fix-song-select-test-failure
Fix intermittent failure in beatmap carousel tests
This commit is contained in:
commit
4906f37109
@ -12,6 +12,7 @@ using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -93,10 +94,12 @@ namespace osu.Game.Tests.Resources
|
||||
{
|
||||
// Create random metadata, then we can check if sorting works based on these
|
||||
Artist = "Some Artist " + RNG.Next(0, 9),
|
||||
Title = $"Some Song (set id {setId}) {Guid.NewGuid()}",
|
||||
Title = $"Some Song (set id {setId:000}) {Guid.NewGuid()}",
|
||||
Author = { Username = "Some Guy " + RNG.Next(0, 9) },
|
||||
};
|
||||
|
||||
Logger.Log($"🛠️ Generating beatmap set \"{metadata}\" for test consumption.");
|
||||
|
||||
var beatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
OnlineID = setId,
|
||||
|
@ -16,7 +16,9 @@ using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Carousel;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
@ -926,10 +928,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
// 10 sets that go osu! -> taiko -> catch -> osu! -> ...
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var rulesetInfo = rulesets.AvailableRulesets.ElementAt(i % 3);
|
||||
sets.Add(TestResources.CreateTestBeatmapSetInfo(5, new[] { rulesetInfo }));
|
||||
}
|
||||
sets.Add(TestResources.CreateTestBeatmapSetInfo(5, new[] { getRuleset(i) }));
|
||||
|
||||
// Sort mode is important to keep the ruleset order
|
||||
loadBeatmaps(sets, () => new FilterCriteria { Sort = SortMode.Title });
|
||||
@ -937,13 +936,29 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
for (int i = 1; i < 10; i++)
|
||||
{
|
||||
var rulesetInfo = rulesets.AvailableRulesets.ElementAt(i % 3);
|
||||
var rulesetInfo = getRuleset(i % 3);
|
||||
|
||||
AddStep($"Set ruleset to {rulesetInfo.ShortName}", () =>
|
||||
{
|
||||
carousel.Filter(new FilterCriteria { Ruleset = rulesetInfo, Sort = SortMode.Title }, false);
|
||||
});
|
||||
waitForSelection(i + 1, 1);
|
||||
}
|
||||
|
||||
static RulesetInfo getRuleset(int index)
|
||||
{
|
||||
switch (index % 3)
|
||||
{
|
||||
default:
|
||||
return new OsuRuleset().RulesetInfo;
|
||||
|
||||
case 1:
|
||||
return new TaikoRuleset().RulesetInfo;
|
||||
|
||||
case 2:
|
||||
return new CatchRuleset().RulesetInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -953,10 +968,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
// 10 sets that go taiko, osu!, osu!, osu!, taiko, osu!, osu!, osu!, ...
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var rulesetInfo = rulesets.AvailableRulesets.ElementAt(i % 4 == 0 ? 1 : 0);
|
||||
sets.Add(TestResources.CreateTestBeatmapSetInfo(5, new[] { rulesetInfo }));
|
||||
}
|
||||
sets.Add(TestResources.CreateTestBeatmapSetInfo(5, new[] { getRuleset(i) }));
|
||||
|
||||
// Sort mode is important to keep the ruleset order
|
||||
loadBeatmaps(sets, () => new FilterCriteria { Sort = SortMode.Title });
|
||||
@ -974,6 +986,18 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
carousel.Filter(new FilterCriteria { Sort = SortMode.Title }, false);
|
||||
});
|
||||
}
|
||||
|
||||
static RulesetInfo getRuleset(int index)
|
||||
{
|
||||
switch (index % 4)
|
||||
{
|
||||
case 0:
|
||||
return new TaikoRuleset().RulesetInfo;
|
||||
|
||||
default:
|
||||
return new OsuRuleset().RulesetInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null, Func<FilterCriteria> initialCriteria = null, Action<BeatmapCarousel> carouselAdjust = null, int? count = null,
|
||||
|
@ -21,6 +21,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
private readonly CarouselBeatmapSet carouselSet;
|
||||
|
||||
private FillFlowContainer<DifficultyIcon> iconFlow = null!;
|
||||
|
||||
public SetPanelContent(CarouselBeatmapSet carouselSet)
|
||||
{
|
||||
this.carouselSet = carouselSet;
|
||||
@ -82,13 +84,12 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
TextPadding = new MarginPadding { Horizontal = 8, Vertical = 2 },
|
||||
Status = beatmapSet.Status
|
||||
},
|
||||
new FillFlowContainer<DifficultyIcon>
|
||||
iconFlow = new FillFlowContainer<DifficultyIcon>
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Spacing = new Vector2(3),
|
||||
ChildrenEnumerable = getDifficultyIcons(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -96,6 +97,12 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
iconFlow.ChildrenEnumerable = getDifficultyIcons();
|
||||
}
|
||||
|
||||
private const int maximum_difficulty_icons = 18;
|
||||
|
||||
private IEnumerable<DifficultyIcon> getDifficultyIcons()
|
||||
|
Loading…
Reference in New Issue
Block a user