Skip to content

Instantly share code, notes, and snippets.

Heitor Colangelo heitorcolangelo

Block or report user

Report or block heitorcolangelo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View RecyclerViewSample.kt
@Test fun recyclerView_example() {
recyclerView(R.id.recycler_view) {
sizeIs(10)
atPosition(3) {
displayed {
id(R.id.item_description)
text(R.string.description_text)
text("Item header text")
}
}
View LoginRobots.kt
@Test
fun whenBothFieldsAreFilled_andClickOnLoginButton_shouldOpenMainActivity() {
login {
username("defaultText")
password("defaultText")
} doLogin {
isSuccess()
}
}
View LoginRobots.java
class LoginRobot {
LoginRobot username(String username) {
onView(withId(R.id.login_username)).perform(typeText(username), closeSoftKeyboard());
return this;
}
LoginRobot password(String password) {
onView(withId(R.id.login_password)).perform(typeText(password), closeSoftKeyboard());
return this;
}
View LoginActivityTest.java
@Test
public void whenBothFieldsAreFilled_andClickOnLoginButton_shouldOpenMainActivity() {
LoginRobot login = new LoginRobot();
ResultLoginRobot result = login
.username("defaultText")
.password("defaultText")
.login();
result.isSuccess()
}
@heitorcolangelo
heitorcolangelo / activity_login.xml
Last active Sep 28, 2016
Layout login activity - adding progress view
View activity_login.xml
<!--
login_image
login_username
login_password
login_button
-->
<LinearLayout
@heitorcolangelo
heitorcolangelo / testbutler_revoke_permission
Created Sep 22, 2016
Logcat when trying to revoke permission already granted
View testbutler_revoke_permission
09-22 07:29:42.114 4002-4002/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
09-22 07:29:42.116 4002-4002/? D/AndroidRuntime: CheckJNI is ON
09-22 07:29:42.139 4006-4006/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
09-22 07:29:42.140 4002-4002/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
09-22 07:29:42.140 4006-4006/? D/AndroidRuntime: CheckJNI is ON
09-22 07:29:42.177 4002-4002/? E/memtrack: Couldn't load memtrack module (No such file or directory)
09-22 07:29:42.177 4002-4002/? E/android.os.Debug: failed to load memtrack module: -2
09-22 07:29:42.179 4002-4002/? I/Radio-JNI: register_android_hardware_Radio DONE
09-22 07:29:42.181 4006-4006/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
09-22 07:29:42.191 4002-4002/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
@heitorcolangelo
heitorcolangelo / UserDetailsActivityTest.java
Last active Sep 9, 2016
UserDetailsActivityTest - test with permission
View UserDetailsActivityTest.java
@Test
public void clickOnPhone_shouldStartPhoneIntent() throws IOException {
mActivityRule.launchActivity(createIntent(false));
Intents.init();
intending(hasAction(Intent.ACTION_CALL))
.respondWith(new Instrumentation.ActivityResult(Activity.RESULT_OK, new Intent()));
onView(withId(R.id.user_details_phone)).perform(scrollTo(), click());
PermissionUtils.allowPermissionsIfNeeded(Manifest.permission.CALL_PHONE);
intended(hasAction(Intent.ACTION_CALL));
Intents.release();
View PermissionUtils.java
/**
* From: https://gist.github.com/rocboronat/65b1187a9fca9eabfebb5121d818a3c4
*/
public class PermissionUtils {
private static final int PERMISSIONS_DIALOG_DELAY = 3000;
private static final int GRANT_BUTTON_INDEX = 1;
public static void allowPermissionsIfNeeded(String permissionNeeded) {
try {
Context context = InstrumentationRegistry.getTargetContext();
@heitorcolangelo
heitorcolangelo / AndroidManifest.xml
Created Sep 9, 2016
AndroidManifest for testing
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:tools="http://schemas.android.com/tools"
package="com.example.heitorcolangelo.espressotests">
<uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/>
</manifest>
@heitorcolangelo
heitorcolangelo / UserDetailsActivityTest.java
Created Sep 7, 2016
UserDetailsActivityTest - runtime permission error
View UserDetailsActivityTest.java
@Test
public void clickOnPhone_shouldStartPhoneIntent() {
mActivityRule.launchActivity(createIntent(false));
Intents.init();
intending(hasAction(Intent.ACTION_CALL))
.respondWith(new Instrumentation.ActivityResult(Activity.RESULT_OK, new Intent()));
onView(withId(R.id.user_details_phone)).perform(scrollTo(), click());
intended(hasAction(Intent.ACTION_CALL));
Intents.release();
}
You can’t perform that action at this time.