Search in sources :

Example 21 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project quickstart-android by firebase.

the class EmailPasswordTest method failedSignInTest.

@Test
public void failedSignInTest() {
    String email = "test@test.com";
    String password = "123456";
    // Make sure we're signed out
    signOutIfPossible();
    // Enter email
    enterEmail(email);
    // Enter password
    enterPassword(password);
    // Click sign in
    ViewInteraction appCompatButton = onView(allOf(withId(R.id.email_sign_in_button), withText(R.string.sign_in), withParent(withId(R.id.email_password_buttons)), isDisplayed()));
    appCompatButton.perform(click());
    // Check that auth failed
    onView(withText(R.string.auth_failed)).check(matches(isDisplayed()));
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 22 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project quickstart-android by firebase.

the class EmailPasswordTest method enterPassword.

private void enterPassword(String password) {
    ViewInteraction passwordField = onView(allOf(withId(R.id.field_password), withParent(withId(R.id.email_password_fields)), isDisplayed()));
    passwordField.perform(replaceText(password));
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction)

Example 23 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project quickstart-android by firebase.

the class MainActivityTest method uploadPhotoTest.

@Test
public void uploadPhotoTest() throws InterruptedException {
    // Log out to start
    logOutIfPossible();
    // Create a temp file
    createTempFile();
    // Click sign in
    ViewInteraction signInButton = onView(allOf(withId(R.id.button_sign_in), withText(R.string.sign_in_anonymously), isDisplayed()));
    signInButton.perform(click());
    // Wait for sign in
    Thread.sleep(5000);
    // Click upload
    ViewInteraction uploadButton = onView(allOf(withId(R.id.button_camera), withText(R.string.camera_button_text), isDisplayed()));
    uploadButton.perform(click());
    // Confirm that download link label is displayed
    onView(withText(R.string.label_link)).check(matches(isDisplayed()));
    // Confirm that there is a download link on screen
    onView(withId(R.id.picture_download_uri)).check(matches(withText(startsWith("https://firebasestorage.googleapis.com"))));
    // Click download
    ViewInteraction downloadButton = onView(allOf(withId(R.id.button_download), withText(R.string.download), isDisplayed()));
    downloadButton.perform(click());
    // Wait for download
    Thread.sleep(5000);
    // Confirm that a success dialog appears
    onView(withText(R.string.success)).inRoot(isDialog()).check(matches(isDisplayed()));
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 24 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project quickstart-android by firebase.

the class MainActivityTest method mainActivityTest.

@Test
public void mainActivityTest() {
    // Select favorite food if the dialog appears
    selectFavoriteFoodIfPossible("Hot Dogs");
    // Initial title
    checkTitleText(R.string.pattern1_title);
    // Swipe, make sure we see the right titles
    ViewInteraction viewPager = onView(withId(R.id.pager));
    viewPager.check(matches(isDisplayed()));
    // Swipe left
    viewPager.perform(swipeLeft());
    checkTitleText(R.string.pattern2_title);
    // Swipe left
    viewPager.perform(swipeLeft());
    checkTitleText(R.string.pattern3_title);
    // Swipe back right
    viewPager.perform(swipeRight());
    checkTitleText(R.string.pattern2_title);
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 25 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project iosched by google.

the class ToolbarUtils method checkToolbarCollapsesAfterSwipingRecyclerViewUp.

public static void checkToolbarCollapsesAfterSwipingRecyclerViewUp(int viewResource) {
    // TODO
    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