Created
September 5, 2012 23:50
-
-
Save tophyr/3647992 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 class LoginActivityTest extends ActivityInstrumentationTestCase2<HomeActivity> { | |
public static final String EMAIL = "[email protected]"; | |
public static final String PASSWORD = "dstest"; | |
public static final String LOGIN_BUTTON = "Sign In"; | |
public static final String LOGGING_IN = "Signing In..."; | |
public static final String HOME_ACTIVITY = "HomeActivity"; | |
private Solo m_Solo; | |
public LoginActivityTest() { | |
super(HomeActivity.class); | |
} | |
protected void setUp() throws Exception { | |
super.setUp(); | |
m_Solo = new Solo(getInstrumentation(), getActivity()); | |
} | |
protected void tearDown() throws Exception { | |
m_Solo.finishOpenedActivities(); | |
super.tearDown(); | |
} | |
public void testLogin() { | |
// are we already logged in? if so, log out | |
if (m_Solo.waitForActivity(HOME_ACTIVITY, 1)) { | |
m_Solo.clickOnView(m_Solo.getView(R.id.home_image_logout)); | |
} | |
// make sure LoginActivity shows up | |
assertTrue(LoginActivity.class.getSimpleName(), m_Solo.waitForActivity(LoginActivity.class.getSimpleName())); | |
EditText email = (EditText)m_Solo.getView(R.id.login_email); | |
EditText password = (EditText)m_Solo.getView(R.id.login_password); | |
assertNotNull("email is null", email); | |
m_Solo.enterText(email, EMAIL); // test fails here, it is unable to click on LoginActivity's button | |
fail("got here"); | |
assertNotNull("password is null", password); | |
m_Solo.enterText(password, PASSWORD); | |
m_Solo.clickOnView(m_Solo.getView(R.id.login_button)); | |
assertTrue("No log in status", m_Solo.waitForText(LOGGING_IN)); | |
assertTrue("Did not go to home activity", m_Solo.waitForActivity(HOME_ACTIVITY)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment