1 /* 2 * Copyright (C) 2014 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 package com.android.cts.managedprofile; 17 18 public class WipeDataTest extends BaseManagedProfileTest { 19 private static final String TEST_WIPE_DATA_REASON = "cts test for WipeDataWithReason"; 20 21 @Override 22 protected void setUp() throws Exception { 23 super.setUp(); 24 // Make sure we are running in a managed profile, otherwise risk wiping the primary user's 25 // data. 26 assertTrue(mDevicePolicyManager.isAdminActive(ADMIN_RECEIVER_COMPONENT)); 27 assertTrue(mDevicePolicyManager.isProfileOwnerApp(ADMIN_RECEIVER_COMPONENT.getPackageName())); 28 } 29 30 /** 31 * Test wipeData() for use in managed profile. If called from a managed profile, wipeData() 32 * should remove the current managed profile. Also, no erasing of external storage should be 33 * allowed. 34 */ 35 public void testWipeData() throws InterruptedException { 36 mDevicePolicyManager.wipeData(0); 37 // The test that the profile will indeed be removed is done in the host. 38 } 39 40 /** 41 * Test wipeDataWithReason() for use in managed profile. If called from a managed profile, 42 * wipeDataWithReason() should remove the current managed profile.In the mean time, it should 43 * send out a notification containing the reason for wiping data to user. Also, no erasing of 44 * external storage should be allowed. 45 */ 46 public void testWipeDataWithReason() throws InterruptedException { 47 mDevicePolicyManager.wipeData(0, TEST_WIPE_DATA_REASON); 48 // The test that the profile will indeed be removed is done in the host. 49 // Notification verification is done in another test. 50 } 51 } 52