summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-06-03 18:03:27 -0700
committerAndrew Lee <anwlee@google.com>2015-06-03 18:25:35 -0700
commitbdf60d080ccab765e659b0e27b1fdb7122f5d008 (patch)
tree9839a9ed5fb283e2808bf82200bfcdd861781f61
parentf42d5ee4d6581d2cb746e615dbb3c94375f8990c (diff)
Fix unit test errors.
When this was refactored before, some of the logic was bad. Some of the expected values were changed as well. I figured "add to contacts" is a really bad default text, because we don't actually support that action in call details. Also, the strings returned by the library for describing relative time spans changed. Bug: 21471763 Change-Id: I0c78c89c9c2e44de198f1f9299711fc31fe81cb1
-rw-r--r--src/com/android/dialer/PhoneCallDetailsHelper.java8
-rw-r--r--src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java8
-rw-r--r--tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java25
3 files changed, 30 insertions, 11 deletions
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java
index db37bb3f3..c8206227a 100644
--- a/src/com/android/dialer/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/PhoneCallDetailsHelper.java
@@ -212,10 +212,12 @@ public class PhoneCallDetailsHelper {
@NeededForTesting
public void setCallDetailsHeader(TextView nameView, PhoneCallDetails details) {
final CharSequence nameText;
- if (TextUtils.isEmpty(details.name)) {
- nameText = mResources.getString(R.string.recentCalls_addToContact);
- } else {
+ if (!TextUtils.isEmpty(details.name)) {
nameText = details.name;
+ } else if (!TextUtils.isEmpty(details.displayNumber)) {
+ nameText = details.displayNumber;
+ } else {
+ nameText = mResources.getString(R.string.unknown);
}
nameView.setText(nameText);
diff --git a/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java b/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java
index e7fcde263..acfd32cf3 100644
--- a/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java
+++ b/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java
@@ -71,14 +71,14 @@ public class PhoneNumberDisplayUtil {
int presentation,
CharSequence formattedNumber,
boolean isVoicemail) {
- if (!TextUtils.isEmpty(formattedNumber)) {
- return formattedNumber;
- }
-
final CharSequence displayName =
getDisplayName(context, accountHandle, number, presentation, isVoicemail);
if (!TextUtils.isEmpty(displayName)) {
return displayName;
+ }
+
+ if (!TextUtils.isEmpty(formattedNumber)) {
+ return formattedNumber;
} else if (!TextUtils.isEmpty(number)) {
return number;
} else {
diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
index 701a06ed9..3e7eb66b6 100644
--- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
@@ -132,11 +132,11 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
setPhoneCallDetailsWithDate(
new GregorianCalendar(2011, 5, 3, 13, 0, 0).getTimeInMillis());
- assertDateEquals("0 mins ago");
+ assertDateEquals("0 min. ago");
setPhoneCallDetailsWithDate(
new GregorianCalendar(2011, 5, 3, 12, 0, 0).getTimeInMillis());
- assertDateEquals("1 hour ago");
+ assertDateEquals("1 hr. ago");
setPhoneCallDetailsWithDate(
new GregorianCalendar(2011, 5, 2, 13, 0, 0).getTimeInMillis());
@@ -223,7 +223,7 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
public void testSetCallDetailsHeader_NumberOnly() {
setCallDetailsHeaderWithNumber(TEST_NUMBER, Calls.PRESENTATION_ALLOWED);
assertEquals(View.VISIBLE, mNameView.getVisibility());
- assertEquals("Add to contacts", mNameView.getText().toString());
+ assertEquals("1-412-255-5555", mNameView.getText().toString());
}
public void testSetCallDetailsHeader_UnknownNumber() {
@@ -245,7 +245,7 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
}
public void testSetCallDetailsHeader_VoicemailNumber() {
- setCallDetailsHeaderWithNumber(TEST_VOICEMAIL_NUMBER, Calls.PRESENTATION_ALLOWED);
+ setCallDetailsHeaderWithVoicemailNumber(TEST_VOICEMAIL_NUMBER, Calls.PRESENTATION_ALLOWED);
assertEquals(View.VISIBLE, mNameView.getVisibility());
assertEquals("Voicemail", mNameView.getText().toString());
}
@@ -412,6 +412,23 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
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 */));
+ }
+
+
private void setCallDetailsHeader(String name) {
mHelper.setCallDetailsHeader(mNameView,
new PhoneCallDetails(