Search in sources :

Example 11 with ViewInteraction

use of androidx.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.buttonSignIn), 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.buttonCamera), 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.pictureDownloadUri)).check(matches(withText(startsWith("https://firebasestorage.googleapis.com"))));
    // Click download
    ViewInteraction downloadButton = onView(allOf(withId(R.id.buttonDownload), 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(androidx.test.espresso.ViewInteraction) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 12 with ViewInteraction

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

the class TestAddNumber method testAddNumber.

@Test
public void testAddNumber() {
    ViewInteraction firstNumber = onView(withId(R.id.fieldFirstNumber));
    ViewInteraction secondNumber = onView(withId(R.id.fieldSecondNumber));
    ViewInteraction addButton = onView(withId(R.id.buttonCalculate));
    firstNumber.perform(replaceText("32"));
    secondNumber.perform(replaceText("16"));
    addButton.perform(scrollTo(), click());
    Assert.assertTrue(new UiObject(new UiSelector().resourceId("com.google.samples.quickstart.functions:id/fieldAddResult").text("48")).waitForExists(60000));
}
Also used : UiObject(androidx.test.uiautomator.UiObject) UiSelector(androidx.test.uiautomator.UiSelector) ViewInteraction(androidx.test.espresso.ViewInteraction) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 13 with ViewInteraction

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

the class MainActivityTest method caughtExceptionTest.

@Test
public void caughtExceptionTest() {
    // Make sure the checkbox is on screen
    ViewInteraction al = onView(allOf(withId(R.id.catchCrashCheckBox), withText(R.string.catch_crash_checkbox_label), isDisplayed()));
    // Click the checkbox if it's not already checked
    CheckBox checkBox = (CheckBox) mActivityTestRule.getActivity().findViewById(R.id.catchCrashCheckBox);
    if (!checkBox.isChecked()) {
        al.perform(click());
    }
    // Cause a crash
    ViewInteraction ak = onView(allOf(withId(R.id.crashButton), withText(R.string.crash_button_label), isDisplayed()));
    ak.perform(click());
}
Also used : CheckBox(android.widget.CheckBox) ViewInteraction(androidx.test.espresso.ViewInteraction) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 14 with ViewInteraction

use of androidx.test.espresso.ViewInteraction in project PocketHub by pockethub.

the class CreateCommentActivityTest method testEmptyCommentIsProhibited.

/**
 * Verify empty comment can't be created
 *
 * @throws Throwable
 */
@Test
public void testEmptyCommentIsProhibited() {
    ViewInteraction createMenu = onView(withId(R.id.m_apply));
    ViewInteraction comment = onView(withId(R.id.et_comment));
    createMenu.check(ViewAssertions.matches(not(isEnabled())));
    closeSoftKeyboard();
    comment.perform(ViewActions.typeText("a"));
    createMenu.check(ViewAssertions.matches(isEnabled()));
    comment.perform(ViewActions.replaceText(""));
    createMenu.check(ViewAssertions.matches(not(isEnabled())));
}
Also used : ViewInteraction(androidx.test.espresso.ViewInteraction) Test(org.junit.Test)

Example 15 with ViewInteraction

use of androidx.test.espresso.ViewInteraction in project fdroidclient by f-droid.

the class MainActivityEspressoTest method showSettings.

@LargeTest
@Test
public void showSettings() {
    ViewInteraction settingsBottonNavButton = onView(allOf(withText(R.string.menu_settings), isDisplayed()));
    settingsBottonNavButton.perform(click());
    onView(withText(R.string.preference_manage_installed_apps)).check(matches(isDisplayed()));
    if (BuildConfig.FLAVOR.startsWith("basic") && BuildConfig.APPLICATION_ID.endsWith(".debug")) {
        // TODO fix me by sorting out the flavor applicationId for debug builds in app/build.gradle
        Log.i(TAG, "Skipping the remainder of showSettings test because it just crashes on basic .debug builds");
        return;
    }
    ViewInteraction manageInstalledAppsButton = onView(allOf(withText(R.string.preference_manage_installed_apps), isDisplayed()));
    manageInstalledAppsButton.perform(click());
    onView(withText(R.string.installed_apps__activity_title)).check(matches(isDisplayed()));
    onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click());
    onView(withText(R.string.menu_manage)).perform(click());
    onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click());
    manageInstalledAppsButton.perform(click());
    onView(withText(R.string.installed_apps__activity_title)).check(matches(isDisplayed()));
    onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click());
    onView(withText(R.string.menu_manage)).perform(click());
    onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click());
    onView(withText(R.string.about_title)).perform(click());
    onView(withId(R.id.version)).check(matches(isDisplayed()));
    onView(withId(R.id.ok_button)).perform(click());
    onView(withId(android.R.id.list_container)).perform(swipeUp()).perform(swipeUp()).perform(swipeUp());
}
Also used : ViewInteraction(androidx.test.espresso.ViewInteraction) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Aggregations

ViewInteraction (androidx.test.espresso.ViewInteraction)17 Test (org.junit.Test)16 LargeTest (androidx.test.filters.LargeTest)9 Intent (android.content.Intent)1 CheckBox (android.widget.CheckBox)1 NoMatchingViewException (androidx.test.espresso.NoMatchingViewException)1 UiObject (androidx.test.uiautomator.UiObject)1 UiSelector (androidx.test.uiautomator.UiSelector)1 ViewVisibilityIdlingResource (com.github.pockethub.android.tests.ViewVisibilityIdlingResource)1