Fix robotests
Fixes: 128536554
Test: rerun robotests
Change-Id: Ife81f9d161fc416a63a9b2f04ce2ae4f9a1e74db
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 4255f3c..625de38 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -40,7 +40,6 @@
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
-import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceClickListener;
import androidx.preference.PreferenceScreen;
@@ -141,20 +140,17 @@
}
};
+ /*
+ * Launch carrier emergency address managemnent activity
+ */
private final OnPreferenceClickListener mUpdateAddressListener =
- new OnPreferenceClickListener() {
- /*
- * Launch carrier emergency address managemnent activity
- */
- @Override
- public boolean onPreferenceClick(Preference preference) {
- Intent carrierAppIntent = getCarrierActivityIntent();
- if (carrierAppIntent != null) {
- carrierAppIntent.putExtra(EXTRA_LAUNCH_CARRIER_APP, LAUCH_APP_UPDATE);
- startActivity(carrierAppIntent);
- }
- return true;
+ preference -> {
+ Intent carrierAppIntent = getCarrierActivityIntent();
+ if (carrierAppIntent != null) {
+ carrierAppIntent.putExtra(EXTRA_LAUNCH_CARRIER_APP, LAUCH_APP_UPDATE);
+ startActivity(carrierAppIntent);
}
+ return true;
};
private final ProvisioningManager.Callback mProvisioningCallback =
@@ -174,8 +170,6 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- final SettingsActivity activity = (SettingsActivity) getActivity();
-
mEmptyView = getView().findViewById(android.R.id.empty);
setEmptyView(mEmptyView);
final Resources res = SubscriptionManager.getResourcesForSubId(getContext(), mSubId);
@@ -265,14 +259,13 @@
mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE))
.createForSubscriptionId(mSubId);
- mButtonWfcMode = (ListWithEntrySummaryPreference) findPreference(BUTTON_WFC_MODE);
+ mButtonWfcMode = findPreference(BUTTON_WFC_MODE);
mButtonWfcMode.setOnPreferenceChangeListener(this);
- mButtonWfcRoamingMode = (ListWithEntrySummaryPreference) findPreference(
- BUTTON_WFC_ROAMING_MODE);
+ mButtonWfcRoamingMode = findPreference(BUTTON_WFC_ROAMING_MODE);
mButtonWfcRoamingMode.setOnPreferenceChangeListener(this);
- mUpdateAddress = (Preference) findPreference(PREFERENCE_EMERGENCY_ADDRESS);
+ mUpdateAddress = findPreference(PREFERENCE_EMERGENCY_ADDRESS);
mUpdateAddress.setOnPreferenceClickListener(mUpdateAddressListener);
mIntentFilter = new IntentFilter();
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
index cc2622f..307c0ac 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
@@ -33,8 +33,6 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import java.io.IOException;
-
@RunWith(RobolectricTestRunner.class)
public class ListWithEntrySummaryPreferenceTest {
@@ -54,6 +52,7 @@
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
+ mContext.setTheme(R.style.Theme_Settings_Home);
mPreference = new ListWithEntrySummaryPreference(mContext, null);
mPreference.setEntries(mDefaultEntries);
mPreference.setEntryValues(mDefaultEntryValues);
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
index 39de254..70f1916 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
@@ -41,11 +41,9 @@
import android.view.View;
import android.widget.TextView;
-import androidx.preference.ListPreference;
import androidx.preference.PreferenceScreen;
import com.android.ims.ImsConfig;
-import com.android.ims.ImsException;
import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
@@ -80,11 +78,11 @@
@Mock private ToggleSwitch mToggleSwitch;
@Mock private View mView;
@Mock private ImsConfig mImsConfig;
- @Mock private ListPreference mButtonWfcMode;
- @Mock private ListPreference mButtonWfcRoamingMode;
+ @Mock private ListWithEntrySummaryPreference mButtonWfcMode;
+ @Mock private ListWithEntrySummaryPreference mButtonWfcRoamingMode;
@Before
- public void setUp() throws NoSuchFieldException, ImsException {
+ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
@@ -100,7 +98,7 @@
final Bundle bundle = new Bundle();
when(mFragment.getArguments()).thenReturn(bundle);
doNothing().when(mFragment).addPreferencesFromResource(anyInt());
- doReturn(mock(ListPreference.class)).when(mFragment).findPreference(any());
+ doReturn(mock(ListWithEntrySummaryPreference.class)).when(mFragment).findPreference(any());
doReturn(mButtonWfcMode).when(mFragment).findPreference(BUTTON_WFC_MODE);
doReturn(mButtonWfcRoamingMode).when(mFragment).findPreference(BUTTON_WFC_ROAMING_MODE);
doNothing().when(mFragment).finish();
@@ -141,7 +139,7 @@
}
@Test
- public void onResume_provisioningAllowed_shouldNotFinish() throws ImsException {
+ public void onResume_provisioningAllowed_shouldNotFinish() {
// Call onResume while provisioning is allowed.
mFragment.onResume();
@@ -160,7 +158,7 @@
}
@Test
- public void onResumeOnPause_provisioningCallbackRegistration() throws ImsException {
+ public void onResumeOnPause_provisioningCallbackRegistration() throws Exception {
// Verify that provisioning callback is registered after call to onResume().
mFragment.onResume();
verify(mImsConfig).addConfigCallback(any(ProvisioningManager.Callback.class));