1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:03:08 +08:00

Clean up carousel tests (#6834)

Clean up carousel tests

Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
Dean Herbert 2019-11-15 13:19:21 +09:00 committed by GitHub
commit aa0feea3c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets; using osu.Game.Rulesets;
@ -51,11 +52,6 @@ namespace osu.Game.Tests.Visual.SongSelect
private void load(RulesetStore rulesets) private void load(RulesetStore rulesets)
{ {
this.rulesets = rulesets; this.rulesets = rulesets;
Add(carousel = new TestBeatmapCarousel
{
RelativeSizeAxes = Axes.Both,
});
} }
/// <summary> /// <summary>
@ -338,10 +334,19 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test] [Test]
public void TestHiding() public void TestHiding()
{ {
BeatmapSetInfo hidingSet = createTestBeatmapSet(1); BeatmapSetInfo hidingSet = null;
hidingSet.Beatmaps[1].Hidden = true; List<BeatmapSetInfo> hiddenList = new List<BeatmapSetInfo>();
loadBeatmaps(new List<BeatmapSetInfo> { hidingSet }); AddStep("create hidden set", () =>
{
hidingSet = createTestBeatmapSet(1);
hidingSet.Beatmaps[1].Hidden = true;
hiddenList.Clear();
hiddenList.Add(hidingSet);
});
loadBeatmaps(hiddenList);
setSelected(1, 1); setSelected(1, 1);
@ -375,9 +380,14 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test] [Test]
public void TestSelectingFilteredRuleset() public void TestSelectingFilteredRuleset()
{ {
var testMixed = createTestBeatmapSet(set_count + 1); BeatmapSetInfo testMixed = null;
createCarousel();
AddStep("add mixed ruleset beatmapset", () => AddStep("add mixed ruleset beatmapset", () =>
{ {
testMixed = createTestBeatmapSet(set_count + 1);
for (int i = 0; i <= 2; i++) for (int i = 0; i <= 2; i++)
{ {
testMixed.Beatmaps[i].Ruleset = rulesets.AvailableRulesets.ElementAt(i); testMixed.Beatmaps[i].Ruleset = rulesets.AvailableRulesets.ElementAt(i);
@ -429,6 +439,8 @@ namespace osu.Game.Tests.Visual.SongSelect
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null) private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null)
{ {
createCarousel();
if (beatmapSets == null) if (beatmapSets == null)
{ {
beatmapSets = new List<BeatmapSetInfo>(); beatmapSets = new List<BeatmapSetInfo>();
@ -448,6 +460,20 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("Wait for load", () => changed); AddUntilStep("Wait for load", () => changed);
} }
private void createCarousel(Container target = null)
{
AddStep("Create carousel", () =>
{
selectedSets.Clear();
eagerSelectedIDs.Clear();
(target ?? this).Child = carousel = new TestBeatmapCarousel
{
RelativeSizeAxes = Axes.Both,
};
});
}
private void ensureRandomFetchSuccess() => private void ensureRandomFetchSuccess() =>
AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet); AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet);