Skip to content

Commit 2481d92

Browse files
[ci] Enable Android emulator-based tests (flutter#4494)
Adds emulators to the Android platform test tasks, and enable both native integration tests and `flutter test` Dart integration tests. This finally gives us presubmit coverage of Android integration tests for non-team-member PRs, as well as giving us a path to reducing the dependency on FTL for all of our Android testing. Currently this uses Android 13 emulators; we could expand this to a set of legacy version emulator tests in the future once this is in place. Some specific notes: - Camera and Google Maps tests are currently excluded, so that we can enable everything else while we work on the blockers for those. - `shared_preferences` was missing its debug entitlement, which prevented the debug service from running, and thus broke `flutter test`; we'd just never noticed because FTL tests don't need that mechanism to work. - IAP was using `test` instead of `testWidget`, which we only check for in `drive-examples`, so hadn't noticed. Fixes flutter#93810
1 parent 18d5506 commit 2481d92

6 files changed

Lines changed: 84 additions & 19 deletions

File tree

.ci.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ targets:
310310
channel: master
311311
version_file: flutter_master.version
312312
package_sharding: "--shardIndex 0 --shardCount 6"
313+
dependencies: >-
314+
[
315+
{"dependency": "android_virtual_device", "version": "33"}
316+
]
313317
314318
- name: Linux_android android_platform_tests_shard_2 master
315319
recipe: packages/packages
@@ -319,6 +323,10 @@ targets:
319323
channel: master
320324
version_file: flutter_master.version
321325
package_sharding: "--shardIndex 1 --shardCount 6"
326+
dependencies: >-
327+
[
328+
{"dependency": "android_virtual_device", "version": "33"}
329+
]
322330
323331
- name: Linux_android android_platform_tests_shard_3 master
324332
recipe: packages/packages
@@ -328,6 +336,10 @@ targets:
328336
channel: master
329337
version_file: flutter_master.version
330338
package_sharding: "--shardIndex 2 --shardCount 6"
339+
dependencies: >-
340+
[
341+
{"dependency": "android_virtual_device", "version": "33"}
342+
]
331343
332344
- name: Linux_android android_platform_tests_shard_4 master
333345
recipe: packages/packages
@@ -337,6 +349,10 @@ targets:
337349
channel: master
338350
version_file: flutter_master.version
339351
package_sharding: "--shardIndex 3 --shardCount 6"
352+
dependencies: >-
353+
[
354+
{"dependency": "android_virtual_device", "version": "33"}
355+
]
340356
341357
- name: Linux_android android_platform_tests_shard_5 master
342358
recipe: packages/packages
@@ -346,6 +362,10 @@ targets:
346362
channel: master
347363
version_file: flutter_master.version
348364
package_sharding: "--shardIndex 4 --shardCount 6"
365+
dependencies: >-
366+
[
367+
{"dependency": "android_virtual_device", "version": "33"}
368+
]
349369
350370
- name: Linux_android android_platform_tests_shard_6 master
351371
recipe: packages/packages
@@ -355,6 +375,10 @@ targets:
355375
channel: master
356376
version_file: flutter_master.version
357377
package_sharding: "--shardIndex 5 --shardCount 6"
378+
dependencies: >-
379+
[
380+
{"dependency": "android_virtual_device", "version": "33"}
381+
]
358382
359383
- name: Linux_android android_platform_tests_shard_1 stable
360384
recipe: packages/packages
@@ -365,6 +389,10 @@ targets:
365389
channel: stable
366390
version_file: flutter_stable.version
367391
package_sharding: "--shardIndex 0 --shardCount 6"
392+
dependencies: >-
393+
[
394+
{"dependency": "android_virtual_device", "version": "33"}
395+
]
368396
369397
- name: Linux_android android_platform_tests_shard_2 stable
370398
recipe: packages/packages
@@ -375,6 +403,10 @@ targets:
375403
channel: stable
376404
version_file: flutter_stable.version
377405
package_sharding: "--shardIndex 1 --shardCount 6"
406+
dependencies: >-
407+
[
408+
{"dependency": "android_virtual_device", "version": "33"}
409+
]
378410
379411
- name: Linux_android android_platform_tests_shard_3 stable
380412
recipe: packages/packages
@@ -385,6 +417,10 @@ targets:
385417
channel: stable
386418
version_file: flutter_stable.version
387419
package_sharding: "--shardIndex 2 --shardCount 6"
420+
dependencies: >-
421+
[
422+
{"dependency": "android_virtual_device", "version": "33"}
423+
]
388424
389425
- name: Linux_android android_platform_tests_shard_4 stable
390426
recipe: packages/packages
@@ -395,6 +431,10 @@ targets:
395431
channel: stable
396432
version_file: flutter_stable.version
397433
package_sharding: "--shardIndex 3 --shardCount 6"
434+
dependencies: >-
435+
[
436+
{"dependency": "android_virtual_device", "version": "33"}
437+
]
398438
399439
- name: Linux_android android_platform_tests_shard_5 stable
400440
recipe: packages/packages
@@ -405,6 +445,10 @@ targets:
405445
channel: stable
406446
version_file: flutter_stable.version
407447
package_sharding: "--shardIndex 4 --shardCount 6"
448+
dependencies: >-
449+
[
450+
{"dependency": "android_virtual_device", "version": "33"}
451+
]
408452
409453
- name: Linux_android android_platform_tests_shard_6 stable
410454
recipe: packages/packages
@@ -415,6 +459,10 @@ targets:
415459
channel: stable
416460
version_file: flutter_stable.version
417461
package_sharding: "--shardIndex 5 --shardCount 6"
462+
dependencies: >-
463+
[
464+
{"dependency": "android_virtual_device", "version": "33"}
465+
]
418466
419467
### Web tasks ###
420468
- name: Linux_web web_build_all_packages master

.ci/targets/android_platform_tests.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ tasks:
1919
- name: native unit tests
2020
script: script/tool_runner.sh
2121
args: ["native-test", "--android", "--no-integration", "--exclude=script/configs/exclude_native_unit_android.yaml"]
22-
# TODO(stuartmorgan): Enable these once
23-
# https://github.com/flutter/flutter/issues/120736 is implemented.
24-
# See also https://github.com/flutter/flutter/issues/114373
25-
#- name: native integration tests
26-
# script: script/tool_runner.sh
27-
# args: ["native-test", "--android", "--no-unit"]
28-
#- name: drive examples
29-
# script: script/tool_runner.sh
30-
# args: ["drive-examples", "--android", "--exclude=script/configs/exclude_integration_android.yaml"]
22+
- name: native integration tests
23+
script: script/tool_runner.sh
24+
args: ["native-test", "--android", "--no-unit"]
25+
- name: drive examples
26+
script: script/tool_runner.sh
27+
args: ["drive-examples", "--android", "--exclude=script/configs/exclude_integration_android.yaml,script/configs/exclude_integration_android_emulator.yaml"]

packages/in_app_purchase/in_app_purchase_android/example/integration_test/in_app_purchase_test.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,33 @@ void main() {
3030
billingClient = BillingClient((PurchasesResultWrapper _) {});
3131
});
3232

