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
This commit is contained in:
Alex Johnston
2020-02-05 11:32:03 +00:00
parent 0a832ffe10
commit f566da5b55

View File

@@ -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