diff --git a/.ci.yaml b/.ci.yaml index e4a5b414e9d..29c1d77303f 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -1297,11 +1297,15 @@ targets: - name: Linux_android_emu flutter_driver_android_test recipe: flutter/flutter_drone timeout: 60 - bringup: true + bringup: false properties: shard: flutter_driver_android tags: > ["framework", "hostonly", "shard", "linux"] + dependencies: >- + [ + {"dependency": "goldctl", "version": "git_revision:720a542f6fe4f92922c3b8f0fdcc4d2ac6bb83cd"} + ] - name: Linux realm_checker recipe: flutter/flutter_drone diff --git a/dev/bots/suite_runners/run_flutter_driver_android_tests.dart b/dev/bots/suite_runners/run_flutter_driver_android_tests.dart index 71cec906eb3..8c3fb5e64e3 100644 --- a/dev/bots/suite_runners/run_flutter_driver_android_tests.dart +++ b/dev/bots/suite_runners/run_flutter_driver_android_tests.dart @@ -2,18 +2,50 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:convert'; +import 'dart:io' as io; + import 'package:path/path.dart' as path; import '../run_command.dart'; import '../utils.dart'; +/// To run this test locally: +/// +/// 1. Connect an Android device or emulator. +/// 2. Run the following command from the root of the Flutter repository: +/// +/// ```sh +/// SHARD=flutter_driver_android bin/cache/dart-sdk/bin/dart dev/bots/test.dart +/// ``` +/// +/// For debugging, it is recommended to instead just run and launch these tests +/// individually _in_ the `dev/integration_tests/android_driver_test` directory. Future runFlutterDriverAndroidTests() async { print('Running Flutter Driver Android tests...'); + // Print out the results of `adb devices`, for uh, science: + print('Listing devices...'); + final io.ProcessResult devices = await _adb( + [ + 'devices', + ], + ); + print(devices.stdout); + print(devices.stderr); + + // We need to configure the emulator to disable confirmations before the + // application starts. Some of these configuration options won't work once + // the application is running. + print('Configuring device...'); + await _configureForScreenshotTesting(); + // TODO(matanlurey): Should we be using another instrumentation method? await runCommand( 'flutter', [ 'drive', + '--test-arguments=test', + '--test-arguments=--reporter=expanded', ], workingDirectory: path.join( 'dev', @@ -22,3 +54,60 @@ Future runFlutterDriverAndroidTests() async { ), ); } + +// TODO(matanlurey): Move this code into flutter_driver instead of here. +Future _configureForScreenshotTesting() async { + // Disable confirmation for immersive mode. + final io.ProcessResult immersive = await _adb( + [ + 'shell', + 'settings', + 'put', + 'secure', + 'immersive_mode_confirmations', + 'confirmed', + ], + ); + + if (immersive.exitCode != 0) { + throw StateError('Failed to configure device: ${immersive.stderr}'); + } + + const Map settings = { + 'show_surface_updates': '1', + 'transition_animation_scale': '0', + 'window_animation_scale': '0', + 'animator_duration_scale': '0', + }; + + for (final MapEntry entry in settings.entries) { + final io.ProcessResult result = await _adb( + [ + 'shell', + 'settings', + 'put', + 'global', + entry.key, + entry.value, + ], + ); + + if (result.exitCode != 0) { + throw StateError('Failed to configure device: ${result.stderr}'); + } + } +} + +Future _adb( + List args, { + Encoding? stdoutEncoding = io.systemEncoding, +}) { + // TODO(matanlurey): Ideally we should specify the device target here. + return io.Process.run( + 'adb', + [ + ...args, + ], + stdoutEncoding: stdoutEncoding, + ); +} diff --git a/dev/integration_tests/android_driver_test/android/app/src/main/res/drawable-v21/launch_background.xml b/dev/integration_tests/android_driver_test/android/app/src/main/res/drawable-v21/launch_background.xml index c7238f4ec6c..841324cf379 100644 --- a/dev/integration_tests/android_driver_test/android/app/src/main/res/drawable-v21/launch_background.xml +++ b/dev/integration_tests/android_driver_test/android/app/src/main/res/drawable-v21/launch_background.xml @@ -1,9 +1,8 @@ + - - diff --git a/dev/integration_tests/android_driver_test/android/app/src/main/res/drawable/launch_background.xml b/dev/integration_tests/android_driver_test/android/app/src/main/res/drawable/launch_background.xml index 32d77987868..8703894be79 100644 --- a/dev/integration_tests/android_driver_test/android/app/src/main/res/drawable/launch_background.xml +++ b/dev/integration_tests/android_driver_test/android/app/src/main/res/drawable/launch_background.xml @@ -1,9 +1,8 @@ + - - diff --git a/dev/integration_tests/android_driver_test/android/app/src/main/res/values-night/styles.xml b/dev/integration_tests/android_driver_test/android/app/src/main/res/values-night/styles.xml index d25ab930167..f3ab3e83cd3 100644 --- a/dev/integration_tests/android_driver_test/android/app/src/main/res/values-night/styles.xml +++ b/dev/integration_tests/android_driver_test/android/app/src/main/res/values-night/styles.xml @@ -1,8 +1,8 @@ + -