Search in sources :

Example 1 with ViewInteraction

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
    }
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException)

Example 2 with ViewInteraction

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()));
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 3 with ViewInteraction

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));
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction)

Example 4 with ViewInteraction

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()));
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 5 with ViewInteraction

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())));
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction)

Aggregations

ViewInteraction (android.support.test.espresso.ViewInteraction)38 Test (org.junit.Test)19 LargeTest (android.test.suitebuilder.annotation.LargeTest)13 Espresso.onView (android.support.test.espresso.Espresso.onView)5 View (android.view.View)5 NoMatchingViewException (android.support.test.espresso.NoMatchingViewException)4 RecyclerView (android.support.v7.widget.RecyclerView)4 ViewAction (android.support.test.espresso.ViewAction)2 ChipsEntity (com.beloo.chipslayoutmanager.sample.entity.ChipsEntity)2 InvalidStrategyException (io.appium.espressoserver.lib.handlers.exceptions.InvalidStrategyException)2 NoSuchElementException (io.appium.espressoserver.lib.handlers.exceptions.NoSuchElementException)2 Nullable (javax.annotation.Nullable)2 Context (android.content.Context)1 PerformException (android.support.test.espresso.PerformException)1 ViewAssertion (android.support.test.espresso.ViewAssertion)1 ViewAssertions.matches (android.support.test.espresso.assertion.ViewAssertions.matches)1 ViewMatchers.isDisplayed (android.support.test.espresso.matcher.ViewMatchers.isDisplayed)1 ViewMatchers.withId (android.support.test.espresso.matcher.ViewMatchers.withId)1 ActivityTestRule (android.support.test.rule.ActivityTestRule)1 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)1