Loading src/com/android/settings/datetime/AutoTimeZonePreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class AutoTimeZonePreferenceController extends PreferenceController } public boolean isEnabled() { return Settings.Global.getInt(mContext.getContentResolver(), return isAvailable() && Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 0) > 0; } } tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ public class AutoTimeZonePreferenceControllerTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); ShadowApplication.getInstance().setSystemService(Context.CONNECTIVITY_SERVICE, mCm); mContext = ShadowApplication.getInstance().getApplicationContext(); mPreference = new Preference(mContext); when(mMockContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mCm); Loading Loading @@ -87,6 +88,24 @@ public class AutoTimeZonePreferenceControllerTest { assertThat(mController.isAvailable()).isFalse(); } @Test public void isFromSUW_notEnable() { mController = new AutoTimeZonePreferenceController( mMockContext, null /* callback */, true /* isFromSUW */); assertThat(mController.isEnabled()).isFalse(); } @Test public void isWifiOnly_notEnable() { when(mCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false); mController = new AutoTimeZonePreferenceController( mMockContext, null /* callback */, false /* isFromSUW */); assertThat(mController.isEnabled()).isFalse(); } @Test public void testIsEnabled_shouldReadFromSettingsProvider() { mController = new AutoTimeZonePreferenceController( Loading Loading
src/com/android/settings/datetime/AutoTimeZonePreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class AutoTimeZonePreferenceController extends PreferenceController } public boolean isEnabled() { return Settings.Global.getInt(mContext.getContentResolver(), return isAvailable() && Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 0) > 0; } }
tests/robotests/src/com/android/settings/datetime/AutoTimeZonePreferenceControllerTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ public class AutoTimeZonePreferenceControllerTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); ShadowApplication.getInstance().setSystemService(Context.CONNECTIVITY_SERVICE, mCm); mContext = ShadowApplication.getInstance().getApplicationContext(); mPreference = new Preference(mContext); when(mMockContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mCm); Loading Loading @@ -87,6 +88,24 @@ public class AutoTimeZonePreferenceControllerTest { assertThat(mController.isAvailable()).isFalse(); } @Test public void isFromSUW_notEnable() { mController = new AutoTimeZonePreferenceController( mMockContext, null /* callback */, true /* isFromSUW */); assertThat(mController.isEnabled()).isFalse(); } @Test public void isWifiOnly_notEnable() { when(mCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false); mController = new AutoTimeZonePreferenceController( mMockContext, null /* callback */, false /* isFromSUW */); assertThat(mController.isEnabled()).isFalse(); } @Test public void testIsEnabled_shouldReadFromSettingsProvider() { mController = new AutoTimeZonePreferenceController( Loading