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

Commit 9e88d6e7 authored by Beverly's avatar Beverly
Browse files

Test no vibration if first ringer state = vibrate

Test to ensure when the device first boots up, that when the ringer
state on the volume dialog is set to VIBRATE, the device won't vibrate.
The device will only vibrate if the ringer is manually set to VIBRATE
later after initalization.

Test: atest VolumeDialogImplTest
Fixes: 169679638
Change-Id: Ia384b299b9fef962992d32355dfe2e2909635239
parent 8862617d
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.systemui.volume.VolumeDialogControllerImpl.STREAMS;
import static junit.framework.Assert.assertTrue;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

import android.app.KeyguardManager;
@@ -167,6 +168,45 @@ public class VolumeDialogImplTest extends SysuiTestCase {
                AccessibilityManager.FLAG_CONTENT_CONTROLS);
    }

    @Test
    public void testVibrateOnRingerChangedToVibrate() {
        final State initialSilentState = new State();
        initialSilentState.ringerModeInternal = AudioManager.RINGER_MODE_SILENT;

        final State vibrateState = new State();
        vibrateState.ringerModeInternal = AudioManager.RINGER_MODE_VIBRATE;

        // change ringer to silent
        mDialog.onStateChangedH(initialSilentState);

        // expected: shouldn't call vibrate yet
        verify(mController, never()).vibrate(any());

        // changed ringer to vibrate
        mDialog.onStateChangedH(vibrateState);

        // expected: vibrate device
        verify(mController).vibrate(any());
    }

    @Test
    public void testNoVibrateOnRingerInitialization() {
        final State initialUnsetState = new State();
        initialUnsetState.ringerModeInternal = -1;

        // ringer not initialized yet:
        mDialog.onStateChangedH(initialUnsetState);

        final State vibrateState = new State();
        vibrateState.ringerModeInternal = AudioManager.RINGER_MODE_VIBRATE;

        // changed ringer to vibrate
        mDialog.onStateChangedH(vibrateState);

        // shouldn't call vibrate
        verify(mController, never()).vibrate(any());
    }

/*
    @Test
    public void testContentDescriptions() {