5package dev.flutter.scenariosui;
7import android.app.Instrumentation;
9import android.content.pm.ActivityInfo;
10import androidx.annotation.NonNull;
11import androidx.test.ext.junit.runners.AndroidJUnit4;
12import androidx.test.filters.LargeTest;
13import androidx.test.platform.app.InstrumentationRegistry;
14import androidx.test.rule.ActivityTestRule;
15import dev.flutter.scenarios.PlatformViewsActivity;
16import org.junit.Before;
19import org.junit.runner.RunWith;
21@RunWith(AndroidJUnit4.class)
24 private Instrumentation instrumentation;
25 private Intent intent;
29 new ActivityTestRule<>(
32 private static String goldName(String
suffix) {
33 return "PlatformViewUiTests_" +
suffix;
38 instrumentation = InstrumentationRegistry.getInstrumentation();
39 intent =
new Intent(Intent.ACTION_MAIN);
41 intent.putExtra(
"use_android_view",
true);
47 intent.putExtra(
"scenario_name",
"platform_view");
53 intent.putExtra(
"scenario_name",
"platform_view_multiple");
55 activityRule.launchActivity(intent), goldName(
"testPlatformViewMultiple"));
60 intent.putExtra(
"scenario_name",
"platform_view_multiple_background_foreground");
63 goldName(
"testPlatformViewMultipleBackgroundForeground"));
68 intent.putExtra(
"scenario_name",
"platform_view_cliprect");
70 activityRule.launchActivity(intent), goldName(
"testPlatformViewCliprect"));
75 intent.putExtra(
"scenario_name",
"platform_view_cliprrect");
77 activityRule.launchActivity(intent), goldName(
"testPlatformViewCliprrect"));
82 intent.putExtra(
"scenario_name",
"platform_view_clippath");
84 activityRule.launchActivity(intent), goldName(
"testPlatformViewClippath"));
89 intent.putExtra(
"scenario_name",
"platform_view_transform");
91 activityRule.launchActivity(intent), goldName(
"testPlatformViewTransform"));
96 intent.putExtra(
"scenario_name",
"platform_view_opacity");
98 activityRule.launchActivity(intent), goldName(
"testPlatformViewOpacity"));
103 intent.putExtra(
"scenario_name",
"platform_view_rotate");
105 activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
106 instrumentation.waitForIdleSync();
112 intent.putExtra(
"scenario_name",
"platform_view_multiple_without_overlays");
114 activityRule.launchActivity(intent), goldName(
"testPlatformViewMultipleWithoutOverlays"));
119 intent.putExtra(
"scenario_name",
"platform_view_two_intersecting_overlays");
121 activityRule.launchActivity(intent), goldName(
"testPlatformViewTwoIntersectingOverlays"));
126 intent.putExtra(
"scenario_name",
"platform_view_no_overlay_intersection");
129 goldName(
"testPlatformViewWithoutOverlayIntersection"));
static void capture(@NonNull TestableFlutterActivity activity, @NonNull String captureName)