1c340409479715945439d137309db350504e7f37cDmitri Plotnikov/*
2c340409479715945439d137309db350504e7f37cDmitri Plotnikov * Copyright (C) 2009 The Android Open Source Project
3c340409479715945439d137309db350504e7f37cDmitri Plotnikov *
4c340409479715945439d137309db350504e7f37cDmitri Plotnikov * Licensed under the Apache License, Version 2.0 (the "License");
5c340409479715945439d137309db350504e7f37cDmitri Plotnikov * you may not use this file except in compliance with the License.
6c340409479715945439d137309db350504e7f37cDmitri Plotnikov * You may obtain a copy of the License at
7c340409479715945439d137309db350504e7f37cDmitri Plotnikov *
8c340409479715945439d137309db350504e7f37cDmitri Plotnikov *      http://www.apache.org/licenses/LICENSE-2.0
9c340409479715945439d137309db350504e7f37cDmitri Plotnikov *
10c340409479715945439d137309db350504e7f37cDmitri Plotnikov * Unless required by applicable law or agreed to in writing, software
11c340409479715945439d137309db350504e7f37cDmitri Plotnikov * distributed under the License is distributed on an "AS IS" BASIS,
12c340409479715945439d137309db350504e7f37cDmitri Plotnikov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c340409479715945439d137309db350504e7f37cDmitri Plotnikov * See the License for the specific language governing permissions and
14c340409479715945439d137309db350504e7f37cDmitri Plotnikov * limitations under the License.
15c340409479715945439d137309db350504e7f37cDmitri Plotnikov */
168920a04b4a68ed6b548bcdef5ca8736dcf8b69b1Omari Stephens
17c340409479715945439d137309db350504e7f37cDmitri Plotnikovpackage com.android.providers.contacts;
18c340409479715945439d137309db350504e7f37cDmitri Plotnikov
19c340409479715945439d137309db350504e7f37cDmitri Plotnikovimport com.android.internal.telephony.CallerInfo;
20c340409479715945439d137309db350504e7f37cDmitri Plotnikov
21c340409479715945439d137309db350504e7f37cDmitri Plotnikovimport android.content.ContentUris;
22c340409479715945439d137309db350504e7f37cDmitri Plotnikovimport android.content.ContentValues;
23c340409479715945439d137309db350504e7f37cDmitri Plotnikovimport android.net.Uri;
24c340409479715945439d137309db350504e7f37cDmitri Plotnikovimport android.provider.ContactsContract.RawContacts;
258920a04b4a68ed6b548bcdef5ca8736dcf8b69b1Omari Stephensimport android.test.suitebuilder.annotation.MediumTest;
26c340409479715945439d137309db350504e7f37cDmitri Plotnikov
27c340409479715945439d137309db350504e7f37cDmitri Plotnikov/**
28c340409479715945439d137309db350504e7f37cDmitri Plotnikov * Integration test for {@link CallerInfo} and {@link ContactsProvider2}.
29c340409479715945439d137309db350504e7f37cDmitri Plotnikov *
30c340409479715945439d137309db350504e7f37cDmitri Plotnikov * Run the test like this:
31c340409479715945439d137309db350504e7f37cDmitri Plotnikov * <code>
328920a04b4a68ed6b548bcdef5ca8736dcf8b69b1Omari Stephens * adb shell am instrument -e class com.android.providers.contacts.CallerInfoIntegrationTest -w \
33c340409479715945439d137309db350504e7f37cDmitri Plotnikov *         com.android.providers.contacts.tests/android.test.InstrumentationTestRunner
34c340409479715945439d137309db350504e7f37cDmitri Plotnikov * </code>
35c340409479715945439d137309db350504e7f37cDmitri Plotnikov */
368920a04b4a68ed6b548bcdef5ca8736dcf8b69b1Omari Stephens@MediumTest
37c340409479715945439d137309db350504e7f37cDmitri Plotnikovpublic class CallerInfoIntegrationTest extends BaseContactsProvider2Test {
38c340409479715945439d137309db350504e7f37cDmitri Plotnikov
39c340409479715945439d137309db350504e7f37cDmitri Plotnikov    public void testCallerInfo() {
40c340409479715945439d137309db350504e7f37cDmitri Plotnikov        ContentValues values = new ContentValues();
41c340409479715945439d137309db350504e7f37cDmitri Plotnikov        values.put(RawContacts.CUSTOM_RINGTONE, "ring");
42c340409479715945439d137309db350504e7f37cDmitri Plotnikov        values.put(RawContacts.SEND_TO_VOICEMAIL, 1);
43c340409479715945439d137309db350504e7f37cDmitri Plotnikov
44c340409479715945439d137309db350504e7f37cDmitri Plotnikov        Uri rawContactUri = mResolver.insert(RawContacts.CONTENT_URI, values);
45c340409479715945439d137309db350504e7f37cDmitri Plotnikov        long rawContactId = ContentUris.parseId(rawContactUri);
46c340409479715945439d137309db350504e7f37cDmitri Plotnikov
47c340409479715945439d137309db350504e7f37cDmitri Plotnikov        insertStructuredName(rawContactId, "Hot", "Tamale");
48c340409479715945439d137309db350504e7f37cDmitri Plotnikov        insertPhoneNumber(rawContactId, "800-466-4411");
49c340409479715945439d137309db350504e7f37cDmitri Plotnikov
50c340409479715945439d137309db350504e7f37cDmitri Plotnikov        CallerInfo callerInfo = CallerInfo.getCallerInfo(getProvider().getContext(), "18004664411");
51c340409479715945439d137309db350504e7f37cDmitri Plotnikov        assertEquals("800-466-4411", callerInfo.phoneNumber);
52c340409479715945439d137309db350504e7f37cDmitri Plotnikov        assertEquals("Home", callerInfo.phoneLabel);
53c340409479715945439d137309db350504e7f37cDmitri Plotnikov        assertEquals("Hot Tamale", callerInfo.name);
54c340409479715945439d137309db350504e7f37cDmitri Plotnikov        assertEquals("ring", String.valueOf(callerInfo.contactRingtoneUri));
55c340409479715945439d137309db350504e7f37cDmitri Plotnikov        assertEquals(true, callerInfo.shouldSendToVoicemail);
56c340409479715945439d137309db350504e7f37cDmitri Plotnikov        assertEquals("content://com.android.contacts/phone_lookup/18004664411",
57c340409479715945439d137309db350504e7f37cDmitri Plotnikov                String.valueOf(callerInfo.contactRefUri));
58c340409479715945439d137309db350504e7f37cDmitri Plotnikov    }
59c340409479715945439d137309db350504e7f37cDmitri Plotnikov}
60