1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.cts.webkit; 18 19 import android.app.admin.DeviceAdminReceiver; 20 import android.webkit.WebView; 21 import android.webkit.cts.WebViewSyncLoader; 22 23 import androidx.test.annotation.UiThreadTest; 24 import androidx.test.ext.junit.rules.ActivityScenarioRule; 25 26 import com.android.compatibility.common.util.NullWebViewUtils; 27 28 import org.junit.Assert; 29 import org.junit.Before; 30 import org.junit.Rule; 31 import org.junit.Test; 32 33 public class WebViewDeviceSideMultipleProfileTest { 34 // Profile owner component. 35 public static class BasicAdminReceiver extends DeviceAdminReceiver {} 36 37 @Rule 38 public ActivityScenarioRule<WebViewStartupCtsActivity> mActivityRule = 39 new ActivityScenarioRule<>(WebViewStartupCtsActivity.class); 40 41 private WebViewStartupCtsActivity mActivity; 42 43 @Before setUp()44 public void setUp() { 45 mActivityRule.getScenario().onActivity(activity -> { 46 mActivity = activity; 47 }); 48 } 49 50 @Test 51 @UiThreadTest testCreateWebViewAndNavigate()52 public void testCreateWebViewAndNavigate() { 53 if (!NullWebViewUtils.isWebViewAvailable()) { 54 return; 55 } 56 57 mActivity.createAndAttachWebView(); 58 WebView webView = mActivity.getWebView(); 59 Assert.assertNotNull(webView); 60 61 WebViewSyncLoader syncLoader = new WebViewSyncLoader(webView); 62 syncLoader.loadUrlAndWaitForCompletion("about:blank"); 63 syncLoader.detach(); 64 } 65 66 67 } 68