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..bb09a981247f7 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 @@ -4,10 +4,12 @@ package dev.flutter.scenariosui; +import android.app.Instrumentation; import android.content.Intent; import android.content.pm.ActivityInfo; import androidx.annotation.NonNull; import androidx.test.filters.LargeTest; +import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; import dev.flutter.scenarios.PlatformViewsActivity; @@ -19,7 +21,8 @@ @RunWith(AndroidJUnit4.class) @LargeTest public class PlatformTextureUiTests { - Intent intent; + private Instrumentation instrumentation; + private Intent intent; @Rule @NonNull public ActivityTestRule activityRule = @@ -32,6 +35,7 @@ private static String goldName(String suffix) { @Before public void setUp() { + instrumentation = InstrumentationRegistry.getInstrumentation(); intent = new Intent(Intent.ACTION_MAIN); // Render a texture. intent.putExtra("use_android_view", false); @@ -99,6 +103,7 @@ public void testPlatformViewRotate() throws Exception { intent.putExtra("scenario_name", "platform_view_rotate"); PlatformViewsActivity activity = activityRule.launchActivity(intent); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + instrumentation.waitForIdleSync(); ScreenshotUtil.capture(activity, goldName("testPlatformViewRotate")); } 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..12cb44044361f 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 @@ -4,10 +4,12 @@ package dev.flutter.scenariosui; +import android.app.Instrumentation; import android.content.Intent; import android.content.pm.ActivityInfo; import androidx.annotation.NonNull; import androidx.test.filters.LargeTest; +import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; import dev.flutter.scenarios.PlatformViewsActivity; @@ -19,7 +21,8 @@ @RunWith(AndroidJUnit4.class) @LargeTest public class PlatformViewUiTests { - Intent intent; + private Instrumentation instrumentation; + private Intent intent; @Rule @NonNull public ActivityTestRule activityRule = @@ -32,6 +35,7 @@ private static String goldName(String suffix) { @Before public void setUp() { + instrumentation = InstrumentationRegistry.getInstrumentation(); intent = new Intent(Intent.ACTION_MAIN); // Render a native android view. intent.putExtra("use_android_view", true); @@ -99,6 +103,7 @@ public void testPlatformViewRotate() throws Exception { intent.putExtra("scenario_name", "platform_view_rotate"); PlatformViewsActivity activity = activityRule.launchActivity(intent); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + instrumentation.waitForIdleSync(); ScreenshotUtil.capture(activity, goldName("testPlatformViewRotate")); } 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..b5d62993bd456 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 @@ -4,10 +4,12 @@ package dev.flutter.scenariosui; +import android.app.Instrumentation; import android.content.Intent; import android.content.pm.ActivityInfo; import androidx.annotation.NonNull; import androidx.test.filters.LargeTest; +import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; import dev.flutter.scenarios.PlatformViewsActivity; @@ -20,7 +22,8 @@ @RunWith(AndroidJUnit4.class) @LargeTest public class PlatformViewWithSurfaceViewUiTest { - Intent intent; + private Instrumentation instrumentation; + private Intent intent; @Rule @NonNull public ActivityTestRule activityRule = @@ -33,6 +36,7 @@ private static String goldName(String suffix) { @Before public void setUp() { + instrumentation = InstrumentationRegistry.getInstrumentation(); intent = new Intent(Intent.ACTION_MAIN); // Render a texture. intent.putExtra("use_android_view", false); @@ -100,6 +104,7 @@ public void testPlatformViewRotate() throws Exception { intent.putExtra("scenario_name", "platform_view_rotate"); PlatformViewsActivity activity = activityRule.launchActivity(intent); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + instrumentation.waitForIdleSync(); ScreenshotUtil.capture(activity, goldName("testPlatformViewRotate")); } 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..c2039b59f4508 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 @@ -4,10 +4,12 @@ package dev.flutter.scenariosui; +import android.app.Instrumentation; import android.content.Intent; import android.content.pm.ActivityInfo; import androidx.annotation.NonNull; import androidx.test.filters.LargeTest; +import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; import dev.flutter.scenarios.PlatformViewsActivity; @@ -19,7 +21,8 @@ @RunWith(AndroidJUnit4.class) @LargeTest public class PlatformViewWithTextureViewUiTest { - Intent intent; + private Instrumentation instrumentation; + private Intent intent; @Rule @NonNull public ActivityTestRule activityRule = @@ -32,6 +35,7 @@ private static String goldName(String suffix) { @Before public void setUp() { + instrumentation = InstrumentationRegistry.getInstrumentation(); intent = new Intent(Intent.ACTION_MAIN); intent.putExtra("view_type", PlatformViewsActivity.TEXTURE_VIEW_PV); } @@ -97,6 +101,7 @@ public void testPlatformViewRotate() throws Exception { intent.putExtra("scenario_name", "platform_view_rotate"); PlatformViewsActivity activity = activityRule.launchActivity(intent); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + instrumentation.waitForIdleSync(); ScreenshotUtil.capture(activity, goldName("testPlatformViewRotate")); }