diff options
author | Brandon Maxwell <maxwelb@google.com> | 2015-10-02 23:45:13 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-10-02 23:45:13 +0000 |
commit | d9833cd25c5d2698699d82b0d0fc163db653810e (patch) | |
tree | 6763656f120a31dbb362b2084c2b41173f88b6f6 /tests | |
parent | 64dffce08a6e63755a0863f9c7975421af572c24 (diff) | |
parent | ede9bfb0d5d5a14883ac0390dc7405349e8e4c34 (diff) |
Merge "Modifying voicemail call log date and time format" into ub-contactsdialer-a-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java index dfacf4605..263642c96 100644 --- a/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java +++ b/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java @@ -42,6 +42,8 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { /** The date of the call log entry. */ private static final long TEST_DATE = new GregorianCalendar(2011, 5, 3, 13, 0, 0).getTimeInMillis(); + private static final long INJECTED_CURRENT_DATE = + new GregorianCalendar(2011, 5, 4, 13, 0, 0).getTimeInMillis(); /** A test duration value for phone calls. */ private static final long TEST_DURATION = 62300; /** The number of the caller/callee in the log entry. */ @@ -74,8 +76,7 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { final TestTelecomCallLogCache phoneUtils = new TestTelecomCallLogCache( mContext, TEST_VOICEMAIL_NUMBER); mHelper = new PhoneCallDetailsHelper(mContext, resources, phoneUtils); - mHelper.setCurrentTimeForTest( - new GregorianCalendar(2011, 5, 4, 13, 0, 0).getTimeInMillis()); + mHelper.setCurrentTimeForTest(INJECTED_CURRENT_DATE); mViews = PhoneCallDetailsViews.createForTest(mContext); mNameView = new TextView(mContext); mLocaleTestUtils = new LocaleTestUtils(mContext); @@ -112,10 +113,25 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { assertNameEqualsResource(R.string.voicemail); } - public void testSetPhoneCallDetails_Normal() { - setPhoneCallDetailsWithNumber("14125551212", - Calls.PRESENTATION_ALLOWED, "1-412-555-1212"); - assertTrue(mViews.callLocationAndDate.getText().toString().contains("Yesterday")); + // Voicemail date string has 3 different formats depending on how long ago the call was placed + public void testSetVoicemailPhoneCallDetails_Today() { + setVoicemailPhoneCallDetailsWithDate(System.currentTimeMillis()); + assertDateEquals("Today at"); + } + + public void testSetVoicemailPhoneCallDetails_WithinCurrentYear() { + mHelper.setCurrentTimeForTest(INJECTED_CURRENT_DATE); + String formattedTestDate = "Jun 3 at 1:00 PM"; + setVoicemailPhoneCallDetailsWithDate(TEST_DATE); + assertDateEquals(formattedTestDate); + } + + public void testSetVoicemailPhoneCallDetails_OutsideCurrentYear() { + mHelper.setCurrentTimeForTest(INJECTED_CURRENT_DATE); + long testDate = new GregorianCalendar(2009, 5, 3, 13, 0, 0).getTimeInMillis(); + String formattedTestDate = "Jun 3, 2009 at 1:00 PM"; + setVoicemailPhoneCallDetailsWithDate(testDate); + assertDateEquals(formattedTestDate); } /** Asserts that a char sequence is actually a Spanned corresponding to the expected HTML. */ @@ -314,7 +330,6 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { assertEquals(id, mViews.callTypeIcons.getCallType(index)); } assertEquals(View.VISIBLE, mViews.callTypeIcons.getVisibility()); - assertTrue(mViews.callLocationAndDate.getText().toString().contains("Yesterday")); } /** @@ -356,6 +371,13 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { mHelper.setPhoneCallDetails(mViews, details); } + private void setVoicemailPhoneCallDetailsWithDate(long date) { + PhoneCallDetails details = getPhoneCallDetails(); + details.date = date; + details.callTypes = new int[] {Calls.VOICEMAIL_TYPE}; + mHelper.setPhoneCallDetails(mViews, details); + } + /** Sets the phone call details with default values and the given call types using icons. */ private void setPhoneCallDetailsWithCallTypeIcons(int... callTypes) { PhoneCallDetails details = getPhoneCallDetails(); |