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

Commit 0bb0d0c4 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Update usages of TestModeBuilder

The API of the builder was changed a bit to clean up some things and
make others more explicit. Update tests in settingslib accordingly.

Bug: 382497909
Flag: TEST_ONLY
Test: this
Change-Id: Ib31991d61e7b232c8a2befda92537d7b388beb5b
parent b5b94029
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public final class InterruptionFilterPreferenceControllerTest {
    @Test
    public void updateState_dnd_enabled() {
        TwoStatePreference preference = mock(TwoStatePreference.class);
        ZenMode dnd = TestModeBuilder.MANUAL_DND_ACTIVE;
        ZenMode dnd = TestModeBuilder.MANUAL_DND;

        mController.updateState(preference, dnd);

@@ -81,7 +81,11 @@ public final class InterruptionFilterPreferenceControllerTest {
    @Test
    public void updateState_specialDnd_disabled() {
        TwoStatePreference preference = mock(TwoStatePreference.class);
        ZenMode specialDnd = TestModeBuilder.manualDnd(INTERRUPTION_FILTER_NONE, true);
        ZenMode specialDnd = new TestModeBuilder()
                .makeManualDnd()
                .setInterruptionFilter(INTERRUPTION_FILTER_NONE)
                .setActive(true)
                .build();

        mController.updateState(preference, specialDnd);

+1 −2
Original line number Diff line number Diff line
@@ -70,8 +70,7 @@ public class ManualDurationPreferenceControllerTest {
    @Test
    public void testIsAvailable_onlyForManualDnd() {
        assertThat(mPrefController.isAvailable(TestModeBuilder.EXAMPLE)).isFalse();
        assertThat(mPrefController.isAvailable(TestModeBuilder.MANUAL_DND_ACTIVE)).isTrue();
        assertThat(mPrefController.isAvailable(TestModeBuilder.MANUAL_DND_INACTIVE)).isTrue();
        assertThat(mPrefController.isAvailable(TestModeBuilder.MANUAL_DND)).isTrue();
    }

    @Test
+6 −3
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ import com.android.settingslib.notification.modes.TestModeBuilder;
import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend;

import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.MoreExecutors;

import org.junit.Before;
@@ -153,14 +152,18 @@ public final class ZenModeAppsLinkPreferenceControllerTest {

    @Test
    public void updateState_dnd_enabled() {
        ZenMode dnd = TestModeBuilder.MANUAL_DND_ACTIVE;
        ZenMode dnd = TestModeBuilder.MANUAL_DND;
        mController.updateState(mPreference, dnd);
        assertThat(mPreference.isEnabled()).isTrue();
    }

    @Test
    public void updateState_specialDnd_disabled() {
        ZenMode specialDnd = TestModeBuilder.manualDnd(INTERRUPTION_FILTER_NONE, true);
        ZenMode specialDnd = new TestModeBuilder()
                .makeManualDnd()
                .setInterruptionFilter(INTERRUPTION_FILTER_NONE)
                .setActive(true)
                .build();
        mController.updateState(mPreference, specialDnd);
        assertThat(mPreference.isEnabled()).isFalse();
    }
+2 −2
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ public final class ZenModeButtonPreferenceControllerTest {
        Button button = new Button(mContext);
        LayoutPreference pref = mock(LayoutPreference.class);
        when(pref.findViewById(anyInt())).thenReturn(button);
        ZenMode zenMode = TestModeBuilder.MANUAL_DND_INACTIVE;
        ZenMode zenMode = TestModeBuilder.MANUAL_DND;

        mController.updateZenMode(pref, zenMode);
        button.callOnClick();
@@ -204,7 +204,7 @@ public final class ZenModeButtonPreferenceControllerTest {
        Button button = new Button(mContext);
        LayoutPreference pref = mock(LayoutPreference.class);
        when(pref.findViewById(anyInt())).thenReturn(button);
        ZenMode zenMode = TestModeBuilder.MANUAL_DND_INACTIVE;
        ZenMode zenMode = TestModeBuilder.MANUAL_DND;

        mController.updateZenMode(pref, zenMode);
        button.callOnClick();
+6 −2
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public final class ZenModeDisplayLinkPreferenceControllerTest {
    @Test
    public void updateState_dnd_enabled() {
        Preference preference = mock(Preference.class);
        ZenMode dnd = TestModeBuilder.MANUAL_DND_ACTIVE;
        ZenMode dnd = TestModeBuilder.MANUAL_DND;

        mController.updateState(preference, dnd);

@@ -78,7 +78,11 @@ public final class ZenModeDisplayLinkPreferenceControllerTest {
    @Test
    public void updateState_specialDnd_disabled() {
        Preference preference = mock(Preference.class);
        ZenMode specialDnd = TestModeBuilder.manualDnd(INTERRUPTION_FILTER_NONE, true);
        ZenMode specialDnd = new TestModeBuilder()
                .makeManualDnd()
                .setInterruptionFilter(INTERRUPTION_FILTER_NONE)
                .setActive(true)
                .build();

        mController.updateState(preference, specialDnd);

Loading