diff options
author | Tony Mak <tonymak@google.com> | 2015-10-21 11:42:49 +0100 |
---|---|---|
committer | Tony Mak <tonymak@google.com> | 2015-10-21 11:42:49 +0100 |
commit | 9d68ffa1079ca2e85a8ccf62bf8dca2f43f1ade3 (patch) | |
tree | 26e128b805b9b9a8c57a5599dd300624f5f1b5ac /tests | |
parent | 3aea695dff7f2449d7f41e91176d647f9131e1c8 (diff) | |
download | android_packages_apps_Bluetooth-9d68ffa1079ca2e85a8ccf62bf8dca2f43f1ade3.tar.gz android_packages_apps_Bluetooth-9d68ffa1079ca2e85a8ccf62bf8dca2f43f1ade3.tar.bz2 android_packages_apps_Bluetooth-9d68ffa1079ca2e85a8ccf62bf8dca2f43f1ade3.zip |
Proper fix of contact_id in bluetooth
Instead of checking null, explictly state which column(s) we need.
Change-Id: I9780930d8c3457cc8e11ae78cd448f3ffa724183
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/bluetooth/tests/pbap/BluetoothPbapVcardManagerTest.java (renamed from tests/src/com/android/bluetooth/tests/pbap/BluetoothPhabVcardManagerTest.java) | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/tests/src/com/android/bluetooth/tests/pbap/BluetoothPhabVcardManagerTest.java b/tests/src/com/android/bluetooth/tests/pbap/BluetoothPbapVcardManagerTest.java index 72168b503..ec000a0e5 100644 --- a/tests/src/com/android/bluetooth/tests/pbap/BluetoothPhabVcardManagerTest.java +++ b/tests/src/com/android/bluetooth/tests/pbap/BluetoothPbapVcardManagerTest.java @@ -16,26 +16,43 @@ package com.android.bluetooth.tests.pbap; +import com.android.bluetooth.pbap.BluetoothPbapObexServer; +import com.android.bluetooth.pbap.BluetoothPbapVcardManager; +import com.android.bluetooth.tests.mock.BluetoothMockContext; +import com.android.bluetooth.tests.mock.SimpleMockContentProvider; + import android.database.Cursor; import android.database.MatrixCursor; import android.provider.ContactsContract; +import android.provider.ContactsContract.PhoneLookup; import android.test.AndroidTestCase; import android.test.mock.MockContentProvider; import android.test.mock.MockContentResolver; +import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.text.TextUtils; -import com.android.bluetooth.pbap.BluetoothPbapObexServer; -import com.android.bluetooth.pbap.BluetoothPbapVcardManager; -import com.android.bluetooth.tests.mock.BluetoothMockContext; -import com.android.bluetooth.tests.mock.SimpleMockContentProvider; import java.util.ArrayList; -public class BluetoothPhabVcardManagerTest extends AndroidTestCase { +public class BluetoothPbapVcardManagerTest extends AndroidTestCase { - public void testGetContactNamesByNumber() { - MatrixCursor mc = new MatrixCursor( - new String[]{ContactsContract.CommonDataKinds.Phone.CONTACT_ID, - ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME}); + public void testGetContactNamesByNumberWithEmptyPhoneNumber() { + getContactNamesByNumberInternal(""); + } + + public void testGetContactNamesByNumberWithPhoneNumber() { + getContactNamesByNumberInternal("111-111-111"); + } + + private void getContactNamesByNumberInternal(String phoneNumber) { + String[] columnNames; + if (TextUtils.isEmpty(phoneNumber)) { + columnNames = new String[]{Phone.CONTACT_ID, Phone.DISPLAY_NAME}; + } else { + columnNames = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME}; + } + + MatrixCursor mc = new MatrixCursor(columnNames); mc.addRow(new Object[]{1L, "A"}); mc.addRow(new Object[]{1L, "A (1)"}); mc.addRow(new Object[]{2L, "B"}); @@ -45,7 +62,7 @@ public class BluetoothPhabVcardManagerTest extends AndroidTestCase { mc.addRow(new Object[]{3L, "C (2)"}); mc.addRow(new Object[]{4L, "D"}); BluetoothPbapVcardManager manager = createBluetoothPbapVcardManager(mc); - ArrayList<String> nameList = manager.getContactNamesByNumber("111-111-111"); + ArrayList<String> nameList = manager.getContactNamesByNumber(phoneNumber); // If there are multiple display name per id, first one is picked. assertEquals("A,1", nameList.get(0)); |