summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorSarmad Hashmi <mhashmi@google.com>2016-01-22 13:07:32 -0800
committerSarmad Hashmi <mhashmi@google.com>2016-02-24 21:26:58 +0000
commit5d9fdc591a5e8b5b8b0cbb1d9060f10fc2816325 (patch)
tree09d251a70e1b93ad5dea94b0b888321feeb21ccc /tests/src
parent450a605729a2d45710e988e5ff4855eb36137e8f (diff)
Collapsed and expanded voicemail cards show duration.
The duration of the voicemail is appended to the date in a MM:SS format. BUG=25728257 Change-Id: I9c3e392336877c2ca69707e14c6ab2eed6f2e7c6 (cherry picked from commit 3f70c27d80b2e3176159f561248f95612d66afe2)
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java
index b6202b904..4e00a462b 100644
--- a/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/dialer/calllog/PhoneCallDetailsHelperTest.java
@@ -34,6 +34,8 @@ import com.android.dialer.util.LocaleTestUtils;
import java.util.GregorianCalendar;
import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Unit tests for {@link PhoneCallDetailsHelper}.
@@ -141,7 +143,27 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
public void testVoicemailLocationNotShownWithDate() {
setVoicemailPhoneCallDetailsWithDate(TEST_DATE);
- assertLocationAndDateExactEquals("Jun 3 at 1:00 PM");
+ assertLocationAndDateExactEquals("Jun 3 at 1:00 PM • 99:20");
+ }
+
+ public void testVoicemailDuration() {
+ setVoicemailPhoneCallDetailsWithDuration(100);
+ assertDurationExactEquals("01:40");
+ }
+
+ public void testVoicemailDuration_Capped() {
+ setVoicemailPhoneCallDetailsWithDuration(TEST_DURATION);
+ assertDurationExactEquals("99:20");
+ }
+
+ public void testVoicemailDuration_Zero() {
+ setVoicemailPhoneCallDetailsWithDuration(0);
+ assertDurationExactEquals("00:00");
+ }
+
+ public void testVoicemailDuration_EvenMinute() {
+ setVoicemailPhoneCallDetailsWithDuration(60);
+ assertDurationExactEquals("01:00");
}
/** Asserts that a char sequence is actually a Spanned corresponding to the expected HTML. */
@@ -346,6 +368,14 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
assertEquals(text, mViews.callLocationAndDate.getText());
}
+ /** Asserts that the duration is exactly as included in the location and date text field. */
+ private void assertDurationExactEquals(String text) {
+ Matcher matcher = Pattern.compile("(.*) (\\u2022) (\\d{2}:\\d{2})").matcher(
+ mViews.callLocationAndDate.getText());
+ assertEquals(true, matcher.matches());
+ assertEquals(text, matcher.group(3));
+ }
+
/** Asserts that the video icon is shown. */
private void assertIsVideoCall(boolean isVideoCall) {
assertEquals(isVideoCall, mViews.callTypeIcons.isVideoShown());
@@ -407,6 +437,14 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
mHelper.setPhoneCallDetails(mViews, details);
}
+ /** Sets the voice mail details with default values and the given duration. */
+ private void setVoicemailPhoneCallDetailsWithDuration(long duration) {
+ PhoneCallDetails details = getPhoneCallDetails();
+ details.duration = duration;
+ 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();