Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PlatformViewUiTests.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
23public class PlatformViewUiTests {
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 "PlatformViewUiTests_" + suffix;
34 }
35
36 @Before
37 public void setUp() {
38 instrumentation = InstrumentationRegistry.getInstrumentation();
39 intent = new Intent(Intent.ACTION_MAIN);
40 // Render a native android view.
41 intent.putExtra("use_android_view", true);
42 intent.putExtra("view_type", PlatformViewsActivity.TEXT_VIEW_PV);
43 }
44
45 @Test
46 public void testPlatformView() throws Exception {
47 intent.putExtra("scenario_name", "platform_view");
48 ScreenshotUtil.capture(activityRule.launchActivity(intent), goldName("testPlatformView"));
49 }
50
51 @Test
52 public void testPlatformViewMultiple() throws Exception {
53 intent.putExtra("scenario_name", "platform_view_multiple");
55 activityRule.launchActivity(intent), goldName("testPlatformViewMultiple"));
56 }
57
58 @Test
59 public void testPlatformViewMultipleBackgroundForeground() throws Exception {
60 intent.putExtra("scenario_name", "platform_view_multiple_background_foreground");
62 activityRule.launchActivity(intent),
63 goldName("testPlatformViewMultipleBackgroundForeground"));
64 }
65
66 @Test
67 public void testPlatformViewCliprect() throws Exception {
68 intent.putExtra("scenario_name", "platform_view_cliprect");
70 activityRule.launchActivity(intent), goldName("testPlatformViewCliprect"));
71 }
72
73 @Test
74 public void testPlatformViewCliprrect() throws Exception {
75 intent.putExtra("scenario_name", "platform_view_cliprrect");
77 activityRule.launchActivity(intent), goldName("testPlatformViewCliprrect"));
78 }
79
80 @Test
81 public void testPlatformViewClippath() throws Exception {
82 intent.putExtra("scenario_name", "platform_view_clippath");
84 activityRule.launchActivity(intent), goldName("testPlatformViewClippath"));
85 }
86
87 @Test
88 public void testPlatformViewTransform() throws Exception {
89 intent.putExtra("scenario_name", "platform_view_transform");
91 activityRule.launchActivity(intent), goldName("testPlatformViewTransform"));
92 }
93
94 @Test
95 public void testPlatformViewOpacity() throws Exception {
96 intent.putExtra("scenario_name", "platform_view_opacity");
98 activityRule.launchActivity(intent), goldName("testPlatformViewOpacity"));
99 }
100
101 @Test
102 public void testPlatformViewRotate() throws Exception {
103 intent.putExtra("scenario_name", "platform_view_rotate");
104 PlatformViewsActivity activity = activityRule.launchActivity(intent);
105 activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
106 instrumentation.waitForIdleSync();
107 ScreenshotUtil.capture(activity, goldName("testPlatformViewRotate"));
108 }
109
110 @Test
111 public void testPlatformViewMultipleWithoutOverlays() throws Exception {
112 intent.putExtra("scenario_name", "platform_view_multiple_without_overlays");
114 activityRule.launchActivity(intent), goldName("testPlatformViewMultipleWithoutOverlays"));
115 }
116
117 @Test
118 public void testPlatformViewTwoIntersectingOverlays() throws Exception {
119 intent.putExtra("scenario_name", "platform_view_two_intersecting_overlays");
121 activityRule.launchActivity(intent), goldName("testPlatformViewTwoIntersectingOverlays"));
122 }
123
124 @Test
125 public void testPlatformViewWithoutOverlayIntersection() throws Exception {
126 intent.putExtra("scenario_name", "platform_view_no_overlay_intersection");
128 activityRule.launchActivity(intent),
129 goldName("testPlatformViewWithoutOverlayIntersection"));
130 }
131}
ActivityTestRule< PlatformViewsActivity > activityRule
static void capture(@NonNull TestableFlutterActivity activity, @NonNull String captureName)