aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2021-06-18 12:24:37 -0700
committerXin Li <delphij@google.com>2021-06-18 12:24:37 -0700
commitb5d7eaf2a045732ed6d5d71fb2277a3cba140bb0 (patch)
treee4296a97494f1074f2308c5d357fa7e18c03f9a5 /tests
parentff31819f6154e7399965f41e8df741bad48f1ca6 (diff)
parent034483b102d83334d3c02c572c153753d20224ca (diff)
downloadCalendar-b5d7eaf2a045732ed6d5d71fb2277a3cba140bb0.tar.gz
DO NOT MERGE - Merge RQ3A.210605.005android-s-beta-4android-s-beta-3android-s-beta-4
Bug: 190855093 Merged-In: I95598726cdbd28a578a9471f8c1ac7ce57aa9350 Change-Id: I5f53018f393eb560d0f33af395c9ab20d9f08901
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java4
-rw-r--r--tests/unit/src/com/android/car/calendar/common/EventDescriptionsTest.java23
2 files changed, 19 insertions, 8 deletions
diff --git a/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java b/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java
index 5c7883c..d342e3d 100644
--- a/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java
+++ b/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java
@@ -35,6 +35,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.provider.CalendarContract;
+import android.telephony.TelephonyManager;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
@@ -122,7 +123,8 @@ public class CarCalendarUiTest {
new TestCalendarContentProvider(context);
mockContentResolver.addProvider(CalendarContract.AUTHORITY, testCalendarContentProvider);
activity.mDependencies =
- new CarCalendarActivity.Dependencies(LOCALE, fixedTimeClock, mockContentResolver);
+ new CarCalendarActivity.Dependencies(LOCALE, fixedTimeClock, mockContentResolver,
+ activity.getSystemService(TelephonyManager.class));
}
private void observeEventsLiveData(CarCalendarActivity activity) {
diff --git a/tests/unit/src/com/android/car/calendar/common/EventDescriptionsTest.java b/tests/unit/src/com/android/car/calendar/common/EventDescriptionsTest.java
index 358e9cf..bea029f 100644
--- a/tests/unit/src/com/android/car/calendar/common/EventDescriptionsTest.java
+++ b/tests/unit/src/com/android/car/calendar/common/EventDescriptionsTest.java
@@ -18,28 +18,36 @@ package com.android.car.calendar.common;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
+
import android.net.Uri;
+import android.telephony.TelephonyManager;
import com.google.common.collect.Iterables;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Locale;
public class EventDescriptionsTest {
-
private static final String BASE_NUMBER = "30 303986300";
private static final String LOCAL_NUMBER = "0" + BASE_NUMBER;
private static final String INTERNATIONAL_NUMBER = "+49 " + BASE_NUMBER;
private static final String ACCESS = ",,12;3*45#";
+ private static final String COUNTRY_ISO_CODE = "DE";
+
private EventDescriptions mEventDescriptions;
+ private TelephonyManager mMockTelephonyManager;
@Before
public void setUp() {
- mEventDescriptions = new EventDescriptions(Locale.GERMANY);
+ mMockTelephonyManager = Mockito.mock(TelephonyManager.class);
+ when(mMockTelephonyManager.getNetworkCountryIso()).thenReturn(COUNTRY_ISO_CODE);
+ mEventDescriptions = new EventDescriptions(Locale.GERMANY, mMockTelephonyManager);
}
@Test
@@ -48,7 +56,7 @@ public class EventDescriptionsTest {
mEventDescriptions.extractNumberAndPins(LOCAL_NUMBER);
assertThat(numberAndAccesses).isNotEmpty();
Dialer.NumberAndAccess numberAndAccess = Iterables.getFirst(numberAndAccesses, null);
- assertThat(numberAndAccess.getNumber()).isEqualTo(INTERNATIONAL_NUMBER);
+ assertThat(numberAndAccess.getNumber()).isEqualTo(LOCAL_NUMBER);
}
@Test
@@ -62,9 +70,10 @@ public class EventDescriptionsTest {
@Test
public void extractNumberAndPin_internationalNumberWithDifferentLocale_resultIsInternational() {
- mEventDescriptions = new EventDescriptions(Locale.FRANCE);
+ EventDescriptions eventDescriptions =
+ new EventDescriptions(Locale.FRANCE, mMockTelephonyManager);
List<Dialer.NumberAndAccess> numberAndAccesses =
- mEventDescriptions.extractNumberAndPins(INTERNATIONAL_NUMBER);
+ eventDescriptions.extractNumberAndPins(INTERNATIONAL_NUMBER);
assertThat(numberAndAccesses).isNotEmpty();
Dialer.NumberAndAccess numberAndAccess = Iterables.getFirst(numberAndAccesses, null);
assertThat(numberAndAccess.getNumber()).isEqualTo(INTERNATIONAL_NUMBER);
@@ -105,8 +114,8 @@ public class EventDescriptionsTest {
List<Dialer.NumberAndAccess> numberAndAccesses =
mEventDescriptions.extractNumberAndPins(input);
- // The local number is valid but repeated so only included once.
- assertThat(numberAndAccesses).hasSize(1);
+ // Keep all variations of a base number.
+ assertThat(numberAndAccesses).hasSize(3);
}
@Test