Refactor android_engine_test, make it easier to debug/deflake locally. (#161534)
The goal here is to have a great standalone `android_engine_test` suite that [replaces `scenario_app/android`](https://github.com/flutter/flutter/pull/160992). No test is _functionally_ changed in this PR, but overview of changes: - Finished renaming the suite `android_engine_tests` instead of `flutter_driver_android` - Added instructions and an environment variable for local generation of golden-files (`UPDATE_GOLDENS=1`) - Added explanations of the individual tests, where they live, and how to run them locally - Added a hybrid-composition (HC, not TLHC, which is already tested) test - Renamed "other_smiley" to "surface_texture_smiley" (and renamed the original to "surface_producer_smiley") - Removed unnecessary ".android" suffix (we will not run this on anything but Android) - Added a `tool/deflake.dart` to run a test suite 10x (or custom) times locally to try and determine flakiness After this PR, I'll add flags to let you control variants and name the screenshots accordingly, i.e.: - API v34 or v35 - OpenGLES or Vulkan (will require an `AndroidManifest.xml` edit during the test instrumentation)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:android_driver_extensions/extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
|
||||
import '../src/allow_list_devices.dart';
|
||||
|
||||
const MethodChannel _channel = MethodChannel('smiley_face_texture');
|
||||
Future<int> _fetchTexture(int width, int height) async {
|
||||
final int? result = await _channel.invokeMethod<int>('initTexture', <String, int>{
|
||||
'width': width,
|
||||
'height': height,
|
||||
});
|
||||
return result!;
|
||||
}
|
||||
|
||||
void main() async {
|
||||
ensureAndroidDevice();
|
||||
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
|
||||
|
||||
// Run on full screen.
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||
|
||||
// Fetch the texture ID.
|
||||
final Future<int> textureId = _fetchTexture(512, 512);
|
||||
runApp(MainApp(textureId));
|
||||
}
|
||||
|
||||
final class MainApp extends StatelessWidget {
|
||||
const MainApp(this.textureId, {super.key});
|
||||
final Future<int> textureId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: FutureBuilder<int>(
|
||||
future: textureId,
|
||||
builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Texture(textureId: snapshot.data!);
|
||||
}
|
||||
return const CircularProgressIndicator();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:android_driver_extensions/extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
|
||||
import '../src/allow_list_devices.dart';
|
||||
|
||||
const MethodChannel _channel = MethodChannel('other_face_texture');
|
||||
Future<int> _fetchTexture(int width, int height) async {
|
||||
final int? result = await _channel.invokeMethod<int>('initTexture', <String, int>{
|
||||
'width': width,
|
||||
'height': height,
|
||||
});
|
||||
return result!;
|
||||
}
|
||||
|
||||
void main() async {
|
||||
ensureAndroidDevice();
|
||||
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
|
||||
|
||||
// Run on full screen.
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||
|
||||
// Fetch the texture ID.
|
||||
final Future<int> textureId = _fetchTexture(512, 512);
|
||||
runApp(MainApp(textureId));
|
||||
}
|
||||
|
||||
final class MainApp extends StatelessWidget {
|
||||
const MainApp(this.textureId, {super.key});
|
||||
final Future<int> textureId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: FutureBuilder<int>(
|
||||
future: textureId,
|
||||
builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Texture(textureId: snapshot.data!);
|
||||
}
|
||||
return const CircularProgressIndicator();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user