Flutter Engine
The Flutter Engine
PlatformViewWithSurfaceViewHybridFallbackUiTest.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.content.Intent;
8import androidx.annotation.NonNull;
9import androidx.test.ext.junit.runners.AndroidJUnit4;
10import androidx.test.filters.LargeTest;
11import androidx.test.rule.ActivityTestRule;
12import dev.flutter.scenarios.PlatformViewsActivity;
13import org.junit.Before;
14import org.junit.Rule;
15import org.junit.Test;
16import org.junit.runner.RunWith;
17
18@RunWith(AndroidJUnit4.class)
19@LargeTest
21 Intent intent;
22
23 @Rule @NonNull
24 public ActivityTestRule<PlatformViewsActivity> activityRule =
25 new ActivityTestRule<>(
26 PlatformViewsActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false);
27
28 private static String goldName(String suffix) {
29 return "PlatformViewWithSurfaceViewHybridFallbackUiTest_" + suffix;
30 }
31
32 @Before
33 public void setUp() {
34 intent = new Intent(Intent.ACTION_MAIN);
35 // Request TLHC with fallback to HC.
36 intent.putExtra("use_android_view", false);
37 intent.putExtra("expect_android_view_fallback", true);
38 // Use a SurfaceView to trigger fallback.
39 intent.putExtra("view_type", PlatformViewsActivity.SURFACE_VIEW_PV);
40 }
41
42 @Test
43 public void testPlatformView() throws Exception {
44 intent.putExtra("scenario_name", "platform_view");
45 ScreenshotUtil.capture(activityRule.launchActivity(intent), goldName("testPlatformView"));
46 }
47}
static void capture(@NonNull TestableFlutterActivity activity, @NonNull String captureName)