Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f566da5b authored by Alex Johnston's avatar Alex Johnston
Browse files

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
parent 0a832ffe
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -38,7 +38,6 @@ import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.Lifecycle;


import org.junit.Before;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mock;
@@ -114,7 +113,6 @@ public class LocationForWorkPreferenceControllerTest {
    }
    }


    @Test
    @Test
    @Ignore
    public void onLocationModeChanged_disabledByAdmin_shouldDisablePreference() {
    public void onLocationModeChanged_disabledByAdmin_shouldDisablePreference() {
        mController.displayPreference(mScreen);
        mController.displayPreference(mScreen);
        final EnforcedAdmin admin = mock(EnforcedAdmin.class);
        final EnforcedAdmin admin = mock(EnforcedAdmin.class);
@@ -124,11 +122,9 @@ public class LocationForWorkPreferenceControllerTest {
        mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
        mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);


        verify(mPreference).setDisabledByAdmin(any());
        verify(mPreference).setDisabledByAdmin(any());
        verify(mPreference).setChecked(false);
    }
    }


    @Test
    @Test
    @Ignore
    public void onLocationModeChanged_locationOff_shouldDisablePreference() {
    public void onLocationModeChanged_locationOff_shouldDisablePreference() {
        mController.displayPreference(mScreen);
        mController.displayPreference(mScreen);
        doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
        doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
@@ -138,7 +134,7 @@ public class LocationForWorkPreferenceControllerTest {


        verify(mPreference).setEnabled(false);
        verify(mPreference).setEnabled(false);
        verify(mPreference).setChecked(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
    @Test