Flutter Engine
The Flutter Engine
PlatformViewWithTextureViewUiTest.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package dev.flutter.scenariosui;
6
7import android.app.Instrumentation;
8import android.content.Intent;
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;
17import org.junit.Rule;
18import org.junit.Test;
19import org.junit.runner.RunWith;
20
21@RunWith(AndroidJUnit4.class)
22@LargeTest
24 private Instrumentation instrumentation;
25 private Intent intent;
26
27 @Rule @NonNull
28 public ActivityTestRule<PlatformViewsActivity> activityRule =
29 new ActivityTestRule<>(
30 PlatformViewsActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false);
31
32 private static String goldName(String suffix) {
33 return "PlatformViewWithTextureViewUiTest_" + suffix;
34 }
35
36 @Before
37 public void setUp() {
38 instrumentation = InstrumentationRegistry.getInstrumentation();
39 intent = new Intent(Intent.ACTION_MAIN);
40 intent.putExtra("view_type", PlatformViewsActivity.TEXTURE_VIEW_PV);
41 }
42
43 @Test
44 public void testPlatformView() throws Exception {
45 intent.putExtra("scenario_name", "platform_view");
46 ScreenshotUtil.capture(activityRule.launchActivity(intent), goldName("testPlatformView"));
47 }
48
49 @Test
50 public void testPlatformViewMultiple() throws Exception {
51 intent.putExtra("scenario_name", "platform_view_multiple");
53 activityRule.launchActivity(intent), goldName("testPlatformViewMultiple"));
54 }
55
56 @Test
57 public void testPlatformViewMultipleBackgroundForeground() throws Exception {
58 intent.putExtra("scenario_name", "platform_view_multiple_background_foreground");
60 activityRule.launchActivity(intent),
61 goldName("testPlatformViewMultipleBackgroundForeground"));
62 }
63
64 @Test
65 public void testPlatformViewCliprect() throws Exception {
66 intent.putExtra("scenario_name", "platform_view_cliprect");
68 activityRule.launchActivity(intent), goldName("testPlatformViewCliprect"));
69 }
70
71 @Test
72 public void testPlatformViewCliprrect() throws Exception {
73 intent.putExtra("scenario_name", "platform_view_cliprrect");
75 activityRule.launchActivity(intent), goldName("testPlatformViewCliprrect"));
76 }
77
78 @Test
79 public void testPlatformViewClippath() throws Exception {
80 intent.putExtra("scenario_name", "platform_view_clippath");
82 activityRule.launchActivity(intent), goldName("testPlatformViewClippath"));
83 }
84
85 @Test
86 public void testPlatformViewTransform() throws Exception {
87 intent.putExtra("scenario_name", "platform_view_transform");
89 activityRule.launchActivity(intent), goldName("testPlatformViewTransform"));
90 }
91
92 @Test
93 public void testPlatformViewOpacity() throws Exception {
94 intent.putExtra("scenario_name", "platform_view_opacity");
96 activityRule.launchActivity(intent), goldName("testPlatformViewOpacity"));
97 }
98
99 @Test
100 public void testPlatformViewRotate() throws Exception {
101 intent.putExtra("scenario_name", "platform_view_rotate");
102 PlatformViewsActivity activity = activityRule.launchActivity(intent);
103 activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
104 instrumentation.waitForIdleSync();
105 ScreenshotUtil.capture(activity, goldName("testPlatformViewRotate"));
106 }
107
108 @Test
109 public void testPlatformViewMultipleWithoutOverlays() throws Exception {
110 intent.putExtra("scenario_name", "platform_view_multiple_without_overlays");
112 activityRule.launchActivity(intent), goldName("testPlatformViewMultipleWithoutOverlays"));
113 }
114
115 @Test
116 public void testPlatformViewTwoIntersectingOverlays() throws Exception {
117 intent.putExtra("scenario_name", "platform_view_two_intersecting_overlays");
119 activityRule.launchActivity(intent), goldName("testPlatformViewTwoIntersectingOverlays"));
120 }
121
122 @Test
123 public void testPlatformViewWithoutOverlayIntersection() throws Exception {
124 intent.putExtra("scenario_name", "platform_view_no_overlay_intersection");
126 activityRule.launchActivity(intent),
127 goldName("testPlatformViewWithoutOverlayIntersection"));
128 }
129}
static void capture(@NonNull TestableFlutterActivity activity, @NonNull String captureName)