aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Patterson <jdp@google.com>2021-01-12 15:34:45 +0100
committerJohn Patterson <jdp@google.com>2021-01-12 16:39:36 +0100
commit6a802e58054c7c9da8245ba291c4d773b090543a (patch)
treea3a97ca36ad67570e005be59663610c8bdbc6b2f /tests
parent7d430a6b6adcdf803124ef2f0943c8917a0dc916 (diff)
downloadCalendar-6a802e58054c7c9da8245ba291c4d773b090543a.tar.gz
Unbundle the Car Calendar App.
Set the sdk_version to "system_current". Remove use of hidden APIs for phone number validation and formatting. Test: Manual testing on Hawk and updated and ran all tests. Bug: 176965230 Change-Id: Id33da19d10f0780c9f569dfd98957eb33fa6b00a
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