Java Code Examples for com.linkedin.android.testbutler.TestButler#grantPermission()
The following examples show how to use
com.linkedin.android.testbutler.TestButler#grantPermission() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PermissionGranterTest.java From test-butler with Apache License 2.0 | 5 votes |
/** * This is not a great test...it will only pass once, unless you revoke the permission externally between test runs */ @Test @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void successfullyGrantPermission() { Context context = ApplicationProvider.getApplicationContext(); String permission = Manifest.permission.WRITE_EXTERNAL_STORAGE; long result = ContextCompat.checkSelfPermission(context, permission); assertEquals(PackageManager.PERMISSION_DENIED, result); TestButler.grantPermission(context, permission); long newResult = ContextCompat.checkSelfPermission(context, permission); assertEquals(PackageManager.PERMISSION_GRANTED, newResult); }
Example 2
Source File: PermissionGranterTest.java From test-butler with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void failWhenTryingToGrantNonDangerousPermission() { Context context = ApplicationProvider.getApplicationContext(); String permission = Manifest.permission.ACCESS_WIFI_STATE; TestButler.grantPermission(context, permission); }
Example 3
Source File: PermissionGranterTest.java From test-butler with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void failWhenTryingToGrantPermissionNotInManifest() { Context context = ApplicationProvider.getApplicationContext(); String permission = Manifest.permission.ADD_VOICEMAIL; TestButler.grantPermission(context, permission); }