Skip to content

Commit bdfedde

Browse files
author
Emmanuel Garcia
authored
Fix scenario tests on Android (flutter#33360)
1 parent 5f0547c commit bdfedde

20 files changed

+482
-284
lines changed

DEPS

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ deps = {
518518
'src/third_party/imgui':
519519
Var('github_git') + '/ocornut/imgui.git' + '@' + '29d462ebce0275345a6ce4621d8fff0ded57c9e5',
520520

521-
'src/gradle': {
521+
'src/third_party/gradle': {
522522
'packages': [
523523
{
524524
'version': 'version:7.0.2',

ci/licenses_golden/tool_signature

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Signature: 8066f905d0713ee8318704cfaa0b8ebe
1+
Signature: 5c3efe46a56136a2ee290d3349383eda
22

testing/rules/run_gradle.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
BAT = '.bat' if sys.platform.startswith(('cygwin', 'win')) else ''
1919
GRADLE_BIN = os.path.normpath(os.path.join(SCRIPT_PATH, '..', '..', '..',
20-
'gradle', 'bin', 'gradle%s' % BAT))
20+
'third_party', 'gradle', 'bin', 'gradle%s' % BAT))
2121

2222
ANDROID_HOME = os.path.normpath(os.path.join(SCRIPT_PATH, '..', '..', '..',
2323
'third_party', 'android_tools', 'sdk'))

testing/run_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def JavaBin():
351351
def RunJavaTests(filter, android_variant='android_debug_unopt'):
352352
"""Runs the Java JUnit unit tests for the Android embedding"""
353353
test_runner_dir = os.path.join(buildroot_dir, 'flutter', 'shell', 'platform', 'android', 'test_runner')
354-
gradle_bin = os.path.join(buildroot_dir, 'gradle', 'bin', 'gradle.bat' if IsWindows() else 'gradle')
354+
gradle_bin = os.path.join(buildroot_dir, 'third_party', 'gradle', 'bin', 'gradle.bat' if IsWindows() else 'gradle')
355355
flutter_jar = os.path.join(out_dir, android_variant, 'flutter.jar')
356356
android_home = os.path.join(buildroot_dir, 'third_party', 'android_tools', 'sdk')
357357
build_dir = os.path.join(out_dir, android_variant, 'robolectric_tests', 'build')

testing/scenario_app/README.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,20 @@ compared against golden reside.
5656

5757
## Running for Android
5858

59-
The only test that is currently run is the Firebase TestLab test, which is a
60-
smoke test to make sure an application can be built and run on a real Android
61-
device.
59+
### Integration tests
6260

63-
To run it, build the `android_profile_arm64` variant of the engine, and run
61+
For emulators running on a x64 host, build `android_debug_unopt_x64` using
62+
`./tools/gn --android --unoptimized --goma --android-cpu=x64`.
63+
64+
Then, launch the emulator, and run `./testing/scenario_app/run_android_tests.sh android_debug_unopt_x64`.
65+
66+
If you wish to build a different engine variant, make sure to pass that variant to the script `run_android_tests.sh`.
67+
68+
If you make a change to the source code, you would need to rebuild the same engine variant.
69+
70+
### Smoke test on FTL
71+
72+
To run the smoke test on Firebase TestLab test, build `android_profile_arm64`, and run
6473
`./flutter/ci/firebase_testlab.py`. If you wish to test a different variant, e.g.
6574
debug arm64, pass `--variant android_debug_arm64`.
6675

@@ -72,5 +81,5 @@ To generate new lockfiles, run:
7281

7382
```bash
7483
cd android
75-
../../../../gradle/bin/gradle generateLockfiles
84+
../../../../third_party/gradle/bin/gradle generateLockfiles
7685
```

testing/scenario_app/android/BUILD.gn

+23-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _android_sources = [
99
"app/src/androidTest/java/dev/flutter/TestRunner.java",
1010
"app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java",
1111
"app/src/androidTest/java/dev/flutter/scenarios/ExampleInstrumentedTest.java",
12+
"app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java",
1213
"app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java",
1314
"app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java",
1415
"app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java",
@@ -47,8 +48,29 @@ gradle_task("build_apk") {
4748
]
4849
}
4950

50-
copy("android") {
51+
gradle_task("build_test_apk") {
52+
app_name = "scenario_app"
53+
task = ":app:packageDebugAndroidTest"
54+
gradle_project_dir = rebase_path(".")
55+
sources = _android_sources
56+
outputs = [ "$root_out_dir/scenario_app/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk" ]
57+
58+
deps = [
59+
":android_lint",
60+
"//flutter/testing/scenario_app:scenario_app_snapshot",
61+
]
62+
}
63+
64+
copy("firebase_apk") {
5165
sources = get_target_outputs(":build_apk")
5266
outputs = [ "$root_out_dir/firebase_apks/scenario_app.apk" ]
5367
deps = [ ":build_apk" ]
5468
}
69+
70+
group("android") {
71+
deps = [
72+
":build_apk",
73+
":build_test_apk",
74+
":firebase_apk",
75+
]
76+
}

testing/scenario_app/android/app/build.gradle

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'com.facebook.testing.screenshot'
32
apply plugin: 'kotlin-android'
43

5-
screenshots {
6-
failureDir = "${rootProject.buildDir}/reports/diff_failures"
7-
recordDir = "${rootProject.projectDir}/reports/screenshots"
8-
}
9-
104
android {
115
lintOptions {
126
abortOnError true
137
checkAllWarnings true
148
showAll true
159
warningsAsErrors true
1610
checkTestSources true
17-
htmlReport false
18-
xmlReport true
19-
xmlOutput file("${rootProject.buildDir}/reports/lint-results.xml")
11+
textOutput 'stdout'
2012
// UnpackedNativeCode can break stack unwinding - see b/193408481
2113
// NewerVersionAvailable and GradleDependency need to be taken care of
2214
// by a roller rather than as part of CI.
@@ -62,13 +54,13 @@ dependencies {
6254
if (project.hasProperty('flutter_jar')) {
6355
implementation files(project.property('flutter_jar'))
6456
}
65-
implementation 'com.facebook.testing.screenshot:layout-hierarchy-common:0.12.0'
6657
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
6758
implementation 'com.google.android.material:material:1.0.0'
6859
androidTestImplementation 'junit:junit:4.12'
6960
androidTestImplementation 'androidx.test:runner:1.2.0'
7061
androidTestImplementation 'androidx.test:rules:1.2.0'
7162
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
63+
androidTestImplementation 'com.google.guava:guava:30.1-android'
7264

7365
def leakcanary_version = '2.7'
7466
androidTestImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
@@ -85,7 +77,7 @@ configureDependencies(new File(rootDir, '../../..')) { dependency ->
8577

8678
tasks.register('generateLockfiles') {
8779
rootProject.subprojects.each { subproject ->
88-
def gradle = "${rootProject.projectDir}/../../../../gradle/bin/gradle"
80+
def gradle = "${rootProject.projectDir}/../../../../third_party/gradle/bin/gradle"
8981
rootProject.exec {
9082
workingDir rootProject.projectDir
9183
executable gradle

0 commit comments

Comments
 (0)