Add test for ReviewerControlPreference.getPreferenceAssignedTo (#13283) - #21423
Merged
david-allison merged 1 commit intoAug 7, 2026
Merged
Conversation
|
First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible. |
david-allison
requested changes
Aug 7, 2026
Member
There was a problem hiding this comment.
This doesn't look self-reviewed: we've moved to SPDX copyright headers, and if you wish to add your name/email, it should be yours, not mine :D
- #20954 for SPDX
GuTS805
force-pushed
the
test/reviewer-control-preference-13283
branch
from
August 7, 2026 18:27
88e0a27 to
8518613
Compare
david-allison
self-requested a review
August 7, 2026 18:29
david-allison
left a comment
Member
There was a problem hiding this comment.
LGTM! One nitpick to be sure we're testing the behaviour we depend on
Covers side-specific binding lookup: a binding on QUESTION/ANSWER only matches a preference on the same side, while a binding on BOTH conflicts with any single-side binding. Verified via mutation testing that re-introducing the bug (ignoring the card side) breaks the test. Fixes part of ankidroid#13283
GuTS805
force-pushed
the
test/reviewer-control-preference-13283
branch
from
August 7, 2026 21:06
8518613 to
7972528
Compare
Contributor
Author
|
Thanks for the review. |
david-allison
enabled auto-merge
August 7, 2026 21:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Covers side-specific binding lookup: a binding on QUESTION/ANSWER only matches a preference on
the same side, while a binding on BOTH conflicts with any single-side binding. Verified via
mutation testing that re-introducing the bug (ignoring the card side) breaks the test.
Fixes part of #13283
Purpose / Description
ReviewerControlPreference.getPreferenceAssignedTohad no test coverage (@NeedsTest("Ensure correct preference is returned for side-specific binding")). This is one of many@NeedsTestitems tracked in #13283 — only this single method is covered here, per the maintainer's stated
preference elsewhere in that thread to keep PRs to one test at a time.
Approach
Added
ReviewerControlPreferenceTestcovering three cases: a binding on the same side is found,a binding on a different side is not found, and a binding on
CardSide.BOTHconflicts with asingle-side binding. Since
getRelatedPreferences()matches preferences by exact class(
it::class == ReviewerControlPreference::class), the test uses realReviewerControlPreferenceinstances (not a subclass) and accesses the
protectedsidefield andgetPreferenceAssignedTomethod via reflection, following the existing pattern in
NumberRangePreferenceCompatTest.How Has This Been Tested?
Ran the new test in isolation and confirmed it fails when the side-overlap logic is broken
(temporarily changed
ReviewerBinding(binding, cardSide)to always useCardSide.BOTH, confirmedthe "different side is not found" test failed, then reverted). Also ran the full
com.ichi2.preferences.*test package with no regressions.Learning (optional, can help others)
ReviewerBinding.equals()treatsCardSide.BOTHas conflicting with any other side, and twosame-typed sides as conflicting with each other — that's the "side overlap" logic this method
relies on via
getPreferencesAssignedTo.Checklist