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.util.Log; 21 import android.webkit.WebView; 22 import android.webkit.cts.WebViewSyncLoader; 23 24 import androidx.test.annotation.UiThreadTest; 25 import androidx.test.ext.junit.rules.ActivityScenarioRule; 26 27 import org.junit.Assert; 28 import org.junit.Before; 29 import org.junit.Rule; 30 import org.junit.Test; 31 32 import java.io.IOException; 33 34 public class WebViewDeviceSideMultipleProfileTest { 35 // Profile owner component. 36 public static class BasicAdminReceiver extends DeviceAdminReceiver {} 37 38 @Rule 39 public ActivityScenarioRule<WebViewStartupCtsActivity> mActivityRule = 40 new ActivityScenarioRule<>(WebViewStartupCtsActivity.class); 41 42 private WebViewStartupCtsActivity mActivity; 43 44 @Before setUp()45 public void setUp() { 46 mActivityRule.getScenario().onActivity(activity -> { 47 mActivity = activity; 48 }); 49 } 50 51 @Test 52 @UiThreadTest testCreateWebViewAndNavigate()53 public void testCreateWebViewAndNavigate() { 54 mActivity.createAndAttachWebView(); 55 WebView webView = mActivity.getWebView(); 56 Assert.assertNotNull(webView); 57 58 WebViewSyncLoader syncLoader = new WebViewSyncLoader(webView); 59 syncLoader.loadUrlAndWaitForCompletion("about:blank"); 60 syncLoader.detach(); 61 } 62 63 64 } 65