More tests for silent status bar setting

Test: this
Change-Id: I2f1890a4843438684c089b837cf74bd520b352e6
Fixes: 123419917
This commit is contained in:
Julia Reynolds
2019-01-30 10:28:22 -05:00
parent e0dde6a6cd
commit f74ff06731
2 changed files with 10 additions and 9 deletions

View File

@@ -24,17 +24,24 @@ import android.provider.Settings;
import com.android.settings.core.TogglePreferenceController;
import com.google.common.annotations.VisibleForTesting;
public class SilentStatusBarPreferenceController extends TogglePreferenceController {
private static final String KEY = "hide_silent_icons";
private static final int MY_USER_ID = UserHandle.myUserId();
private final NotificationBackend mBackend;
private NotificationBackend mBackend;
public SilentStatusBarPreferenceController(Context context) {
super(context, KEY);
mBackend = new NotificationBackend();
}
@VisibleForTesting
void setBackend(NotificationBackend backend) {
mBackend = backend;
}
@Override
public boolean isChecked() {
return mBackend.shouldHideSilentStatusBarIcons(mContext);

View File

@@ -48,7 +48,6 @@ public class SilentStatusBarPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
private FakeFeatureFactory mFeatureFactory;
private Context mContext;
private SilentStatusBarPreferenceController mController;
private Preference mPreference;
@@ -57,8 +56,8 @@ public class SilentStatusBarPreferenceControllerTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new SilentStatusBarPreferenceController(mContext);
mController.setBackend(mBackend);
mPreference = new Preference(mContext);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
@@ -83,7 +82,7 @@ public class SilentStatusBarPreferenceControllerTest {
when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(false);
assertThat(mController.isChecked()).isFalse();
}
/**
@Test
public void isChecked_settingIsOn_true() {
when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(true);
@@ -93,18 +92,13 @@ public class SilentStatusBarPreferenceControllerTest {
@Test
public void onPreferenceChange_on() {
mController.onPreferenceChange(mPreference, true);
assertThat(mController.isChecked()).isTrue();
verify(mBackend).setHideSilentStatusIcons(true);
}
@Test
public void onPreferenceChange_off() {
mController.onPreferenceChange(mPreference, false);
assertThat(mController.isChecked()).isFalse();
verify(mBackend).setHideSilentStatusIcons(false);
}
**/
}