private static void assertPermission(final Context context, final String permission, final boolean granted) throws NameNotFoundException {
		final int state = granted ? PERMISSION_GRANTED : PERMISSION_DENIED;
		assertEquals(state, context.checkPermission(permission, Process.myPid(), Process.myUid()));
		if (SDK_INT >= M) assertEquals(state, context.checkSelfPermission(permission));

		final PackageInfo pkg_info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS);
		if (! granted) return;
		assertNotNull(pkg_info.requestedPermissions);
		for (int i = 0; i < pkg_info.requestedPermissions.length; i++)
			if (permission.equals(pkg_info.requestedPermissions[i])) {
				assertEquals("Not granted: " + permission, PackageInfo.REQUESTED_PERMISSION_GRANTED, pkg_info.requestedPermissionsFlags[i]);
				return;
			}
		fail(permission + " is not in requested permissions: " + Arrays.deepToString(pkg_info.requestedPermissions));
	}
Test cases for {@link CondomKit}

Created by Oasis on 2017/7/22.
library/src/androidTest/java/com/oasisfeng/condom/CondomKitTest.java