1/* 2 * Copyright (C) 2009 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 17package com.android.providers.contacts; 18 19import android.content.ContentUris; 20import android.content.ContentValues; 21import android.net.Uri; 22import android.provider.ContactsContract.RawContacts; 23import android.test.suitebuilder.annotation.MediumTest; 24 25import com.android.internal.telephony.CallerInfo; 26import com.android.providers.contacts.testutil.DataUtil; 27 28/** 29 * Integration test for {@link CallerInfo} and {@link ContactsProvider2}. 30 * 31 * Run the test like this: 32 * <code> 33 * adb shell am instrument -e class com.android.providers.contacts.CallerInfoIntegrationTest -w \ 34 * com.android.providers.contacts.tests/android.test.InstrumentationTestRunner 35 * </code> 36 */ 37@MediumTest 38public class CallerInfoIntegrationTest extends BaseContactsProvider2Test { 39 40 public void testCallerInfo() { 41 ContentValues values = new ContentValues(); 42 values.put(RawContacts.CUSTOM_RINGTONE, "ring"); 43 values.put(RawContacts.SEND_TO_VOICEMAIL, 1); 44 45 Uri rawContactUri = mResolver.insert(RawContacts.CONTENT_URI, values); 46 long rawContactId = ContentUris.parseId(rawContactUri); 47 48 DataUtil.insertStructuredName(mResolver, rawContactId, "Hot", "Tamale"); 49 insertPhoneNumber(rawContactId, "800-466-4411"); 50 51 CallerInfo callerInfo = CallerInfo.getCallerInfo(getProvider().getContext(), "18004664411"); 52 assertEquals("800-466-4411", callerInfo.phoneNumber); 53 assertEquals("Home", callerInfo.phoneLabel); 54 assertEquals("Hot Tamale", callerInfo.name); 55 assertEquals("ring", String.valueOf(callerInfo.contactRingtoneUri)); 56 assertEquals(true, callerInfo.shouldSendToVoicemail); 57 assertEquals("content://com.android.contacts/phone_lookup/18004664411", 58 String.valueOf(callerInfo.contactRefUri)); 59 } 60} 61