diff --git a/.ci/Dockerfile b/.ci/Dockerfile index a69f9cb67526..c02083317174 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -1,5 +1,18 @@ FROM cirrusci/flutter:stable +RUN sudo apt-get update && \ + sudo apt-get install -y git wget curl unzip python lsb-release sudo apt-transport-https + +# Add repo for gcloud sdk and install it +RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | \ + sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list + +RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ + sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && \ + sudo apt-get update && sudo apt-get install -y google-cloud-sdk && \ + gcloud config set core/disable_usage_reporting true && \ + gcloud config set component_manager/disable_update_check true + RUN yes | sdkmanager \ "platforms;android-27" \ "build-tools;27.0.3" \ diff --git a/.cirrus.yml b/.cirrus.yml index 0caa1a226807..a49a2a6f1c9b 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,7 +8,8 @@ task: - flutter channel master - flutter upgrade - git fetch origin master - activate_script: pub global activate flutter_plugin_tools + activate_script: + - pub global activate flutter_plugin_tools matrix: - name: publishable script: ./script/check_publish.sh @@ -30,7 +31,10 @@ task: PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2" PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2" MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] + CLOUDSDK_CORE_DISABLE_PROMPTS: 1 + GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[ae17cec7f4d708b1e5c2e841c3643006c2ef46f3745e28fd965bc26b224158f408a0c2da40a1beb0addb163fa4c11389] script: + - echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json # Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they # might include non-ASCII characters which makes Gradle crash. # See: https://github.com/flutter/flutter/issues/24935 @@ -43,6 +47,7 @@ task: - export CIRRUS_COMMIT_MESSAGE="" - ./script/incremental_build.sh build-examples --apk - ./script/incremental_build.sh java-test # must come after apk build + - ./script/incremental_build.sh firebase-test-lab - export CIRRUS_CHANGE_MESSAGE=`cat /tmp/cirrus_change_message.txt` - export CIRRUS_COMMIT_MESSAGE=`cat /tmp/cirrus_commit_message.txt` diff --git a/packages/package_info/CHANGELOG.md b/packages/package_info/CHANGELOG.md index a041f9115004..690d2a3afe17 100644 --- a/packages/package_info/CHANGELOG.md +++ b/packages/package_info/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.0+8 + +* Update instrumentation test to use instrumentation_adapter plugin. + ## 0.4.0+7 * Update and migrate iOS example project. diff --git a/packages/package_info/example/android/app/src/androidTest/java/io/flutter/plugins/packageinfoexample/MainActivityTest.java b/packages/package_info/example/android/app/src/androidTest/java/io/flutter/plugins/packageinfoexample/MainActivityTest.java new file mode 100644 index 000000000000..ff2c0f38e6bc --- /dev/null +++ b/packages/package_info/example/android/app/src/androidTest/java/io/flutter/plugins/packageinfoexample/MainActivityTest.java @@ -0,0 +1,15 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.packageinfoexample; + +import androidx.test.rule.ActivityTestRule; +import dev.flutter.plugins.instrumentationadapter.FlutterRunner; +import org.junit.Rule; +import org.junit.runner.RunWith; + +@RunWith(FlutterRunner.class) +public class MainActivityTest { + @Rule public ActivityTestRule rule = new ActivityTestRule<>(MainActivity.class); +} diff --git a/packages/package_info/example/instrumentation_adapter/package_info.dart b/packages/package_info/example/instrumentation_adapter/package_info.dart new file mode 100644 index 000000000000..e0498eac6931 --- /dev/null +++ b/packages/package_info/example/instrumentation_adapter/package_info.dart @@ -0,0 +1,31 @@ +// Copyright 2019 The Chromium 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 'dart:io'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:instrumentation_adapter/instrumentation_adapter.dart'; +import 'package:package_info/package_info.dart'; + +void main() { + InstrumentationAdapterFlutterBinding.ensureInitialized(); + group('package_info test', () { + testWidgets('test package info result', (_) async { + final PackageInfo info = await PackageInfo.fromPlatform(); + // These tests are based on the example app. The tests should be updated if any related info changes. + if (Platform.isAndroid) { + expect(info.appName, 'package_info_example'); + expect(info.buildNumber, '1'); + expect(info.packageName, 'io.flutter.plugins.packageinfoexample'); + expect(info.version, '1.0'); + } else if (Platform.isIOS) { + expect(info.appName, 'Package Info Example'); + expect(info.buildNumber, '1'); + expect(info.packageName, 'io.flutter.plugins.packageInfoExample'); + expect(info.version, '1.0'); + } else { + throw (UnsupportedError('platform not supported')); + } + }); + }); +} diff --git a/packages/package_info/example/pubspec.yaml b/packages/package_info/example/pubspec.yaml index e4844cd95648..4b06cb3e3be0 100644 --- a/packages/package_info/example/pubspec.yaml +++ b/packages/package_info/example/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: dev_dependencies: flutter_driver: sdk: flutter + instrumentation_adapter: "^0.1.3" test: any flutter: diff --git a/packages/package_info/example/test_driver/package_info.dart b/packages/package_info/example/test_driver/package_info.dart index 97c2db6363c7..a026dcf398af 100644 --- a/packages/package_info/example/test_driver/package_info.dart +++ b/packages/package_info/example/test_driver/package_info.dart @@ -1,31 +1,5 @@ -import 'dart:async'; -import 'dart:io'; -import 'package:flutter_driver/driver_extension.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:package_info/package_info.dart'; +import '../instrumentation_adapter/package_info.dart' as test; void main() { - final Completer completer = Completer(); - enableFlutterDriverExtension(handler: (_) => completer.future); - tearDownAll(() => completer.complete(null)); - - group('package_info test driver', () { - test('test package info result', () async { - final PackageInfo info = await PackageInfo.fromPlatform(); - // These tests are based on the example app. The tests should be updated if any related info changes. - if (Platform.isAndroid) { - expect(info.appName, 'package_info_example'); - expect(info.buildNumber, '1'); - expect(info.packageName, 'io.flutter.plugins.packageinfoexample'); - expect(info.version, '1.0'); - } else if (Platform.isIOS) { - expect(info.appName, 'Package Info Example'); - expect(info.buildNumber, '1'); - expect(info.packageName, 'io.flutter.plugins.packageInfoExample'); - expect(info.version, '1.0'); - } else { - throw (UnsupportedError('platform not supported')); - } - }); - }); + test.main(); } diff --git a/packages/package_info/example/test_driver/package_info_test.dart b/packages/package_info/example/test_driver/package_info_test.dart index c1d690c17ee3..88e53d1c1f05 100644 --- a/packages/package_info/example/test_driver/package_info_test.dart +++ b/packages/package_info/example/test_driver/package_info_test.dart @@ -1,10 +1,9 @@ +import 'dart:async'; + import 'package:flutter_driver/flutter_driver.dart'; -import 'package:test/test.dart'; -void main() { - test('package_info', () async { - final FlutterDriver driver = await FlutterDriver.connect(); - await driver.requestData(null, timeout: const Duration(minutes: 1)); - driver.close(); - }); +Future main() async { + final FlutterDriver driver = await FlutterDriver.connect(); + await driver.requestData(null, timeout: const Duration(minutes: 1)); + driver.close(); } diff --git a/packages/package_info/pubspec.yaml b/packages/package_info/pubspec.yaml index f24b5d711adf..a67c827ec386 100644 --- a/packages/package_info/pubspec.yaml +++ b/packages/package_info/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/package_info -version: 0.4.0+7 +version: 0.4.0+8 flutter: plugin: