Last active
July 25, 2017 21:11
-
-
Save baz8080/e6b0f7d252895468bddcafc89ee7b0bc to your computer and use it in GitHub Desktop.
Snackbar testing: the less crap version
This file contains 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
@Test | |
fun genericErrrorSnackbarShouldHaveExpectedText() { | |
// Same setup as previous example - omitting | |
// Simple tests same as previous example - omitting | |
val snackbarLayout = snackbar.view | |
// Now we can use standard findViewById | |
val snackbarTextView = snackbarLayout.findViewById<TextView>(R.id.snackbar_text) | |
assertThat(snackbarTextView).isNotNull() | |
assertThat(snackbarTextView.text).isEqualTo("Oops, the speech didn't work!") | |
// This Snackbar doesn't have an action. There should also be a test which | |
// asserts the below after show is called | |
val snackbarAction = snackbarLayout.findViewById<Button>(R.id.snackbar_action) | |
assertThat(snackbarAction).isNotNull() | |
assertThat(snackbarAction.hasOnClickListeners()).isFalse() | |
assertThat(snackbarAction.visibility).isEqualTo(View.GONE) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment