diff --git a/dev/devicelab/bin/tasks/complex_layout_semantics_perf.dart b/dev/devicelab/bin/tasks/complex_layout_semantics_perf.dart index ab1d4b7c12..bb5b6606b3 100644 --- a/dev/devicelab/bin/tasks/complex_layout_semantics_perf.dart +++ b/dev/devicelab/bin/tasks/complex_layout_semantics_perf.dart @@ -32,6 +32,7 @@ void main() { '-d', deviceId, ]); + await device.uninstallApp(); }); final String outputPath = Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? p.join(complexLayoutPath, 'build'); diff --git a/dev/devicelab/bin/tasks/drive_perf_debug_warning.dart b/dev/devicelab/bin/tasks/drive_perf_debug_warning.dart index 0390ad891e..d67abb9216 100644 --- a/dev/devicelab/bin/tasks/drive_perf_debug_warning.dart +++ b/dev/devicelab/bin/tasks/drive_perf_debug_warning.dart @@ -16,6 +16,7 @@ Future _runWithMode(String mode, String deviceId) async { '-d', deviceId, ]); + await evalFlutter('install', options: ['--uninstall-only', '-d', deviceId]); return stderr.toString(); } diff --git a/dev/devicelab/bin/tasks/hello_world__memory.dart b/dev/devicelab/bin/tasks/hello_world__memory.dart index 60fa3e1a08..c8869060b9 100644 --- a/dev/devicelab/bin/tasks/hello_world__memory.dart +++ b/dev/devicelab/bin/tasks/hello_world__memory.dart @@ -29,6 +29,7 @@ class HelloWorldMemoryTest extends MemoryTest { await recordStart(); await Future.delayed(const Duration(milliseconds: 3000)); await recordEnd(); + await device!.uninstallApp(); } } diff --git a/dev/devicelab/bin/tasks/hello_world_impeller.dart b/dev/devicelab/bin/tasks/hello_world_impeller.dart index e67a25b48e..22bdd8bdef 100644 --- a/dev/devicelab/bin/tasks/hello_world_impeller.dart +++ b/dev/devicelab/bin/tasks/hello_world_impeller.dart @@ -65,6 +65,7 @@ Future run() async { await Future.delayed(const Duration(seconds: 30)); process.stdin.write('q'); await adb.cancel(); + await device.uninstallApp(); }); if (!isUsingValidationLayers || impellerBackendCount != 1) { diff --git a/dev/devicelab/bin/tasks/route_test_ios.dart b/dev/devicelab/bin/tasks/route_test_ios.dart index 4ba3b42fc1..a2ac3081a4 100644 --- a/dev/devicelab/bin/tasks/route_test_ios.dart +++ b/dev/devicelab/bin/tasks/route_test_ios.dart @@ -16,9 +16,9 @@ void main() { final Device device = await devices.workingDevice; await device.unlock(); final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui')); - section('TEST WHETHER `flutter drive --route` WORKS on IOS'); + section('TEST WHETHER `flutter drive --route` WORKS ON iOS'); await inDirectory(appDir, () async { - return flutter( + await flutter( 'drive', options: [ '--verbose', @@ -29,6 +29,7 @@ void main() { 'lib/route.dart', ], ); + await device.uninstallApp(); }); return TaskResult.success(null); }); diff --git a/dev/devicelab/bin/tasks/service_extensions_test.dart b/dev/devicelab/bin/tasks/service_extensions_test.dart index 1ca335774a..f1ebc10bb4 100644 --- a/dev/devicelab/bin/tasks/service_extensions_test.dart +++ b/dev/devicelab/bin/tasks/service_extensions_test.dart @@ -118,6 +118,7 @@ void main() { if (result != 0) { throw 'Received unexpected exit code $result from run process.'; } + await device.uninstallApp(); }); return TaskResult.success(null); }); diff --git a/dev/devicelab/lib/tasks/android_choreographer_do_frame_test.dart b/dev/devicelab/lib/tasks/android_choreographer_do_frame_test.dart index 59eb41da31..50b1a6d683 100644 --- a/dev/devicelab/lib/tasks/android_choreographer_do_frame_test.dart +++ b/dev/devicelab/lib/tasks/android_choreographer_do_frame_test.dart @@ -161,6 +161,13 @@ Future main() async { await stderr.cancel(); run.kill(); + await inDirectory(path.join(tempDir.path, 'app'), () async { + await flutter( + 'install', + options: ['--uninstall-only'], + ); + }); + if (nextCompleterIdx == sentinelCompleters.values.length) { return TaskResult.success(null); } diff --git a/dev/devicelab/lib/tasks/android_lifecycles_test.dart b/dev/devicelab/lib/tasks/android_lifecycles_test.dart index 38c74595a8..907c4774d9 100644 --- a/dev/devicelab/lib/tasks/android_lifecycles_test.dart +++ b/dev/devicelab/lib/tasks/android_lifecycles_test.dart @@ -154,6 +154,13 @@ void main() { await lifecycles.close(); await stdout.cancel(); await stderr.cancel(); + + await inDirectory(path.join(tempDir.path, 'app'), () async { + await flutter( + 'install', + options: ['--uninstall-only'], + ); + }); return TaskResult.success(null); } diff --git a/dev/devicelab/lib/tasks/android_verified_input_test.dart b/dev/devicelab/lib/tasks/android_verified_input_test.dart index ec084110a5..eb492c9628 100644 --- a/dev/devicelab/lib/tasks/android_verified_input_test.dart +++ b/dev/devicelab/lib/tasks/android_verified_input_test.dart @@ -53,7 +53,7 @@ class DriverTest { ...extraOptions, ]; await flutter('drive', options: options, environment: environment); - + await flutter('install', options: ['--uninstall-only', '-d', deviceId], environment: environment); return TaskResult.success(null); }); } diff --git a/dev/devicelab/lib/tasks/android_views_test.dart b/dev/devicelab/lib/tasks/android_views_test.dart index 8900f2c411..c77b5b8b66 100644 --- a/dev/devicelab/lib/tasks/android_views_test.dart +++ b/dev/devicelab/lib/tasks/android_views_test.dart @@ -34,8 +34,7 @@ TaskFunction androidViewsTest({ final int exitCode = await exec( './gradlew', ['-q', 'dependencies'], - workingDirectory: - '${flutterDirectory.path}/dev/integration_tests/android_views/android' + workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views/android' ); if (exitCode != 0) { return TaskResult.failure('Failed to download gradle dependencies'); @@ -51,6 +50,12 @@ TaskFunction androidViewsTest({ environment: environment, workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views' ); + await flutter( + 'install', + options: ['--uninstall-only'], + environment: environment, + workingDirectory: '${flutterDirectory.path}/dev/integration_tests/android_views', + ); return TaskResult.success(null); }; } diff --git a/dev/devicelab/lib/tasks/build_test_task.dart b/dev/devicelab/lib/tasks/build_test_task.dart index 2405763fd1..29c69d824d 100644 --- a/dev/devicelab/lib/tasks/build_test_task.dart +++ b/dev/devicelab/lib/tasks/build_test_task.dart @@ -61,7 +61,6 @@ abstract class BuildTestTask { await flutter('build', options: getBuildArgs(deviceOperatingSystem)); copyArtifacts(); }); - } /// Run Flutter drive test from [getTestArgs] against the application under test on the device. @@ -74,7 +73,7 @@ abstract class BuildTestTask { section('DRIVE START'); await flutter('drive', options: getTestArgs(deviceOperatingSystem, device.deviceId)); }); - + await device.uninstallApp(); return parseTaskResult(); } diff --git a/dev/devicelab/lib/tasks/dart_plugin_registry_tests.dart b/dev/devicelab/lib/tasks/dart_plugin_registry_tests.dart index 794dfde700..bc3c620cd7 100644 --- a/dev/devicelab/lib/tasks/dart_plugin_registry_tests.dart +++ b/dev/devicelab/lib/tasks/dart_plugin_registry_tests.dart @@ -65,12 +65,13 @@ class ApluginPlatformInterfaceMacOS { pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst( ' pluginClass: ApluginPlatformImplementationPlugin', ' pluginClass: ApluginPlatformImplementationPlugin\n' - ' dartPluginClass: ApluginPlatformInterfaceMacOS\n', + ' dartPluginClass: ApluginPlatformInterfaceMacOS\n', ); pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst( ' platforms:\n', ' implements: aplugin_platform_interface\n' - ' platforms:\n'); + ' platforms:\n', + ); await pluginImplPubspec.writeAsString(pluginImplPubspecContent, flush: true); @@ -104,8 +105,8 @@ class ApluginPlatformInterfaceMacOS { pluginInterfacePubspecContent.replaceFirst( 'dependencies:', 'dependencies:\n' - ' aplugin_platform_implementation:\n' - ' path: ../aplugin_platform_implementation\n'); + ' aplugin_platform_implementation:\n' + ' path: ../aplugin_platform_implementation\n'); await pluginInterfacePubspec.writeAsString(pluginInterfacePubspecContent, flush: true); @@ -135,8 +136,8 @@ class ApluginPlatformInterfaceMacOS { appPubspecContent = appPubspecContent.replaceFirst( 'dependencies:', 'dependencies:\n' - ' aplugin_platform_interface:\n' - ' path: ../aplugin_platform_interface\n'); + ' aplugin_platform_interface:\n' + ' path: ../aplugin_platform_interface\n'); await appPubspec.writeAsString(appPubspecContent, flush: true); section('Flutter run for macos'); @@ -207,6 +208,11 @@ class ApluginPlatformInterfaceMacOS { unawaited(stdoutSub.cancel()); unawaited(stderrSub.cancel()); + await flutter( + 'install', + options: ['--uninstall-only', '-d', 'macos'], + ); + return TaskResult.success(null); } finally { rmTree(tempDir); diff --git a/dev/devicelab/lib/tasks/entrypoint_dart_registrant.dart b/dev/devicelab/lib/tasks/entrypoint_dart_registrant.dart index d9a1f3ea8c..9ca207e1f1 100644 --- a/dev/devicelab/lib/tasks/entrypoint_dart_registrant.dart +++ b/dev/devicelab/lib/tasks/entrypoint_dart_registrant.dart @@ -82,6 +82,7 @@ Future _runWithTempDir(Directory tempDir) async { process.stdin.write('q'); await process.stdin.flush(); process.kill(ProcessSignal.sigint); + await device.uninstallApp(); return entrypoint; }); if (entrypoint.contains('$_messagePrefix $_entrypointName')) { diff --git a/dev/devicelab/lib/tasks/gallery.dart b/dev/devicelab/lib/tasks/gallery.dart index f9ae9a058c..16ef3cd623 100644 --- a/dev/devicelab/lib/tasks/gallery.dart +++ b/dev/devicelab/lib/tasks/gallery.dart @@ -80,7 +80,6 @@ TaskFunction createGalleryTransitionHybridTest({bool semanticsEnabled = false}) } class GalleryTransitionTest { - GalleryTransitionTest({ this.semanticsEnabled = false, this.testFile = 'transitions_perf', @@ -154,6 +153,7 @@ class GalleryTransitionTest { '-v', '--verbose-system-logs' ]); + await flutter('install', options: ['--uninstall-only', '-d', deviceId]); }); final String testOutputDirectory = Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '${galleryDirectory.path}/build'; diff --git a/dev/devicelab/lib/tasks/hot_mode_tests.dart b/dev/devicelab/lib/tasks/hot_mode_tests.dart index 003b7e88ce..1430050c11 100644 --- a/dev/devicelab/lib/tasks/hot_mode_tests.dart +++ b/dev/devicelab/lib/tasks/hot_mode_tests.dart @@ -168,6 +168,8 @@ TaskFunction createHotModeTest({ >[stdoutDone.future, stderrDone.future]); await process.exitCode; + await flutter('install', options: ['--uninstall-only', '-d', deviceIdOverride!]); + freshRestartReloadsData = json.decode(benchmarkFile.readAsStringSync()) as Map; } diff --git a/dev/devicelab/lib/tasks/integration_tests.dart b/dev/devicelab/lib/tasks/integration_tests.dart index 17f5d3d9df..06df01e034 100644 --- a/dev/devicelab/lib/tasks/integration_tests.dart +++ b/dev/devicelab/lib/tasks/integration_tests.dart @@ -208,7 +208,7 @@ class DriverTest { ...extraOptions, ]; await flutter('drive', options: options, environment: environment); - + await flutter('install', options: ['--uninstall-only', '-d', deviceId], environment: environment); return TaskResult.success(null); }); } @@ -267,6 +267,7 @@ class IntegrationTest { if (withTalkBack) { await disableTalkBack(); } + await flutter('install', options: ['--uninstall-only', '-d', deviceId], environment: environment); return TaskResult.success(null); }); diff --git a/dev/devicelab/lib/tasks/microbenchmarks.dart b/dev/devicelab/lib/tasks/microbenchmarks.dart index aa38ab9a57..9061bd5d43 100644 --- a/dev/devicelab/lib/tasks/microbenchmarks.dart +++ b/dev/devicelab/lib/tasks/microbenchmarks.dart @@ -47,7 +47,9 @@ TaskFunction createMicrobenchmarkTask({ environment: environment, ); }); - return readJsonResults(flutterProcess); + final Future> result = readJsonResults(flutterProcess); + await device.uninstallApp(); + return result; } return run(); diff --git a/dev/devicelab/lib/tasks/native_assets_test.dart b/dev/devicelab/lib/tasks/native_assets_test.dart index d6ee607420..8e54708696 100644 --- a/dev/devicelab/lib/tasks/native_assets_test.dart +++ b/dev/devicelab/lib/tasks/native_assets_test.dart @@ -99,6 +99,7 @@ TaskFunction createNativeAssetsTest({ if (runFlutterResult != 0) { print('Flutter run returned non-zero exit code: $runFlutterResult.'); } + await flutter('install', options: ['--uninstall-only', '-d', deviceIdOverride!]); }); final int expectedNumberOfTransitions = buildMode == 'debug' ? 4 : 1; diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index c6d1a2e22a..19f3a90b3f 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -1245,9 +1245,10 @@ class PerfTest { /// If null, the device is selected depending on the current environment. final Device? device; - /// The function called instead of the actually `flutter drive`. + /// The function called instead of the actual `flutter drive`. /// - /// If it is not `null`, `flutter drive` will not happen in the PerfTests. + /// If it is not `null`, `flutter drive` and `flutter install --uninstall-only` + /// will not happen in the PerfTests. final FlutterDriveCallback? flutterDriveCallback; /// Whether the perf test should enable Impeller. @@ -1260,6 +1261,8 @@ class PerfTest { final bool disablePartialRepaint; /// Number of seconds to time out the test after, allowing debug callbacks to run. + /// + /// Passed to `--timeout`. final int? timeoutSeconds; /// The keys of the values that need to be reported. @@ -1393,6 +1396,7 @@ class PerfTest { flutterDriveCallback!(options); } else { await flutter('drive', options: options); + await flutter('install', options: ['--uninstall-only', '-d', deviceId]); } } finally { await resetManifest(); @@ -2127,6 +2131,8 @@ class DevToolsMemoryTest { } } + await _device.uninstallApp(); + return TaskResult.success( {'maxRss': maxRss, 'maxAdbTotal': maxAdbTotal}, benchmarkScoreKeys: ['maxRss', 'maxAdbTotal'], @@ -2199,13 +2205,12 @@ class ReportedDurationTest { await device!.stop(package); await adb.cancel(); + await device!.uninstallApp(); _device = null; final Map reportedDuration = { 'duration': duration, }; - _device = null; - return TaskResult.success(reportedDuration, benchmarkScoreKeys: reportedDuration.keys.toList()); }); } diff --git a/dev/devicelab/lib/tasks/platform_channels_benchmarks.dart b/dev/devicelab/lib/tasks/platform_channels_benchmarks.dart index fcb579c04c..1be4cc9933 100644 --- a/dev/devicelab/lib/tasks/platform_channels_benchmarks.dart +++ b/dev/devicelab/lib/tasks/platform_channels_benchmarks.dart @@ -47,6 +47,7 @@ TaskFunction runTask(adb.DeviceOperatingSystem operatingSystem) { final Map results = await microbenchmarks.readJsonResults(flutterProcess); + await device.uninstallApp(); return TaskResult.success(results, benchmarkScoreKeys: results.keys.toList()); }; diff --git a/dev/devicelab/lib/tasks/run_tests.dart b/dev/devicelab/lib/tasks/run_tests.dart index 33651ae867..f553eeffdd 100644 --- a/dev/devicelab/lib/tasks/run_tests.dart +++ b/dev/devicelab/lib/tasks/run_tests.dart @@ -109,7 +109,7 @@ class AndroidRunOutputTest extends RunOutputTask { @override bool isExpectedStderr(String line) { - // TODO(egarciad): Remove once https://github.com/flutter/flutter/issues/95131 is fixed. + // TODO(egarciad): Remove (because https://github.com/flutter/flutter/issues/95131 is now fixed) return line.contains('Mapping new ns'); } @@ -321,6 +321,8 @@ abstract class RunOutputTask { await run.exitCode; + await device.uninstallApp(); + if (stderr.isNotEmpty) { throw 'flutter run ${release ? '--release' : ''} had unexpected output on standard error.'; } diff --git a/dev/devicelab/lib/tasks/web_dev_mode_tests.dart b/dev/devicelab/lib/tasks/web_dev_mode_tests.dart index fde8eb48ef..f243d4fc27 100644 --- a/dev/devicelab/lib/tasks/web_dev_mode_tests.dart +++ b/dev/devicelab/lib/tasks/web_dev_mode_tests.dart @@ -125,7 +125,6 @@ TaskFunction createWebDevModeTest(String webDevice, bool enableIncrementalCompil // Start `flutter run` again to make sure it loads from the previous // state. dev compilers loads up from previously compiled JavaScript. { - final Stopwatch sw = Stopwatch()..start(); final Process process = await startFlutter( 'run',