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 rewind incorrectly selecting the same beatmap #26127

Merged
merged 4 commits into from
Dec 26, 2023

Conversation

ntransw
Copy link
Contributor

@ntransw ntransw commented Dec 25, 2023

Fixes #25904

@peppy
Copy link
Member

peppy commented Dec 26, 2023

Please add test coverage (ie. add a test which fails without your change) somewhere around here:

/// <summary>
/// Test random non-repeating algorithm
/// </summary>
[Test]
public void TestRandom()
{
loadBeatmaps();
setSelected(1, 1);
nextRandom();
ensureRandomDidntRepeat();
nextRandom();
ensureRandomDidntRepeat();
nextRandom();
ensureRandomDidntRepeat();
prevRandom();
ensureRandomFetchSuccess();
prevRandom();
ensureRandomFetchSuccess();
nextRandom();
ensureRandomDidntRepeat();
nextRandom();
ensureRandomDidntRepeat();
nextRandom();
AddAssert("ensure repeat", () => selectedSets.Contains(carousel.SelectedBeatmapSet));
AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(TestResources.CreateTestBeatmapSetInfo(100, rulesets.AvailableRulesets.ToArray())));
AddStep("Filter Extra", () => carousel.Filter(new FilterCriteria { SearchText = "Extra 10" }, false));
checkInvisibleDifficultiesUnselectable();
checkInvisibleDifficultiesUnselectable();
checkInvisibleDifficultiesUnselectable();
checkInvisibleDifficultiesUnselectable();
checkInvisibleDifficultiesUnselectable();
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
}
[Test]
public void TestRewindToDeletedBeatmap()
{
loadBeatmaps();
var firstAdded = TestResources.CreateTestBeatmapSetInfo();
AddStep("add new set", () => carousel.UpdateBeatmapSet(firstAdded));
AddStep("select set", () => carousel.SelectBeatmap(firstAdded.Beatmaps.First()));
nextRandom();
AddStep("delete set", () => carousel.RemoveBeatmapSet(firstAdded));
prevRandom();
AddAssert("deleted set not selected", () => carousel.SelectedBeatmapSet?.Equals(firstAdded) == false);
}

peppy
peppy previously requested changes Dec 26, 2023
Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs test

@ntransw
Copy link
Contributor Author

ntransw commented Dec 26, 2023

Added a working test, although I wasn't sure how to populate randomSelectedBeatmaps with duplicates to reproduce the failure outside of just calling nextRandom() excessively.

@ntransw ntransw requested a review from peppy December 26, 2023 09:09
@bdach bdach requested review from bdach and removed request for peppy December 26, 2023 10:33
@bdach
Copy link
Collaborator

bdach commented Dec 26, 2023

Test fails on master, so it'll work.

bdach
bdach previously approved these changes Dec 26, 2023
@bdach
Copy link
Collaborator

bdach commented Dec 26, 2023

@ntransw no need to merge master. please read contributing guidelines. now i have to re-approve the CI run that i was gonna see if it passes.

@bdach bdach merged commit 4077d3a into ppy:master Dec 26, 2023
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After randomly selecting every beatmap more than once, rewind keeps selecting the same beatmap
3 participants