Last active
April 11, 2017 07:10
-
-
Save ecgreb/dd322efdbd360667634d687bb7467a80 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
@RunWith(RobolectricTestRunner.class) | |
@Config(manifest="src/main/AndroidManifest.xml", sdk=23) | |
public class LoginFormTest { | |
LoginForm loginForm = new LoginForm(RuntimeEnvironment.application); | |
TextView emailView = (TextView) loginForm.findViewById(R.id.email); | |
TextView passwordView = (TextView) loginForm.findViewById(R.id.password); | |
Button signInButton = (Button) loginForm.findViewById(R.id.email_sign_in_button); | |
TestListener listener = new TestListener(); | |
@Test public void onClickSignInButton_shouldNotInvokeListenerForInvalidInput() throws Exception { | |
emailView.setText("bad_email"); | |
passwordView.setText("bad_password"); | |
loginForm.setOnClickListener(listener); | |
signInButton.performClick(); | |
assertThat(listener.click).isFalse(); | |
} | |
@Test public void onClickSignInButton_shouldInvokeListenerForValidInput() throws Exception { | |
emailView.setText("[email protected]"); | |
passwordView.setText("hello"); | |
loginForm.setOnClickListener(listener); | |
signInButton.performClick(); | |
assertThat(listener.click).isTrue(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment