Skip to content

Instantly share code, notes, and snippets.

View heitorcolangelo's full-sized avatar

Heitor Colangelo heitorcolangelo

View GitHub Profile
@heitorcolangelo
heitorcolangelo / CircleTransform.java
Last active August 29, 2015 14:27 — forked from julianshen/CircleTransform.java
CircleTransform for Picasso
/*
* Copyright 2014 Julian Shen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@heitorcolangelo
heitorcolangelo / LoginActivityTest.java
Last active July 24, 2016 15:55
ActivityTestRule
@RunWith(AndroidJUnit4.class)
public class LoginActivityTest {
@Rule
public ActivityTestRule<LoginActivity>
mActivityRule = new ActivityTestRule<>(LoginActivity.class, false, true);
}
@heitorcolangelo
heitorcolangelo / LoginActivityTest.java
Last active July 24, 2016 16:06
LoginActivityTest - Initial state test
@Test
public void whenActivityIsLaunched_shouldDisplayInitialState() {
onView(withId(R.id.login_image)).check(matches(isDisplayed()));
onView(withId(R.id.login_username)).check(matches(isDisplayed()));
onView(withId(R.id.login_password)).check(matches(isDisplayed()));
onView(withId(R.id.login_button)).check(matches(isDisplayed()));
}
@heitorcolangelo
heitorcolangelo / LoginActivityTest.java
Last active October 25, 2016 12:41
LoginActivityTest - Empty fields state
@Test
public void whenAnyEditTextIsEmpty_andClickOnLoginButton_shouldDisplayDialog() {
onView(withId(R.id.login_username)).perform(typeText("admin"));
onView(withId(R.id.login_button)).perform(click());
onView(withText(R.string.validation_message)).check(matches(isDisplayed()));
onView(withText(R.string.ok)).perform(click());
onView(withId(R.id.login_username)).perform(clearText());
onView(withId(R.id.login_password)).perform(typeText("pass123"));
onView(withId(R.id.login_button)).perform(click());
@heitorcolangelo
heitorcolangelo / LoginActivityTest.java
Last active July 25, 2016 18:04
LoginActivityTest - empty state refactor
@Test
public void whenPasswordIsEmpty_andClickOnLoginButton_shouldDisplayDialog() {
onView(withId(R.id.login_username)).perform(typeText("admin"));
onView(withId(R.id.login_button)).perform(click());
onView(withText(R.string.validation_message)).check(matches(isDisplayed()));
onView(withText(R.string.ok)).perform(click());
}
@Test
public void whenUserNameIsEmpty_andClickOnLoginButton_shouldDisplayDialog() {
@heitorcolangelo
heitorcolangelo / LoginActivityTest.java
Last active July 25, 2016 18:05
LoginActivityTest - empty state test - refactor 2
@Test
public void whenPasswordIsEmpty_andClickOnLoginButton_shouldDisplayDialog() {
testEmptyFieldState(R.id.login_username);
}
@Test
public void whenUserNameIsEmpty_andClickOnLoginButton_shouldDisplayDialog() {
testEmptyFieldState(R.id.login_password);
}
@heitorcolangelo
heitorcolangelo / LoginActivityTest.java
Created July 25, 2016 20:10
LoginActivityTest - wrong test
@Test
public void whenBothFieldsAreFilled_andClickOnLoginButton_shouldOpenMainActivity() {
onView(withId(R.id.login_username)).perform(typeText("defaultText"), closeSoftKeyboard());
onView(withId(R.id.login_password)).perform(typeText("defaultText"), closeSoftKeyboard());
onView(withId(R.id.login_button)).perform(click());
onView(withId(R.id.main_activity_container)).check(matches(isDisplayed()));
}
@heitorcolangelo
heitorcolangelo / LoginActivityTest.java
Created July 26, 2016 17:32
LoginActivityTest - intent test 1
@Test
public void whenBothFieldsAreFilled_andClickOnLoginButton_shouldOpenMainActivity() {
Intents.init();
onView(withId(R.id.login_username)).perform(typeText("username"), closeSoftKeyboard());
onView(withId(R.id.login_password)).perform(typeText("password"), closeSoftKeyboard());
Matcher<Intent> matcher = hasComponent(MainActivity.class.getName());
onView(withId(R.id.login_button)).perform(click());
@heitorcolangelo
heitorcolangelo / LoginActivityTest.java
Created July 27, 2016 01:32
LoginActivityTest - intent test 2
@Test
public void whenBothFieldsAreFilled_andClickOnLoginButton_shouldOpenMainActivity() {
Intents.init();
onView(withId(R.id.login_username)).perform(typeText("defaultText"), closeSoftKeyboard());
onView(withId(R.id.login_password)).perform(typeText("defaultText"), closeSoftKeyboard());
Matcher<Intent> matcher = hasComponent(MainActivity.class.getName());
ActivityResult result = new ActivityResult(Activity.RESULT_OK, null);
intending(matcher).respondWith(result);
@heitorcolangelo
heitorcolangelo / MainActivityTest.java
Created August 4, 2016 01:35
MainActivityTest - initial config
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity>
mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
}