PermissionManager { public synchronized boolean granted( int requestCode, String[] permissions, int[] results) { if (requestCode != mRequestCode) { return false; } if (results.length != permissions.length) { return false; } for (int i = 0; i < results.length; i++) { if (results[i] != PackageManager.PERMISSION_GRANTED) { return false; } } return true; } PermissionManager(int androidLevel, Activity activity, int requestCode, String[] perms);  PermissionManager(Activity activity, int requestCode, String[] perms); boolean haveAllPermissions(); synchronized void obtainPermission(); synchronized boolean granted(
            int requestCode, String[] permissions, int[] results);  }
@Test public void grantedNotEnough() { int[] notEnough = {PackageManager.PERMISSION_GRANTED}; assertFalse(mManager.granted(REQUEST_CODE, REQUIRED_PERMS, notEnough)); }
@Test public void grantedDenied() { int[] denied = {PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_DENIED}; assertFalse(mManager.granted(REQUEST_CODE, REQUIRED_PERMS, denied)); }
@Test public void grantedWrongCode() { int[] granted = {PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED}; assertFalse(mManager.granted(REQUEST_CODE + 1, REQUIRED_PERMS, granted)); }
@Test public void grantedOkay() { int[] granted = {PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED}; assertTrue(mManager.granted(REQUEST_CODE, REQUIRED_PERMS, granted)); }