[camera_platform_interface][flutter roll] Fix hashCode tests and manual roll#6618
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
stuartmorgan-g
left a comment
There was a problem hiding this comment.
LGTM as a quick fix.
As a less fragile longer-term fix, maybe we should fundamentally change the way we test our hash implementations. Instead of testing the expected outcome, we could test that, for every property we expect to matter for hashing, two objects that differ only in that property have different hashes. I think that would assert the actual behavior we want without asserting implementation details.
Cause
It looks like a recent Flutter change caused the following to no longer be true.
Each subclass of
CameraEventoverridesint get hashCodeand usesWhile
CameraEventuses the hashCode ofcameraId:With the equality at the top no longer being true, this causes the failing tests.
Fix
To fix this we could:
cameraIdinstead ofsuper.hashCode.cameraId.hashCodein the test expectation.Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.