This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./gradlew connectedAndroidTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onView(withText("ALLOW")).perform(click()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
// other dependencies | |
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error:Execution failed for task ':app:processDebugAndroidTestManifest'. | |
> java.lang.RuntimeException: Manifest merger failed : | |
uses-sdk:minSdkVersion 16 cannot be smaller than version 18 declared in library | |
[com.android.support.test.uiautomator:uiautomator-v18:2.1.2] | |
/<app-path>/app/build/intermediates/exploded-aar/com.android.support.test.uiautomator/uiautomator-v18/2.1.2/AndroidManifest.xml | |
Suggestion: use tools:overrideLibrary="android.support.test.uiautomator.v18" to force usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest | |
package="me.egorand.contactssync" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/> | |
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void assertViewWithTextIsVisible(UiDevice device, String text) { | |
UiObject allowButton = device.findObject(new UiSelector().text(text)); | |
if (!allowButton.exists()) { | |
throw new AssertionError("View with text <" + text + "> not found!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void denyCurrentPermission(UiDevice device) throws UiObjectNotFoundException { | |
UiObject denyButton = device.findObject(new UiSelector().text(TEXT_DENY)); | |
denyButton.click(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void a_shouldDisplayPermissionRequestDialogAtStartup() throws Exception { | |
assertViewWithTextIsVisible(device, "ALLOW"); | |
assertViewWithTextIsVisible(device, "DENY"); | |
// cleanup for the next test | |
denyCurrentPermission(device); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onResume() { | |
super.onResume(); | |
int permissionStatus = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS); | |
if (permissionStatus == PackageManager.PERMISSION_GRANTED) { | |
loadContacts(); | |
} else if (!isPermissionAlreadyDenied) { | |
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, | |
REQ_CODE_PERMISSIONS_READ_CONTACTS); |