33-
test('BillingClient.acknowledgePurchase', () async {
33+
testWidgets('BillingClient.acknowledgePurchase',
34+
(WidgetTester tester) async {
3435
try {
3536
await billingClient.acknowledgePurchase('purchaseToken');
3637
} on MissingPluginException {
3738
fail('Method channel is not setup correctly');
3839
}
3940
});
4041

41-
test('BillingClient.consumeAsync', () async {
42+
testWidgets('BillingClient.consumeAsync', (WidgetTester tester) async {
4243
try {
4344
await billingClient.consumeAsync('purchaseToken');
4445
} on MissingPluginException {
4546
fail('Method channel is not setup correctly');
4647
}
4748
});
4849

49-
test('BillingClient.endConnection', () async {
50+
testWidgets('BillingClient.endConnection', (WidgetTester tester) async {
5051
try {
5152
await billingClient.endConnection();
5253
} on MissingPluginException {
5354
fail('Method channel is not setup correctly');
5455
}
5556
});
5657

57-
test('BillingClient.isFeatureSupported', () async {
58+
testWidgets('BillingClient.isFeatureSupported',
59+
(WidgetTester tester) async {
5860
try {
5961
await billingClient
6062
.isFeatureSupported(BillingClientFeature.productDetails);
@@ -63,15 +65,15 @@ void main() {
6365
}
6466
});
6567

66-
test('BillingClient.isReady', () async {
68+
testWidgets('BillingClient.isReady', (WidgetTester tester) async {
6769
try {
6870
await billingClient.isReady();
6971
} on MissingPluginException {
7072
fail('Method channel is not setup correctly');
7173
}
7274
});
7375

74-
test('BillingClient.launchBillingFlow', () async {
76+
testWidgets('BillingClient.launchBillingFlow', (WidgetTester tester) async {
7577
try {
7678
await billingClient.launchBillingFlow(product: 'product');
7779
} on MissingPluginException {
@@ -84,7 +86,8 @@ void main() {
8486
}
8587
});
8688

87-
test('BillingClient.queryProductDetails', () async {
89+
testWidgets('BillingClient.queryProductDetails',
90+
(WidgetTester tester) async {
8891
try {
8992
await billingClient
9093
.queryProductDetails(productList: <ProductWrapper>[]);
@@ -99,23 +102,24 @@ void main() {
99102
}
100103
});
101104

102-
test('BillingClient.queryPurchaseHistory', () async {
105+
testWidgets('BillingClient.queryPurchaseHistory',
106+
(WidgetTester tester) async {
103107
try {
104108
await billingClient.queryPurchaseHistory(ProductType.inapp);
105109
} on MissingPluginException {
106110
fail('Method channel is not setup correctly');
107111
}
108112
});
109113

110-
test('BillingClient.queryPurchases', () async {
114+
testWidgets('BillingClient.queryPurchases', (WidgetTester tester) async {
111115
try {
112116
await billingClient.queryPurchases(ProductType.inapp);
113117
} on MissingPluginException {
114118
fail('Method channel is not setup correctly');
115119
}
116120
});
117121

118-
test('BillingClient.startConnection', () async {
122+
testWidgets('BillingClient.startConnection', (WidgetTester tester) async {
119123
try {
120124
await billingClient.startConnection(
121125
onBillingServiceDisconnected: () {});

packages/shared_preferences/shared_preferences/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## NEXT
22

3+
* Fixes the example app to be debuggable on Android.
34
* Deletes deprecated splash screen meta-data element.
45

56
## 2.2.0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.sharedpreferencesexample">
3+
<!-- Flutter needs it to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
</manifest>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Hangs due to permission issue, see https://github.com/flutter/flutter/issues/130987
2+
# TODO(stuartmorgan): Remove once the permission issue is addressed.
3+
- camera/camera
4+
- camera_android
5+
- camera_android_camerax
6+
# Frequent flaky failures, see https://github.com/flutter/flutter/issues/130986
7+
# TODO(stuartmorgan): Remove once the flake is fixed.
8+
- google_maps_flutter_android

0 commit comments

Comments
 (0)