-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[image_picker] Image picker fix camera device #3898
[image_picker] Image picker fix camera device #3898
Conversation
# Conflicts: # packages/image_picker/image_picker/pubspec.yaml
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md
When camera is chosen the originalAsset will be nil which leads wrong orientation settings. This can be YES all the time because limited access only available with iOS 14+ and it will be handled with PHPicker implementation.
9df8716
to
877b0d8
Compare
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md
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.
We should have tests covering this. Long-term that will probably require some refactoring for testability, but short term: was this test failing and we just didn't know because it's device-only?
packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
Outdated
Show resolved
Hide resolved
I think the problem is not this test. Since But I double-check and I think we even don't need a |
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md
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.
We should have tests covering this. Long-term that will probably require some refactoring for testability, but short term: was this test failing and we just didn't know because it's device-only?
I think the problem is not this test. Since
UIImagePickerControllerCameraDevice _device
is a global variable we need to re-assign before we call theshowCamera
method from bothpickImage
andpickVideo
inhandleMethodCall
.
Sorry, I'm not seeing how this answers my question. To clarify, there are two parts:
- Where are the test changes that this PR needs to verify the fix, per Flutter policy?
- What is the status of the test referenced above, which sounds like it should already have been testing this scenario, but had not alerted us to the failure previously given that the tree is green?
packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
Outdated
Show resolved
Hide resolved
After some tests, I realized that this test is failing as you said and we didn't know because it's device-only. I was not able to run this test on the real device (because of some weird errors when I was trying to run unit tests of the |
That means we don't have any meaningful test coverage here, since a regression would (as evidenced by this PR) never show up in our CI. It looks like this should be testable via native unit tests. It would require class mocking of |
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md # packages/image_picker/image_picker/pubspec.yaml
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md # packages/image_picker/image_picker/pubspec.yaml
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md # packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m # packages/image_picker/image_picker/pubspec.yaml
@stuartmorgan could you have another look at this PR? @ydag updated the tests so the device specific features are mocked using OCMock and unit-tests will run correctly on the simulator. Chris already approved but the PR is blocked on your requested changes. |
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md
packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
Show resolved
Hide resolved
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { | ||
#pragma mark - Test camera devices, no op on simulators | ||
- (void)testPluginPickImageDeviceCancelClickMultipleTimes { | ||
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { |
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.
Why are you aborting the test if the camera is available?
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.
Hi Stuart,
This change made by this commit and it already exists in master as well and got merged in my PR. Do you think we should remove it? Or do you think we should ask what was this test about and try to fix it?
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.
@cyanglaz Was this a bug, or is this intentionally only supposed to run on simulator? That seems bizarre.
packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
Show resolved
Hide resolved
packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
Show resolved
Hide resolved
packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
Outdated
Show resolved
Hide resolved
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md
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.
LGTM with one comment nit (no need to get another review once fixed)
packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
Outdated
Show resolved
Hide resolved
* upstream_master: (40 commits) [image_picker] Image picker fix camera device (flutter#3898) [flutter_plugin_tools] Improve license-check output (flutter#4154) [webview_flutter] Fix broken keyboard issue link (flutter#3266) [flutter_plugin_tools] Support format on Windows (flutter#4150) [flutter_plugin_tools] Make unit tests pass on Windows (flutter#4149) [image_picker_for_web] Migrate image_picker to package:cross_file (flutter#4083) [various] Prepare plugin repo for binding API improvements (flutter#4148) [quick_actions] Add const constructor (flutter#4131) [in_app_purchase] Add iOS currency symbol to ProductDetails (flutter#4144) [in_app_purchase] Added priceCurrencySymbol to SkuDetailsWrapper (flutter#4114) [image_picker_platform_interface] Add methods that return package:cross_file (flutter#4072) [flutter_plugin_tools] Improve and test 'format' (flutter#4145) [flutter_plugin_tools] Only check target packages in analyze (flutter#4146) [in_app_purchase] Fix crash when retrieveReceiptWithError gives an error. (flutter#4138) [video_player] Pause video when it completes (flutter#3727) [in_app_purchase] Add currencySymbol to ProductDetails (flutter#4115) [in_app_purchase] Add documentation for price change confirmations (flutter#4092) [camera] android-rework part 8: Supporting modules for final implementation (flutter#4054) [plugin_platform_interface] Fix README broken link (flutter#4143) [various] Prepare plugin repo for binding API improvements (flutter#4137) ...
# Conflicts: # packages/image_picker/image_picker/CHANGELOG.md # packages/image_picker/image_picker/example/ios/Podfile # packages/image_picker/image_picker/pubspec.yaml
This PR fixes an issue where
preferredCameraDevice
is not working as expected forgetVideo
method. I also refactor device-only unit tests to make sure we can test camera devices on the CI as well.Related issues :
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
dart format
. See plugin_tool format)[shared_preferences]
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.