-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(macos): (WIP) adds support for macOS PHPicker for image_picker_m…
…acos - Updates the `image_picke_macos`'s `pubspec.yaml` to add `pigeon` as dev dependency and add the `pluginClass` for Swift native code - Adds the `ImagePickerPlugin` in `image_picker_macos/macos` for native macOS plugin with support for SPM and CocoaPods with basic native unit tests - Uses the steps in https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#enabling-xctests-or-xcuitests to enable `XCTests` and `XCUITests` - Updates the `image_picker_macos_test.dart` to fix the test failure and ensure PHPicker is disabled by default - Adds a new button in the example to enable/disable PHPicker macOS implementation and enable the PHPicker by default - Updates the `README.md` of `image_picker_macos` and `image_picker` to document the usage - Removes two TODOs in `image_picker_macos.dart` as they are done with this PR - Adds TODOs that need to be done before merging the PR, some of them are questions, will be removed - Implement the getMultiImageWithOptions() since the getMultiImage is deprecated, updates getMultiImage() to delegate to getMultiImageWithOptions() since getMultiImageWithOptions() is required to access the limit property - Updates the Dart unit tests of image_picker_macos - Adds simple integration test for the example - Updates `pubspec.yaml` and `CHANGELOG.md` of `image_picker` and `image_picker_macos`
- Loading branch information
Showing
32 changed files
with
3,415 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
62 changes: 62 additions & 0 deletions
62
packages/image_picker/image_picker_macos/example/integration_test/image_picker_test.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:example/main.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:image_picker_macos/image_picker_macos.dart'; | ||
import 'package:image_picker_macos/src/messages.g.dart'; | ||
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
ImagePickerMacOS get requireMacOSImplementation { | ||
final ImagePickerPlatform imagePickerImplementation = | ||
ImagePickerPlatform.instance; | ||
if (imagePickerImplementation is! ImagePickerMacOS) { | ||
fail('Expected the implementation to be $ImagePickerMacOS'); | ||
} | ||
return imagePickerImplementation; | ||
} | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
group('example', () { | ||
testWidgets( | ||
'Pressing the PHPicker toggle button updates it correctly', | ||
(WidgetTester tester) async { | ||
final ImagePickerMacOS imagePickerImplementation = | ||
requireMacOSImplementation; | ||
expect(imagePickerImplementation.useMacOSPHPicker, false, | ||
reason: 'The default is to not using PHPicker'); | ||
|
||
await tester.pumpWidget(const MyApp()); | ||
final Finder togglePHPickerFinder = | ||
find.byTooltip('toggle macOS PHPPicker'); | ||
expect(togglePHPickerFinder, findsOneWidget); | ||
|
||
await tester.tap(togglePHPickerFinder); | ||
expect(imagePickerImplementation.useMacOSPHPicker, true, | ||
reason: 'Pressing the toggle button should update it correctly'); | ||
|
||
await tester.tap(togglePHPickerFinder); | ||
expect(imagePickerImplementation.useMacOSPHPicker, false, | ||
reason: 'Pressing the toggle button should update it correctly'); | ||
}, | ||
); | ||
testWidgets( | ||
'multi-video selection is not implemented', | ||
(WidgetTester tester) async { | ||
final ImagePickerApi hostApi = ImagePickerApi(); | ||
await expectLater( | ||
hostApi.pickVideos(GeneralOptions(limit: 2)), | ||
throwsA(predicate<PlatformException>( | ||
(PlatformException e) => | ||
e.code == 'UNIMPLEMENTED' && | ||
e.message == 'Multi-video selection is not implemented', | ||
)), | ||
); | ||
}, | ||
); | ||
}); | ||
} |
This file contains 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
Oops, something went wrong.