1 /* 2 * Copyright (C) 2024 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 android.resources.cts; 18 19 import android.content.res.Flags; 20 import android.platform.test.annotations.AppModeFull; 21 import android.platform.test.annotations.RequiresFlagsEnabled; 22 import android.platform.test.flag.junit.CheckFlagsRule; 23 import android.platform.test.flag.junit.host.HostFlagsValueProvider; 24 25 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; 26 import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; 27 28 import org.junit.Rule; 29 import org.junit.Test; 30 import org.junit.runner.RunWith; 31 32 /** 33 * Test class testing different scenarios of WebView behavior after WebView registered and 34 * initialized within an App. 35 * The test methods in this class should be run one-to-one to a separate device side app to ensure 36 * we don't run the device tests in the same process (since WebView can only be loaded into a 37 * process once - after that it will reuse the same WebView provider). Currently, tradefed does 38 * not provide a way of restarting a process for a new test case. 39 * When adding a new test here - remember to add the corresponding device-side test to a single 40 * separate package. 41 */ 42 @RunWith(DeviceJUnit4ClassRunner.class) 43 @AppModeFull 44 public class RegisterResourcePathsHostTests extends BaseHostJUnit4Test { 45 @Rule 46 public final CheckFlagsRule mCheckFlagsRule = 47 HostFlagsValueProvider.createCheckFlagsRule(this::getDevice); 48 private static final String DEVICE_TEST_PKG1 = "android.resources.registerresourcepaths1"; 49 private static final String DEVICE_TEST_PKG2 = "android.resources.registerresourcepaths2"; 50 private static final String DEVICE_TEST_CLASS = "RegisterResourcePathsTest"; 51 52 @Test 53 @RequiresFlagsEnabled(Flags.FLAG_REGISTER_RESOURCE_PATHS) testWebViewInitialization()54 public void testWebViewInitialization() throws Exception { 55 runDeviceTests(DEVICE_TEST_PKG1, DEVICE_TEST_PKG1 + "." + DEVICE_TEST_CLASS, 56 "testWebViewInitialization"); 57 } 58 59 @Test 60 @RequiresFlagsEnabled(Flags.FLAG_REGISTER_RESOURCE_PATHS) testWebViewInitializeOnBackGroundThread()61 public void testWebViewInitializeOnBackGroundThread() throws Exception { 62 runDeviceTests(DEVICE_TEST_PKG2, DEVICE_TEST_PKG2 + "." + DEVICE_TEST_CLASS, 63 "testWebViewInitializeOnBackGroundThread"); 64 } 65 66 } 67 68