diff options
author | Nancy Chen <nancychen@google.com> | 2015-11-11 16:24:15 -0800 |
---|---|---|
committer | Nancy Chen <nancychen@google.com> | 2015-11-12 12:03:56 -0800 |
commit | c2087df5fac6bc8760395ebf8c8366c569fa2f9d (patch) | |
tree | a68fe916a3266141ea595b88a3dd60ec35597167 /InCallUI/tests/src | |
parent | 3c4f8067c0ce904fb05c8ef427cf8ff083ba334e (diff) |
Modify the hours of operation display text for multiple intervals.
In order to not overflow the business hours display, we only want to
display two intervals at most. Other logic will be used for determining
what to display if there are more than 2 intervals, it is currently closed
between intervals, and it is closed after all open hours.
Bug: 25488385
Change-Id: I9a3ee2967dfd0acc9a9cdc653b27e45c358255e8
Diffstat (limited to 'InCallUI/tests/src')
-rw-r--r-- | InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java | 84 |
1 files changed, 69 insertions, 15 deletions
diff --git a/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java b/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java index 0d03848b6..1c2e9ded7 100644 --- a/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java +++ b/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java @@ -25,6 +25,7 @@ import com.android.incallui.InCallContactInteractions.BusinessContextInfo; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.List; import java.util.Locale; /** @@ -137,10 +138,10 @@ public class InCallContactInteractionsTest extends AndroidTestCase { .heading); } - public void testOpeningHours_SingleOpenRange() { + public void testOpeningHours_SingleOpenRangeWhileOpen() { assertEquals("8:00 AM - 8:00 PM", mInCallContactInteractions.constructHoursInfo( - getTestCalendarWithHour(21), + getTestCalendarWithHour(12), Arrays.asList( Pair.create( getTestCalendarWithHour(8), @@ -148,10 +149,10 @@ public class InCallContactInteractionsTest extends AndroidTestCase { .detail); } - public void testOpeningHours_TwoOpenRanges() { + public void testOpeningHours_TwoOpenRangesWhileOpen() { assertEquals("8:00 AM - 10:00 AM, 12:00 PM - 3:00 PM", mInCallContactInteractions.constructHoursInfo( - getTestCalendarWithHour(13), + getTestCalendarWithHour(12), Arrays.asList( Pair.create( getTestCalendarWithHour(8), @@ -162,20 +163,54 @@ public class InCallContactInteractionsTest extends AndroidTestCase { .detail); } - public void testOpeningHours_MultipleOpenRanges() { - assertEquals("8:00 AM - 10:00 AM, 12:00 PM - 3:00 PM, 5:00 PM - 9:00 PM", + public void testOpeningHours_AfterClosedNoTomorrow() { + assertEquals("Closed today at 8:00 PM", mInCallContactInteractions.constructHoursInfo( - getTestCalendarWithHour(13), + getTestCalendarWithHour(21), Arrays.asList( Pair.create( - getTestCalendarWithHour(8), - getTestCalendarWithHour(10)), - Pair.create( - getTestCalendarWithHour(12), - getTestCalendarWithHour(15)), - Pair.create( - getTestCalendarWithHour(17), - getTestCalendarWithHour(21)))) + getTestCalendarWithHour(8), + getTestCalendarWithHour(20)))) + .detail); + } + + public void testMultipleOpenRanges_BeforeOpen() { + assertEquals("Opens today at 8:00 AM", + mInCallContactInteractions.constructHoursInfo( + getTestCalendarWithHour(7), + getMultipleOpeningHours()) + .detail); + } + + public void testMultipleOpenRanges_DuringFirstRange() { + assertEquals("Closes at 10:00 AM", + mInCallContactInteractions.constructHoursInfo( + getTestCalendarWithHour(9), + getMultipleOpeningHours()) + .detail); + } + + public void testMultipleOpenRanges_BeforeMiddleRange() { + assertEquals("Opens today at 12:00 PM", + mInCallContactInteractions.constructHoursInfo( + getTestCalendarWithHour(11), + getMultipleOpeningHours()) + .detail); + } + + public void testMultipleOpeningHours_DuringLastRange() { + assertEquals("Closes at 9:00 PM", + mInCallContactInteractions.constructHoursInfo( + getTestCalendarWithHour(19), + getMultipleOpeningHours()) + .detail); + } + + public void testMultipleOpeningHours_AfterClose() { + assertEquals("Opens tomorrow at 8:00 AM", + mInCallContactInteractions.constructHoursInfo( + getTestCalendarWithHour(22), + getMultipleOpeningHours()) .detail); } @@ -257,4 +292,23 @@ public class InCallContactInteractionsTest extends AndroidTestCase { calendar.add(Calendar.DATE, daysFromToday); return calendar; } + + private List<Pair<Calendar, Calendar>> getMultipleOpeningHours() { + return Arrays.asList( + Pair.create( + getTestCalendarWithHour(8), + getTestCalendarWithHour(10)), + Pair.create( + getTestCalendarWithHour(12), + getTestCalendarWithHour(15)), + Pair.create( + getTestCalendarWithHour(17), + getTestCalendarWithHour(21)), + Pair.create( + getTestCalendarWithHourAndDaysFromToday(8, 1), + getTestCalendarWithHourAndDaysFromToday(10, 1)), + Pair.create( + getTestCalendarWithHourAndDaysFromToday(12, 1), + getTestCalendarWithHourAndDaysFromToday(8, 1))); + } } |