Adopt robolectric 3.5.1

Bug: 70685114
Test: make RunEmergencyInfoRoboTests
Change-Id: I8aeab1016dd51e2985add5fbec89edd70d2cc0a3
diff --git a/Android.mk b/Android.mk
index 2587d6f..55d68b5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -12,10 +12,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
+
 include $(CLEAR_VARS)
 
+LOCAL_PACKAGE_NAME := EmergencyInfo
 LOCAL_MODULE_TAGS := eng
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+
+LOCAL_PRIVILEGED_MODULE := true
+
 LOCAL_STATIC_ANDROID_LIBRARIES := \
     android-support-v14-preference \
     android-support-v13 \
@@ -26,21 +32,16 @@
     android-support-design \
     android-support-transition
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res
-
 LOCAL_USE_AAPT2 := true
 
-LOCAL_PACKAGE_NAME := EmergencyInfo
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
 LOCAL_CERTIFICATE := platform
-LOCAL_PRIVILEGED_MODULE := true
-
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.emergency.*
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
 
 include frameworks/base/packages/SettingsLib/common.mk
 
 include $(BUILD_PACKAGE)
 
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(call first-makefiles-under, $(LOCAL_PATH))
\ No newline at end of file
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index efcd332..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# Include all makefiles in subdirectories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/robolectric/Android.mk b/tests/robolectric/Android.mk
index 4b2c618..86ac475 100644
--- a/tests/robolectric/Android.mk
+++ b/tests/robolectric/Android.mk
@@ -15,25 +15,23 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := \
-    junit \
-    platform-robolectric-3.1.1-prebuilt \
-    sdk_vcurrent \
-    android.test.base
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-v7-preference \
+    platform-robolectric-android-all-stubs \
     mockito-robolectric-prebuilt \
     truth-prebuilt \
     emergencyinfo-test-common
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_JAVA_LIBRARIES := \
+    junit \
+    platform-robolectric-3.5.1-prebuilt
 
 LOCAL_INSTRUMENTATION_FOR := EmergencyInfo
 LOCAL_MODULE := EmergencyInfoRoboTests
 
+LOCAL_MODULE_TAGS := optional
+
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 #############################################################
@@ -50,6 +48,4 @@
 
 LOCAL_TEST_PACKAGE := EmergencyInfo
 
-LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src
-
-include prebuilts/misc/common/robolectric/3.1.1/run_robotests.mk
+include prebuilts/misc/common/robolectric/3.5.1/run_robotests.mk
\ No newline at end of file
diff --git a/tests/robolectric/src/com/android/emergency/EmergencySearchIndexablesProviderTest.java b/tests/robolectric/src/com/android/emergency/EmergencySearchIndexablesProviderTest.java
index 51cf592..7989230 100644
--- a/tests/robolectric/src/com/android/emergency/EmergencySearchIndexablesProviderTest.java
+++ b/tests/robolectric/src/com/android/emergency/EmergencySearchIndexablesProviderTest.java
@@ -19,7 +19,6 @@
 
 import android.database.Cursor;
 import android.provider.SearchIndexablesContract;
-import android.test.suitebuilder.annotation.SmallTest;
 
 import com.android.emergency.R;
 import com.android.emergency.TestConfig;
@@ -34,7 +33,6 @@
 import org.robolectric.annotation.Config;
 
 /** Unit tests for {@link EmergencySearchIndexablesProvider}. */
