Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Actually use Impeller in scenario_app tests #50977

Merged
merged 8 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion testing/scenario_app/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import("//flutter/testing/rules/android.gni")
_android_sources = [
"app/build.gradle",
"app/src/androidTest/java/dev/flutter/TestRunner.java",
"app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java",
"app/src/androidTest/java/dev/flutter/scenarios/ExampleInstrumentedTest.java",
"app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java",
"app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@
import androidx.annotation.Nullable;
import androidx.test.runner.AndroidJUnitRunner;
import dev.flutter.scenariosui.ScreenshotUtil;
import io.flutter.FlutterInjector;

public class TestRunner extends AndroidJUnitRunner {
@Override
public void onCreate(@Nullable Bundle arguments) {
String[] engineArguments = null;
if ("true".equals(arguments.getString("enable-impeller"))) {
// Set up the global settings object so that Impeller is enabled for all tests.
engineArguments = new String[] {"--enable-impeller=true"};
}
// For consistency, just always initilaize FlutterJNI etc.
FlutterInjector.instance().flutterLoader().startInitialization(getTargetContext());
FlutterInjector.instance()
.flutterLoader()
.ensureInitializationComplete(getTargetContext(), engineArguments);
ScreenshotUtil.onCreate();
super.onCreate(arguments);
}
Expand Down

This file was deleted.

22 changes: 19 additions & 3 deletions testing/scenario_app/bin/run_android_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Future<void> _run({

late Process logcatProcess;
late Future<int> logcatProcessExitCode;
bool seenImpeller = false;

final IOSink logcat = File(logcatPath).openWrite();
try {
Expand All @@ -212,6 +213,9 @@ Future<void> _run({
logcatOutput.listen((String line) {
// Always write to the full log.
logcat.writeln(line);
if (enableImpeller && !seenImpeller) {
seenImpeller = line.contains('Using the Impeller rendering backend');
}

// Conditionally parse and write to stderr.
final AdbLogLine? adbLogLine = AdbLogLine.tryParse(line);
Expand Down Expand Up @@ -316,11 +320,13 @@ Future<void> _run({
'am',
'instrument',
'-w',
if (smokeTestFullPath != null) '-e class $smokeTestFullPath',
'dev.flutter.scenarios.test/dev.flutter.TestRunner',
if (enableImpeller) '-e enable-impeller',
if (smokeTestFullPath != null)
'-e class $smokeTestFullPath',
if (enableImpeller)
'-e enable-impeller true',
if (impellerBackend != null)
'-e impeller-backend ${impellerBackend.name}',
'dev.flutter.scenarios.test/dev.flutter.TestRunner',
]);
if (exitCode != 0) {
panic(<String>['instrumented tests failed to run']);
Expand Down Expand Up @@ -348,6 +354,16 @@ Future<void> _run({
log('wrote logcat to $logcatPath');
});

if (enableImpeller) {
await step('Validating Impeller...', () async {
if (!seenImpeller) {
panic(<String>[
'--enable-impeller was specified, but Impeller was not used.',
]);
}
});
}

await step('Symbolize stack traces', () async {
final ProcessResult result = await pm.run(
<String>[
Expand Down
15 changes: 5 additions & 10 deletions testing/scenario_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ void main() {
channelBuffers.setListener('driver', _handleDriverMessage);
channelBuffers.setListener('write_timeline', _handleWriteTimelineMessage);

// TODO(matanlurey): https://github.com/flutter/flutter/issues/142746.
// This Dart program is used for every test, but there is at least one test
// (EngineLaunchE2ETest.java) that does not create a FlutterView, so the
// implicit view's size is not initialized (and the assert would be tripped).
//
// final FlutterView view = PlatformDispatcher.instance.implicitView!;
final FlutterView view = PlatformDispatcher.instance.implicitView!;
// Asserting that this is greater than zero since this app runs on different
// platforms with different sizes. If it is greater than zero, it has been
// initialized to some meaningful value at least.
// assert(
// view.display.size > Offset.zero,
// 'Expected ${view.display} to be initialized.',
// );
assert(
view.display.size > Offset.zero,
'Expected ${view.display} to be initialized.',
);

final ByteData data = ByteData(1);
data.setUint8(0, 1);
Expand Down