Merge "Update string for discarding changes to a particular APN's settings."
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 883e968..5100c03 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -4,3 +4,5 @@
strings_lint_hook = ${REPO_ROOT}/frameworks/base/tools/stringslint/stringslint_sha.sh ${PREUPLOAD_COMMIT}
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
+
+robolectric_hook = ${REPO_ROOT}/packages/apps/Settings/tests/robotests/new_tests_hook.sh ${REPO_PROJECT}
diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
index ba12146..348c9c8 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
@@ -185,6 +185,7 @@
return this;
}
+ @VisibleForTesting
protected int getMode() {
return MODE_NONE;
}
@@ -194,12 +195,12 @@
}
@VisibleForTesting
- VolteQueryImsState queryImsState(int subId) {
+ protected VolteQueryImsState queryImsState(int subId) {
return new VolteQueryImsState(mContext, subId);
}
@VisibleForTesting
- boolean isCallStateIdle() {
+ protected boolean isCallStateIdle() {
return (mCallState != null) && (mCallState == TelephonyManager.CALL_STATE_IDLE);
}
diff --git a/tests/robotests/new_tests_hook.sh b/tests/robotests/new_tests_hook.sh
new file mode 100755
index 0000000..92d6670
--- /dev/null
+++ b/tests/robotests/new_tests_hook.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# This script detects the presence of new robolectric java tests within
+# commits to be uploaded. If a new file is detected the script will print an
+# error message and return an error code. Intended to be used as a repo hook.
+
+new_robolectric_tests=$(
+ git diff --name-status $REPO_LREV | grep "^A.*tests/robotests.*\.java")
+if [ $new_robolectric_tests != "" ]
+then
+ echo "New Robolectric unit tests detected. Please submit junit tests" \
+ "instead, in the tests/junit directory." \
+ "See go/android-platform-robolectric-cleanup."
+ echo $new_robolectric_tests
+ exit 1
+fi
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
similarity index 89%
rename from tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
rename to tests/unit/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
index d107814..ec4f1d7 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -21,6 +21,7 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.PersistableBundle;
@@ -30,6 +31,8 @@
import android.telephony.ims.ProvisioningManager;
import androidx.preference.SwitchPreference;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.network.ims.MockVolteQueryImsState;
@@ -40,10 +43,8 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class Enhanced4gBasePreferenceControllerTest {
private static final int SUB_ID = 2;
@@ -69,10 +70,12 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
- doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
- doReturn(mCarrierConfigManager).when(mContext).getSystemService(CarrierConfigManager.class);
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
+ when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
+ when(mContext.getSystemService(CarrierConfigManager.class))
+ .thenReturn(mCarrierConfigManager);
+
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(
SubscriptionManager.INVALID_SUBSCRIPTION_ID);