Unverified Commit bd02e4f5 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Test that modules built as AAR contain the right assets and artifacts (#37206)

parent dfad0395
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter_devicelab/framework/apk_utils.dart';
import 'package:flutter_devicelab/framework/framework.dart'; import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart'; import 'package:flutter_devicelab/framework/utils.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
...@@ -134,6 +135,33 @@ Future<void> main() async { ...@@ -134,6 +135,33 @@ Future<void> main() async {
'package_info_release-1.0.pom', 'package_info_release-1.0.pom',
)); ));
section('Check assets in release AAR');
final Iterable<String> releaseAar = await getFilesInAar(path.join(
repoPath,
'io',
'flutter',
'devicelab',
'hello',
'flutter_release',
'1.0',
'flutter_release-1.0.aar',
));
checkItContains<String>(<String>[
'assets/flutter_assets/FontManifest.json',
'assets/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf',
], releaseAar);
section('Check AOT blobs in release AAR');
checkItContains<String>(<String>[
'jni/arm64-v8a/libapp.so',
'jni/arm64-v8a/libflutter.so',
'jni/armeabi-v7a/libapp.so',
'jni/armeabi-v7a/libflutter.so',
], releaseAar);
section('Build debug AAR'); section('Build debug AAR');
await inDirectory(projectDir, () async { await inDirectory(projectDir, () async {
...@@ -149,9 +177,9 @@ Future<void> main() async { ...@@ -149,9 +177,9 @@ Future<void> main() async {
'flutter', 'flutter',
'devicelab', 'devicelab',
'hello', 'hello',
'flutter_release', 'flutter_debug',
'1.0', '1.0',
'flutter_release-1.0.aar', 'flutter_debug-1.0.aar',
)); ));
checkFileExists(path.join( checkFileExists(path.join(
...@@ -209,7 +237,41 @@ Future<void> main() async { ...@@ -209,7 +237,41 @@ Future<void> main() async {
'package_info_debug-1.0.pom', 'package_info_debug-1.0.pom',
)); ));
section('Check assets in debug AAR');
final Iterable<String> debugAar = await getFilesInAar(path.join(
repoPath,
'io',
'flutter',
'devicelab',
'hello',
'flutter_debug',
'1.0',
'flutter_debug-1.0.aar',
));
checkItContains<String>(<String>[
'assets/flutter_assets/FontManifest.json',
'assets/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf',
// JIT snapshots.
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
], debugAar);
section('Check AOT blobs in debug AAR');
checkItContains<String>(<String>[
'jni/arm64-v8a/libflutter.so',
'jni/armeabi-v7a/libflutter.so',
'jni/x86/libflutter.so',
'jni/x86_64/libflutter.so',
], debugAar);
return TaskResult.success(null); return TaskResult.success(null);
} on TaskResult catch (taskResult) {
return taskResult;
} catch (e) { } catch (e) {
return TaskResult.failure(e.toString()); return TaskResult.failure(e.toString());
} finally { } finally {
......
...@@ -34,6 +34,7 @@ Future<void> runPluginProjectTest(Future<void> testFunction(FlutterPluginProject ...@@ -34,6 +34,7 @@ Future<void> runPluginProjectTest(Future<void> testFunction(FlutterPluginProject
} }
} }
/// Returns the list of files inside an Android Package Kit.
Future<Iterable<String>> getFilesInApk(String apk) async { Future<Iterable<String>> getFilesInApk(String apk) async {
if (!File(apk).existsSync()) if (!File(apk).existsSync())
throw TaskResult.failure( throw TaskResult.failure(
...@@ -50,11 +51,16 @@ Future<Iterable<String>> getFilesInApk(String apk) async { ...@@ -50,11 +51,16 @@ Future<Iterable<String>> getFilesInApk(String apk) async {
.map((String line) => line.split(' ').last) .map((String line) => line.split(' ').last)
.toList(); .toList();
} }
/// Returns the list of files inside an Android App Bundle.
Future<Iterable<String>> getFilesInAppBundle(String bundle) { Future<Iterable<String>> getFilesInAppBundle(String bundle) {
return getFilesInApk(bundle); return getFilesInApk(bundle);
} }
/// Returns the list of files inside an Android Archive.
Future<Iterable<String>> getFilesInAar(String aar) {
return getFilesInApk(aar);
}
void checkItContains<T>(Iterable<T> values, Iterable<T> collection) { void checkItContains<T>(Iterable<T> values, Iterable<T> collection) {
for (T value in values) { for (T value in values) {
if (!collection.contains(value)) { if (!collection.contains(value)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment