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

Commit 12cec798 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "More tests for silent status bar setting"

parents a52b227c f74ff067
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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);
+2 −8
Original line number Diff line number Diff line
@@ -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);
    }
    **/
}