diff options
author | Nancy Chen <nancychen@google.com> | 2015-10-22 17:02:01 -0700 |
---|---|---|
committer | Nancy Chen <nancychen@google.com> | 2015-10-23 17:08:03 -0700 |
commit | a26fd83cf27789b3e40ac680d7be75ed984abb39 (patch) | |
tree | 83adf0beb4e77f7c435b96e9eb311e45eca964a6 /InCallUI/tests/src | |
parent | ef7ebe3065bbef11a48118ac2d642d50c37895a7 (diff) |
Add the city/locality to the displayed business information.
To disambiguate, include the city/locality with the address in the form
"[street address], [city/locality]" in the contact interactions. Also
add tests to ensure the construction of the location info is correct.
Bug: 23351559
Change-Id: Ib0b2ce8a80a8494d5b006a6a74ad94447befc0ef
Diffstat (limited to 'InCallUI/tests/src')
-rw-r--r-- | InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java b/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java index c3ec08d69..b97be01ee 100644 --- a/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java +++ b/InCallUI/tests/src/com/android/incallui/InCallContactInteractionsTest.java @@ -16,15 +16,18 @@ package com.android.incallui; +import android.location.Address; import android.test.AndroidTestCase; import android.util.Pair; import com.android.incallui.InCallContactInteractions.BusinessContextInfo; import java.util.Calendar; +import java.util.Locale; public class InCallContactInteractionsTest extends AndroidTestCase { private InCallContactInteractions mInCallContactInteractions; + private static final float TEST_DISTANCE = (float) 1234.56; @Override protected void setUp() { @@ -35,7 +38,7 @@ public class InCallContactInteractionsTest extends AndroidTestCase { Calendar currentTimeForTest = Calendar.getInstance(); currentTimeForTest.set(Calendar.HOUR_OF_DAY, 10); BusinessContextInfo info = - mInCallContactInteractions.constructHoursInfoByTime( + mInCallContactInteractions.constructHoursInfo( currentTimeForTest, Pair.create("0800", "2000")); assertEquals(mContext.getString(R.string.open_now), info.heading); @@ -45,7 +48,7 @@ public class InCallContactInteractionsTest extends AndroidTestCase { Calendar currentTimeForTest = Calendar.getInstance(); currentTimeForTest.set(Calendar.HOUR_OF_DAY, 6); BusinessContextInfo info = - mInCallContactInteractions.constructHoursInfoByTime( + mInCallContactInteractions.constructHoursInfo( currentTimeForTest, Pair.create("0800", "2000")); assertEquals(mContext.getString(R.string.closed_now), info.heading); @@ -55,7 +58,7 @@ public class InCallContactInteractionsTest extends AndroidTestCase { Calendar currentTimeForTest = Calendar.getInstance(); currentTimeForTest.set(Calendar.HOUR_OF_DAY, 21); BusinessContextInfo info = - mInCallContactInteractions.constructHoursInfoByTime( + mInCallContactInteractions.constructHoursInfo( currentTimeForTest, Pair.create("0800", "2000")); assertEquals(mContext.getString(R.string.closed_now), info.heading); @@ -65,9 +68,66 @@ public class InCallContactInteractionsTest extends AndroidTestCase { Calendar currentTimeForTest = Calendar.getInstance(); currentTimeForTest.set(Calendar.HOUR_OF_DAY, 21); BusinessContextInfo info = - mInCallContactInteractions.constructHoursInfoByTime( + mInCallContactInteractions.constructHoursInfo( currentTimeForTest, Pair.create("", "2000")); assertEquals(null, info); } + + public void testLocationInfo_ForUS() { + BusinessContextInfo info = + mInCallContactInteractions.constructLocationInfo( + Locale.US, + getAddressForTest(), + TEST_DISTANCE); + assertEquals("0.8 mi away", info.heading); + assertEquals("Test address, Test locality", info.detail); + } + + public void testLocationInfo_ForNotUS() { + BusinessContextInfo info = + mInCallContactInteractions.constructLocationInfo( + Locale.CANADA, + getAddressForTest(), + TEST_DISTANCE); + assertEquals("1.2 km away", info.heading); + assertEquals("Test address, Test locality", info.detail); + } + + public void testLocationInfo_NoLocality() { + Address address = getAddressForTest(); + address.setLocality(null); + BusinessContextInfo info = + mInCallContactInteractions.constructLocationInfo( + Locale.CANADA, + address, + TEST_DISTANCE); + assertEquals("1.2 km away", info.heading); + assertEquals("Test address", info.detail); + } + + public void testLocationInfo_NoAddress() { + BusinessContextInfo info = + mInCallContactInteractions.constructLocationInfo( + Locale.CANADA, + null, + TEST_DISTANCE); + assertEquals(null, info); + } + + public void testLocationInfo_NoDistance() { + BusinessContextInfo info = + mInCallContactInteractions.constructLocationInfo( + Locale.US, + getAddressForTest(), + DistanceHelper.DISTANCE_NOT_FOUND); + assertEquals(null, info.heading); + } + + private Address getAddressForTest() { + Address address = new Address(Locale.US); + address.setAddressLine(0, "Test address"); + address.setLocality("Test locality"); + return address; + } } |