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 import android.content.Intent; 19 import android.content.pm.PackageManager; 20 import android.test.ActivityInstrumentationTestCase2; 21 import android.provider.Settings; 22 23 24 /** 25 * Tests that make sure that some core application intents as described in Compatibility Definition 26 * Document are handled within a managed profile. 27 * Note that OEMs can replace the Settings apps, so we we can at most check if the intent resolves. 28 */ 29 public class SettingsIntentsTest extends ActivityInstrumentationTestCase2<TestActivity> { 30 31 private PackageManager mPackageManager; 32 33 public SettingsIntentsTest() { 34 super(TestActivity.class); 35 } 36 37 @Override 38 protected void setUp() throws Exception { 39 super.setUp(); 40 mPackageManager = getActivity().getPackageManager(); 41 } 42 43 public void testSettings() { 44 assertNotNull(mPackageManager.resolveActivity( 45 new Intent(Settings.ACTION_SETTINGS), 0 /* flags */)); 46 } 47 48 public void testAccounts() { 49 assertNotNull(mPackageManager.resolveActivity( 50 new Intent(Settings.ACTION_SYNC_SETTINGS), 0 /* flags */)); 51 } 52 53 public void testApps() { 54 assertNotNull(mPackageManager.resolveActivity( 55 new Intent(Settings.ACTION_APPLICATION_SETTINGS), 0 /* flags */)); 56 } 57 58 public void testSecurity() { 59 // This leads to device administrators, screenlock etc. 60 assertNotNull(mPackageManager.resolveActivity( 61 new Intent(Settings.ACTION_SECURITY_SETTINGS), 0 /* flags */)); 62 } 63 64 public void testNfc() { 65 if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC)) { 66 assertNotNull(mPackageManager.resolveActivity( 67 new Intent(Settings.ACTION_NFC_SETTINGS), 0 /* flags */)); 68 } 69 } 70 71 public void testLocation() { 72 assertNotNull(mPackageManager.resolveActivity( 73 new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0 /* flags */)); 74 } 75 } 76