diff options
author | Jay Shrauner <shrauner@google.com> | 2013-05-30 15:41:13 -0700 |
---|---|---|
committer | Jay Shrauner <shrauner@google.com> | 2013-06-13 10:56:06 -0700 |
commit | 719a7adde25e0a717816b00668c16c3a1e3c5518 (patch) | |
tree | 14037f2530a9c987950cc64485408578197d7a93 /tests | |
parent | 72635ed4edfd76baf78a81afa047b612a2f4d58f (diff) |
Use new CallLog number presentation column
Switch to using new number presentation column in the CallLog table and
discontinue using special phone number strings in CallerInfo. Needed for
unbundling.
Bug:6948882
Change-Id: Ibf27ea55cee783c4530101e4e228198e245e6684
Diffstat (limited to 'tests')
6 files changed, 102 insertions, 78 deletions
diff --git a/tests/src/com/android/dialer/CallDetailActivityTest.java b/tests/src/com/android/dialer/CallDetailActivityTest.java index eebb681d9..1ad17c4f4 100644 --- a/tests/src/com/android/dialer/CallDetailActivityTest.java +++ b/tests/src/com/android/dialer/CallDetailActivityTest.java @@ -230,6 +230,7 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal ContentResolver contentResolver = getContentResolver(); ContentValues values = new ContentValues(); values.put(CallLog.Calls.NUMBER, CONTACT_NUMBER); + values.put(CallLog.Calls.NUMBER_PRESENTATION, CallLog.Calls.PRESENTATION_ALLOWED); values.put(CallLog.Calls.TYPE, CallLog.Calls.INCOMING_TYPE); mCallLogUri = contentResolver.insert(CallLog.Calls.CONTENT_URI, values); setActivityIntent(new Intent(Intent.ACTION_VIEW, mCallLogUri)); diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java index 80bbf34db..9170a0b18 100644 --- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java +++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java @@ -29,7 +29,6 @@ import com.android.dialer.calllog.CallTypeHelper; import com.android.dialer.calllog.PhoneNumberHelper; import com.android.dialer.calllog.TestPhoneNumberHelper; import com.android.dialer.util.LocaleTestUtils; -import com.android.internal.telephony.CallerInfo; import java.util.GregorianCalendar; import java.util.Locale; @@ -89,27 +88,29 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { } public void testSetPhoneCallDetails_Unknown() { - setPhoneCallDetailsWithNumber(CallerInfo.UNKNOWN_NUMBER, CallerInfo.UNKNOWN_NUMBER); + setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_UNKNOWN, ""); assertNameEqualsResource(R.string.unknown); } public void testSetPhoneCallDetails_Private() { - setPhoneCallDetailsWithNumber(CallerInfo.PRIVATE_NUMBER, CallerInfo.PRIVATE_NUMBER); + setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_RESTRICTED, ""); assertNameEqualsResource(R.string.private_num); } public void testSetPhoneCallDetails_Payphone() { - setPhoneCallDetailsWithNumber(CallerInfo.PAYPHONE_NUMBER, CallerInfo.PAYPHONE_NUMBER); + setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_PAYPHONE, ""); assertNameEqualsResource(R.string.payphone); } public void testSetPhoneCallDetails_Voicemail() { - setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, TEST_VOICEMAIL_NUMBER); + setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, + Calls.PRESENTATION_ALLOWED, TEST_VOICEMAIL_NUMBER); assertNameEqualsResource(R.string.voicemail); } public void testSetPhoneCallDetails_Normal() { - setPhoneCallDetailsWithNumber("14125551212", "1-412-555-1212"); + setPhoneCallDetailsWithNumber("14125551212", + Calls.PRESENTATION_ALLOWED, "1-412-555-1212"); assertEquals("Yesterday", mViews.callTypeAndDate.getText().toString()); assertEqualsHtml("<font color='#33b5e5'><b>Yesterday</b></font>", mViews.callTypeAndDate.getText()); @@ -199,35 +200,36 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { } public void testSetPhoneCallDetails_Highlighted() { - setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, ""); + setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, + Calls.PRESENTATION_ALLOWED, ""); } public void testSetCallDetailsHeader_NumberOnly() { - setCallDetailsHeaderWithNumberOnly(TEST_NUMBER); + setCallDetailsHeaderWithNumber(TEST_NUMBER, Calls.PRESENTATION_ALLOWED); assertEquals(View.VISIBLE, mNameView.getVisibility()); assertEquals("Add to contacts", mNameView.getText().toString()); } public void testSetCallDetailsHeader_UnknownNumber() { - setCallDetailsHeaderWithNumberOnly(CallerInfo.UNKNOWN_NUMBER); + setCallDetailsHeaderWithNumber("", Calls.PRESENTATION_UNKNOWN); assertEquals(View.VISIBLE, mNameView.getVisibility()); assertEquals("Unknown", mNameView.getText().toString()); } public void testSetCallDetailsHeader_PrivateNumber() { - setCallDetailsHeaderWithNumberOnly(CallerInfo.PRIVATE_NUMBER); + setCallDetailsHeaderWithNumber("", Calls.PRESENTATION_RESTRICTED); assertEquals(View.VISIBLE, mNameView.getVisibility()); assertEquals("Private number", mNameView.getText().toString()); } public void testSetCallDetailsHeader_PayphoneNumber() { - setCallDetailsHeaderWithNumberOnly(CallerInfo.PAYPHONE_NUMBER); + setCallDetailsHeaderWithNumber("", Calls.PRESENTATION_PAYPHONE); assertEquals(View.VISIBLE, mNameView.getVisibility()); assertEquals("Pay phone", mNameView.getText().toString()); } public void testSetCallDetailsHeader_VoicemailNumber() { - setCallDetailsHeaderWithNumberOnly(TEST_VOICEMAIL_NUMBER); + setCallDetailsHeaderWithNumber(TEST_VOICEMAIL_NUMBER, Calls.PRESENTATION_ALLOWED); assertEquals(View.VISIBLE, mNameView.getVisibility()); assertEquals("Voicemail", mNameView.getText().toString()); } @@ -284,15 +286,21 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { } /** Sets the phone call details with default values and the given number. */ - private void setPhoneCallDetailsWithNumber(String number, String formattedNumber) { - setPhoneCallDetailsWithNumberAndGeocode(number, formattedNumber, TEST_GEOCODE); + private void setPhoneCallDetailsWithNumber(String number, int presentation, + String formattedNumber) { + mHelper.setPhoneCallDetails(mViews, + new PhoneCallDetails(number, presentation, formattedNumber, + TEST_COUNTRY_ISO, TEST_GEOCODE, + new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION), + true); } /** Sets the phone call details with default values and the given number. */ private void setPhoneCallDetailsWithNumberAndGeocode(String number, String formattedNumber, String geocodedLocation) { mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails(number, formattedNumber, TEST_COUNTRY_ISO, geocodedLocation, + new PhoneCallDetails(number, Calls.PRESENTATION_ALLOWED, + formattedNumber, TEST_COUNTRY_ISO, geocodedLocation, new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION), true); } @@ -300,29 +308,33 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { /** Sets the phone call details with default values and the given date. */ private void setPhoneCallDetailsWithDate(long date) { mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, - TEST_GEOCODE, new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION), + new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, + new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION), false); } /** Sets the phone call details with default values and the given call types using icons. */ private void setPhoneCallDetailsWithCallTypeIcons(int... callTypes) { mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, - TEST_GEOCODE, callTypes, TEST_DATE, TEST_DURATION), + new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, + callTypes, TEST_DATE, TEST_DURATION), false); } - private void setCallDetailsHeaderWithNumberOnly(String number) { + private void setCallDetailsHeaderWithNumber(String number, int presentation) { mHelper.setCallDetailsHeader(mNameView, - new PhoneCallDetails(number, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, - TEST_GEOCODE, new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION)); + new PhoneCallDetails(number, presentation, + TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, + new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION)); } private void setCallDetailsHeader(String name) { mHelper.setCallDetailsHeader(mNameView, - new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, - TEST_GEOCODE, new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION, + new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, + new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION, name, 0, "", null, null)); } } diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java index 67132fd45..c94f8d9ac 100644 --- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java @@ -40,7 +40,6 @@ import android.widget.FrameLayout; import com.android.contacts.common.test.FragmentTestActivity; import com.android.dialer.CallDetailActivity; import com.android.dialer.R; -import com.android.internal.telephony.CallerInfo; import java.util.Date; import java.util.Formatter; @@ -165,9 +164,9 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme @MediumTest public void testCallAndGroupViews_GroupView() { mCursor.moveToFirst(); - insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE); - insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE); - insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE); + insertPrivate(NOW, 0); + insertPrivate(NOW, 0); + insertPrivate(NOW, 0); View view = mAdapter.newGroupView(getActivity(), mParentView); mAdapter.bindGroupView(view, getActivity(), mCursor, 3, false); assertNotNull(view.findViewById(R.id.secondary_action_icon)); @@ -176,7 +175,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme @MediumTest public void testCallAndGroupViews_StandAloneView() { mCursor.moveToFirst(); - insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE); + insertPrivate(NOW, 0); View view = mAdapter.newStandAloneView(getActivity(), mParentView); mAdapter.bindStandAloneView(view, getActivity(), mCursor); assertNotNull(view.findViewById(R.id.secondary_action_icon)); @@ -185,7 +184,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme @MediumTest public void testCallAndGroupViews_ChildView() { mCursor.moveToFirst(); - insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE); + insertPrivate(NOW, 0); View view = mAdapter.newChildView(getActivity(), mParentView); mAdapter.bindChildView(view, getActivity(), mCursor); assertNotNull(view.findViewById(R.id.secondary_action_icon)); @@ -194,7 +193,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme @MediumTest public void testBindView_NumberOnlyNoCache() { mCursor.moveToFirst(); - insert(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE); + insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); mAdapter.bindStandAloneView(view, getActivity(), mCursor); @@ -205,7 +204,8 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme @MediumTest public void testBindView_NumberOnlyDbCachedFormattedNumber() { mCursor.moveToFirst(); - Object[] values = getValuesToInsert(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE); + Object[] values = getValuesToInsert(TEST_NUMBER, + Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); values[CallLogQuery.CACHED_FORMATTED_NUMBER] = TEST_FORMATTED_NUMBER; insertValues(values); View view = mAdapter.newStandAloneView(getActivity(), mParentView); @@ -296,7 +296,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme @MediumTest public void testBindView_WithoutQuickContactBadge() { mCursor.moveToFirst(); - insert(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE); + insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); mAdapter.bindStandAloneView(view, getActivity(), mCursor); @@ -307,7 +307,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme @MediumTest public void testBindView_CallButton() { mCursor.moveToFirst(); - insert(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE); + insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE); View view = mAdapter.newStandAloneView(getActivity(), mParentView); mAdapter.bindStandAloneView(view, getActivity(), mCursor); @@ -323,7 +323,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme @MediumTest public void testBindView_PlayButton() { mCursor.moveToFirst(); - insertVoicemail(TEST_NUMBER, NOW, 0); + insertVoicemail(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0); View view = mAdapter.newStandAloneView(getActivity(), mParentView); mAdapter.bindStandAloneView(view, getActivity(), mCursor); @@ -363,9 +363,9 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme break; } mItem = (CallLogListItemViews) mList[i].getTag(); - String number = getPhoneNumberForListEntry(i); - if (CallerInfo.PRIVATE_NUMBER.equals(number) || - CallerInfo.UNKNOWN_NUMBER.equals(number)) { + int presentation = getPhoneNumberPresentationForListEntry(i); + if (presentation == Calls.PRESENTATION_RESTRICTED || + presentation == Calls.PRESENTATION_UNKNOWN) { assertFalse(View.VISIBLE == mItem.secondaryActionView.getVisibility()); } else { assertEquals(View.VISIBLE, mItem.secondaryActionView.getVisibility()); @@ -422,11 +422,11 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme } } - /** Returns the number associated with the given entry in {{@link #mList}. */ - private String getPhoneNumberForListEntry(int index) { + /** Returns the number presentation associated with the given entry in {{@link #mList}. */ + private int getPhoneNumberPresentationForListEntry(int index) { // The entries are added backward, so count from the end of the cursor. mCursor.moveToPosition(mCursor.getCount() - index - 1); - return mCursor.getString(CallLogQuery.NUMBER); + return mCursor.getInt(CallLogQuery.NUMBER_PRESENTATION); } // @@ -458,8 +458,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme * * It includes the values for the cached contact associated with the number. * - * @param number The phone number. For unknown and private numbers, - * use CallerInfo.UNKNOWN_NUMBER or CallerInfo.PRIVATE_NUMBER. + * @param number The phone number. * @param date In millisec since epoch. Use NOW to use the current time. * @param duration In seconds of the call. Use RAND_DURATION to pick a random one. * @param type Either Call.OUTGOING_TYPE or Call.INCOMING_TYPE or Call.MISSED_TYPE. @@ -469,7 +468,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme */ private void insertWithCachedValues(String number, long date, int duration, int type, String cachedName, int cachedNumberType, String cachedNumberLabel) { - insert(number, date, duration, type); + insert(number, Calls.PRESENTATION_ALLOWED, date, duration, type); ContactInfo contactInfo = new ContactInfo(); contactInfo.lookupUri = TEST_LOOKUP_URI; contactInfo.name = cachedName; @@ -487,14 +486,15 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme /** * Insert a new call entry in the test DB. - * @param number The phone number. For unknown and private numbers, - * use CallerInfo.UNKNOWN_NUMBER or CallerInfo.PRIVATE_NUMBER. + * @param number The phone number. + * @param presentation Number representing display rules for "allowed", + * "payphone", "restricted", or "unknown". * @param date In millisec since epoch. Use NOW to use the current time. * @param duration In seconds of the call. Use RAND_DURATION to pick a random one. * @param type Either Call.OUTGOING_TYPE or Call.INCOMING_TYPE or Call.MISSED_TYPE. */ - private void insert(String number, long date, int duration, int type) { - insertValues(getValuesToInsert(number, date, duration, type)); + private void insert(String number, int presentation, long date, int duration, int type) { + insertValues(getValuesToInsert(number, presentation, date, duration, type)); } /** Inserts the given values in the cursor. */ @@ -506,16 +506,19 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme /** * Returns the values for a new call entry. * - * @param number The phone number. For unknown and private numbers, - * use CallerInfo.UNKNOWN_NUMBER or CallerInfo.PRIVATE_NUMBER. + * @param number The phone number. + * @param presentation Number representing display rules for "allowed", + * "payphone", "restricted", or "unknown". * @param date In millisec since epoch. Use NOW to use the current time. * @param duration In seconds of the call. Use RAND_DURATION to pick a random one. * @param type Either Call.OUTGOING_TYPE or Call.INCOMING_TYPE or Call.MISSED_TYPE. */ - private Object[] getValuesToInsert(String number, long date, int duration, int type) { + private Object[] getValuesToInsert(String number, int presentation, + long date, int duration, int type) { Object[] values = CallLogQueryTestUtils.createTestExtendedValues(); values[CallLogQuery.ID] = mIndex; values[CallLogQuery.NUMBER] = number; + values[CallLogQuery.NUMBER_PRESENTATION] = presentation; values[CallLogQuery.DATE] = date == NOW ? new Date().getTime() : date; values[CallLogQuery.DURATION] = duration < 0 ? mRnd.nextInt(10 * 60) : duration; if (mVoicemail != null && mVoicemail.equals(number)) { @@ -529,13 +532,14 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme /** * Insert a new voicemail entry in the test DB. - * @param number The phone number. For unknown and private numbers, - * use CallerInfo.UNKNOWN_NUMBER or CallerInfo.PRIVATE_NUMBER. + * @param number The phone number. + * @param presentation Number representing display rules for "allowed", + * "payphone", "restricted", or "unknown". * @param date In millisec since epoch. Use NOW to use the current time. * @param duration In seconds of the call. Use RAND_DURATION to pick a random one. */ - private void insertVoicemail(String number, long date, int duration) { - Object[] values = getValuesToInsert(number, date, duration, Calls.VOICEMAIL_TYPE); + private void insertVoicemail(String number, int presentation, long date, int duration) { + Object[] values = getValuesToInsert(number, presentation, date, duration, Calls.VOICEMAIL_TYPE); // Must have the same index as the row. values[CallLogQuery.VOICEMAIL_URI] = ContentUris.withAppendedId(VoicemailContract.Voicemails.CONTENT_URI, mIndex); @@ -548,7 +552,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme * @param duration In seconds of the call. Use RAND_DURATION to pick a random one. */ private void insertPrivate(long date, int duration) { - insert(CallerInfo.PRIVATE_NUMBER, date, duration, Calls.INCOMING_TYPE); + insert("", Calls.PRESENTATION_RESTRICTED, date, duration, Calls.INCOMING_TYPE); } /** @@ -557,7 +561,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme * @param duration In seconds of the call. Use RAND_DURATION to pick a random one. */ private void insertUnknown(long date, int duration) { - insert(CallerInfo.UNKNOWN_NUMBER, date, duration, Calls.INCOMING_TYPE); + insert("", Calls.PRESENTATION_UNKNOWN, date, duration, Calls.INCOMING_TYPE); } /** @@ -568,7 +572,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme private void insertCalltoVoicemail(long date, int duration) { // mVoicemail may be null if (mVoicemail != null) { - insert(mVoicemail, date, duration, Calls.OUTGOING_TYPE); + insert(mVoicemail, Calls.PRESENTATION_ALLOWED, date, duration, Calls.OUTGOING_TYPE); } } @@ -605,7 +609,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme } else { int inout = mRnd.nextBoolean() ? Calls.OUTGOING_TYPE : Calls.INCOMING_TYPE; String number = new Formatter().format("1800123%04d", i).toString(); - insert(number, NOW, RAND_DURATION, inout); + insert(number, Calls.PRESENTATION_ALLOWED, NOW, RAND_DURATION, inout); } } return privateOrUnknownOrVm; diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java index 3ad5abe0a..73c33ae6d 100644 --- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java @@ -24,7 +24,6 @@ import android.view.View; import com.android.dialer.PhoneCallDetails; import com.android.dialer.PhoneCallDetailsHelper; -import com.android.internal.telephony.CallerInfo; /** * Unit tests for {@link CallLogListItemHelper}. @@ -73,27 +72,29 @@ public class CallLogListItemHelperTest extends AndroidTestCase { } public void testSetPhoneCallDetails() { - setPhoneCallDetailsWithNumber("12125551234", "1-212-555-1234"); + setPhoneCallDetailsWithNumber("12125551234", Calls.PRESENTATION_ALLOWED, + "1-212-555-1234"); assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility()); } public void testSetPhoneCallDetails_Unknown() { - setPhoneCallDetailsWithNumber(CallerInfo.UNKNOWN_NUMBER, CallerInfo.UNKNOWN_NUMBER); + setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_UNKNOWN, ""); assertNoCallButton(); } public void testSetPhoneCallDetails_Private() { - setPhoneCallDetailsWithNumber(CallerInfo.PRIVATE_NUMBER, CallerInfo.PRIVATE_NUMBER); + setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_RESTRICTED, ""); assertNoCallButton(); } public void testSetPhoneCallDetails_Payphone() { - setPhoneCallDetailsWithNumber(CallerInfo.PAYPHONE_NUMBER, CallerInfo.PAYPHONE_NUMBER); + setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_PAYPHONE, ""); assertNoCallButton(); } public void testSetPhoneCallDetails_VoicemailNumber() { - setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, TEST_VOICEMAIL_NUMBER); + setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, + Calls.PRESENTATION_ALLOWED, TEST_VOICEMAIL_NUMBER); assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility()); } @@ -108,8 +109,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase { } public void testSetPhoneCallDetails_VoicemailFromUnknown() { - setPhoneCallDetailsWithNumberAndType(CallerInfo.UNKNOWN_NUMBER, CallerInfo.UNKNOWN_NUMBER, - Calls.VOICEMAIL_TYPE); + setPhoneCallDetailsWithNumberAndType("", Calls.PRESENTATION_UNKNOWN, + "", Calls.VOICEMAIL_TYPE); assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility()); } @@ -120,15 +121,18 @@ public class CallLogListItemHelperTest extends AndroidTestCase { } /** Sets the details of a phone call using the specified phone number. */ - private void setPhoneCallDetailsWithNumber(String number, String formattedNumber) { - setPhoneCallDetailsWithNumberAndType(number, formattedNumber, Calls.INCOMING_TYPE); + private void setPhoneCallDetailsWithNumber(String number, + int presentation, String formattedNumber) { + setPhoneCallDetailsWithNumberAndType(number, presentation, + formattedNumber, Calls.INCOMING_TYPE); } /** Sets the details of a phone call using the specified phone number. */ - private void setPhoneCallDetailsWithNumberAndType(String number, String formattedNumber, - int callType) { + private void setPhoneCallDetailsWithNumberAndType(String number, + int presentation, String formattedNumber, int callType) { mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails(number, formattedNumber, TEST_COUNTRY_ISO, TEST_GEOCODE, + new PhoneCallDetails(number, presentation, formattedNumber, + TEST_COUNTRY_ISO, TEST_GEOCODE, new int[]{ callType }, TEST_DATE, TEST_DURATION), false); } @@ -136,16 +140,18 @@ public class CallLogListItemHelperTest extends AndroidTestCase { /** Sets the details of a phone call using the specified call type. */ private void setPhoneCallDetailsWithTypes(int... types) { mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, - TEST_GEOCODE, types, TEST_DATE, TEST_DURATION), + new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, + types, TEST_DATE, TEST_DURATION), false); } /** Sets the details of a phone call using the specified call type. */ private void setUnreadPhoneCallDetailsWithTypes(int... types) { mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, - TEST_GEOCODE, types, TEST_DATE, TEST_DURATION), + new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, + types, TEST_DATE, TEST_DURATION), true); } } diff --git a/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java b/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java index 4be84aede..52b3b5d4f 100644 --- a/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java +++ b/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java @@ -29,7 +29,7 @@ public class CallLogQueryTestUtils { public static Object[] createTestValues() { Object[] values = new Object[]{ 0L, "", 0L, 0L, Calls.INCOMING_TYPE, "", "", "", null, 0, null, null, null, null, - 0L, null, 0, + 0L, null, 0, Calls.PRESENTATION_ALLOWED, }; assertEquals(CallLogQuery._PROJECTION.length, values.length); return values; @@ -38,7 +38,7 @@ public class CallLogQueryTestUtils { public static Object[] createTestExtendedValues() { Object[] values = new Object[]{ 0L, "", 0L, 0L, Calls.INCOMING_TYPE, "", "", "", null, 0, null, null, null, null, - 0L, null, 1, CallLogQuery.SECTION_OLD_ITEM + 0L, null, 1, Calls.PRESENTATION_ALLOWED, CallLogQuery.SECTION_OLD_ITEM }; Assert.assertEquals(CallLogQuery.EXTENDED_PROJECTION.length, values.length); return values; diff --git a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java index ed492205c..b1b8e2f05 100644 --- a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java +++ b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java @@ -161,6 +161,7 @@ public class FillCallLogTestActivity extends Activity { for (int i = 0; i < count; i++) { values[i] = new ContentValues(); values[i].put(Calls.NUMBER, generateRandomNumber()); + values[i].put(Calls.NUMBER_PRESENTATION, Calls.PRESENTATION_ALLOWED); values[i].put(Calls.DATE, System.currentTimeMillis()); // Will be randomized later values[i].put(Calls.DURATION, 1); // Will be overwritten later } |