Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TestCaseBeatmapCarousel occasionally failing #2725

Merged
merged 2 commits into from Jun 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 13 additions & 6 deletions osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs
Expand Up @@ -65,11 +65,7 @@ private void load(RulesetStore rulesets)

carousel.SelectionChanged = s => currentSelection = s;

AddStep("Load Beatmaps", () => { carousel.BeatmapSets = beatmapSets; });

bool changed = false;
carousel.BeatmapSetsChanged = () => changed = true;
AddUntilStep(() => changed, "Wait for load");
loadBeatmaps(beatmapSets);

testTraversal();
testFiltering();
Expand All @@ -84,6 +80,17 @@ private void load(RulesetStore rulesets)
testCarouselRootIsRandom();
}

private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets)
{
bool changed = false;
AddStep($"Load {beatmapSets.Count} Beatmaps", () =>
{
carousel.BeatmapSetsChanged = () => changed = true;
carousel.BeatmapSets = beatmapSets;
});
AddUntilStep(() => changed, "Wait for load");
}

private void ensureRandomFetchSuccess() =>
AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet);

Expand Down Expand Up @@ -423,7 +430,7 @@ private void testCarouselRootIsRandom()
for (int i = 1; i <= 50; i++)
beatmapSets.Add(createTestBeatmapSet(i));

AddStep("Load 50 Beatmaps", () => { carousel.BeatmapSets = beatmapSets; });
loadBeatmaps(beatmapSets);
advanceSelection(direction: 1, diff: false);
checkNonmatchingFilter();
checkNonmatchingFilter();
Expand Down