Move date/time prefs to PreferenceController and add tests.
Bug: 32996243 Test: RunSettingsRoboTests Change-Id: Ie537bbcc35a96a63251e46f84b57c0a861b9d013
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.datetime;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AutoTimePreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private UpdateTimeAndDateCallback mCallback;
|
||||
|
||||
private Context mContext;
|
||||
private RestrictedSwitchPreference mPreference;
|
||||
private AutoTimePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = ShadowApplication.getInstance().getApplicationContext();
|
||||
mPreference = new RestrictedSwitchPreference(mContext);
|
||||
mController = new AutoTimePreferenceController(mContext, mCallback);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_shouldReadFromSettingsProvider() {
|
||||
// Disabled
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.AUTO_TIME, 0);
|
||||
assertThat(mController.isEnabled()).isFalse();
|
||||
|
||||
// Enabled
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.AUTO_TIME, 1);
|
||||
assertThat(mController.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferenceChange_prefIsChecked_shouldUpdatePreferenceAndNotifyCallback() {
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
assertThat(mController.isEnabled()).isTrue();
|
||||
verify(mCallback).updateTimeAndDateDisplay(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferenceChange_prefIsUnchecked_shouldUpdatePreferenceAndNotifyCallback() {
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
assertThat(mController.isEnabled()).isFalse();
|
||||
verify(mCallback).updateTimeAndDateDisplay(mContext);
|
||||
}
|
||||
}
|
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.datetime;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AutoTimeZonePreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private Context mMockContext;
|
||||
@Mock
|
||||
private ConnectivityManager mCm;
|
||||
@Mock
|
||||
private UpdateTimeAndDateCallback mCallback;
|
||||
|
||||
private Context mContext;
|
||||
private AutoTimeZonePreferenceController mController;
|
||||
private Preference mPreference;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = ShadowApplication.getInstance().getApplicationContext();
|
||||
mPreference = new Preference(mContext);
|
||||
when(mMockContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mCm);
|
||||
when(mCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isFromSUW_notAvailable() {
|
||||
mController = new AutoTimeZonePreferenceController(
|
||||
mMockContext, null /* callback */, true /* isFromSUW */);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notFromSUW_isAvailable() {
|
||||
mController = new AutoTimeZonePreferenceController(
|
||||
mMockContext, null /* callback */, false /* isFromSUW */);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isWifiOnly_notAvailable() {
|
||||
when(mCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
|
||||
|
||||
mController = new AutoTimeZonePreferenceController(
|
||||
mMockContext, null /* callback */, false /* isFromSUW */);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEnabled_shouldReadFromSettingsProvider() {
|
||||
mController = new AutoTimeZonePreferenceController(
|
||||
mContext, null /* callback */, false /* isFromSUW */);
|
||||
|
||||
// Disabled
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.AUTO_TIME_ZONE, 0);
|
||||
assertThat(mController.isEnabled()).isFalse();
|
||||
|
||||
// Enabled
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.AUTO_TIME_ZONE, 1);
|
||||
assertThat(mController.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferenceChange_prefIsChecked_shouldUpdatePreferenceAndNotifyCallback() {
|
||||
mController = new AutoTimeZonePreferenceController(
|
||||
mContext, mCallback, false /* isFromSUW */);
|
||||
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
assertThat(mController.isEnabled()).isTrue();
|
||||
verify(mCallback).updateTimeAndDateDisplay(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferenceChange_prefIsUnchecked_shouldUpdatePreferenceAndNotifyCallback() {
|
||||
mController = new AutoTimeZonePreferenceController(
|
||||
mContext, mCallback, false /* isFromSUW */);
|
||||
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
assertThat(mController.isEnabled()).isFalse();
|
||||
verify(mCallback).updateTimeAndDateDisplay(mContext);
|
||||
}
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.datetime;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class DatePreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private AlarmManager mAlarmManager;
|
||||
@Mock
|
||||
private DatePreferenceController.DatePreferenceHost mHost;
|
||||
@Mock
|
||||
private AutoTimePreferenceController mAutoTimePreferenceController;
|
||||
|
||||
private Preference mPreference;
|
||||
private DatePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getSystemService(Context.ALARM_SERVICE)).thenReturn(mAlarmManager);
|
||||
mPreference = new Preference(ShadowApplication.getInstance().getApplicationContext());
|
||||
mController = new DatePreferenceController(mContext, mHost, mAutoTimePreferenceController);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAlwaysAvailable() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleDateSetCallback() {
|
||||
mController.onDateSet(null, 2016, 1, 1);
|
||||
verify(mHost).updateTimeAndDateDisplay(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_autoTimeEnabled_shouldDisablePref() {
|
||||
when(mAutoTimePreferenceController.isEnabled()).thenReturn(true);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_autoTimeDisabled_shouldEnablePref() {
|
||||
when(mAutoTimePreferenceController.isEnabled()).thenReturn(false);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clickPreference_showDatePicker() {
|
||||
// Click a preference that's not controlled by this controller.
|
||||
mPreference.setKey("fake_key");
|
||||
assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse();
|
||||
|
||||
// Click a preference controlled by this controller.
|
||||
mPreference.setKey(mController.getPreferenceKey());
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
// Should show date picker
|
||||
verify(mHost).showDatePicker();
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.datetime;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settings.core.lifecycle.events.OnPause;
|
||||
import com.android.settings.core.lifecycle.events.OnResume;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class TimeChangeListenerMixinTest {
|
||||
|
||||
@Mock
|
||||
private UpdateTimeAndDateCallback mCallback;
|
||||
|
||||
private Context mContext;
|
||||
private TimeChangeListenerMixin mMixin;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = ShadowApplication.getInstance().getApplicationContext();
|
||||
mMixin = new TimeChangeListenerMixin(mContext, mCallback);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldImplementMixinInterfaces() {
|
||||
assertThat(mMixin instanceof LifecycleObserver).isTrue();
|
||||
assertThat(mMixin instanceof OnPause).isTrue();
|
||||
assertThat(mMixin instanceof OnResume).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_shouldRegisterIntentFilter() {
|
||||
mMixin.onResume();
|
||||
mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_TICK));
|
||||
mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_CHANGED));
|
||||
mContext.sendBroadcast(new Intent(Intent.ACTION_TIMEZONE_CHANGED));
|
||||
|
||||
verify(mCallback, times(3)).updateTimeAndDateDisplay(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_shouldUnregisterIntentFilter() {
|
||||
mMixin.onResume();
|
||||
mMixin.onPause();
|
||||
mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_TICK));
|
||||
mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_CHANGED));
|
||||
mContext.sendBroadcast(new Intent(Intent.ACTION_TIMEZONE_CHANGED));
|
||||
|
||||
verify(mCallback, never()).updateTimeAndDateDisplay(mContext);
|
||||
}
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.datetime;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class TimePreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private TimePreferenceController.TimePreferenceHost mHost;
|
||||
@Mock
|
||||
private AutoTimePreferenceController mAutoTimePreferenceController;
|
||||
|
||||
private TimePreferenceController mController;
|
||||
private Preference mPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mPreference = new Preference(ShadowApplication.getInstance().getApplicationContext());
|
||||
mController = new TimePreferenceController(mContext, mHost, mAutoTimePreferenceController);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAlwaysAvailable() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_autoTimeEnabled_shouldDisablePref() {
|
||||
when(mAutoTimePreferenceController.isEnabled()).thenReturn(true);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_autoTimeDisabled_shouldEnablePref() {
|
||||
when(mAutoTimePreferenceController.isEnabled()).thenReturn(false);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clickPreference_showTimePicker() {
|
||||
// Click a preference that's not controlled by this controller.
|
||||
mPreference.setKey("fake_key");
|
||||
assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse();
|
||||
|
||||
// Click a preference controlled by this controller.
|
||||
mPreference.setKey(mController.getPreferenceKey());
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
// Should show date picker
|
||||
verify(mHost).showTimePicker();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.datetime;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class TimeZonePreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private AutoTimeZonePreferenceController mAutoTimeZonePreferenceController;
|
||||
private Context mContext;
|
||||
private TimeZonePreferenceController mController;
|
||||
private Preference mPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = ShadowApplication.getInstance().getApplicationContext();
|
||||
mPreference = new Preference(mContext);
|
||||
mController = spy(new TimeZonePreferenceController(mContext,
|
||||
mAutoTimeZonePreferenceController));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAlwaysAvailable() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_autoTimeZoneEnabled_shouldDisablePref() {
|
||||
doReturn("test timezone").when(mController).getTimeZoneOffsetAndName();
|
||||
when(mAutoTimeZonePreferenceController.isEnabled()).thenReturn(true);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_autoTimeZoneDisabled_shouldEnablePref() {
|
||||
doReturn("test timezone").when(mController).getTimeZoneOffsetAndName();
|
||||
when(mAutoTimeZonePreferenceController.isEnabled()).thenReturn(false);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user