From 0e1bfc32db89820e86262a0587dd90263c78caeb Mon Sep 17 00:00:00 2001 From: Nancy Chen Date: Wed, 28 Oct 2015 18:04:42 -0700 Subject: Fix Open Now in Contact Context to account for after midnight times. Originally the close time was set to the same date as the open time, but sometimes a place is open past midnight, which means that it's open until the next day. Update this so that Open Now correctly represents the state even when the place is open past midnight. Bug: 25345785 Change-Id: I417ecb046bb2d5f708279f2b3808af0afd7662c7 --- .../incallui/InCallContactInteractionsTest.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'InCallUI/tests') diff --git a/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java b/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java index b97be01ee..50d0aaf6c 100644 --- a/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java +++ b/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java @@ -44,6 +44,26 @@ public class InCallContactInteractionsTest extends AndroidTestCase { assertEquals(mContext.getString(R.string.open_now), info.heading); } + public void testIsOpenNow_ClosingAfterMidnight() { + Calendar currentTimeForTest = Calendar.getInstance(); + currentTimeForTest.set(Calendar.HOUR_OF_DAY, 10); + BusinessContextInfo info = + mInCallContactInteractions.constructHoursInfo( + currentTimeForTest, + Pair.create("0800", "0100")); + assertEquals(mContext.getString(R.string.open_now), info.heading); + } + + public void testIsOpenNow_Open24Hours() { + Calendar currentTimeForTest = Calendar.getInstance(); + currentTimeForTest.set(Calendar.HOUR_OF_DAY, 10); + BusinessContextInfo info = + mInCallContactInteractions.constructHoursInfo( + currentTimeForTest, + Pair.create("0800", "0800")); + assertEquals(mContext.getString(R.string.open_now), info.heading); + } + public void testIsClosedNow_BeforeOpen() { Calendar currentTimeForTest = Calendar.getInstance(); currentTimeForTest.set(Calendar.HOUR_OF_DAY, 6); -- cgit v1.2.3