-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[camera] Fix event type check #2123
Conversation
| event.put("eventType", eventType.toString().toLowerCase()); | ||
| // Only errors have description | ||
| if (eventType != EventType.ERROR) { | ||
| if (eventType == EventType.ERROR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. Thank you for fixing this.
|
Thank you for the fix! We've recently re-emphasized that all PRs need tests, following the style guide. This is difficult for plugins PRs since we don't have an integrated testing solution, but I don't think it's impossible to do here. Normally I would recommend writing a flutter driver test that tries to do something invalid and then make sure the error has a description, but tests for this plugin need to somehow automatically accept the camera permission to run and we don't have a good cross platform solution for that yet. We do have the ability to write JUnit tests though, and I think that would also work. Would you be able to create a CameraTests.java class with a unit test making sure messages are sent with a description? I think the easiest way to do this would be to open If you're not able to carry this forward, please let us know and we'll be happy to shepherd it on from here. Thanks again for the contribution. |
Break out the functionality related to sending Dart callbacks into its own class, DartMessenger. This will let us test the former `sendEvent` without needing to initialize the camera hardware.
|
Thanks for trying! I opened up Android Studio myself to add in a "quick test" skeleton for you to pick up and then realized that actually properly unit testing this fix is actually really difficult. The class wasn't set up to be testable. I didn't see a way to do it without refactoring the So instead I ended up making two commits, first to refactor the class and then to actually test this method. What do you think about cherry picking them into this PR and then we can land it all together? |
Cherry-pick from @mklim
|
Not sure if cherry picked or just merged (a bit new to this tools, excuse me if this isn't the correct process), but tests are passing correctly so this is probably ready to merge (waiting for review approvals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trivial change to properly check if the type of an event is an error, so a description can be added.
Trivial change to properly check if the type of an event is an error, so a description can be added.
Trivial change to properly check if the type of an event is an error, so a description can be added.


Description
Trivial change to properly check if the type of an event is an error, so a description can be added.
Related Issues
Fixes flutter/flutter#41601
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?