From e4d8f67ee56a96246a0b037428de8d1ab4d399b0 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 26 Feb 2024 12:15:31 -0800 Subject: [PATCH 1/6] Actually use Impeller in scenario_app tests --- testing/scenario_app/android/BUILD.gn | 1 + .../scenariosui/ArgumentAwareIntent.java | 48 +++++++++++++++++++ .../scenariosui/DrawSolidBlueScreenTest.java | 4 +- .../scenariosui/ExternalTextureTests.java | 14 ++++-- .../flutter/scenariosui/GetBitmapTests.java | 4 +- .../flutter/scenariosui/MemoryLeakTests.java | 4 +- .../scenariosui/PlatformTextureUiTests.java | 3 +- .../scenariosui/PlatformViewUiTests.java | 3 +- ...rmViewWithSurfaceViewBadContextUiTest.java | 3 +- ...ewWithSurfaceViewHybridFallbackUiTest.java | 3 +- ...atformViewWithSurfaceViewHybridUiTest.java | 3 +- .../PlatformViewWithSurfaceViewUiTest.java | 3 +- .../PlatformViewWithTextureViewUiTest.java | 3 +- .../flutter/scenariosui/SpawnEngineTests.java | 3 +- .../scenariosui/SpawnMultiEngineTest.java | 3 +- .../scenario_app/bin/run_android_tests.dart | 18 ++++++- 16 files changed, 101 insertions(+), 19 deletions(-) create mode 100644 testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ArgumentAwareIntent.java diff --git a/testing/scenario_app/android/BUILD.gn b/testing/scenario_app/android/BUILD.gn index 9aabbdc72adaa..aff99a3e6ebc3 100644 --- a/testing/scenario_app/android/BUILD.gn +++ b/testing/scenario_app/android/BUILD.gn @@ -9,6 +9,7 @@ _android_sources = [ "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/ArgumentAwareIntent.java", "app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java", "app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java", "app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java", diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ArgumentAwareIntent.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ArgumentAwareIntent.java new file mode 100644 index 0000000000000..86492652281a6 --- /dev/null +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ArgumentAwareIntent.java @@ -0,0 +1,48 @@ +// Copyright 2013 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. + +package dev.flutter.scenariosui; + +import android.content.Intent; +import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.test.InstrumentationRegistry; +import io.flutter.embedding.engine.FlutterShellArgs; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +public class ArgumentAwareIntent implements TestRule { + public ArgumentAwareIntent() { + this.intent = new Intent(Intent.ACTION_MAIN); + } + + public ArgumentAwareIntent(@NonNull Intent intent) { + this.intent = intent; + } + + private @NonNull Intent intent; + + public @NonNull Intent getIntent() { + return intent; + } + + @Override + public @NonNull Statement apply(@NonNull Statement base, @NonNull Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + Bundle arguments = InstrumentationRegistry.getArguments(); + if ("true".equals(arguments.getString(FlutterShellArgs.ARG_KEY_ENABLE_IMPELLER))) { + getIntent().putExtra(FlutterShellArgs.ARG_KEY_ENABLE_IMPELLER, true); + String backend = arguments.getString("impeller-backend"); + if (backend != null) { + getIntent().putExtra("impeller-backend", backend); + } + } + base.evaluate(); + } + }; + } +} diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java index b61a69f7848bd..0dec7e6f459ae 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java @@ -18,9 +18,11 @@ public final class DrawSolidBlueScreenTest { new ActivityTestRule<>( PlatformViewsActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false); + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); + @Test public void test() throws Exception { - Intent intent = new Intent(Intent.ACTION_MAIN); + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "solid_blue"); ScreenshotUtil.capture(activityRule.launchActivity(intent), "DrawSolidBlueScreenTest"); } diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java index 37d96fa3e261f..6832f5395bb64 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java @@ -13,7 +13,6 @@ import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; import dev.flutter.scenarios.ExternalTextureFlutterActivity; -import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,13 +32,11 @@ public class ExternalTextureTests { /*initialTouchMode=*/ false, /*launchActivity=*/ false); - @Before - public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); - } + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Test public void testCanvasSurface() throws Exception { + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "canvas"); ScreenshotUtil.capture( @@ -49,6 +46,7 @@ public void testCanvasSurface() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) public void testMediaSurface() throws Exception { + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "media"); ScreenshotUtil.capture( @@ -58,6 +56,7 @@ public void testMediaSurface() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) public void testRotatedMediaSurface_90() throws Exception { + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "media"); intent.putExtra("rotation", 90); @@ -68,6 +67,7 @@ public void testRotatedMediaSurface_90() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) public void testRotatedMediaSurface_180() throws Exception { + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "media"); intent.putExtra("rotation", 180); @@ -78,6 +78,7 @@ public void testRotatedMediaSurface_180() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) public void testRotatedMediaSurface_270() throws Exception { + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "media"); intent.putExtra("rotation", 270); @@ -88,6 +89,7 @@ public void testRotatedMediaSurface_270() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.M) public void testCroppedMediaSurface_bottomLeft() throws Exception { + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "image"); intent.putExtra("crop", new Rect(0, 0, SURFACE_WIDTH / 2, SURFACE_HEIGHT / 2)); @@ -99,6 +101,7 @@ public void testCroppedMediaSurface_bottomLeft() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.M) public void testCroppedMediaSurface_topRight() throws Exception { + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "image"); intent.putExtra( @@ -111,6 +114,7 @@ public void testCroppedMediaSurface_topRight() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.M) public void testCroppedRotatedMediaSurface_bottomLeft_90() throws Exception { + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "image"); intent.putExtra("crop", new Rect(0, 0, SURFACE_WIDTH / 2, SURFACE_HEIGHT / 2)); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java index 4b44da007f482..ccf203cd70ce5 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java @@ -25,9 +25,11 @@ public class GetBitmapTests { new ActivityTestRule<>( GetBitmapActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false); + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); + @Test public void getBitmap() throws Exception { - Intent intent = new Intent(Intent.ACTION_MAIN); + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "get_bitmap"); GetBitmapActivity activity = activityRule.launchActivity(intent); Bitmap bitmap = activity.getBitmap(); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java index 7fbf4bdb9b218..af8fb1cc5bdd9 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java @@ -23,10 +23,12 @@ public class MemoryLeakTests { new ActivityTestRule<>( PlatformViewsActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false); + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); + @Test @FailTestOnLeak public void platformViewHybridComposition_launchActivityFinishAndLaunchAgain() throws Exception { - Intent intent = new Intent(Intent.ACTION_MAIN); + Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "platform_view"); intent.putExtra("use_android_view", true); intent.putExtra("view_type", PlatformViewsActivity.TEXT_VIEW_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java index a4aa061f2a82c..84bea2a3cee6a 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java @@ -20,6 +20,7 @@ @LargeTest public class PlatformTextureUiTests { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -32,7 +33,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = intentRule.getIntent(); // Render a texture. intent.putExtra("use_android_view", false); intent.putExtra("view_type", PlatformViewsActivity.TEXT_VIEW_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java index 50dc5dfef600b..dcbe4a3f075cf 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java @@ -20,6 +20,7 @@ @LargeTest public class PlatformViewUiTests { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -32,7 +33,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = intentRule.getIntent(); // Render a native android view. intent.putExtra("use_android_view", true); intent.putExtra("view_type", PlatformViewsActivity.TEXT_VIEW_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewBadContextUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewBadContextUiTest.java index a036a90a73e02..41357ae6fa28e 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewBadContextUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewBadContextUiTest.java @@ -19,6 +19,7 @@ @LargeTest public class PlatformViewWithSurfaceViewBadContextUiTest { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -31,7 +32,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = intentRule.getIntent(); // Render a texture. intent.putExtra("use_android_view", false); intent.putExtra("view_type", PlatformViewsActivity.SURFACE_VIEW_BAD_CONTEXT_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridFallbackUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridFallbackUiTest.java index 578c686fb4e40..fed96c56d98c9 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridFallbackUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridFallbackUiTest.java @@ -19,6 +19,7 @@ @LargeTest public class PlatformViewWithSurfaceViewHybridFallbackUiTest { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -31,7 +32,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = intentRule.getIntent(); // Request TLHC with fallback to HC. intent.putExtra("use_android_view", false); intent.putExtra("expect_android_view_fallback", true); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridUiTest.java index 81938ec39b145..789e125452d3d 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridUiTest.java @@ -19,6 +19,7 @@ @LargeTest public class PlatformViewWithSurfaceViewHybridUiTest { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -31,7 +32,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = intentRule.getIntent(); intent.putExtra("use_android_view", true); intent.putExtra("view_type", PlatformViewsActivity.SURFACE_VIEW_PV); } diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java index b445a3d8407a5..09d0d0260bedd 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java @@ -21,6 +21,7 @@ @LargeTest public class PlatformViewWithSurfaceViewUiTest { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -33,7 +34,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = inentRule.getIntent(); // Render a texture. intent.putExtra("use_android_view", false); intent.putExtra("view_type", PlatformViewsActivity.SURFACE_VIEW_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java index 9a8dfd99878ee..8596977201af0 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java @@ -20,6 +20,7 @@ @LargeTest public class PlatformViewWithTextureViewUiTest { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -32,7 +33,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = intentRule.getIntent(); intent.putExtra("view_type", PlatformViewsActivity.TEXTURE_VIEW_PV); } diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java index 80e3f12cff005..acbac5367426f 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java @@ -19,6 +19,7 @@ @LargeTest public class SpawnEngineTests { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -27,7 +28,7 @@ public class SpawnEngineTests { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = intentRule.getIntent(); } @Test diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java index bc1017b76039d..3cd081bb4351c 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java @@ -19,6 +19,7 @@ @LargeTest public class SpawnMultiEngineTest { Intent intent; + @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -27,7 +28,7 @@ public class SpawnMultiEngineTest { @Before public void setUp() { - intent = new Intent(Intent.ACTION_MAIN); + intent = intentRule.getIntent(); } @Test diff --git a/testing/scenario_app/bin/run_android_tests.dart b/testing/scenario_app/bin/run_android_tests.dart index f0ad8276b0465..47a98ae6efdea 100644 --- a/testing/scenario_app/bin/run_android_tests.dart +++ b/testing/scenario_app/bin/run_android_tests.dart @@ -294,6 +294,7 @@ Future _run({ late Process logcatProcess; late Future logcatProcessExitCode; + bool seenImpeller = false; final IOSink logcat = File(logcatPath).openWrite(); try { @@ -314,6 +315,9 @@ Future _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); @@ -414,11 +418,11 @@ Future _run({ '-w', if (smokeTestFullPath != null) '-e class $smokeTestFullPath', - 'dev.flutter.scenarios.test/dev.flutter.TestRunner', if (enableImpeller) - '-e enable-impeller', + '-e enable-impeller true', if (impellerBackend != null) '-e impeller-backend ${impellerBackend.name}', + 'dev.flutter.scenarios.test/dev.flutter.TestRunner', ]); if (exitCode != 0) { panic(['instrumented tests failed to run']); @@ -446,6 +450,16 @@ Future _run({ log('wrote logcat to $logcatPath'); }); + if (enableImpeller) { + await step('Validating Impeller...', () { + if (!seenImpeller) { + panic([ + '--enable-impeller was specified, but Impeller was not used.', + ]); + } + }); + } + await step('Symbolize stack traces', () async { final ProcessResult result = await pm.run( [ From 96c4fb8aa3af30c770f8c97be06f8e087796f6ef Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 26 Feb 2024 12:32:28 -0800 Subject: [PATCH 2/6] typo --- .../flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java index 09d0d0260bedd..9b55b72192092 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java @@ -34,7 +34,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = inentRule.getIntent(); + intent = intentRule.getIntent(); // Render a texture. intent.putExtra("use_android_view", false); intent.putExtra("view_type", PlatformViewsActivity.SURFACE_VIEW_PV); From d629b0d453cb549d05a6bae96c618330111233e6 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 26 Feb 2024 12:35:00 -0800 Subject: [PATCH 3/6] fix one more test --- .../flutter/scenariosui/ExternalTextureTests.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java index 6832f5395bb64..fea708e516e71 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java @@ -34,9 +34,13 @@ public class ExternalTextureTests { @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); + @Before + public void setUp() { + intent = intentRule.getIntent(); + } + @Test public void testCanvasSurface() throws Exception { - Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "canvas"); ScreenshotUtil.capture( @@ -46,7 +50,6 @@ public void testCanvasSurface() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) public void testMediaSurface() throws Exception { - Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "media"); ScreenshotUtil.capture( @@ -56,7 +59,6 @@ public void testMediaSurface() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) public void testRotatedMediaSurface_90() throws Exception { - Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "media"); intent.putExtra("rotation", 90); @@ -67,7 +69,6 @@ public void testRotatedMediaSurface_90() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) public void testRotatedMediaSurface_180() throws Exception { - Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "media"); intent.putExtra("rotation", 180); @@ -78,7 +79,6 @@ public void testRotatedMediaSurface_180() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) public void testRotatedMediaSurface_270() throws Exception { - Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "media"); intent.putExtra("rotation", 270); @@ -89,7 +89,6 @@ public void testRotatedMediaSurface_270() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.M) public void testCroppedMediaSurface_bottomLeft() throws Exception { - Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "image"); intent.putExtra("crop", new Rect(0, 0, SURFACE_WIDTH / 2, SURFACE_HEIGHT / 2)); @@ -101,7 +100,6 @@ public void testCroppedMediaSurface_bottomLeft() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.M) public void testCroppedMediaSurface_topRight() throws Exception { - Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "image"); intent.putExtra( @@ -114,7 +112,6 @@ public void testCroppedMediaSurface_topRight() throws Exception { @Test @SdkSuppress(minSdkVersion = VERSION_CODES.M) public void testCroppedRotatedMediaSurface_bottomLeft_90() throws Exception { - Intent intent = intentRule.getIntent(); intent.putExtra("scenario_name", "display_texture"); intent.putExtra("surface_renderer", "image"); intent.putExtra("crop", new Rect(0, 0, SURFACE_WIDTH / 2, SURFACE_HEIGHT / 2)); From 7e3c8d4a6fb00e0978c5e67d9cf5ce4a9ca2af7f Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 26 Feb 2024 12:50:17 -0800 Subject: [PATCH 4/6] :( --- .../java/dev/flutter/scenariosui/ExternalTextureTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java index fea708e516e71..7ab6935727f7d 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java @@ -13,6 +13,7 @@ import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; import dev.flutter.scenarios.ExternalTextureFlutterActivity; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; From 7c647d799460a94d7c648f855f9984fe90aa239f Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 26 Feb 2024 13:20:16 -0800 Subject: [PATCH 5/6] fix script --- testing/scenario_app/bin/run_android_tests.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/scenario_app/bin/run_android_tests.dart b/testing/scenario_app/bin/run_android_tests.dart index e89b5878db199..fc35c1ed5e41a 100644 --- a/testing/scenario_app/bin/run_android_tests.dart +++ b/testing/scenario_app/bin/run_android_tests.dart @@ -475,7 +475,7 @@ Future _run({ }); if (enableImpeller) { - await step('Validating Impeller...', () { + await step('Validating Impeller...', () async { if (!seenImpeller) { panic([ '--enable-impeller was specified, but Impeller was not used.', From 0b852a25638b64c1ab994bce165eb404b7a30e95 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 26 Feb 2024 17:54:14 -0800 Subject: [PATCH 6/6] better --- testing/scenario_app/android/BUILD.gn | 2 - .../java/dev/flutter/TestRunner.java | 11 +++ .../scenarios/EngineLaunchE2ETest.java | 83 ------------------- .../scenariosui/ArgumentAwareIntent.java | 48 ----------- .../scenariosui/DrawSolidBlueScreenTest.java | 4 +- .../scenariosui/ExternalTextureTests.java | 4 +- .../flutter/scenariosui/GetBitmapTests.java | 4 +- .../flutter/scenariosui/MemoryLeakTests.java | 4 +- .../scenariosui/PlatformTextureUiTests.java | 3 +- .../scenariosui/PlatformViewUiTests.java | 3 +- ...rmViewWithSurfaceViewBadContextUiTest.java | 3 +- ...ewWithSurfaceViewHybridFallbackUiTest.java | 3 +- ...atformViewWithSurfaceViewHybridUiTest.java | 3 +- .../PlatformViewWithSurfaceViewUiTest.java | 3 +- .../PlatformViewWithTextureViewUiTest.java | 3 +- .../flutter/scenariosui/SpawnEngineTests.java | 3 +- .../scenariosui/SpawnMultiEngineTest.java | 3 +- testing/scenario_app/lib/main.dart | 15 ++-- 18 files changed, 29 insertions(+), 173 deletions(-) delete mode 100644 testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java delete mode 100644 testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ArgumentAwareIntent.java diff --git a/testing/scenario_app/android/BUILD.gn b/testing/scenario_app/android/BUILD.gn index aff99a3e6ebc3..8d00892fa5726 100644 --- a/testing/scenario_app/android/BUILD.gn +++ b/testing/scenario_app/android/BUILD.gn @@ -7,9 +7,7 @@ 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/ArgumentAwareIntent.java", "app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java", "app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java", "app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java", diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/TestRunner.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/TestRunner.java index 18962141cca02..ac9b70cce61a5 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/TestRunner.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/TestRunner.java @@ -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); } diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java deleted file mode 100644 index ab874f45fb741..0000000000000 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2013 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. - -package dev.flutter.scenarios; - -import static org.junit.Assert.fail; - -import android.content.Context; -import androidx.test.InstrumentationRegistry; -import androidx.test.internal.runner.junit4.statement.UiThreadStatement; -import androidx.test.runner.AndroidJUnit4; -import com.google.common.util.concurrent.SettableFuture; -import io.flutter.embedding.engine.FlutterEngine; -import io.flutter.embedding.engine.dart.DartExecutor; -import java.util.Arrays; -import java.util.Locale; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicReference; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -public class EngineLaunchE2ETest { - @Test - public void smokeTestEngineLaunch() throws Throwable { - Context applicationContext = InstrumentationRegistry.getTargetContext(); - // Specifically, create the engine without running FlutterMain first. - final AtomicReference engine = new AtomicReference<>(); - - // Run the production under test on the UI thread instead of annotating the whole test - // as @UiThreadTest because having the message handler and the CompletableFuture both being - // on the same thread will create deadlocks. - UiThreadStatement.runOnUiThread( - () -> - engine.set( - new FlutterEngine( - applicationContext, - /*dartVmArgs */ null, - /* automaticallyRegisterPlugins */ false))); - SettableFuture statusReceived = SettableFuture.create(); - - // Resolve locale to `en_US`. - // This is required, so `window.locale` in populated in dart. - // TODO: Fix race condition between sending this over the channel and starting the entrypoint. - // https://github.com/flutter/flutter/issues/55999 - UiThreadStatement.runOnUiThread( - () -> engine.get().getLocalizationChannel().sendLocales(Arrays.asList(Locale.US))); - - // The default Dart main entrypoint sends back a platform message on the "waiting_for_status" - // channel. That will be our launch success assertion condition. - engine - .get() - .getDartExecutor() - .setMessageHandler( - "waiting_for_status", (byteBuffer, binaryReply) -> statusReceived.set(Boolean.TRUE)); - - // Launching the entrypoint will run the Dart code that sends the "waiting_for_status" platform - // message. - UiThreadStatement.runOnUiThread( - () -> - engine - .get() - .getDartExecutor() - .executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault())); - - try { - Boolean result = statusReceived.get(10, TimeUnit.SECONDS); - if (!result) { - fail("expected message on waiting_for_status not received"); - } - } catch (ExecutionException e) { - fail(e.getMessage()); - } catch (InterruptedException e) { - fail(e.getMessage()); - } catch (TimeoutException e) { - fail("timed out waiting for engine started signal"); - } - // If it gets to here, statusReceived is true. - } -} diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ArgumentAwareIntent.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ArgumentAwareIntent.java deleted file mode 100644 index 86492652281a6..0000000000000 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ArgumentAwareIntent.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2013 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. - -package dev.flutter.scenariosui; - -import android.content.Intent; -import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.test.InstrumentationRegistry; -import io.flutter.embedding.engine.FlutterShellArgs; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -public class ArgumentAwareIntent implements TestRule { - public ArgumentAwareIntent() { - this.intent = new Intent(Intent.ACTION_MAIN); - } - - public ArgumentAwareIntent(@NonNull Intent intent) { - this.intent = intent; - } - - private @NonNull Intent intent; - - public @NonNull Intent getIntent() { - return intent; - } - - @Override - public @NonNull Statement apply(@NonNull Statement base, @NonNull Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - Bundle arguments = InstrumentationRegistry.getArguments(); - if ("true".equals(arguments.getString(FlutterShellArgs.ARG_KEY_ENABLE_IMPELLER))) { - getIntent().putExtra(FlutterShellArgs.ARG_KEY_ENABLE_IMPELLER, true); - String backend = arguments.getString("impeller-backend"); - if (backend != null) { - getIntent().putExtra("impeller-backend", backend); - } - } - base.evaluate(); - } - }; - } -} diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java index 0dec7e6f459ae..b61a69f7848bd 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/DrawSolidBlueScreenTest.java @@ -18,11 +18,9 @@ public final class DrawSolidBlueScreenTest { new ActivityTestRule<>( PlatformViewsActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false); - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); - @Test public void test() throws Exception { - Intent intent = intentRule.getIntent(); + Intent intent = new Intent(Intent.ACTION_MAIN); intent.putExtra("scenario_name", "solid_blue"); ScreenshotUtil.capture(activityRule.launchActivity(intent), "DrawSolidBlueScreenTest"); } diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java index 7ab6935727f7d..37d96fa3e261f 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java @@ -33,11 +33,9 @@ public class ExternalTextureTests { /*initialTouchMode=*/ false, /*launchActivity=*/ false); - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); - @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); } @Test diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java index ccf203cd70ce5..4b44da007f482 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/GetBitmapTests.java @@ -25,11 +25,9 @@ public class GetBitmapTests { new ActivityTestRule<>( GetBitmapActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false); - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); - @Test public void getBitmap() throws Exception { - Intent intent = intentRule.getIntent(); + Intent intent = new Intent(Intent.ACTION_MAIN); intent.putExtra("scenario_name", "get_bitmap"); GetBitmapActivity activity = activityRule.launchActivity(intent); Bitmap bitmap = activity.getBitmap(); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java index af8fb1cc5bdd9..7fbf4bdb9b218 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java @@ -23,12 +23,10 @@ public class MemoryLeakTests { new ActivityTestRule<>( PlatformViewsActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false); - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); - @Test @FailTestOnLeak public void platformViewHybridComposition_launchActivityFinishAndLaunchAgain() throws Exception { - Intent intent = intentRule.getIntent(); + Intent intent = new Intent(Intent.ACTION_MAIN); intent.putExtra("scenario_name", "platform_view"); intent.putExtra("use_android_view", true); intent.putExtra("view_type", PlatformViewsActivity.TEXT_VIEW_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java index 84bea2a3cee6a..a4aa061f2a82c 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java @@ -20,7 +20,6 @@ @LargeTest public class PlatformTextureUiTests { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -33,7 +32,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); // Render a texture. intent.putExtra("use_android_view", false); intent.putExtra("view_type", PlatformViewsActivity.TEXT_VIEW_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java index dcbe4a3f075cf..50dc5dfef600b 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java @@ -20,7 +20,6 @@ @LargeTest public class PlatformViewUiTests { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -33,7 +32,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); // Render a native android view. intent.putExtra("use_android_view", true); intent.putExtra("view_type", PlatformViewsActivity.TEXT_VIEW_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewBadContextUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewBadContextUiTest.java index 41357ae6fa28e..a036a90a73e02 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewBadContextUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewBadContextUiTest.java @@ -19,7 +19,6 @@ @LargeTest public class PlatformViewWithSurfaceViewBadContextUiTest { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -32,7 +31,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); // Render a texture. intent.putExtra("use_android_view", false); intent.putExtra("view_type", PlatformViewsActivity.SURFACE_VIEW_BAD_CONTEXT_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridFallbackUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridFallbackUiTest.java index fed96c56d98c9..578c686fb4e40 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridFallbackUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridFallbackUiTest.java @@ -19,7 +19,6 @@ @LargeTest public class PlatformViewWithSurfaceViewHybridFallbackUiTest { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -32,7 +31,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); // Request TLHC with fallback to HC. intent.putExtra("use_android_view", false); intent.putExtra("expect_android_view_fallback", true); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridUiTest.java index 789e125452d3d..81938ec39b145 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewHybridUiTest.java @@ -19,7 +19,6 @@ @LargeTest public class PlatformViewWithSurfaceViewHybridUiTest { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -32,7 +31,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); intent.putExtra("use_android_view", true); intent.putExtra("view_type", PlatformViewsActivity.SURFACE_VIEW_PV); } diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java index 9b55b72192092..b445a3d8407a5 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithSurfaceViewUiTest.java @@ -21,7 +21,6 @@ @LargeTest public class PlatformViewWithSurfaceViewUiTest { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -34,7 +33,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); // Render a texture. intent.putExtra("use_android_view", false); intent.putExtra("view_type", PlatformViewsActivity.SURFACE_VIEW_PV); diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java index 8596977201af0..9a8dfd99878ee 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java @@ -20,7 +20,6 @@ @LargeTest public class PlatformViewWithTextureViewUiTest { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -33,7 +32,7 @@ private static String goldName(String suffix) { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); intent.putExtra("view_type", PlatformViewsActivity.TEXTURE_VIEW_PV); } diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java index acbac5367426f..80e3f12cff005 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java @@ -19,7 +19,6 @@ @LargeTest public class SpawnEngineTests { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -28,7 +27,7 @@ public class SpawnEngineTests { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); } @Test diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java index 3cd081bb4351c..bc1017b76039d 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java @@ -19,7 +19,6 @@ @LargeTest public class SpawnMultiEngineTest { Intent intent; - @Rule @NonNull public ArgumentAwareIntent intentRule = new ArgumentAwareIntent(); @Rule @NonNull public ActivityTestRule activityRule = @@ -28,7 +27,7 @@ public class SpawnMultiEngineTest { @Before public void setUp() { - intent = intentRule.getIntent(); + intent = new Intent(Intent.ACTION_MAIN); } @Test diff --git a/testing/scenario_app/lib/main.dart b/testing/scenario_app/lib/main.dart index 6116bb1a80d82..5e76f1d7306bf 100644 --- a/testing/scenario_app/lib/main.dart +++ b/testing/scenario_app/lib/main.dart @@ -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);