1 /*
2  * Copyright (C) 2013 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.provider.cts.contacts;
18 
19 import android.content.Intent;
20 import android.content.pm.ResolveInfo;
21 import android.provider.ContactsContract;
22 import android.test.AndroidTestCase;
23 
24 import java.util.List;
25 
26 /**
27  * Tests to verify that common actions on {@link ContactsContract} content are
28  * available.
29  */
30 public class ContactsContractIntentsTest extends AndroidTestCase {
assertCanBeHandled(Intent intent)31     public void assertCanBeHandled(Intent intent) {
32         List<ResolveInfo> resolveInfoList = getContext()
33                 .getPackageManager().queryIntentActivities(intent, 0);
34         assertNotNull("Missing ResolveInfo", resolveInfoList);
35         assertTrue("No ResolveInfo found for " + intent.toString(),
36                 resolveInfoList.size() > 0);
37     }
38 
testViewContactDir()39     public void testViewContactDir() {
40         Intent intent = new Intent(Intent.ACTION_VIEW);
41         intent.setData(ContactsContract.Contacts.CONTENT_URI);
42         assertCanBeHandled(intent);
43     }
44 
testPickContactDir()45     public void testPickContactDir() {
46         Intent intent = new Intent(Intent.ACTION_PICK);
47         intent.setData(ContactsContract.Contacts.CONTENT_URI);
48         assertCanBeHandled(intent);
49     }
50 
testGetContentContactDir()51     public void testGetContentContactDir() {
52         Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
53         intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
54         assertCanBeHandled(intent);
55     }
56 }
57