Skip to content

Commit ffa59ac

Browse files
matanlureysealesj
authored andcommitted
Add useful default options to scenario_app/bin/android_integration_tests.dart (flutter#50667)
Closes flutter/flutter#143474. This makes `--adb` and `--out_dir` have useful defaults for most environments. To be explicit, the `--out-dir` is still specified in the test runner (I could imagine refactoring this further to take a `--variant` instead, but not a priority). /cc @gmackall
1 parent e45664f commit ffa59ac

4 files changed

Lines changed: 43 additions & 11 deletions

File tree

testing/scenario_app/bin/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ captured and compared using Skia Gold (if available, for example on CI).
88
## Usage
99

1010
```sh
11-
dart bin/android_integration_tests.dart \
12-
--adb ../third_party/android_tools/sdk/platform-tools/adb \
13-
--out-dir ../out/android_debug_unopt_arm64
11+
dart bin/android_integration_tests.dart
1412
```
1513

1614
## Debugging
@@ -21,17 +19,20 @@ by class name, which can be useful to verify the setup.
2119
For example, to run the `EngineLaunchE2ETest` test:
2220

2321
```sh
24-
dart bin/android_integration_tests.dart \
25-
--adb ../third_party/android_tools/sdk/platform-tools/adb \
26-
--out-dir ../out/android_debug_unopt_arm64 \
27-
--smoke-test dev.flutter.scenarios.EngineLaunchE2ETest
22+
dart bin/android_integration_tests.dart --smoke-test dev.flutter.scenarios.EngineLaunchE2ETest
2823
```
2924

3025
## Additional arguments
3126

27+
- `--adb`: The path to the `adb` tool. Defaults to
28+
`third_party/android_tools/sdk/platform-tools/adb`.
29+
30+
- `--out-dir`: The directory containing the build artifacts. Defaults to the
31+
last updated build directory in `out/` that starts with `android_`.
32+
3233
- `--use-skia-gold`: Use Skia Gold to compare screenshots. Defaults to true
3334
when running on CI, and false otherwise (i.e. when running locally). If
34-
set to true, [isSkiaGoldClientAvailable] must be true.
35+
set to true, `isSkiaGoldClientAvailable` must be true.
3536

3637
- `--enable-impeller`: Enable Impeller for the Android app. Defaults to
3738
false, which means that the app will use Skia as the graphics backend.

testing/scenario_app/bin/android_integration_tests.dart

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'dart:io';
88
import 'dart:typed_data';
99

1010
import 'package:args/args.dart';
11+
import 'package:engine_repo_tools/engine_repo_tools.dart';
1112
import 'package:path/path.dart';
1213
import 'package:process/process.dart';
1314
import 'package:skia_gold_client/skia_gold_client.dart';
@@ -18,16 +19,34 @@ import 'utils/screenshot_transformer.dart';
1819

1920
// If you update the arguments, update the documentation in the README.md file.
2021
void main(List<String> args) async {
22+
final Engine? engine = Engine.tryFindWithin();
2123
final ArgParser parser = ArgParser()
24+
..addFlag(
25+
'help',
26+
help: 'Prints usage information',
27+
negatable: false,
28+
)
2229
..addOption(
2330
'adb',
2431
help: 'Absolute path to the adb tool',
25-
mandatory: true,
32+
defaultsTo: engine != null ? join(
33+
engine.srcDir.path,
34+
'third_party',
35+
'android_tools',
36+
'sdk',
37+
'platform-tools',
38+
'adb',
39+
) : null,
2640
)
2741
..addOption(
2842
'out-dir',
2943
help: 'Out directory',
30-
mandatory: true,
44+
defaultsTo:
45+
engine?.
46+
outputs().
47+
where((Output o) => basename(o.path.path).startsWith('android_')).
48+
firstOrNull?.
49+
path.path,
3150
)
3251
..addOption(
3352
'smoke-test',
@@ -52,6 +71,18 @@ void main(List<String> args) async {
5271
runZonedGuarded(
5372
() async {
5473
final ArgResults results = parser.parse(args);
74+
if (results['help'] as bool) {
75+
stdout.writeln(parser.usage);
76+
return;
77+
}
78+
79+
if (results['out-dir'] == null) {
80+
panic(<String>['--out-dir is required']);
81+
}
82+
if (results['adb'] == null) {
83+
panic(<String>['--adb is required']);
84+
}
85+
5586
final Directory outDir = Directory(results['out-dir'] as String);
5687
final File adb = File(results['adb'] as String);
5788
final bool useSkiaGold = results['use-skia-gold'] as bool;

testing/scenario_app/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ environment:
1616
# relative to this directory into //third_party/dart, or //third_party/pkg
1717
dependencies:
1818
args: any
19+
engine_repo_tools: any
1920
path: any
2021
process: any
2122
sky_engine: any

testing/scenario_app/run_android_tests.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,5 @@ cd $SCRIPT_DIR
6767

6868
"$SRC_DIR"/third_party/dart/tools/sdks/dart-sdk/bin/dart run \
6969
"$SCRIPT_DIR"/bin/android_integration_tests.dart \
70-
--adb="$SRC_DIR"/third_party/android_tools/sdk/platform-tools/adb \
7170
--out-dir="$OUT_DIR" \
7271
"$@"

0 commit comments

Comments
 (0)