From 6f8bb67d921e065af599a7792d76a38a6e6c7dc4 Mon Sep 17 00:00:00 2001 From: Yusuf <82844127+ydag@users.noreply.github.com> Date: Mon, 10 May 2021 16:13:03 +0200 Subject: [PATCH 01/10] Fix the description (#3869) --- packages/image_picker/image_picker/CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md index 58002a8630b4..9c2bcc72b7e3 100644 --- a/packages/image_picker/image_picker/CHANGELOG.md +++ b/packages/image_picker/image_picker/CHANGELOG.md @@ -1,9 +1,8 @@ ## 0.7.5 * Fixes an issue where image rotation is wrong when Select Photos chose and image is scaled. -* Breaking Changes: - * Migrate to PHPicker for iOS 14 and higher versions to pick image from the photo library. - * Implement the limited permission to pick photo from the photo library when Select Photo is chose. +* Migrate to PHPicker for iOS 14 and higher versions to pick image from the photo library. +* Implement the limited permission to pick photo from the photo library when Select Photo is chose. ## 0.7.4 From 7765fa01acda94f132ff0afefb468a37a06c0da8 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 10 May 2021 12:09:45 -0400 Subject: [PATCH 02/10] Check in macOS example Podfiles (#3864) PR #3747 stopped ignoring Podfiles and added the missing iOS Podfiles, but not the macOS Podfiles. --- .../connectivity/example/macos/Podfile | 40 +++++++++++++++++++ .../connectivity_macos/example/macos/Podfile | 40 +++++++++++++++++++ .../integration_test/example/macos/Podfile | 40 +++++++++++++++++++ packages/package_info/example/macos/Podfile | 40 +++++++++++++++++++ .../path_provider/example/macos/Podfile | 40 +++++++++++++++++++ .../path_provider_macos/example/macos/Podfile | 40 +++++++++++++++++++ .../shared_preferences/example/macos/Podfile | 40 +++++++++++++++++++ .../example/macos/Podfile | 40 +++++++++++++++++++ .../url_launcher/example/macos/Podfile | 40 +++++++++++++++++++ .../url_launcher_macos/example/macos/Podfile | 40 +++++++++++++++++++ 10 files changed, 400 insertions(+) create mode 100644 packages/connectivity/connectivity/example/macos/Podfile create mode 100644 packages/connectivity/connectivity_macos/example/macos/Podfile create mode 100644 packages/integration_test/example/macos/Podfile create mode 100644 packages/package_info/example/macos/Podfile create mode 100644 packages/path_provider/path_provider/example/macos/Podfile create mode 100644 packages/path_provider/path_provider_macos/example/macos/Podfile create mode 100644 packages/shared_preferences/shared_preferences/example/macos/Podfile create mode 100644 packages/shared_preferences/shared_preferences_macos/example/macos/Podfile create mode 100644 packages/url_launcher/url_launcher/example/macos/Podfile create mode 100644 packages/url_launcher/url_launcher_macos/example/macos/Podfile diff --git a/packages/connectivity/connectivity/example/macos/Podfile b/packages/connectivity/connectivity/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/connectivity/connectivity/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/connectivity/connectivity_macos/example/macos/Podfile b/packages/connectivity/connectivity_macos/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/connectivity/connectivity_macos/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/integration_test/example/macos/Podfile b/packages/integration_test/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/integration_test/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/package_info/example/macos/Podfile b/packages/package_info/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/package_info/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/path_provider/path_provider/example/macos/Podfile b/packages/path_provider/path_provider/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/path_provider/path_provider/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/path_provider/path_provider_macos/example/macos/Podfile b/packages/path_provider/path_provider_macos/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/path_provider/path_provider_macos/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/shared_preferences/shared_preferences/example/macos/Podfile b/packages/shared_preferences/shared_preferences/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/shared_preferences/shared_preferences/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/shared_preferences/shared_preferences_macos/example/macos/Podfile b/packages/shared_preferences/shared_preferences_macos/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/shared_preferences/shared_preferences_macos/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/url_launcher/url_launcher/example/macos/Podfile b/packages/url_launcher/url_launcher/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/url_launcher/url_launcher/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/url_launcher/url_launcher_macos/example/macos/Podfile b/packages/url_launcher/url_launcher_macos/example/macos/Podfile new file mode 100644 index 000000000000..dade8dfad0dc --- /dev/null +++ b/packages/url_launcher/url_launcher_macos/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end From 0c99a3ba749bbdc57b0d8895cdfaeef835119613 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 10 May 2021 12:36:21 -0400 Subject: [PATCH 03/10] Simplify the tooling bash scripts (#3865) - Rename incremental_build.sh to tool_runner.sh since it has been used for things other than building for a while, and also isn't always incremental. - Replace check_publish.sh with tool_runner.sh to reduce the number of special-case scripts. This is a small behavioral change in that now PRs that don't change any packages will test all packages, as with our other scripts. - Eliminate check_changed_packages. All critical uses have now been replaced by the Dart version of the logic, and the one remaining use was purely for an error message that says something that should be relatively easy to figure out from context anyway. This means we have less bash code to maintain (without unit tests) and understand. --- .cirrus.yml | 40 +++++++++--------- .../video_player/video_player/CONTRIBUTING.md | 2 +- script/build_all_plugins_app.sh | 14 +------ script/check_publish.sh | 22 ---------- script/common.sh | 42 ------------------- .../{incremental_build.sh => tool_runner.sh} | 0 6 files changed, 23 insertions(+), 97 deletions(-) delete mode 100755 script/check_publish.sh rename script/{incremental_build.sh => tool_runner.sh} (100%) diff --git a/.cirrus.yml b/.cirrus.yml index d269f901a180..fe36ec1d5eae 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -48,10 +48,10 @@ task: - CIRRUS_BUILD_ID=null pub run test - name: publishable script: - - ./script/incremental_build.sh version-check - - ./script/check_publish.sh + - ./script/tool_runner.sh version-check + - ./script/tool_runner.sh publish-check - name: format - format_script: ./script/incremental_build.sh format --fail-on-change + format_script: ./script/tool_runner.sh format --fail-on-change license_script: - dart script/tool/lib/src/main.dart license-check - name: test @@ -60,7 +60,7 @@ task: CHANNEL: "master" CHANNEL: "stable" test_script: - - ./script/incremental_build.sh test + - ./script/tool_runner.sh test - name: analyze_master env: matrix: @@ -68,8 +68,8 @@ task: tool_script: - cd script/tool - dart analyze --fatal-infos - plugins_script: - - ./script/incremental_build.sh analyze + script: + - ./script/tool_runner.sh analyze ## TODO(cyanglaz): ## Combing stable and master analyze jobs when integration test null safety is ready on flutter stable. - name: analyze_stable @@ -78,7 +78,7 @@ task: CHANNEL: "stable" script: - find . -depth -type d -wholename '*_web/example' -exec rm -rf {} \; - - ./script/incremental_build.sh analyze + - ./script/tool_runner.sh analyze ### Android tasks ### - name: build_all_plugins_apk env: @@ -111,9 +111,9 @@ task: CHANNEL: "stable" build_script: - flutter config --enable-linux-desktop - - ./script/incremental_build.sh build-examples --linux + - ./script/tool_runner.sh build-examples --linux test_script: - - xvfb-run ./script/incremental_build.sh drive-examples --linux + - xvfb-run ./script/tool_runner.sh drive-examples --linux # Heavy-workload Linux tasks. # These use machines with more CPUs and memory, so will reduce parallelization @@ -154,11 +154,11 @@ task: - echo "$CIRRUS_COMMIT_MESSAGE" > /tmp/cirrus_commit_message.txt - export CIRRUS_CHANGE_MESSAGE="" - export CIRRUS_COMMIT_MESSAGE="" - - ./script/incremental_build.sh build-examples --apk - - ./script/incremental_build.sh java-test # must come after apk build + - ./script/tool_runner.sh build-examples --apk + - ./script/tool_runner.sh java-test # must come after apk build - if [[ -n "$GCLOUD_FIREBASE_TESTLAB_KEY" ]]; then - echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json - - ./script/incremental_build.sh firebase-test-lab --device model=flame,version=29 --device model=starqlteue,version=26 + - ./script/tool_runner.sh firebase-test-lab --device model=flame,version=29 --device model=starqlteue,version=26 - else - echo "This user does not have permission to run Firebase Test Lab tests." - fi @@ -177,11 +177,11 @@ task: - dart lib/web_driver_installer.dart chromedriver --install-only - ./chromedriver/chromedriver --port=4444 & build_script: - - ./script/incremental_build.sh build-examples --web + - ./script/tool_runner.sh build-examples --web test_script: # TODO(stuartmorgan): Eliminate this check once 2.1 reaches stable. - if [[ "$CHANNEL" == "master" ]]; then - - ./script/incremental_build.sh drive-examples --web + - ./script/tool_runner.sh drive-examples --web - else - echo "Requires null-safe integration_test; skipping." - fi @@ -216,13 +216,13 @@ task: - xcrun simctl list - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot build_script: - - ./script/incremental_build.sh build-examples --ipa + - ./script/tool_runner.sh build-examples --ipa test_script: - - ./script/incremental_build.sh xctest --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest" + - ./script/tool_runner.sh xctest --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest" # `drive-examples` contains integration tests, which changes the UI of the application. # This UI change sometimes affects `xctest`. # So we run `drive-examples` after `xctest`, changing the order will result ci failure. - - ./script/incremental_build.sh drive-examples --ios + - ./script/tool_runner.sh drive-examples --ios ### macOS desktop tasks ### - name: build_all_plugins_macos env: @@ -240,9 +240,9 @@ task: PATH: $PATH:/usr/local/bin build_script: - flutter config --enable-macos-desktop - - ./script/incremental_build.sh build-examples --macos --no-ipa + - ./script/tool_runner.sh build-examples --macos --no-ipa test_script: - - ./script/incremental_build.sh drive-examples --macos + - ./script/tool_runner.sh drive-examples --macos task: # Don't use FLUTTER_UPGRADE_TEMPLATE, Flutter tooling not needed. @@ -253,4 +253,4 @@ task: script: # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation. - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm - - ./script/incremental_build.sh podspecs + - ./script/tool_runner.sh podspecs diff --git a/packages/video_player/video_player/CONTRIBUTING.md b/packages/video_player/video_player/CONTRIBUTING.md index 32c9d1b791d1..15c48038f6fc 100644 --- a/packages/video_player/video_player/CONTRIBUTING.md +++ b/packages/video_player/video_player/CONTRIBUTING.md @@ -8,7 +8,7 @@ dependencies in the examples directory): flutter pub upgrade flutter pub run pigeon --dart_null_safety --input pigeons/messages.dart # git commit your changes so that your working environment is clean -(cd ../../../; ./script/incremental_build.sh format --travis --clang-format=clang-format-7) +(cd ../../../; ./script/tool_runner.sh format --clang-format=clang-format-7) ``` If you update pigeon itself and want to test the changes here, diff --git a/script/build_all_plugins_app.sh b/script/build_all_plugins_app.sh index 06566f059a54..3b3416021a42 100755 --- a/script/build_all_plugins_app.sh +++ b/script/build_all_plugins_app.sh @@ -18,8 +18,6 @@ readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" source "$SCRIPT_DIR/common.sh" -check_changed_packages > /dev/null - # This list should be kept as short as possible, and things should remain here # only as long as necessary, since in general the goal is for all of the latest # versions of plugins to be mutually compatible. @@ -63,18 +61,10 @@ for version in "${BUILD_MODES[@]}"; do if [ $? -eq 0 ]; then echo "Successfully built $version all_plugins app." - echo "All first party plugins compile together." + echo "All first-party plugins compile together." else error "Failed to build $version all_plugins app." - if [[ "${#CHANGED_PACKAGE_LIST[@]}" == 0 ]]; then - error "There was a failure to compile all first party plugins together, but there were no changes detected in packages." - else - error "Changes to the following packages may prevent all first party plugins from compiling together:" - for package in "${CHANGED_PACKAGE_LIST[@]}"; do - error "$package" - done - echo "" - fi + error "This indicates a conflict between two or more first-party plugins." failures=$(($failures + 1)) fi done diff --git a/script/check_publish.sh b/script/check_publish.sh deleted file mode 100755 index a08df7a0b5d8..000000000000 --- a/script/check_publish.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# 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. - -set -e - -# This script checks to make sure that each of the plugins *could* be published. -# It doesn't actually publish anything. - -# So that users can run this script from anywhere and it will work as expected. -readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" -readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" - -source "$SCRIPT_DIR/common.sh" - -# Sets CHANGED_PACKAGE_LIST and CHANGED_PACKAGES -check_changed_packages - -if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then - plugin_tools publish-check --plugins="${CHANGED_PACKAGES}" -fi diff --git a/script/common.sh b/script/common.sh index 52eeefa6e9ff..0e5290e33d8c 100644 --- a/script/common.sh +++ b/script/common.sh @@ -7,48 +7,6 @@ function error() { echo "$@" 1>&2 } -function get_branch_base_sha() { - local branch_base_sha="$(git merge-base --fork-point FETCH_HEAD HEAD || git merge-base FETCH_HEAD HEAD)" - echo "$branch_base_sha" -} - -function check_changed_packages() { - # Try get a merge base for the branch and calculate affected packages. - # We need this check because some CIs can do a single branch clones with a limited history of commits. - local packages - local branch_base_sha="$(get_branch_base_sha)" - if [[ "$branch_base_sha" != "" ]]; then - echo "Checking for changed packages from $branch_base_sha" - IFS=$'\n' packages=( $(git diff --name-only "$branch_base_sha" HEAD | grep -o "packages/[^/]*" | sed -e "s/packages\///g" | sort | uniq) ) - else - error "Cannot find a merge base for the current branch to run an incremental build..." - error "Please rebase your branch onto the latest master!" - return 1 - fi - - CHANGED_PACKAGES="" - CHANGED_PACKAGE_LIST=() - - # Filter out packages that have been deleted. - for package in "${packages[@]}"; do - if [ -d "$REPO_DIR/packages/$package" ]; then - CHANGED_PACKAGES="${CHANGED_PACKAGES},$package" - CHANGED_PACKAGE_LIST=("${CHANGED_PACKAGE_LIST[@]}" "$package") - fi - done - - if [[ "${#CHANGED_PACKAGE_LIST[@]}" == 0 ]]; then - echo "No changes detected in packages." - else - echo "Detected changes in the following ${#CHANGED_PACKAGE_LIST[@]} package(s):" - for package in "${CHANGED_PACKAGE_LIST[@]}"; do - echo "$package" - done - echo "" - fi - return 0 -} - # Runs the plugin tools from the plugin_tools git submodule. function plugin_tools() { (pushd "$REPO_DIR/script/tool" && dart pub get && popd) >/dev/null diff --git a/script/incremental_build.sh b/script/tool_runner.sh similarity index 100% rename from script/incremental_build.sh rename to script/tool_runner.sh From 37ac97fa42508d8c69450439bde3615d9ad784c7 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 10 May 2021 14:14:45 -0400 Subject: [PATCH 04/10] Ensure that integration tests are actually being run (#3857) Many of our integration tests weren't actually being run on CI because they were in the wrong place and/or missing the driver file, and it seems we've just never noticed. This makes a number of changes: - Ensures that all packages with integration tests also have a driver file in the right location. - Also standardizes the format of those files, as the boilerplate `main()` is available in `integration_test`. - Ensures that all integration_test directories are in the right place. - In a couple of places, removes a duplicate copy of the integration test file. - Makes it an error for a plugin that's not excluded to not have integration tests, so this can't easily happen again. - Adds logging of what's being run and skipped, so if something does go wrong in the future it's easy to determine what from the logs. - Excludes `*_platform_interface` since the logging was (potentially confusingly) reporting that they were skipped because they don't support the current platform. Skipping them is correct, just not for that reason. - Excludes the plugins that currently have no integration tests, with references to issues about adding them. Fixes https://github.com/flutter/flutter/issues/81929 --- .cirrus.yml | 18 ++++-- .../example/test_driver/integration_test.dart | 17 +----- .../example/test_driver/integration_test.dart | 19 +------ .../integration_test/battery_test.dart | 16 +++++- .../example/test_driver/integration_test.dart | 9 +++ .../integration_test/connectivity_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../test_driver/test/integration_test.dart | 20 ------- .../integration_test/connectivity_test.dart | 27 --------- .../example/test_driver/integration_test.dart | 2 +- .../integration_test/connectivity_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../test_driver/test/integration_test.dart | 17 ------ .../example/test_driver/integration_test.dart | 17 +----- .../example/test_driver/integration_test.dart | 15 +---- .../example/test_driver/integration_test.dart | 2 +- .../integration_test/google_sign_in_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../test_driver/integration_test.dart | 19 ------- .../example/test_driver/integration_test.dart | 2 +- .../old_image_picker_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../test_driver/test/integration_test.dart | 18 ------ .../in_app_purchase_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../test_driver/test/integration_test.dart | 18 ------ .../example/test_driver/integration_test.dart | 2 + .../integration_test/local_auth_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../example/test_driver/integration_test.dart | 16 +----- .../example/test_driver/integration_test.dart | 13 +---- .../integration_test/path_provider_test.dart | 18 ------ .../example/test_driver/integration_test.dart | 13 +---- .../example/test_driver/integration_test.dart | 13 +---- .../example/test_driver/integration_test.dart | 13 +---- .../example/test_driver/integration_test.dart | 17 ++---- .../integration_test/sensors_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../test_driver/test/integration_test.dart | 19 ------- .../integration_test/share_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../test_driver/test/integration_test.dart | 19 ------- .../example/test_driver/integration_test.dart | 14 +---- .../example/test_driver/integration_test.dart | 14 +---- .../example/test_driver/integration_test.dart | 14 +---- .../example/test_driver/integration_test.dart | 14 +---- .../example/test_driver/integration_test.dart | 17 +----- .../example/test_driver/integration_test.dart | 16 +----- .../example/test_driver/integration_test.dart | 16 +----- .../example/test_driver/integration_test.dart | 2 +- .../example/test_driver/integration_test.dart | 16 +----- .../example/test_driver/integration_test.dart | 17 +----- .../example/test_driver/integration_test.dart | 16 +----- .../integration_test/wifi_info_test.dart | 0 .../example/test_driver/integration_test.dart | 9 +++ .../integration_test/wifi_info_test.dart | 28 --------- .../test_driver/test/integration_test.dart | 17 ------ .../tool/lib/src/drive_examples_command.dart | 37 ++++++++++-- .../test/drive_examples_command_test.dart | 57 +++++++++++++++++++ 59 files changed, 263 insertions(+), 492 deletions(-) rename packages/battery/battery/{ => example}/integration_test/battery_test.dart (51%) create mode 100644 packages/battery/battery/example/test_driver/integration_test.dart rename packages/connectivity/connectivity/example/{test_driver => }/integration_test/connectivity_test.dart (100%) create mode 100644 packages/connectivity/connectivity/example/test_driver/integration_test.dart delete mode 100644 packages/connectivity/connectivity/example/test_driver/test/integration_test.dart delete mode 100644 packages/connectivity/connectivity/integration_test/connectivity_test.dart rename packages/connectivity/connectivity_macos/example/{test_driver => }/integration_test/connectivity_test.dart (100%) create mode 100644 packages/connectivity/connectivity_macos/example/test_driver/integration_test.dart delete mode 100644 packages/connectivity/connectivity_macos/example/test_driver/test/integration_test.dart rename packages/google_sign_in/google_sign_in/{ => example}/integration_test/google_sign_in_test.dart (100%) create mode 100644 packages/google_sign_in/google_sign_in/example/test_driver/integration_test.dart delete mode 100644 packages/google_sign_in/google_sign_in/test_driver/integration_test.dart rename packages/image_picker/image_picker/{ => example}/integration_test/old_image_picker_test.dart (100%) create mode 100644 packages/image_picker/image_picker/example/test_driver/integration_test.dart delete mode 100644 packages/image_picker/image_picker/example/test_driver/test/integration_test.dart rename packages/in_app_purchase/in_app_purchase/{ => example}/integration_test/in_app_purchase_test.dart (100%) create mode 100644 packages/in_app_purchase/in_app_purchase/example/test_driver/integration_test.dart delete mode 100644 packages/in_app_purchase/in_app_purchase/example/test_driver/test/integration_test.dart rename packages/local_auth/{ => example}/integration_test/local_auth_test.dart (100%) create mode 100644 packages/local_auth/example/test_driver/integration_test.dart delete mode 100644 packages/path_provider/path_provider/integration_test/path_provider_test.dart rename packages/sensors/{ => example}/integration_test/sensors_test.dart (100%) create mode 100644 packages/sensors/example/test_driver/integration_test.dart delete mode 100644 packages/sensors/example/test_driver/test/integration_test.dart rename packages/share/{ => example}/integration_test/share_test.dart (100%) create mode 100644 packages/share/example/test_driver/integration_test.dart delete mode 100644 packages/share/example/test_driver/test/integration_test.dart rename packages/wifi_info_flutter/wifi_info_flutter/{ => example}/integration_test/wifi_info_test.dart (100%) create mode 100644 packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test.dart delete mode 100644 packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test/wifi_info_test.dart delete mode 100644 packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/test/integration_test.dart diff --git a/.cirrus.yml b/.cirrus.yml index fe36ec1d5eae..8ae5b384aee1 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -112,7 +112,7 @@ task: build_script: - flutter config --enable-linux-desktop - ./script/tool_runner.sh build-examples --linux - test_script: + drive_script: - xvfb-run ./script/tool_runner.sh drive-examples --linux # Heavy-workload Linux tasks. @@ -167,6 +167,8 @@ task: ### Web tasks ### - name: build-web+drive-examples env: + # Currently missing; see https://github.com/flutter/flutter/issues/81982 + PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "image_picker_for_web,shared_preferences_web,video_player_web" matrix: CHANNEL: "master" CHANNEL: "stable" @@ -178,10 +180,10 @@ task: - ./chromedriver/chromedriver --port=4444 & build_script: - ./script/tool_runner.sh build-examples --web - test_script: + drive_script: # TODO(stuartmorgan): Eliminate this check once 2.1 reaches stable. - if [[ "$CHANNEL" == "master" ]]; then - - ./script/tool_runner.sh drive-examples --web + - ./script/tool_runner.sh drive-examples --web --exclude $PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS - else - echo "Requires null-safe integration_test; skipping." - fi @@ -203,6 +205,9 @@ task: env: PATH: $PATH:/usr/local/bin PLUGINS_TO_SKIP_XCTESTS: "integration_test" + # in_app_purchase_ios is currently missing tests; see https://github.com/flutter/flutter/issues/81695 + # sensor hangs on CI. + PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "in_app_purchase_ios,sensors" matrix: PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" @@ -217,12 +222,13 @@ task: - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot build_script: - ./script/tool_runner.sh build-examples --ipa - test_script: + xctest_script: - ./script/tool_runner.sh xctest --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest" + drive_script: # `drive-examples` contains integration tests, which changes the UI of the application. # This UI change sometimes affects `xctest`. # So we run `drive-examples` after `xctest`, changing the order will result ci failure. - - ./script/tool_runner.sh drive-examples --ios + - ./script/tool_runner.sh drive-examples --ios --exclude $PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS ### macOS desktop tasks ### - name: build_all_plugins_macos env: @@ -241,7 +247,7 @@ task: build_script: - flutter config --enable-macos-desktop - ./script/tool_runner.sh build-examples --macos --no-ipa - test_script: + drive_script: - ./script/tool_runner.sh drive-examples --macos task: diff --git a/packages/android_alarm_manager/example/test_driver/integration_test.dart b/packages/android_alarm_manager/example/test_driver/integration_test.dart index c08f4a817f6c..6a0e6fa82dbe 100644 --- a/packages/android_alarm_manager/example/test_driver/integration_test.dart +++ b/packages/android_alarm_manager/example/test_driver/integration_test.dart @@ -4,19 +4,6 @@ // @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; +import 'package:integration_test/integration_test_driver.dart'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = await driver.requestData( - null, - timeout: const Duration(minutes: 1), - ); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/android_intent/example/test_driver/integration_test.dart b/packages/android_intent/example/test_driver/integration_test.dart index cc91e52ef2ef..6a0e6fa82dbe 100644 --- a/packages/android_intent/example/test_driver/integration_test.dart +++ b/packages/android_intent/example/test_driver/integration_test.dart @@ -2,21 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 +// @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; +import 'package:integration_test/integration_test_driver.dart'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = await driver.requestData( - null, - timeout: const Duration(minutes: 1), - ); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/battery/battery/integration_test/battery_test.dart b/packages/battery/battery/example/integration_test/battery_test.dart similarity index 51% rename from packages/battery/battery/integration_test/battery_test.dart rename to packages/battery/battery/example/integration_test/battery_test.dart index 24f5a5adc7f9..eced27e5a1cd 100644 --- a/packages/battery/battery/integration_test/battery_test.dart +++ b/packages/battery/battery/example/integration_test/battery_test.dart @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 +// @dart=2.9 +import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:battery/battery.dart'; import 'package:integration_test/integration_test.dart'; @@ -13,7 +14,18 @@ void main() { testWidgets('Can get battery level', (WidgetTester tester) async { final Battery battery = Battery(); - final int batteryLevel = await battery.batteryLevel; + int batteryLevel; + try { + batteryLevel = await battery.batteryLevel; + } on PlatformException catch (e) { + // The "UNAVAIBLE" error just means that the system reported the battery + // level as unknown (e.g., the test is running on simulator); it still + // indicates that the plugin itself is working as expected, so consider it + // as passing. + if (e.code == 'UNAVAILABLE') { + batteryLevel = 1; + } + } expect(batteryLevel, isNotNull); }); } diff --git a/packages/battery/battery/example/test_driver/integration_test.dart b/packages/battery/battery/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/battery/battery/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/connectivity/connectivity/example/test_driver/integration_test/connectivity_test.dart b/packages/connectivity/connectivity/example/integration_test/connectivity_test.dart similarity index 100% rename from packages/connectivity/connectivity/example/test_driver/integration_test/connectivity_test.dart rename to packages/connectivity/connectivity/example/integration_test/connectivity_test.dart diff --git a/packages/connectivity/connectivity/example/test_driver/integration_test.dart b/packages/connectivity/connectivity/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/connectivity/connectivity/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/connectivity/connectivity/example/test_driver/test/integration_test.dart b/packages/connectivity/connectivity/example/test_driver/test/integration_test.dart deleted file mode 100644 index 79c1875f85d2..000000000000 --- a/packages/connectivity/connectivity/example/test_driver/test/integration_test.dart +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -// TODO(amirh): Remove this once flutter_driver supports null safety. -// https://github.com/flutter/flutter/issues/71379 -// @dart = 2.9 - -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} diff --git a/packages/connectivity/connectivity/integration_test/connectivity_test.dart b/packages/connectivity/connectivity/integration_test/connectivity_test.dart deleted file mode 100644 index 454ddd4c351b..000000000000 --- a/packages/connectivity/connectivity/integration_test/connectivity_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -// TODO(cyanglaz): Remove once https://github.com/flutter/plugins/pull/3158 is landed. -// @dart = 2.9 - -import 'package:integration_test/integration_test.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:connectivity/connectivity.dart'; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - group('Connectivity test driver', () { - Connectivity _connectivity; - - setUpAll(() async { - _connectivity = Connectivity(); - }); - - testWidgets('test connectivity result', (WidgetTester tester) async { - final ConnectivityResult result = await _connectivity.checkConnectivity(); - expect(result, isNotNull); - }); - }); -} diff --git a/packages/connectivity/connectivity_for_web/example/test_driver/integration_test.dart b/packages/connectivity/connectivity_for_web/example/test_driver/integration_test.dart index f26b6a310cfe..4f10f2a522f3 100644 --- a/packages/connectivity/connectivity_for_web/example/test_driver/integration_test.dart +++ b/packages/connectivity/connectivity_for_web/example/test_driver/integration_test.dart @@ -4,4 +4,4 @@ import 'package:integration_test/integration_test_driver.dart'; -Future main() async => integrationDriver(); +Future main() => integrationDriver(); diff --git a/packages/connectivity/connectivity_macos/example/test_driver/integration_test/connectivity_test.dart b/packages/connectivity/connectivity_macos/example/integration_test/connectivity_test.dart similarity index 100% rename from packages/connectivity/connectivity_macos/example/test_driver/integration_test/connectivity_test.dart rename to packages/connectivity/connectivity_macos/example/integration_test/connectivity_test.dart diff --git a/packages/connectivity/connectivity_macos/example/test_driver/integration_test.dart b/packages/connectivity/connectivity_macos/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/connectivity/connectivity_macos/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/connectivity/connectivity_macos/example/test_driver/test/integration_test.dart b/packages/connectivity/connectivity_macos/example/test_driver/test/integration_test.dart deleted file mode 100644 index 9647a12d77ce..000000000000 --- a/packages/connectivity/connectivity_macos/example/test_driver/test/integration_test.dart +++ /dev/null @@ -1,17 +0,0 @@ -// 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. - -// @dart = 2.9 -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} diff --git a/packages/device_info/device_info/example/test_driver/integration_test.dart b/packages/device_info/device_info/example/test_driver/integration_test.dart index 156ecae508c1..6a0e6fa82dbe 100644 --- a/packages/device_info/device_info/example/test_driver/integration_test.dart +++ b/packages/device_info/device_info/example/test_driver/integration_test.dart @@ -2,19 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(cyanglaz): Remove once https://github.com/flutter/flutter/issues/59879 is fixed. -// @dart = 2.9 +// @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/google_maps_flutter/google_maps_flutter/example/test_driver/integration_test.dart b/packages/google_maps_flutter/google_maps_flutter/example/test_driver/integration_test.dart index ab30698581d0..6a0e6fa82dbe 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/test_driver/integration_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/test_driver/integration_test.dart @@ -1,18 +1,9 @@ // 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. + // @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/test_driver/integration_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/test_driver/integration_test.dart index f26b6a310cfe..4f10f2a522f3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/test_driver/integration_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/test_driver/integration_test.dart @@ -4,4 +4,4 @@ import 'package:integration_test/integration_test_driver.dart'; -Future main() async => integrationDriver(); +Future main() => integrationDriver(); diff --git a/packages/google_sign_in/google_sign_in/integration_test/google_sign_in_test.dart b/packages/google_sign_in/google_sign_in/example/integration_test/google_sign_in_test.dart similarity index 100% rename from packages/google_sign_in/google_sign_in/integration_test/google_sign_in_test.dart rename to packages/google_sign_in/google_sign_in/example/integration_test/google_sign_in_test.dart diff --git a/packages/google_sign_in/google_sign_in/example/test_driver/integration_test.dart b/packages/google_sign_in/google_sign_in/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/google_sign_in/google_sign_in/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/google_sign_in/google_sign_in/test_driver/integration_test.dart b/packages/google_sign_in/google_sign_in/test_driver/integration_test.dart deleted file mode 100644 index 257b0d3c0930..000000000000 --- a/packages/google_sign_in/google_sign_in/test_driver/integration_test.dart +++ /dev/null @@ -1,19 +0,0 @@ -// 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. - -// @dart = 2.9 - -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} diff --git a/packages/google_sign_in/google_sign_in_web/example/test_driver/integration_test.dart b/packages/google_sign_in/google_sign_in_web/example/test_driver/integration_test.dart index f26b6a310cfe..4f10f2a522f3 100644 --- a/packages/google_sign_in/google_sign_in_web/example/test_driver/integration_test.dart +++ b/packages/google_sign_in/google_sign_in_web/example/test_driver/integration_test.dart @@ -4,4 +4,4 @@ import 'package:integration_test/integration_test_driver.dart'; -Future main() async => integrationDriver(); +Future main() => integrationDriver(); diff --git a/packages/image_picker/image_picker/integration_test/old_image_picker_test.dart b/packages/image_picker/image_picker/example/integration_test/old_image_picker_test.dart similarity index 100% rename from packages/image_picker/image_picker/integration_test/old_image_picker_test.dart rename to packages/image_picker/image_picker/example/integration_test/old_image_picker_test.dart diff --git a/packages/image_picker/image_picker/example/test_driver/integration_test.dart b/packages/image_picker/image_picker/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/image_picker/image_picker/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/image_picker/image_picker/example/test_driver/test/integration_test.dart b/packages/image_picker/image_picker/example/test_driver/test/integration_test.dart deleted file mode 100644 index 4c4c006068b8..000000000000 --- a/packages/image_picker/image_picker/example/test_driver/test/integration_test.dart +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -// @dart = 2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} diff --git a/packages/in_app_purchase/in_app_purchase/integration_test/in_app_purchase_test.dart b/packages/in_app_purchase/in_app_purchase/example/integration_test/in_app_purchase_test.dart similarity index 100% rename from packages/in_app_purchase/in_app_purchase/integration_test/in_app_purchase_test.dart rename to packages/in_app_purchase/in_app_purchase/example/integration_test/in_app_purchase_test.dart diff --git a/packages/in_app_purchase/in_app_purchase/example/test_driver/integration_test.dart b/packages/in_app_purchase/in_app_purchase/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/in_app_purchase/in_app_purchase/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/in_app_purchase/in_app_purchase/example/test_driver/test/integration_test.dart b/packages/in_app_purchase/in_app_purchase/example/test_driver/test/integration_test.dart deleted file mode 100644 index 4c4c006068b8..000000000000 --- a/packages/in_app_purchase/in_app_purchase/example/test_driver/test/integration_test.dart +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -// @dart = 2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} diff --git a/packages/integration_test/example/test_driver/integration_test.dart b/packages/integration_test/example/test_driver/integration_test.dart index 4f10f2a522f3..6a0e6fa82dbe 100644 --- a/packages/integration_test/example/test_driver/integration_test.dart +++ b/packages/integration_test/example/test_driver/integration_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/local_auth/integration_test/local_auth_test.dart b/packages/local_auth/example/integration_test/local_auth_test.dart similarity index 100% rename from packages/local_auth/integration_test/local_auth_test.dart rename to packages/local_auth/example/integration_test/local_auth_test.dart diff --git a/packages/local_auth/example/test_driver/integration_test.dart b/packages/local_auth/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/local_auth/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/package_info/example/test_driver/integration_test.dart b/packages/package_info/example/test_driver/integration_test.dart index 1bcccae039d6..6a0e6fa82dbe 100644 --- a/packages/package_info/example/test_driver/integration_test.dart +++ b/packages/package_info/example/test_driver/integration_test.dart @@ -4,18 +4,6 @@ // @dart=2.9 -import 'dart:convert'; -import 'dart:io'; +import 'package:integration_test/integration_test_driver.dart'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = await driver.requestData( - null, - timeout: const Duration(minutes: 1), - ); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/path_provider/path_provider/example/test_driver/integration_test.dart b/packages/path_provider/path_provider/example/test_driver/integration_test.dart index 24a0ee720b2a..6a0e6fa82dbe 100644 --- a/packages/path_provider/path_provider/example/test_driver/integration_test.dart +++ b/packages/path_provider/path_provider/example/test_driver/integration_test.dart @@ -4,15 +4,6 @@ // @dart=2.9 -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data) as Map; - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/path_provider/path_provider/integration_test/path_provider_test.dart b/packages/path_provider/path_provider/integration_test/path_provider_test.dart deleted file mode 100644 index 71550682444c..000000000000 --- a/packages/path_provider/path_provider/integration_test/path_provider_test.dart +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -// @dart=2.9 - -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; -import 'package:path_provider/path_provider.dart'; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - testWidgets('Can get temporary directory', (WidgetTester tester) async { - final String tempPath = (await getTemporaryDirectory()).path; - expect(tempPath, isNotEmpty); - }); -} diff --git a/packages/path_provider/path_provider_linux/example/test_driver/integration_test.dart b/packages/path_provider/path_provider_linux/example/test_driver/integration_test.dart index 24a0ee720b2a..6a0e6fa82dbe 100644 --- a/packages/path_provider/path_provider_linux/example/test_driver/integration_test.dart +++ b/packages/path_provider/path_provider_linux/example/test_driver/integration_test.dart @@ -4,15 +4,6 @@ // @dart=2.9 -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data) as Map; - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/path_provider/path_provider_macos/example/test_driver/integration_test.dart b/packages/path_provider/path_provider_macos/example/test_driver/integration_test.dart index 24a0ee720b2a..6a0e6fa82dbe 100644 --- a/packages/path_provider/path_provider_macos/example/test_driver/integration_test.dart +++ b/packages/path_provider/path_provider_macos/example/test_driver/integration_test.dart @@ -4,15 +4,6 @@ // @dart=2.9 -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data) as Map; - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/path_provider/path_provider_windows/example/test_driver/integration_test.dart b/packages/path_provider/path_provider_windows/example/test_driver/integration_test.dart index 24a0ee720b2a..6a0e6fa82dbe 100644 --- a/packages/path_provider/path_provider_windows/example/test_driver/integration_test.dart +++ b/packages/path_provider/path_provider_windows/example/test_driver/integration_test.dart @@ -4,15 +4,6 @@ // @dart=2.9 -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data) as Map; - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/quick_actions/quick_actions/example/test_driver/integration_test.dart b/packages/quick_actions/quick_actions/example/test_driver/integration_test.dart index 4c4c006068b8..6a0e6fa82dbe 100644 --- a/packages/quick_actions/quick_actions/example/test_driver/integration_test.dart +++ b/packages/quick_actions/quick_actions/example/test_driver/integration_test.dart @@ -2,17 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +// @dart=2.9 -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/sensors/integration_test/sensors_test.dart b/packages/sensors/example/integration_test/sensors_test.dart similarity index 100% rename from packages/sensors/integration_test/sensors_test.dart rename to packages/sensors/example/integration_test/sensors_test.dart diff --git a/packages/sensors/example/test_driver/integration_test.dart b/packages/sensors/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/sensors/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/sensors/example/test_driver/test/integration_test.dart b/packages/sensors/example/test_driver/test/integration_test.dart deleted file mode 100644 index 257b0d3c0930..000000000000 --- a/packages/sensors/example/test_driver/test/integration_test.dart +++ /dev/null @@ -1,19 +0,0 @@ -// 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. - -// @dart = 2.9 - -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} diff --git a/packages/share/integration_test/share_test.dart b/packages/share/example/integration_test/share_test.dart similarity index 100% rename from packages/share/integration_test/share_test.dart rename to packages/share/example/integration_test/share_test.dart diff --git a/packages/share/example/test_driver/integration_test.dart b/packages/share/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/share/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/share/example/test_driver/test/integration_test.dart b/packages/share/example/test_driver/test/integration_test.dart deleted file mode 100644 index 257b0d3c0930..000000000000 --- a/packages/share/example/test_driver/test/integration_test.dart +++ /dev/null @@ -1,19 +0,0 @@ -// 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. - -// @dart = 2.9 - -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} diff --git a/packages/shared_preferences/shared_preferences/example/test_driver/integration_test.dart b/packages/shared_preferences/shared_preferences/example/test_driver/integration_test.dart index 18ed3cff3ee8..6a0e6fa82dbe 100644 --- a/packages/shared_preferences/shared_preferences/example/test_driver/integration_test.dart +++ b/packages/shared_preferences/shared_preferences/example/test_driver/integration_test.dart @@ -4,16 +4,6 @@ // @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/shared_preferences/shared_preferences_linux/example/test_driver/integration_test.dart b/packages/shared_preferences/shared_preferences_linux/example/test_driver/integration_test.dart index 18ed3cff3ee8..6a0e6fa82dbe 100644 --- a/packages/shared_preferences/shared_preferences_linux/example/test_driver/integration_test.dart +++ b/packages/shared_preferences/shared_preferences_linux/example/test_driver/integration_test.dart @@ -4,16 +4,6 @@ // @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/shared_preferences/shared_preferences_macos/example/test_driver/integration_test.dart b/packages/shared_preferences/shared_preferences_macos/example/test_driver/integration_test.dart index 18ed3cff3ee8..6a0e6fa82dbe 100644 --- a/packages/shared_preferences/shared_preferences_macos/example/test_driver/integration_test.dart +++ b/packages/shared_preferences/shared_preferences_macos/example/test_driver/integration_test.dart @@ -4,16 +4,6 @@ // @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/shared_preferences/shared_preferences_windows/example/test_driver/integration_test.dart b/packages/shared_preferences/shared_preferences_windows/example/test_driver/integration_test.dart index 18ed3cff3ee8..6a0e6fa82dbe 100644 --- a/packages/shared_preferences/shared_preferences_windows/example/test_driver/integration_test.dart +++ b/packages/shared_preferences/shared_preferences_windows/example/test_driver/integration_test.dart @@ -4,16 +4,6 @@ // @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/url_launcher/url_launcher/example/test_driver/integration_test.dart b/packages/url_launcher/url_launcher/example/test_driver/integration_test.dart index 053e985a78ce..6a0e6fa82dbe 100644 --- a/packages/url_launcher/url_launcher/example/test_driver/integration_test.dart +++ b/packages/url_launcher/url_launcher/example/test_driver/integration_test.dart @@ -2,19 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(egarciad): Remove once flutter_driver is migrated to null safety. -// @dart = 2.9 +// @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/url_launcher/url_launcher_linux/example/test_driver/integration_test.dart b/packages/url_launcher/url_launcher_linux/example/test_driver/integration_test.dart index 257b0d3c0930..6a0e6fa82dbe 100644 --- a/packages/url_launcher/url_launcher_linux/example/test_driver/integration_test.dart +++ b/packages/url_launcher/url_launcher_linux/example/test_driver/integration_test.dart @@ -2,18 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 +// @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/url_launcher/url_launcher_macos/example/test_driver/integration_test.dart b/packages/url_launcher/url_launcher_macos/example/test_driver/integration_test.dart index 257b0d3c0930..6a0e6fa82dbe 100644 --- a/packages/url_launcher/url_launcher_macos/example/test_driver/integration_test.dart +++ b/packages/url_launcher/url_launcher_macos/example/test_driver/integration_test.dart @@ -2,18 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 +// @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/url_launcher/url_launcher_web/example/test_driver/integration_test.dart b/packages/url_launcher/url_launcher_web/example/test_driver/integration_test.dart index f26b6a310cfe..4f10f2a522f3 100644 --- a/packages/url_launcher/url_launcher_web/example/test_driver/integration_test.dart +++ b/packages/url_launcher/url_launcher_web/example/test_driver/integration_test.dart @@ -4,4 +4,4 @@ import 'package:integration_test/integration_test_driver.dart'; -Future main() async => integrationDriver(); +Future main() => integrationDriver(); diff --git a/packages/url_launcher/url_launcher_windows/example/test_driver/integration_test.dart b/packages/url_launcher/url_launcher_windows/example/test_driver/integration_test.dart index 257b0d3c0930..6a0e6fa82dbe 100644 --- a/packages/url_launcher/url_launcher_windows/example/test_driver/integration_test.dart +++ b/packages/url_launcher/url_launcher_windows/example/test_driver/integration_test.dart @@ -2,18 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 +// @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/video_player/video_player/example/test_driver/integration_test.dart b/packages/video_player/video_player/example/test_driver/integration_test.dart index 6a3ccada0232..6a0e6fa82dbe 100644 --- a/packages/video_player/video_player/example/test_driver/integration_test.dart +++ b/packages/video_player/video_player/example/test_driver/integration_test.dart @@ -2,19 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(egarciad): Remove once Flutter driver is migrated to null safety. -// @dart = 2.9 +// @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/webview_flutter/example/test_driver/integration_test.dart b/packages/webview_flutter/example/test_driver/integration_test.dart index 257b0d3c0930..6a0e6fa82dbe 100644 --- a/packages/webview_flutter/example/test_driver/integration_test.dart +++ b/packages/webview_flutter/example/test_driver/integration_test.dart @@ -2,18 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 +// @dart=2.9 -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:integration_test/integration_test_driver.dart'; -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} +Future main() => integrationDriver(); diff --git a/packages/wifi_info_flutter/wifi_info_flutter/integration_test/wifi_info_test.dart b/packages/wifi_info_flutter/wifi_info_flutter/example/integration_test/wifi_info_test.dart similarity index 100% rename from packages/wifi_info_flutter/wifi_info_flutter/integration_test/wifi_info_test.dart rename to packages/wifi_info_flutter/wifi_info_flutter/example/integration_test/wifi_info_test.dart diff --git a/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test.dart b/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..6a0e6fa82dbe --- /dev/null +++ b/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test.dart @@ -0,0 +1,9 @@ +// 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. + +// @dart=2.9 + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test/wifi_info_test.dart b/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test/wifi_info_test.dart deleted file mode 100644 index 103be52aa56b..000000000000 --- a/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test/wifi_info_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -// 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. - -// @dart = 2.9 -import 'dart:io'; -import 'package:integration_test/integration_test.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:wifi_info_flutter/wifi_info_flutter.dart'; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - group('$WifiInfo test driver', () { - WifiInfo _wifiInfo; - - setUpAll(() async { - _wifiInfo = WifiInfo(); - }); - - testWidgets('test location methods, iOS only', (WidgetTester tester) async { - expect( - (await _wifiInfo.getLocationServiceAuthorization()), - LocationAuthorizationStatus.notDetermined, - ); - }, skip: !Platform.isIOS); - }); -} diff --git a/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/test/integration_test.dart b/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/test/integration_test.dart deleted file mode 100644 index 9647a12d77ce..000000000000 --- a/packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/test/integration_test.dart +++ /dev/null @@ -1,17 +0,0 @@ -// 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. - -// @dart = 2.9 -import 'dart:convert'; -import 'dart:io'; -import 'package:flutter_driver/flutter_driver.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String data = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - await driver.close(); - final Map result = jsonDecode(data); - exit(result['result'] == 'true' ? 0 : 1); -} diff --git a/script/tool/lib/src/drive_examples_command.dart b/script/tool/lib/src/drive_examples_command.dart index 0230ebd671e1..1572b941078e 100644 --- a/script/tool/lib/src/drive_examples_command.dart +++ b/script/tool/lib/src/drive_examples_command.dart @@ -52,23 +52,37 @@ class DriveExamplesCommand extends PluginCommand { @override Future run() async { final List failingTests = []; + final List pluginsWithoutTests = []; final bool isLinux = argResults[kLinux] == true; final bool isMacos = argResults[kMacos] == true; final bool isWeb = argResults[kWeb] == true; final bool isWindows = argResults[kWindows] == true; await for (final Directory plugin in getPlugins()) { + final String pluginName = plugin.basename; + if (pluginName.endsWith('_platform_interface') && + !plugin.childDirectory('example').existsSync()) { + // Platform interface packages generally aren't intended to have + // examples, and don't need integration tests, so silently skip them + // unless for some reason there is an example directory. + continue; + } + print('\n==========\nChecking $pluginName...'); + if (!(await _pluginSupportedOnCurrentPlatform(plugin, fileSystem))) { + print('Not supported for the target platform; skipping.'); + continue; + } + int examplesFound = 0; + bool testsRan = false; final String flutterCommand = const LocalPlatform().isWindows ? 'flutter.bat' : 'flutter'; for (final Directory example in getExamplesForPlugin(plugin)) { + ++examplesFound; final String packageName = p.relative(example.path, from: packagesDir.path); - if (!(await _pluginSupportedOnCurrentPlatform(plugin, fileSystem))) { - continue; - } final Directory driverTests = fileSystem.directory(p.join(example.path, 'test_driver')); if (!driverTests.existsSync()) { - // No driver tests available for this example + print('No driver tests found for $packageName'); continue; } // Look for driver tests ending in _test.dart in test_driver/ @@ -160,6 +174,7 @@ Tried searching for the following: } for (final String targetPath in targetPaths) { + testsRan = true; final int exitCode = await processRunner.runAndStream( flutterCommand, [ @@ -177,6 +192,11 @@ Tried searching for the following: } } } + if (!testsRan) { + pluginsWithoutTests.add(pluginName); + print( + 'No driver tests run for $pluginName ($examplesFound examples found)'); + } } print('\n\n'); @@ -188,6 +208,15 @@ Tried searching for the following: throw ToolExit(1); } + if (pluginsWithoutTests.isNotEmpty) { + print('The following plugins did not run any integration tests:'); + for (final String plugin in pluginsWithoutTests) { + print(' * $plugin'); + } + print('If this is intentional, they must be explicitly excluded.'); + throw ToolExit(1); + } + print('All driver tests successful!'); } diff --git a/script/tool/test/drive_examples_command_test.dart b/script/tool/test/drive_examples_command_test.dart index c5960b2c342e..5ba8d8af25ff 100644 --- a/script/tool/test/drive_examples_command_test.dart +++ b/script/tool/test/drive_examples_command_test.dart @@ -55,6 +55,7 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', '\n\n', 'All driver tests successful!', ]), @@ -100,6 +101,7 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', '\n\n', 'All driver tests successful!', ]), @@ -143,6 +145,25 @@ void main() { throwsA(const TypeMatcher())); }); + test('a plugin without any integration test files is reported as an error', + () async { + createFakePlugin('plugin', + withExtraFiles: >[ + ['example', 'lib', 'main.dart'], + ], + isAndroidPlugin: true, + isIosPlugin: true); + + final Directory pluginExampleDirectory = + mockPackagesDir.childDirectory('plugin').childDirectory('example'); + + createFakePubspec(pluginExampleDirectory, isFlutter: true); + + await expectLater( + () => runCapturingPrint(runner, ['drive-examples']), + throwsA(const TypeMatcher())); + }); + test( 'driving under folder "test_driver" when targets are under "integration_test"', () async { @@ -168,6 +189,7 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', '\n\n', 'All driver tests successful!', ]), @@ -223,6 +245,8 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', + 'Not supported for the target platform; skipping.', '\n\n', 'All driver tests successful!', ]), @@ -255,6 +279,7 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', '\n\n', 'All driver tests successful!', ]), @@ -300,6 +325,8 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', + 'Not supported for the target platform; skipping.', '\n\n', 'All driver tests successful!', ]), @@ -332,6 +359,7 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', '\n\n', 'All driver tests successful!', ]), @@ -379,6 +407,8 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', + 'Not supported for the target platform; skipping.', '\n\n', 'All driver tests successful!', ]), @@ -411,6 +441,7 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', '\n\n', 'All driver tests successful!', ]), @@ -460,6 +491,8 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', + 'Not supported for the target platform; skipping.', '\n\n', 'All driver tests successful!', ]), @@ -492,6 +525,7 @@ void main() { expect( output, orderedEquals([ + '\n==========\nChecking plugin...', '\n\n', 'All driver tests successful!', ]), @@ -535,6 +569,29 @@ void main() { 'drive-examples', ]); + expect( + output, + orderedEquals([ + '\n==========\nChecking plugin...', + 'Not supported for the target platform; skipping.', + '\n\n', + 'All driver tests successful!', + ]), + ); + + print(processRunner.recordedCalls); + // Output should be empty since running drive-examples --macos with no macos + // implementation is a no-op. + expect(processRunner.recordedCalls, []); + }); + + test('platform interface plugins are silently skipped', () async { + createFakePlugin('aplugin_platform_interface'); + + final List output = await runCapturingPrint(runner, [ + 'drive-examples', + ]); + expect( output, orderedEquals([ From 0474ef8f850d605df03dfc3eaf83c9539c9cbfca Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 10 May 2021 16:17:09 -0400 Subject: [PATCH 05/10] Exclude some missing integration tests (#3872) ios_platform_images does not currently have an integration test, and file_chooser does not have a web integration test, so both must be explicitly excluded due to recent tooling changes. See: https://github.com/flutter/flutter/issues/82208 https://github.com/flutter/flutter/issues/82211 --- .cirrus.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 8ae5b384aee1..e3d6f7881382 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -168,7 +168,8 @@ task: - name: build-web+drive-examples env: # Currently missing; see https://github.com/flutter/flutter/issues/81982 - PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "image_picker_for_web,shared_preferences_web,video_player_web" + # and https://github.com/flutter/flutter/issues/82211 + PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "file_selector,image_picker_for_web,shared_preferences_web,video_player_web" matrix: CHANNEL: "master" CHANNEL: "stable" @@ -206,8 +207,9 @@ task: PATH: $PATH:/usr/local/bin PLUGINS_TO_SKIP_XCTESTS: "integration_test" # in_app_purchase_ios is currently missing tests; see https://github.com/flutter/flutter/issues/81695 + # ios_platform_images is currently missing tests; see https://github.com/flutter/flutter/issues/82208 # sensor hangs on CI. - PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "in_app_purchase_ios,sensors" + PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "in_app_purchase_ios,ios_platform_images,sensors" matrix: PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" From fcbb0ce87ffb1940e8b4d7d0242e8d8f2c8ac4a6 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 10 May 2021 13:52:57 -0700 Subject: [PATCH 06/10] [google_sign_in] fix registration links (#3859) Fixes https://github.com/flutter/flutter/issues/81847 --- .../google_sign_in/CHANGELOG.md | 4 ++ .../google_sign_in/google_sign_in/README.md | 69 ++++++++++--------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md index 4e8ed80cba9c..539121c2943c 100644 --- a/packages/google_sign_in/google_sign_in/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Fixed links in `README.md`. + ## 5.0.2 * Fix flutter/flutter#48602 iOS flow shows account selection, if user is signed in to Google on the device. diff --git a/packages/google_sign_in/google_sign_in/README.md b/packages/google_sign_in/google_sign_in/README.md index 61c4380cdcb7..75d3029b283b 100644 --- a/packages/google_sign_in/google_sign_in/README.md +++ b/packages/google_sign_in/google_sign_in/README.md @@ -1,34 +1,42 @@ -# google_sign_in - [![pub package](https://img.shields.io/pub/v/google_sign_in.svg)](https://pub.dev/packages/google_sign_in) A Flutter plugin for [Google Sign In](https://developers.google.com/identity/). -*Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback](https://github.com/flutter/flutter/issues) and [Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome! +_Note_: This plugin is still under development, and some APIs might not be +available yet. [Feedback](https://github.com/flutter/flutter/issues) and +[Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome! ## Android integration -To access Google Sign-In, you'll need to make sure to [register your -application](https://developers.google.com/mobile/add?platform=android). +To access Google Sign-In, you'll need to make sure to +[register your application](https://firebase.google.com/docs/android/setup). You don't need to include the google-services.json file in your app unless you are using Google services that require it. You do need to enable the OAuth APIs -that you want, using the [Google Cloud Platform API -manager](https://console.developers.google.com/). For example, if you -want to mimic the behavior of the Google Sign-In sample app, you'll need to -enable the [Google People API](https://developers.google.com/people/). +that you want, using the +[Google Cloud Platform API manager](https://console.developers.google.com/). For +example, if you want to mimic the behavior of the Google Sign-In sample app, +you'll need to enable the +[Google People API](https://developers.google.com/people/). -Make sure you've filled out all required fields in the console for [OAuth consent screen](https://console.developers.google.com/apis/credentials/consent). Otherwise, you may encounter `APIException` errors. +Make sure you've filled out all required fields in the console for +[OAuth consent screen](https://console.developers.google.com/apis/credentials/consent). +Otherwise, you may encounter `APIException` errors. ## iOS integration -1. [First register your application](https://developers.google.com/mobile/add?platform=ios). -2. Make sure the file you download in step 1 is named `GoogleService-Info.plist`. -3. Move or copy `GoogleService-Info.plist` into the `[my_project]/ios/Runner` directory. -4. Open Xcode, then right-click on `Runner` directory and select `Add Files to "Runner"`. +1. [First register your application](https://firebase.google.com/docs/ios/setup). +2. Make sure the file you download in step 1 is named + `GoogleService-Info.plist`. +3. Move or copy `GoogleService-Info.plist` into the `[my_project]/ios/Runner` + directory. +4. Open Xcode, then right-click on `Runner` directory and select + `Add Files to "Runner"`. 5. Select `GoogleService-Info.plist` from the file manager. -6. A dialog will show up and ask you to select the targets, select the `Runner` target. -7. Then add the `CFBundleURLTypes` attributes below into the `[my_project]/ios/Runner/Info.plist` file. +6. A dialog will show up and ask you to select the targets, select the `Runner` + target. +7. Then add the `CFBundleURLTypes` attributes below into the + `[my_project]/ios/Runner/Info.plist` file. ```xml @@ -51,21 +59,26 @@ Make sure you've filled out all required fields in the console for [OAuth consen ### iOS additional requirement -Note that according to https://developer.apple.com/sign-in-with-apple/get-started, -starting June 30, 2020, apps that use login services must also offer a "Sign in -with Apple" option when submitting to the Apple App Store. +Note that according to +https://developer.apple.com/sign-in-with-apple/get-started, starting June 30, +2020, apps that use login services must also offer a "Sign in with Apple" option +when submitting to the Apple App Store. Consider also using an Apple sign in plugin from pub.dev. -The Flutter Favorite [sign_in_with_apple](https://pub.dev/packages/sign_in_with_apple) -plugin could be an option. +The Flutter Favorite +[sign_in_with_apple](https://pub.dev/packages/sign_in_with_apple) plugin could +be an option. ## Usage ### Import the package -To use this plugin, follow the [plugin installation instructions](https://pub.dev/packages/google_sign_in#pub-pkg-tab-installing). + +To use this plugin, follow the +[plugin installation instructions](https://pub.dev/packages/google_sign_in#pub-pkg-tab-installing). ### Use the plugin + Add the following import to your Dart code: ```dart @@ -82,6 +95,7 @@ GoogleSignIn _googleSignIn = GoogleSignIn( ], ); ``` + [Full list of available scopes](https://developers.google.com/identity/protocols/googlescopes). You can now use the `GoogleSignIn` class to authenticate in your Dart code, e.g. @@ -98,13 +112,6 @@ Future _handleSignIn() async { ## Example -Find the example wiring in the [Google sign-in example application](https://github.com/flutter/plugins/blob/master/packages/google_sign_in/google_sign_in/example/lib/main.dart). - -## API details - -See the [google_sign_in.dart](https://github.com/flutter/plugins/blob/master/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart) for more API details. - -## Issues and feedback +Find the example wiring in the +[Google sign-in example application](https://github.com/flutter/plugins/blob/master/packages/google_sign_in/google_sign_in/example/lib/main.dart). -Please file [issues](https://github.com/flutter/flutter/issues/new) -to send feedback or report a bug. Thank you! From e11179d5300fab0e1917144b9570cf1bb86da4ab Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 10 May 2021 14:32:25 -0700 Subject: [PATCH 07/10] [in_app_purchase] platform interface improvement (#3821) Adds some improvements to the platform interface. 1. Make `InAppPurchasePlatformAddition` a subclass of `PlatformInterface` to take advantage of the existing token checking logic. (I also consider `InAppPurchasePlatformAddition` a `PlatformInterface` because it works in a similar way. 2. Make the `instance` variable `late` as we should never access it before setter. 3. Add tests for `InAppPurchasePlatformAddition` part of flutter/flutter#78525 --- .../in_app_purchase/CHANGELOG.md | 2 +- .../src/in_app_purchase/product_details.dart | 2 +- .../lib/src/in_app_purchase_platform.dart | 13 +-- .../in_app_purchase_platform_addition.dart | 31 ++++++- ...p_purchase_platform_addition_provider.dart | 8 +- .../src/types/product_details_response.dart | 2 +- .../test/in_app_purchase_platform_test.dart | 80 +++++++++++++++++-- 7 files changed, 114 insertions(+), 24 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md index 5e7f54560b8c..45b8b7661203 100644 --- a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md @@ -354,7 +354,7 @@ Beta release. * Ability to list products, load previous purchases, and make purchases. * Simplified Dart API that's been unified for ease of use. -* Platform specific APIs more directly exposing `StoreKit` and `BillingClient`. +* Platform-specific APIs more directly exposing `StoreKit` and `BillingClient`. Includes: diff --git a/packages/in_app_purchase/in_app_purchase/lib/src/in_app_purchase/product_details.dart b/packages/in_app_purchase/in_app_purchase/lib/src/in_app_purchase/product_details.dart index ccdec42b7303..4ba61305e445 100644 --- a/packages/in_app_purchase/in_app_purchase/lib/src/in_app_purchase/product_details.dart +++ b/packages/in_app_purchase/in_app_purchase/lib/src/in_app_purchase/product_details.dart @@ -90,7 +90,7 @@ class ProductDetailsResponse { /// The list of identifiers that are in the `identifiers` of [InAppPurchaseConnection.queryProductDetails] but failed to be fetched. /// - /// There's multiple platform specific reasons that product information could fail to be fetched, + /// There's multiple platform-specific reasons that product information could fail to be fetched, /// ranging from products not being correctly configured in the storefront to the queried IDs not existing. final List notFoundIDs; diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart index f8dc4c998494..eac4a0712078 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart @@ -23,27 +23,28 @@ abstract class InAppPurchasePlatform extends PlatformInterface { /// The instance of [InAppPurchasePlatform] to use. /// - /// Defaults to `null`. - static InAppPurchasePlatform? get instance => _instance; - - static InAppPurchasePlatform? _instance; + /// Must be set before accessing. + static InAppPurchasePlatform get instance => _instance; /// Platform-specific plugins should set this with their own platform-specific /// class that extends [InAppPurchasePlatform] when they register themselves. // TODO(amirh): Extract common platform interface logic. // https://github.com/flutter/flutter/issues/43368 - static void setInstance(InAppPurchasePlatform instance) { + static set instance(InAppPurchasePlatform instance) { PlatformInterface.verifyToken(instance, _token); _instance = instance; } + // Should only be accessed after setter is called. + static late InAppPurchasePlatform _instance; + /// Listen to this broadcast stream to get real time update for purchases. /// /// This stream will never close as long as the app is active. /// /// Purchase updates can happen in several situations: /// * When a purchase is triggered by user in the app. - /// * When a purchase is triggered by user from the platform specific store front. + /// * When a purchase is triggered by user from the platform-specific store front. /// * When a purchase is restored on the device by the user in the app. /// * If a purchase is not completed ([completePurchase] is not called on the /// purchase object) from the last app session. Purchase updates will happen diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform_addition.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform_addition.dart index 5c41f138ecea..746675549295 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform_addition.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform_addition.dart @@ -2,18 +2,33 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart'; + // ignore: avoid_classes_with_only_static_members /// The interface that platform implementations must implement when they want to -/// provide platform specific in_app_purchase features. +/// provide platform-specific in_app_purchase features. +/// +/// Platforms that wants to introduce platform-specific public APIs should create +/// a class that either extend or implements [InAppPurchasePlatformAddition]. Then set +/// the [InAppPurchasePlatformAddition.instance] to an instance of that class. +/// +/// All the APIs added by [InAppPurchasePlatformAddition] implementations will be accessed from +/// [InAppPurchasePlatformAdditionProvider.getPlatformAddition] by the client APPs. +/// To avoid clients directly calling [InAppPurchasePlatform] APIs, +/// an [InAppPurchasePlatformAddition] implementation should not be a type of [InAppPurchasePlatform]. abstract class InAppPurchasePlatformAddition { + static InAppPurchasePlatformAddition? _instance; + /// The instance containing the platform-specific in_app_purchase /// functionality. /// + /// Returns `null` by default. + /// /// To implement additional functionality extend /// [`InAppPurchasePlatformAddition`][3] with the platform-specific /// functionality, and when the plugin is registered, set the /// `InAppPurchasePlatformAddition.instance` with the new addition - /// implementationinstance. + /// implementation instance. /// /// Example implementation might look like this: /// ```dart @@ -22,7 +37,7 @@ abstract class InAppPurchasePlatformAddition { /// } /// ``` /// - /// The following snippit shows how to register the `InAppPurchaseMyPlatformAddition`: + /// The following snippet shows how to register the `InAppPurchaseMyPlatformAddition`: /// ```dart /// class InAppPurchaseMyPlatformPlugin { /// static void registerWith(Registrar registrar) { @@ -36,5 +51,13 @@ abstract class InAppPurchasePlatformAddition { /// } /// } /// ``` - static InAppPurchasePlatformAddition? instance; + static InAppPurchasePlatformAddition? get instance => _instance; + + /// Sets the instance to a desired [InAppPurchasePlatformAddition] implementation. + /// + /// The `instance` should not be a type of [InAppPurchasePlatform]. + static set instance(InAppPurchasePlatformAddition? instance) { + assert(instance is! InAppPurchasePlatform); + _instance = instance; + } } diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform_addition_provider.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform_addition_provider.dart index d981f73b4019..642bbb419c6e 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform_addition_provider.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform_addition_provider.dart @@ -5,13 +5,13 @@ import 'package:in_app_purchase_platform_interface/src/in_app_purchase_platform_addition.dart'; /// The [InAppPurchasePlatformAdditionProvider] is responsible for providing -/// a platform specific [InAppPurchasePlatformAddition]. +/// a platform-specific [InAppPurchasePlatformAddition]. /// -/// [InAppPurchasePlatformAddition] implementation contain platform specific +/// [InAppPurchasePlatformAddition] implementation contain platform-specific /// features that are not available from the platform idiomatic /// [InAppPurchasePlatform] API. abstract class InAppPurchasePlatformAdditionProvider { - /// Provides a platform specific implementation of the [InAppPurchasePlatformAddition] + /// Provides a platform-specific implementation of the [InAppPurchasePlatformAddition] /// class. - T getPlatformAddition(); + T getPlatformAddition(); } diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/product_details_response.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/product_details_response.dart index 868f9428add2..11b244a84ae3 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/product_details_response.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/product_details_response.dart @@ -18,7 +18,7 @@ class ProductDetailsResponse { /// The list of identifiers that are in the `identifiers` of [InAppPurchasePlatform.queryProductDetails] but failed to be fetched. /// - /// There's multiple platform specific reasons that product information could fail to be fetched, + /// There are multiple platform-specific reasons that product information could fail to be fetched, /// ranging from products not being correctly configured in the storefront to the queried IDs not existing. final List notFoundIDs; diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart index d5c1ae5fc127..9c0f2dc00020 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart @@ -11,22 +11,18 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('$InAppPurchasePlatform', () { - test('Default instance should return null', () { - expect(InAppPurchasePlatform.instance, null); - }); - test('Cannot be implemented with `implements`', () { expect(() { - InAppPurchasePlatform.setInstance(ImplementsInAppPurchasePlatform()); + InAppPurchasePlatform.instance = ImplementsInAppPurchasePlatform(); }, throwsNoSuchMethodError); }); test('Can be extended', () { - InAppPurchasePlatform.setInstance(ExtendsInAppPurchasePlatform()); + InAppPurchasePlatform.instance = ExtendsInAppPurchasePlatform(); }); test('Can be mocked with `implements`', () { - InAppPurchasePlatform.setInstance(MockInAppPurchasePlatform()); + InAppPurchasePlatform.instance = MockInAppPurchasePlatform(); }); test( @@ -124,6 +120,50 @@ void main() { ); }); }); + + group('$InAppPurchasePlatformAddition', () { + setUp(() { + InAppPurchasePlatformAddition.instance = null; + }); + + test('Cannot be implemented with `implements`', () { + expect(InAppPurchasePlatformAddition.instance, isNull); + }); + + test('Can be implemented.', () { + InAppPurchasePlatformAddition.instance = + ImplementsInAppPurchasePlatformAddition(); + }); + + test('InAppPurchasePlatformAddition Can be extended', () { + InAppPurchasePlatformAddition.instance = + ExtendsInAppPurchasePlatformAddition(); + }); + + test('Can not be a `InAppPurchasePlatform`', () { + expect( + () => InAppPurchasePlatformAddition.instance = + ExtendsInAppPurchasePlatformAdditionIsPlatformInterface(), + throwsAssertionError); + }); + + test('Provider can provide', () { + ImplementsInAppPurchasePlatformAdditionProvider.register(); + final ImplementsInAppPurchasePlatformAdditionProvider provider = + ImplementsInAppPurchasePlatformAdditionProvider(); + final InAppPurchasePlatformAddition? addition = + provider.getPlatformAddition(); + expect(addition.runtimeType, ExtendsInAppPurchasePlatformAddition); + }); + + test('Provider can provide `null`', () { + final ImplementsInAppPurchasePlatformAdditionProvider provider = + ImplementsInAppPurchasePlatformAdditionProvider(); + final InAppPurchasePlatformAddition? addition = + provider.getPlatformAddition(); + expect(addition, isNull); + }); + }); } class ImplementsInAppPurchasePlatform implements InAppPurchasePlatform { @@ -143,3 +183,29 @@ class ExtendsInAppPurchasePlatform extends InAppPurchasePlatform {} class MockPurchaseParam extends Mock implements PurchaseParam {} class MockPurchaseDetails extends Mock implements PurchaseDetails {} + +class ImplementsInAppPurchasePlatformAddition + implements InAppPurchasePlatformAddition { + @override + dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); +} + +class ExtendsInAppPurchasePlatformAddition + extends InAppPurchasePlatformAddition {} + +class ImplementsInAppPurchasePlatformAdditionProvider + implements InAppPurchasePlatformAdditionProvider { + static void register() { + InAppPurchasePlatformAddition.instance = + ExtendsInAppPurchasePlatformAddition(); + } + + @override + T getPlatformAddition() { + return InAppPurchasePlatformAddition.instance as T; + } +} + +class ExtendsInAppPurchasePlatformAdditionIsPlatformInterface + extends InAppPurchasePlatform + implements ExtendsInAppPurchasePlatformAddition {} From d3b9711fcfafbed6d0ef2a2cf6894846c182699b Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Mon, 10 May 2021 23:54:30 +0200 Subject: [PATCH 08/10] Add InAppPurchaseException to platform interface (#3852) --- .../in_app_purchase_platform_interface.dart | 1 + .../lib/src/errors/errors.dart | 5 ++++ .../src/errors/in_app_purchase_exception.dart | 27 +++++++++++++++++++ .../in_app_purchase_exception_test.dart | 23 ++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/errors.dart create mode 100644 packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/in_app_purchase_exception.dart create mode 100644 packages/in_app_purchase/in_app_purchase_platform_interface/test/src/errors/in_app_purchase_exception_test.dart diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/in_app_purchase_platform_interface.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/in_app_purchase_platform_interface.dart index 9e12a9dd33e4..25eb4a44c4b4 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/in_app_purchase_platform_interface.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/in_app_purchase_platform_interface.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +export 'src/errors/errors.dart'; export 'src/in_app_purchase_platform.dart'; export 'src/in_app_purchase_platform_addition.dart'; export 'src/in_app_purchase_platform_addition_provider.dart'; diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/errors.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/errors.dart new file mode 100644 index 000000000000..95a770362449 --- /dev/null +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/errors.dart @@ -0,0 +1,5 @@ +// 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. + +export 'errors.dart'; diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/in_app_purchase_exception.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/in_app_purchase_exception.dart new file mode 100644 index 000000000000..0a89a6e39a5e --- /dev/null +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/in_app_purchase_exception.dart @@ -0,0 +1,27 @@ +// 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. + +/// Thrown to indicate that an action failed while interacting with the +/// in_app_purchase plugin. +class InAppPurchaseException implements Exception { + /// Creates a [InAppPurchaseException] with the specified source and error + /// [code] and optional [message]. + InAppPurchaseException({ + required this.source, + required this.code, + this.message, + }) : assert(code != null); + + /// An error code. + final String code; + + /// A human-readable error message, possibly null. + final String? message; + + /// Which source is the error on. + final String source; + + @override + String toString() => 'InAppPurchaseException($code, $message, $source)'; +} diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/test/src/errors/in_app_purchase_exception_test.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/test/src/errors/in_app_purchase_exception_test.dart new file mode 100644 index 000000000000..ff9468ec2d88 --- /dev/null +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/test/src/errors/in_app_purchase_exception_test.dart @@ -0,0 +1,23 @@ +// 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:flutter_test/flutter_test.dart'; +import 'package:in_app_purchase_platform_interface/src/errors/in_app_purchase_exception.dart'; + +void main() { + test('toString: Should return a description of the exception', () { + final InAppPurchaseException exception = InAppPurchaseException( + code: 'error_code', + message: 'dummy message', + source: 'dummy_source', + ); + + // Act + final String actual = exception.toString(); + + // Assert + expect(actual, + 'InAppPurchaseException(error_code, dummy message, dummy_source)'); + }); +} From 39e003541836d691e9d369d59db6c0d680ab28e4 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Tue, 11 May 2021 00:02:19 +0200 Subject: [PATCH 09/10] [in_app_purchase] Implement registerPlatform method for iOS implementation (#3851) --- .../in_app_purchase_ios/README.md | 3 + .../lib/src/in_app_purchase_ios_platform.dart | 15 ++--- .../in_app_purchase_ios_platform_test.dart | 56 +++++++++---------- 3 files changed, 32 insertions(+), 42 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_ios/README.md b/packages/in_app_purchase/in_app_purchase_ios/README.md index 025ed36b72a6..3ab033849f39 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/README.md +++ b/packages/in_app_purchase/in_app_purchase_ios/README.md @@ -31,4 +31,7 @@ dependencies: ... ``` +## TODO +- [ ] Add an example application demonstrating the use of the [in_app_purchase_ios] package (see also issue [flutter/flutter#81695](https://github.com/flutter/flutter/issues/81695)). + [1]: ../in_app_purchase/in_app_purchase \ No newline at end of file diff --git a/packages/in_app_purchase/in_app_purchase_ios/lib/src/in_app_purchase_ios_platform.dart b/packages/in_app_purchase/in_app_purchase_ios/lib/src/in_app_purchase_ios_platform.dart index bb2fd2b3639a..5a2c40821007 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/lib/src/in_app_purchase_ios_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/lib/src/in_app_purchase_ios_platform.dart @@ -23,10 +23,6 @@ const String kIAPSource = 'app_store'; /// This translates various `StoreKit` calls and responses into the /// generic plugin API. class InAppPurchaseIosPlatform extends InAppPurchasePlatform { - /// Returns the singleton instance of the [InAppPurchaseIosPlatform] that should be - /// used across the app. - static InAppPurchaseIosPlatform get instance => _getOrCreateInstance(); - static InAppPurchaseIosPlatform? _instance; static late SKPaymentQueueWrapper _skPaymentQueueWrapper; static late _TransactionObserver _observer; @@ -44,22 +40,19 @@ class InAppPurchaseIosPlatform extends InAppPurchasePlatform { @visibleForTesting static SKTransactionObserverWrapper get observer => _observer; - static InAppPurchaseIosPlatform _getOrCreateInstance() { - if (_instance != null) { - return _instance!; - } - + /// Registers this class as the default instance of [InAppPurchasePlatform]. + static void registerPlatform() { // Register the [InAppPurchaseIosPlatformAddition] containing iOS // platform-specific functionality. InAppPurchasePlatformAddition.instance = InAppPurchaseIosPlatformAddition(); // Register the platform-specific implementation of the idiomatic // InAppPurchase API. - _instance = InAppPurchaseIosPlatform(); + InAppPurchasePlatform.setInstance(InAppPurchaseIosPlatform()); + _skPaymentQueueWrapper = SKPaymentQueueWrapper(); _observer = _TransactionObserver(StreamController.broadcast()); _skPaymentQueueWrapper.setTransactionObserver(observer); - return _instance!; } @override diff --git a/packages/in_app_purchase/in_app_purchase_ios/test/in_app_purchase_ios_platform_test.dart b/packages/in_app_purchase/in_app_purchase_ios/test/in_app_purchase_ios_platform_test.dart index a70e2d9191bb..b15249c81947 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/test/in_app_purchase_ios_platform_test.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/test/in_app_purchase_ios_platform_test.dart @@ -18,19 +18,24 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); final FakeIOSPlatform fakeIOSPlatform = FakeIOSPlatform(); + late InAppPurchaseIosPlatform iapIosPlatform; setUpAll(() { SystemChannels.platform .setMockMethodCallHandler(fakeIOSPlatform.onMethodCall); }); - setUp(() => fakeIOSPlatform.reset()); + setUp(() { + InAppPurchaseIosPlatform.registerPlatform(); + iapIosPlatform = InAppPurchasePlatform.instance as InAppPurchaseIosPlatform; + fakeIOSPlatform.reset(); + }); tearDown(() => fakeIOSPlatform.reset()); group('isAvailable', () { test('true', () async { - expect(await InAppPurchaseIosPlatform.instance.isAvailable(), isTrue); + expect(await iapIosPlatform.isAvailable(), isTrue); }); }); @@ -69,8 +74,7 @@ void main() { group('restore purchases', () { test('should emit restored transactions on purchase stream', () async { Completer completer = Completer(); - Stream> stream = - InAppPurchaseIosPlatform.instance.purchaseStream; + Stream> stream = iapIosPlatform.purchaseStream; late StreamSubscription subscription; subscription = stream.listen((purchaseDetailsList) { @@ -80,7 +84,7 @@ void main() { } }); - await InAppPurchaseIosPlatform.instance.restorePurchases(); + await iapIosPlatform.restorePurchases(); List details = await completer.future; expect(details.length, 2); @@ -103,8 +107,7 @@ void main() { fakeIOSPlatform.transactions .insert(0, fakeIOSPlatform.createPurchasedTransaction('foo', 'bar')); Completer completer = Completer(); - Stream> stream = - InAppPurchaseIosPlatform.instance.purchaseStream; + Stream> stream = iapIosPlatform.purchaseStream; late StreamSubscription subscription; subscription = stream.listen((purchaseDetailsList) { @@ -113,7 +116,7 @@ void main() { subscription.cancel(); } }); - await InAppPurchaseIosPlatform.instance.restorePurchases(); + await iapIosPlatform.restorePurchases(); List details = await completer.future; expect(details.length, 3); for (int i = 0; i < fakeIOSPlatform.transactions.length; i++) { @@ -139,8 +142,7 @@ void main() { () async { fakeIOSPlatform.receiptData = null; Completer completer = Completer(); - Stream> stream = - InAppPurchaseIosPlatform.instance.purchaseStream; + Stream> stream = iapIosPlatform.purchaseStream; late StreamSubscription subscription; subscription = stream.listen((purchaseDetailsList) { @@ -150,7 +152,7 @@ void main() { } }); - await InAppPurchaseIosPlatform.instance.restorePurchases(); + await iapIosPlatform.restorePurchases(); List details = await completer.future; for (PurchaseDetails purchase in details) { @@ -166,7 +168,7 @@ void main() { userInfo: {'message': 'errorMessage'}); expect( - () => InAppPurchaseIosPlatform.instance.restorePurchases(), + () => iapIosPlatform.restorePurchases(), throwsA( isA() .having((error) => error.code, 'code', 123) @@ -183,8 +185,7 @@ void main() { () async { List details = []; Completer completer = Completer(); - Stream> stream = - InAppPurchaseIosPlatform.instance.purchaseStream; + Stream> stream = iapIosPlatform.purchaseStream; late StreamSubscription subscription; subscription = stream.listen((purchaseDetailsList) { @@ -198,8 +199,7 @@ void main() { productDetails: AppStoreProductDetails.fromSKProduct(dummyProductWrapper), applicationUserName: 'appName'); - await InAppPurchaseIosPlatform.instance - .buyNonConsumable(purchaseParam: purchaseParam); + await iapIosPlatform.buyNonConsumable(purchaseParam: purchaseParam); List result = await completer.future; expect(result.length, 2); @@ -211,8 +211,7 @@ void main() { () async { List details = []; Completer completer = Completer(); - Stream> stream = - InAppPurchaseIosPlatform.instance.purchaseStream; + Stream> stream = iapIosPlatform.purchaseStream; late StreamSubscription subscription; subscription = stream.listen((purchaseDetailsList) { @@ -226,8 +225,7 @@ void main() { productDetails: AppStoreProductDetails.fromSKProduct(dummyProductWrapper), applicationUserName: 'appName'); - await InAppPurchaseIosPlatform.instance - .buyConsumable(purchaseParam: purchaseParam); + await iapIosPlatform.buyConsumable(purchaseParam: purchaseParam); List result = await completer.future; expect(result.length, 2); @@ -240,8 +238,8 @@ void main() { AppStoreProductDetails.fromSKProduct(dummyProductWrapper), applicationUserName: 'appName'); expect( - () => InAppPurchaseIosPlatform.instance - .buyConsumable(purchaseParam: purchaseParam, autoConsume: false), + () => iapIosPlatform.buyConsumable( + purchaseParam: purchaseParam, autoConsume: false), throwsA(isInstanceOf())); }); @@ -251,8 +249,7 @@ void main() { Completer completer = Completer(); late IAPError error; - Stream> stream = - InAppPurchaseIosPlatform.instance.purchaseStream; + Stream> stream = iapIosPlatform.purchaseStream; late StreamSubscription subscription; subscription = stream.listen((purchaseDetailsList) { details.addAll(purchaseDetailsList); @@ -268,8 +265,7 @@ void main() { productDetails: AppStoreProductDetails.fromSKProduct(dummyProductWrapper), applicationUserName: 'appName'); - await InAppPurchaseIosPlatform.instance - .buyNonConsumable(purchaseParam: purchaseParam); + await iapIosPlatform.buyNonConsumable(purchaseParam: purchaseParam); IAPError completerError = await completer.future; expect(completerError.code, 'purchase_error'); @@ -283,14 +279,13 @@ void main() { test('should complete purchase', () async { List details = []; Completer completer = Completer(); - Stream> stream = - InAppPurchaseIosPlatform.instance.purchaseStream; + Stream> stream = iapIosPlatform.purchaseStream; late StreamSubscription subscription; subscription = stream.listen((purchaseDetailsList) { details.addAll(purchaseDetailsList); purchaseDetailsList.forEach((purchaseDetails) { if (purchaseDetails.pendingCompletePurchase) { - InAppPurchaseIosPlatform.instance.completePurchase(purchaseDetails); + iapIosPlatform.completePurchase(purchaseDetails); completer.complete(details); subscription.cancel(); } @@ -300,8 +295,7 @@ void main() { productDetails: AppStoreProductDetails.fromSKProduct(dummyProductWrapper), applicationUserName: 'appName'); - await InAppPurchaseIosPlatform.instance - .buyNonConsumable(purchaseParam: purchaseParam); + await iapIosPlatform.buyNonConsumable(purchaseParam: purchaseParam); List result = await completer.future; expect(result.length, 2); expect(result.first.productID, dummyProductWrapper.productIdentifier); From be327bbf19e81e411d0d0ea3b488b13bba6b55f4 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Tue, 11 May 2021 00:04:49 +0200 Subject: [PATCH 10/10] Update instructions on running integration_test (#3871) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d11c6ad59dc..ed3dd7932d0d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,7 +91,7 @@ To run the integration tests using Flutter driver: ```console cd example -flutter drive test_driver/.dart +flutter drive --driver test_driver/integration_test.dart --target integration_test/.dart ``` To run integration tests as instrumentation tests on a local Android device: