Loading src/com/android/settings/notification/SilentStatusBarPreferenceController.java +8 −1 Original line number Diff line number Diff line Loading @@ -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); Loading tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java +2 −8 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ public class SilentStatusBarPreferenceControllerTest { @Mock private PreferenceScreen mScreen; private FakeFeatureFactory mFeatureFactory; private Context mContext; private SilentStatusBarPreferenceController mController; private Preference mPreference; Loading @@ -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); Loading @@ -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); Loading @@ -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); } **/ } Loading
src/com/android/settings/notification/SilentStatusBarPreferenceController.java +8 −1 Original line number Diff line number Diff line Loading @@ -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); Loading
tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java +2 −8 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ public class SilentStatusBarPreferenceControllerTest { @Mock private PreferenceScreen mScreen; private FakeFeatureFactory mFeatureFactory; private Context mContext; private SilentStatusBarPreferenceController mController; private Preference mPreference; Loading @@ -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); Loading @@ -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); Loading @@ -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); } **/ }