diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-09 18:22:14 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-06-10 10:47:45 -0700 |
commit | edb22da2b40549631a08150cbfc205e6ad243c20 (patch) | |
tree | 2c8c1fbf06d3d96e85706de5a944fd6484c8551e /tests/src | |
parent | 02db755505920f55d4f25a3a4d226795823e9b6a (diff) |
Change PhoneCallDetail fields to be non-final.
It's been a pain to add/change fields on PhoneCallDetails because
a multitude of parameters required for the constructors to create
an instance. I ran into this while considering how to add an
objectId to its parameters, and have previously too...
Make fields non-final so that they are more easily set. This has
the side-effect of making the casing of some initialization code
more straightforward.
+ Change it's constructor to a subset of required fields.
+ Simplify/reorganize CallLogAdapter and CallLogAsyncTaskUtil code.
+ Simplify tests.
Bug: 21733599
Change-Id: I236dfb0b8e6513f4b44dbdae17ce2eb9c9ae4778
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java | 184 | ||||
-rw-r--r-- | tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java | 308 |
2 files changed, 129 insertions, 363 deletions
diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java index 3e7eb66b6..9edbbc9b3 100644 --- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java +++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java @@ -25,6 +25,7 @@ import android.text.Spanned; import android.view.View; import android.widget.TextView; +import com.android.dialer.calllog.ContactInfo; import com.android.dialer.calllog.TestPhoneNumberUtilsWrapper; import com.android.dialer.util.LocaleTestUtils; @@ -165,7 +166,10 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { * Tests a case where the video call feature is present. */ public void testSetPhoneCallDetails_Video() { - setPhoneCallDetailsWithFeatures(Calls.FEATURES_VIDEO); + PhoneCallDetails details = getPhoneCallDetails(); + details.features = Calls.FEATURES_VIDEO; + mHelper.setPhoneCallDetails(mViews, details); + assertIsVideoCall(true); } @@ -173,7 +177,10 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { * Tests a case where the video call feature is not present. */ public void testSetPhoneCallDetails_NoVideo() { - setPhoneCallDetailsWithFeatures(0); + PhoneCallDetails details = getPhoneCallDetails(); + details.features = 0; + mHelper.setPhoneCallDetails(mViews, details); + assertIsVideoCall(false); } @@ -245,7 +252,11 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { } public void testSetCallDetailsHeader_VoicemailNumber() { - setCallDetailsHeaderWithVoicemailNumber(TEST_VOICEMAIL_NUMBER, Calls.PRESENTATION_ALLOWED); + PhoneCallDetails details = getPhoneCallDetails( + TEST_VOICEMAIL_NUMBER, + Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER); + mHelper.setCallDetailsHeader(mNameView, details); assertEquals(View.VISIBLE, mNameView.getVisibility()); assertEquals("Voicemail", mNameView.getText().toString()); } @@ -310,140 +321,75 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { /** Sets the phone call details with default values and the given number. */ private void setPhoneCallDetailsWithNumber(String number, int presentation, String formattedNumber) { - mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails( - mContext, - number, - presentation, - formattedNumber, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{ Calls.VOICEMAIL_TYPE }, - TEST_DATE, - TEST_DURATION, - isVoicemail(number))); + PhoneCallDetails details = getPhoneCallDetails(number, presentation, formattedNumber); + details.callTypes = new int[]{ Calls.VOICEMAIL_TYPE }; + mHelper.setPhoneCallDetails(mViews, details); } /** 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( - mContext, - number, - Calls.PRESENTATION_ALLOWED, - formattedNumber, - TEST_COUNTRY_ISO, - geocodedLocation, - new int[]{ Calls.VOICEMAIL_TYPE }, - TEST_DATE, - TEST_DURATION, - isVoicemail(number))); + private void setPhoneCallDetailsWithNumberAndGeocode( + String number, String formattedNumber, String geocodedLocation) { + PhoneCallDetails details = getPhoneCallDetails( + number, Calls.PRESENTATION_ALLOWED, formattedNumber); + details.geocode = geocodedLocation; + mHelper.setPhoneCallDetails(mViews, details); } /** Sets the phone call details with default values and the given date. */ private void setPhoneCallDetailsWithDate(long date) { - mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{ Calls.INCOMING_TYPE }, - date, - TEST_DURATION, - false /* isVoicemail */)); + PhoneCallDetails details = getPhoneCallDetails(); + details.date = date; + mHelper.setPhoneCallDetails(mViews, details); } /** 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( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - callTypes, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */)); - } - - /** - * Sets the phone call details with default values and the given call features. - */ - private void setPhoneCallDetailsWithFeatures(int features) { - mHelper.setPhoneCallDetails(mViews, - new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{ Calls.INCOMING_TYPE }, - TEST_DATE, - TEST_DURATION, - null, - features, - null, - null, - false /* isVoicemail */) - ); + PhoneCallDetails details = getPhoneCallDetails(); + details.callTypes = callTypes; + mHelper.setPhoneCallDetails(mViews, details); } private void setCallDetailsHeaderWithNumber(String number, int presentation) { mHelper.setCallDetailsHeader(mNameView, - new PhoneCallDetails( - mContext, - number, - presentation, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{ Calls.INCOMING_TYPE }, - TEST_DATE, - TEST_DURATION, - null, 0, null, null, - false /* isVoicemail */)); - } - - private void setCallDetailsHeaderWithVoicemailNumber(String number, int presentation) { - mHelper.setCallDetailsHeader(mNameView, - new PhoneCallDetails( - mContext, - number, - presentation, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{ Calls.INCOMING_TYPE }, - TEST_DATE, - TEST_DURATION, - null, 0, null, null, - true /* isVoicemail */)); + getPhoneCallDetails(number, presentation, TEST_FORMATTED_NUMBER)); } - private void setCallDetailsHeader(String name) { - mHelper.setCallDetailsHeader(mNameView, - new PhoneCallDetails( - mContext, - 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, 0, null, 0, null, null, - false /* isVoicemail */)); + PhoneCallDetails details = getPhoneCallDetails(); + details.name = name; + mHelper.setCallDetailsHeader(mNameView, details); + } + + private PhoneCallDetails getPhoneCallDetails() { + PhoneCallDetails details = new PhoneCallDetails( + mContext, + TEST_NUMBER, + Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, + false /* isVoicemail */); + setDefaultDetails(details); + return details; + } + + private PhoneCallDetails getPhoneCallDetails( + String number, int presentation, String formattedNumber) { + PhoneCallDetails details = new PhoneCallDetails( + mContext, + number, + presentation, + formattedNumber, + isVoicemail(number)); + setDefaultDetails(details); + return details; + } + + private void setDefaultDetails(PhoneCallDetails details) { + details.callTypes = new int[]{ Calls.INCOMING_TYPE }; + details.countryIso = TEST_COUNTRY_ISO; + details.date = TEST_DATE; + details.duration = TEST_DURATION; + details.geocode = TEST_GEOCODE; + details.numberLabel = ContactInfo.GEOCODE_AS_LABEL; } private boolean isVoicemail(String number) { diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java index a7d9b9967..091065b91 100644 --- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java @@ -103,12 +103,14 @@ public class CallLogListItemHelperTest extends AndroidTestCase { } public void testSetPhoneCallDetails_ReadVoicemail() { - setPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE); + PhoneCallDetails details = getPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE); + mHelper.setPhoneCallDetails(getContext(), mViewHolder, details); assertEquals(View.VISIBLE, mViewHolder.voicemailPlaybackView.getVisibility()); } public void testSetPhoneCallDetails_UnreadVoicemail() { - setUnreadPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE); + PhoneCallDetails details = getPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE); + mHelper.setPhoneCallDetails(getContext(), mViewHolder, details); assertEquals(View.VISIBLE, mViewHolder.voicemailPlaybackView.getVisibility()); } @@ -120,121 +122,29 @@ public class CallLogListItemHelperTest extends AndroidTestCase { /** * Test getCallDescriptionID method used to get the accessibility description for calls. - * Test case where an answered unknown call is received. */ - public void testGetCallDescriptionID_UnknownAnswered() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - "", - Calls.PRESENTATION_UNKNOWN, - "", - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.INCOMING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + public void testGetCallDescriptionID_Answered() { + int[] callTypes = new int[]{ Calls.INCOMING_TYPE }; assertEquals(R.string.description_incoming_answered_call, - mHelper.getCallDescriptionStringID(details)); + mHelper.getCallDescriptionStringID(callTypes)); } /** * Test getCallDescriptionID method used to get the accessibility description for calls. - * Test case where an missed unknown call is received. */ - public void testGetCallDescriptionID_UnknownMissed() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - "", - Calls.PRESENTATION_UNKNOWN, - "", - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.MISSED_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + public void testGetCallDescriptionID_Missed() { + int[] callTypes = new int[]{ Calls.MISSED_TYPE }; assertEquals(R.string.description_incoming_missed_call, - mHelper.getCallDescriptionStringID(details)); + mHelper.getCallDescriptionStringID(callTypes)); } /** * Test getCallDescriptionID method used to get the accessibility description for calls. - * Test case where an missed unknown call is received and a voicemail was left. */ - public void testGetCallDescriptionID_UnknownVoicemail() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - "", - Calls.PRESENTATION_UNKNOWN, - "", - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.VOICEMAIL_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + public void testGetCallDescriptionID_Voicemail() { + int[] callTypes = new int[]{ Calls.VOICEMAIL_TYPE }; assertEquals(R.string.description_incoming_missed_call, - mHelper.getCallDescriptionStringID(details)); - } - - /** - * Test getCallDescriptionID method used to get the accessibility description for calls. - * Test case where an answered call from a known caller is received. - */ - public void testGetCallDescriptionID_KnownAnswered() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.INCOMING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); - assertEquals(R.string.description_incoming_answered_call, - mHelper.getCallDescriptionStringID(details)); - } - - /** - * Test getCallDescriptionID method used to get the accessibility description for calls. - * Test case where a missed call from a known caller is received. - */ - public void testGetCallDescriptionID_KnownMissed() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.MISSED_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); - assertEquals(R.string.description_incoming_missed_call, - mHelper.getCallDescriptionStringID(details)); - } - - /** - * Test getCallDescriptionID method used to get the accessibility description for calls. - * Test case where a missed call from a known caller is received and a voicemail was left. - */ - public void testGetCallDescriptionID_KnownVoicemail() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, TEST_GEOCODE, - new int[]{Calls.VOICEMAIL_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); - assertEquals(R.string.description_incoming_missed_call, - mHelper.getCallDescriptionStringID(details)); + mHelper.getCallDescriptionStringID(callTypes)); } /** @@ -243,19 +153,9 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * only a single call for this caller. */ public void testGetCallDescriptionID_OutgoingSingle() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.OUTGOING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + int[] callTypes = new int[]{ Calls.OUTGOING_TYPE }; assertEquals(R.string.description_outgoing_call, - mHelper.getCallDescriptionStringID(details)); + mHelper.getCallDescriptionStringID(callTypes)); } /** @@ -264,19 +164,9 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * many calls for this caller. */ public void testGetCallDescriptionID_OutgoingMultiple() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + int[] callTypes = new int[]{ Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE }; assertEquals(R.string.description_outgoing_call, - mHelper.getCallDescriptionStringID(details)); + mHelper.getCallDescriptionStringID(callTypes)); } /** @@ -284,17 +174,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * For outgoing calls, we should NOT have "New Voicemail" in the description. */ public void testGetCallDescription_NoVoicemailOutgoing() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + PhoneCallDetails details = + getPhoneCallDetailsWithTypes(Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE); CharSequence description = mHelper.getCallDescription(getContext(), details); assertFalse(description.toString() .contains(this.mResources.getString(R.string.description_new_voicemail))); @@ -305,17 +186,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * For regular incoming calls, we should NOT have "New Voicemail" in the description. */ public void testGetCallDescription_NoVoicemailIncoming() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + PhoneCallDetails details = + getPhoneCallDetailsWithTypes(Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE); CharSequence description = mHelper.getCallDescription(getContext(), details); assertFalse(description.toString() .contains(this.mResources.getString(R.string.description_new_voicemail))); @@ -326,17 +198,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * For regular missed calls, we should NOT have "New Voicemail" in the description. */ public void testGetCallDescription_NoVoicemailMissed() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.MISSED_TYPE, Calls.OUTGOING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + PhoneCallDetails details = + getPhoneCallDetailsWithTypes(Calls.MISSED_TYPE, Calls.OUTGOING_TYPE); CharSequence description = mHelper.getCallDescription(getContext(), details); assertFalse(description.toString() .contains(this.mResources.getString(R.string.description_new_voicemail))); @@ -347,17 +210,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * For voicemail calls, we should have "New Voicemail" in the description. */ public void testGetCallDescription_Voicemail() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.VOICEMAIL_TYPE, Calls.OUTGOING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + PhoneCallDetails details = + getPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE, Calls.OUTGOING_TYPE); CharSequence description = mHelper.getCallDescription(getContext(), details); assertTrue(description.toString() .contains(this.mResources.getString(R.string.description_new_voicemail))); @@ -368,16 +222,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * Test that the "X calls" message is not present if there is only a single call. */ public void testGetCallDescription_NumCallsSingle() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{Calls.VOICEMAIL_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + PhoneCallDetails details = getPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE); CharSequence description = mHelper.getCallDescription(getContext(), details); // Rather than hard coding the "X calls" string message, we'll generate it with an empty @@ -393,15 +238,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * Test that the "X calls" message is present if there are many calls. */ public void testGetCallDescription_NumCallsMultiple() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, TEST_GEOCODE, - new int[]{Calls.VOICEMAIL_TYPE, Calls.INCOMING_TYPE}, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */); + PhoneCallDetails details = + getPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE, Calls.INCOMING_TYPE); CharSequence description = mHelper.getCallDescription(getContext(), details); assertTrue(description.toString() .contains(this.mResources.getString(R.string.description_num_calls, 2))); @@ -412,20 +250,9 @@ public class CallLogListItemHelperTest extends AndroidTestCase { * Test that the "Video call." message is present if the call had video capability. */ public void testGetCallDescription_Video() { - PhoneCallDetails details = new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, TEST_GEOCODE, - new int[]{Calls.INCOMING_TYPE, Calls.INCOMING_TYPE}, - TEST_DATE, - TEST_DURATION, - null, - Calls.FEATURES_VIDEO, - null, - null, - false /* isVoicemail */); + PhoneCallDetails details = + getPhoneCallDetailsWithTypes(Calls.INCOMING_TYPE, Calls.INCOMING_TYPE); + details.features = Calls.FEATURES_VIDEO; CharSequence description = mHelper.getCallDescription(getContext(), details); final boolean isVideoEnabled = CallUtil.isVideoEnabled(getContext()); @@ -454,49 +281,42 @@ public class CallLogListItemHelperTest extends AndroidTestCase { /** Sets the details of a phone call using the specified phone number. */ private void setPhoneCallDetailsWithNumberAndType(String number, int presentation, String formattedNumber, int callType) { - mHelper.setPhoneCallDetails(mContext, mViewHolder, - new PhoneCallDetails( - mContext, - number, - presentation, - formattedNumber, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - new int[]{ callType }, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */)); + PhoneCallDetails details = getPhoneCallDetails( + number, presentation, formattedNumber); + details.callTypes = new int[]{ callType }; + mHelper.setPhoneCallDetails(mContext, mViewHolder, details); + } + + private PhoneCallDetails getPhoneCallDetails( + String number, int presentation, String formattedNumber) { + PhoneCallDetails details = new PhoneCallDetails( + mContext, + number, + presentation, + formattedNumber, + false /* isVoicemail */); + setDefaultDetails(details); + return details; } - /** Sets the details of a phone call using the specified call type. */ - private void setPhoneCallDetailsWithTypes(int... types) { - mHelper.setPhoneCallDetails(getContext(), mViewHolder, - new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - types, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */)); + /** Returns the details of a phone call using the specified call type. */ + private PhoneCallDetails getPhoneCallDetailsWithTypes(int... types) { + PhoneCallDetails details = new PhoneCallDetails( + mContext, + TEST_NUMBER, + Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, + false /* isVoicemail */); + setDefaultDetails(details); + details.callTypes = types; + return details; } - /** Sets the details of an unread phone call using the specified call type. */ - private void setUnreadPhoneCallDetailsWithTypes(int... types) { - mHelper.setPhoneCallDetails(getContext(), mViewHolder, - new PhoneCallDetails( - mContext, - TEST_NUMBER, - Calls.PRESENTATION_ALLOWED, - TEST_FORMATTED_NUMBER, - TEST_COUNTRY_ISO, - TEST_GEOCODE, - types, - TEST_DATE, - TEST_DURATION, - false /* isVoicemail */)); + private void setDefaultDetails(PhoneCallDetails details) { + details.callTypes = new int[]{ Calls.INCOMING_TYPE }; + details.countryIso = TEST_COUNTRY_ISO; + details.date = TEST_DATE; + details.duration = TEST_DURATION; + details.geocode = TEST_GEOCODE; } } |