use of android.support.test.espresso.ViewInteraction in project quickstart-android by firebase.
the class MainActivityTest method selectFavoriteFoodIfPossible.
private void selectFavoriteFoodIfPossible(String food) {
try {
ViewInteraction appCompatTextView = onView(allOf(withId(android.R.id.text1), withText(food), withParent(allOf(withId(R.id.select_dialog_listview), withParent(withId(R.id.contentPanel)))), isDisplayed()));
appCompatTextView.perform(click());
} catch (NoMatchingViewException e) {
// This is ok
}
}
use of android.support.test.espresso.ViewInteraction in project quickstart-android by firebase.
the class EmailPasswordTest method successfulSignUpAndSignInTest.
@Test
public void successfulSignUpAndSignInTest() {
String email = "user" + randomInt() + "@example.com";
String password = "password" + randomInt();
// Make sure we're signed out
signOutIfPossible();
// Enter email
enterEmail(email);
// Enter password
enterPassword(password);
// Click sign up
ViewInteraction appCompatButton = onView(allOf(withId(R.id.email_create_account_button), withText(R.string.create_account), withParent(withId(R.id.email_password_buttons)), isDisplayed()));
appCompatButton.perform(click());
// Sign out button shown
onView(allOf(withId(R.id.sign_out_button), withText(R.string.sign_out), isDisplayed()));
// User email shown
String emailString = mActivityTestRule.getActivity().getString(R.string.emailpassword_status_fmt, email);
onView(withText(emailString)).check(matches(isDisplayed()));
// Sign out
signOutIfPossible();
// Sign back in with the email and password
enterEmail(email);
enterPassword(password);
// Click sign in
ViewInteraction signInButton = onView(allOf(withId(R.id.email_sign_in_button), withText(R.string.sign_in), withParent(withId(R.id.email_password_buttons)), isDisplayed()));
signInButton.perform(click());
// User email shown
onView(withText(emailString)).check(matches(isDisplayed()));
}
use of android.support.test.espresso.ViewInteraction in project quickstart-android by firebase.
the class EmailPasswordTest method enterEmail.
private void enterEmail(String email) {
ViewInteraction emailField = onView(allOf(withId(R.id.field_email), withParent(withId(R.id.email_password_fields)), isDisplayed()));
emailField.perform(replaceText(email));
}
use of android.support.test.espresso.ViewInteraction in project quickstart-android by firebase.
the class InterstitialAdTest method interstitialAdTest.
@Test
public void interstitialAdTest() {
// Wait for ad to load
mAdResource.setIsLoadingAd(true);
// Confirm that banner ad appears
onView(withId(R.id.adView)).check(matches(isDisplayed()));
// Click show interstitial button
ViewInteraction showInterstitialButton = onView(allOf(withId(R.id.load_interstitial_button), withText(R.string.interstitial_button_text), isDisplayed()));
showInterstitialButton.perform(click());
// Click close interstitial button
ViewInteraction closeInterstitialButton = onView(allOf(withContentDescription("Interstitial close button"), isDisplayed()));
closeInterstitialButton.perform(click());
// Confirm that we're on the second activity
onView(withText(R.string.second_activity_content)).check(matches(isDisplayed()));
}
use of android.support.test.espresso.ViewInteraction in project iosched by google.
the class ToolbarUtils method checkToolbarHidesAfterSwipingRecyclerViewUp.
public static void checkToolbarHidesAfterSwipingRecyclerViewUp(int viewResource) {
ViewInteraction view = onView(withId(R.id.toolbar));
// Swiping up should hide the toolbar.
onView(withId(viewResource)).perform(RecyclerViewActions.actionOnItemAtPosition(0, swipeUp()));
// Check if the toolbar is hidden.
view.check(matches(not(isDisplayed())));
}
Aggregations