From 9e88d6e7ffa48f79003d391710a73fae78f2426a Mon Sep 17 00:00:00 2001 From: Beverly Date: Thu, 1 Oct 2020 08:56:05 -0400 Subject: [PATCH] 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 --- .../systemui/volume/VolumeDialogImplTest.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java index f3cdbf7409c1c..c0856892dc44a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java @@ -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() {