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.devicepolicy; 18 19 /** 20 * Set of tests for use cases that apply to profile and device owner with DPC 21 * targeting API level 25. 22 */ 23 public abstract class DeviceAndProfileOwnerTestApi30 extends BaseDevicePolicyTest { 24 25 protected static final String DEVICE_ADMIN_PKG = "com.android.cts.deviceandprofileowner"; 26 protected static final String DEVICE_ADMIN_APK = "CtsDeviceAndProfileOwnerApp30.apk"; 27 28 protected static final String ADMIN_RECEIVER_TEST_CLASS = 29 ".BaseDeviceAdminTest$BasicAdminReceiver"; 30 31 protected int mUserId; 32 33 @Override tearDown()34 public void tearDown() throws Exception { 35 getDevice().uninstallPackage(DEVICE_ADMIN_PKG); 36 37 // Clear device lock in case test fails (testUnlockFbe in particular) 38 getDevice().executeShellCommand("cmd lock_settings clear --old 12345"); 39 // Press the HOME key to close any alart dialog that may be shown. 40 getDevice().executeShellCommand("input keyevent 3"); 41 42 super.tearDown(); 43 } 44 executeDeviceTestClass(String className)45 protected void executeDeviceTestClass(String className) throws Exception { 46 runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, mUserId); 47 } 48 executeDeviceTestMethod(String className, String testName)49 protected void executeDeviceTestMethod(String className, String testName) throws Exception { 50 runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, testName, mUserId); 51 } 52 } 53