1 /*
2  * Copyright (C) 2015 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 import com.android.ddmlib.Log.LogLevel;
20 import com.android.tradefed.device.DeviceNotAvailableException;
21 import com.android.tradefed.log.LogUtil.CLog;
22 
23 import junit.framework.AssertionFailedError;
24 
25 /**
26  * Set of tests for device owner use cases that also apply to profile owners.
27  * Tests that should be run identically in both cases are added in DeviceAndProfileOwnerTest.
28  */
29 public class MixedDeviceOwnerTest extends DeviceAndProfileOwnerTest {
30 
31     private static final String CLEAR_DEVICE_OWNER_TEST_CLASS =
32             DEVICE_ADMIN_PKG + ".ClearDeviceOwnerTest";
33 
34     @Override
setUp()35     protected void setUp() throws Exception {
36         super.setUp();
37 
38         if (mHasFeature) {
39             mUserId = USER_OWNER;
40 
41             installApp(DEVICE_ADMIN_APK);
42             assertTrue("Failed to set device owner",
43                     setDeviceOwner(DEVICE_ADMIN_PKG + "/" + ADMIN_RECEIVER_TEST_CLASS));
44         }
45     }
46 
47     @Override
tearDown()48     protected void tearDown() throws Exception {
49         if (mHasFeature) {
50             assertTrue("Failed to remove device owner.",
51                     runDeviceTests(DEVICE_ADMIN_PKG, CLEAR_DEVICE_OWNER_TEST_CLASS));
52         }
53         super.tearDown();
54     }
55 
56     // All tests for this class are defined in DeviceAndProfileOwnerTest
57 }
58