-@SmallTest
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public final class EmergencySearchIndexablesProviderTest {
diff --git a/tests/robolectric/src/com/android/emergency/preferences/ContactPreferencesTest.java b/tests/robolectric/src/com/android/emergency/preferences/ContactPreferencesTest.java
index 7a039e4..a1f9a07 100644
--- a/tests/robolectric/src/com/android/emergency/preferences/ContactPreferencesTest.java
+++ b/tests/robolectric/src/com/android/emergency/preferences/ContactPreferencesTest.java
@@ -32,7 +32,6 @@
 import android.net.Uri;
 import android.os.Looper;
 import android.provider.ContactsContract;
-import android.test.suitebuilder.annotation.SmallTest;
 
 import com.android.emergency.ContactTestUtils;
 import com.android.emergency.EmergencyContactManager;
@@ -53,7 +52,6 @@
 import org.robolectric.annotation.Config;
 
 /** Unit tests for {@link ContactPreferences}. */
-@SmallTest
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class ContactPreferencesTest {
diff --git a/tests/robolectric/src/com/android/emergency/preferences/EmergencyContactsPreferenceTest.java b/tests/robolectric/src/com/android/emergency/preferences/EmergencyContactsPreferenceTest.java
index 6cc07c0..caddd12 100644
--- a/tests/robolectric/src/com/android/emergency/preferences/EmergencyContactsPreferenceTest.java
+++ b/tests/robolectric/src/com/android/emergency/preferences/EmergencyContactsPreferenceTest.java
@@ -32,7 +32,6 @@
 import android.support.v7.preference.PreferenceGroup;
 import android.support.v7.preference.PreferenceManager;
 import android.support.v7.preference.PreferenceScreen;
-import android.test.suitebuilder.annotation.SmallTest;
 
 import com.android.emergency.ContactTestUtils;
 import com.android.emergency.EmergencyContactManager;
@@ -52,7 +51,6 @@
 import org.robolectric.annotation.Config;
 
 /** Unit tests for {@link EmergencyContactsPreference}. */
-@SmallTest
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class EmergencyContactsPreferenceTest {
diff --git a/tests/robolectric/src/com/android/emergency/preferences/EmergencyEditTextPreferenceTest.java b/tests/robolectric/src/com/android/emergency/preferences/EmergencyEditTextPreferenceTest.java
index 1dc6b1f..fbac306 100644
--- a/tests/robolectric/src/com/android/emergency/preferences/EmergencyEditTextPreferenceTest.java
+++ b/tests/robolectric/src/com/android/emergency/preferences/EmergencyEditTextPreferenceTest.java
@@ -26,7 +26,6 @@
 import android.support.v7.preference.PreferenceGroup;
 import android.support.v7.preference.PreferenceManager;
 import android.support.v7.preference.PreferenceScreen;
-import android.test.suitebuilder.annotation.SmallTest;
 
 import com.android.emergency.PreferenceKeys;
 import com.android.emergency.TestConfig;
@@ -41,7 +40,6 @@
 import org.robolectric.annotation.Config;
 
 /** Unit tests for {@link EmergencyEditTextPreference}. */
-@SmallTest
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class EmergencyEditTextPreferenceTest {
diff --git a/tests/robolectric/src/com/android/emergency/preferences/EmergencyListPreferenceTest.java b/tests/robolectric/src/com/android/emergency/preferences/EmergencyListPreferenceTest.java
index e96d0fb..df7eb1b 100644
--- a/tests/robolectric/src/com/android/emergency/preferences/EmergencyListPreferenceTest.java
+++ b/tests/robolectric/src/com/android/emergency/preferences/EmergencyListPreferenceTest.java
@@ -21,14 +21,11 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
-import android.test.suitebuilder.annotation.SmallTest;
-
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.support.v7.preference.PreferenceGroup;
 import android.support.v7.preference.PreferenceManager;
 import android.support.v7.preference.PreferenceScreen;
-import android.test.suitebuilder.annotation.SmallTest;
 import android.text.TextUtils;
 
 import com.android.emergency.PreferenceKeys;
@@ -47,7 +44,6 @@
 import org.robolectric.annotation.Config;
 
 /** Unit tests for {@link EmergencyListPreference}. */
-@SmallTest
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public final class EmergencyListPreferenceTest {
diff --git a/tests/robolectric/src/com/android/emergency/util/PreferenceUtilsTest.java b/tests/robolectric/src/com/android/emergency/util/PreferenceUtilsTest.java
index 15de021..e47a1de 100644
--- a/tests/robolectric/src/com/android/emergency/util/PreferenceUtilsTest.java
+++ b/tests/robolectric/src/com/android/emergency/util/PreferenceUtilsTest.java
@@ -30,7 +30,6 @@
 import android.content.pm.PackageManager;
 import android.database.Cursor;
 import android.net.Uri;
-import android.test.suitebuilder.annotation.SmallTest;
 
 import com.android.emergency.ContactTestUtils;
 import com.android.emergency.PreferenceKeys;
@@ -46,16 +45,12 @@
 import org.robolectric.annotation.Config;
 
 /** Unit tests for {@link PreferenceUtils}. */
-@SmallTest
 @RunWith(RobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public final class PreferenceUtilsTest {
     private static final String PACKAGE_NAME = "com.android.emergency";
     private static final String NAME = "Jane";
     private static final String PHONE_NUMBER = "5150";
-    private static final ComponentName COMPONENT_NAME = new ComponentName(
-                PACKAGE_NAME,
-                PACKAGE_NAME + PreferenceUtils.SETTINGS_SUGGESTION_ACTIVITY_ALIAS);
 
     @Mock ContentResolver mContentResolver;
     @Mock Context mContext;
@@ -64,10 +59,16 @@
     @Mock SharedPreferences mSharedPreferences;
     @Mock SharedPreferences.Editor mSharedPreferencesEditor;
 
+    private ComponentName mComponentName;
+
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
+        mComponentName = new ComponentName(
+            PACKAGE_NAME,
+            PACKAGE_NAME + PreferenceUtils.SETTINGS_SUGGESTION_ACTIVITY_ALIAS);
+
         when(mContext.getContentResolver()).thenReturn(mContentResolver);
         when(mContext.getPackageManager()).thenReturn(mPackageManager);
         when(mContext.getPackageName()).thenReturn(PACKAGE_NAME);
@@ -117,7 +118,7 @@
         PreferenceUtils.enableSettingsSuggestion(mContext);
 
         verify(mPackageManager).setComponentEnabledSetting(
-                eq(COMPONENT_NAME),
+                eq(mComponentName),
                 eq(PackageManager.COMPONENT_ENABLED_STATE_ENABLED),
                 eq(PackageManager.DONT_KILL_APP));
     }
@@ -135,7 +136,7 @@
         PreferenceUtils.updateSettingsSuggestionState(mContext);
 
         verify(mPackageManager).setComponentEnabledSetting(
-                eq(COMPONENT_NAME),
+                eq(mComponentName),
                 eq(PackageManager.COMPONENT_ENABLED_STATE_DISABLED),
                 eq(PackageManager.DONT_KILL_APP));
     }
@@ -147,7 +148,7 @@
         PreferenceUtils.updateSettingsSuggestionState(mContext);
 
         verify(mPackageManager).setComponentEnabledSetting(
-                eq(COMPONENT_NAME),
+                eq(mComponentName),
                 eq(PackageManager.COMPONENT_ENABLED_STATE_ENABLED),
                 eq(PackageManager.DONT_KILL_APP));
     }
@@ -160,7 +161,7 @@
         PreferenceUtils.updateSettingsSuggestionState(mContext);
 
         verify(mPackageManager).setComponentEnabledSetting(
-                eq(COMPONENT_NAME),
+                eq(mComponentName),
                 eq(PackageManager.COMPONENT_ENABLED_STATE_DISABLED),
                 eq(PackageManager.DONT_KILL_APP));
     }