@@ -0,0 +1,3066 @@
+package com.braintreepayments.cardform.utils;%0A%0Aimport android.Manifest;%0Aimport android.content.Context;%0Aimport android.content.pm.PackageManager;%0Aimport android.os.Vibrator;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.robolectric.RobolectricGradleTestRunner;%0A%0Aimport static junit.framework.Assert.assertFalse;%0Aimport static junit.framework.Assert.assertTrue;%0Aimport static org.mockito.Matchers.anyString;%0Aimport static org.mockito.Matchers.eq;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.verifyZeroInteractions;%0Aimport static org.mockito.Mockito.when;%0A%0A@RunWith(RobolectricGradleTestRunner.class)%0Apublic class VibrationHelperTest %7B%0A%0A    @Test%0A    public void vibrate_callsVibrateIfHasVibratePermissionIsTrue() %7B%0A        PackageManager packageManager = mock(PackageManager.class);%0A        when(packageManager.checkPermission(eq(Manifest.permission.VIBRATE), anyString()))%0A                .thenReturn(PackageManager.PERMISSION_GRANTED);%0A        Vibrator vibrator = mock(Vibrator.class);%0A        Context context = mock(Context.class);%0A        when(context.getPackageManager()).thenReturn(packageManager);%0A        when(context.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(vibrator);%0A%0A        VibrationHelper.vibrate(context, 1000);%0A%0A        verify(vibrator).vibrate(1000);%0A    %7D%0A%0A    @Test%0A    public void vibrate_doesNotCallVibrateIfHasVibratePermissionIsFalse() %7B%0A        PackageManager packageManager = mock(PackageManager.class);%0A        when(packageManager.checkPermission(eq(Manifest.permission.VIBRATE), anyString()))%0A                .thenReturn(PackageManager.PERMISSION_DENIED);%0A        Vibrator vibrator = mock(Vibrator.class);%0A        Context context = mock(Context.class);%0A        when(context.getPackageManager()).thenReturn(packageManager);%0A        when(context.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(vibrator);%0A%0A        VibrationHelper.vibrate(context, 1000);%0A%0A        verifyZeroInteractions(vibrator);%0A    %7D%0A%0A    @Test%0A    public void hasVibratePermission_returnsTrueIfVibratePermissionInManifest() %7B%0A        PackageManager packageManager = mock(PackageManager.class);%0A        when(packageManager.checkPermission(eq(Manifest.permission.VIBRATE), anyString()))%0A                .thenReturn(PackageManager.PERMISSION_GRANTED);%0A        Context context = mock(Context.class);%0A        when(context.getPackageManager()).thenReturn(packageManager);%0A%0A        assertTrue(VibrationHelper.hasVibrationPermission(context));%0A    %7D%0A%0A    @Test%0A    public void hasVibratePermission_returnsFalseIfVibratePermissionNotInManifest() %7B%0A        PackageManager packageManager = mock(PackageManager.class);%0A        when(packageManager.checkPermission(eq(Manifest.permission.VIBRATE), anyString()))%0A                .thenReturn(PackageManager.PERMISSION_DENIED);%0A        Context context = mock(Context.class);%0A        when(context.getPackageManager()).thenReturn(packageManager);%0A%0A        assertFalse(VibrationHelper.hasVibrationPermission(context));%0A    %7D%0A%7D%0A

Add VibrationHelperTest