Created
September 5, 2012 01:00
-
-
Save tophyr/3628684 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<LoginActivity> { | |
public static final String EMAIL = "[email protected]"; | |
public static final String PASSWORD = "testpassword"; | |
public static final String LOGIN_BUTTON = "Login"; | |
public static final String LOGGING_IN = "Logging in..."; | |
public static final String HOME_ACTIVITY = "HomeActivity"; | |
private Solo m_Solo; | |
public LoginActivityTest() { | |
super(LoginActivity.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() { | |
// this is *awful*.. is this really how i have to do it? (or refer by "index", aka "first EditText, second EditText"... no better | |
// not possible to "find text 'Email', find EditText directly to that text's right"..? or simply at least refer by ID more easily | |
// since referring like this is already violating black-box.. but m_Solo.enterText(R.id.login_email, ...) would at least be less ugly | |
m_Solo.enterText((EditText)m_Solo.getView(com.myapp.R.id.login_email), EMAIL); | |
m_Solo.enterText((EditText)m_Solo.getView(com.myapp.R.id.login_password), PASSWORD); | |
m_Solo.clickOnButton(LOGIN_BUTTON); | |
assertTrue(m_Solo.waitForText(LOGGING_IN)); | |
assertTrue(m_Solo.waitForActivity(HOME_ACTIVITY)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment