From f566da5b55302b5e65593dcb1b995eba5f7eb671 Mon Sep 17 00:00:00 2001 From: Alex Johnston Date: Wed, 5 Feb 2020 11:32:03 +0000 Subject: [PATCH] Fix LocationForWorkPreferenceControllerTest * If the location is disabled by admin, then the preference is disabled and the toggle is no longer shown. This means that setChecked is no longer called and the verify statement can be removed. * If the location is off, the summary should be 'Location is off' rather than 'off'. The verify statement is now updated with the correct summary. Bug: 148755845 Test: atest com.android.settings.location.LocationForWorkPreferenceControllerTest Change-Id: I089be0c4f8e8ec8c10160771055730289d72c8ed --- .../location/LocationForWorkPreferenceControllerTest.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java index 4b0df9839f6..b4bda14af59 100644 --- a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java @@ -38,7 +38,6 @@ import com.android.settingslib.RestrictedSwitchPreference; import com.android.settingslib.core.lifecycle.Lifecycle; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -114,7 +113,6 @@ public class LocationForWorkPreferenceControllerTest { } @Test - @Ignore public void onLocationModeChanged_disabledByAdmin_shouldDisablePreference() { mController.displayPreference(mScreen); final EnforcedAdmin admin = mock(EnforcedAdmin.class); @@ -124,11 +122,9 @@ public class LocationForWorkPreferenceControllerTest { mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false); verify(mPreference).setDisabledByAdmin(any()); - verify(mPreference).setChecked(false); } @Test - @Ignore public void onLocationModeChanged_locationOff_shouldDisablePreference() { mController.displayPreference(mScreen); doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt()); @@ -138,7 +134,7 @@ public class LocationForWorkPreferenceControllerTest { verify(mPreference).setEnabled(false); verify(mPreference).setChecked(false); - verify(mPreference).setSummary(R.string.switch_off_text); + verify(mPreference).setSummary(R.string.location_app_permission_summary_location_off); } @Test