Search in sources :

Example 1 with ViewVisibilityIdlingResource

use of com.github.pockethub.android.tests.ViewVisibilityIdlingResource in project PocketHub by pockethub.

the class EditIssueActivityTest method testSaveMenuEnabled.

/**
 * Verify save menu is properly enabled/disable depending on the issue have
 * a non-empty title
 *
 * @throws Throwable
 */
@Test
public void testSaveMenuEnabled() {
    ViewInteraction createMenu = onView(withId(R.id.m_apply));
    ViewInteraction comment = onView(withId(R.id.et_issue_title));
    ViewVisibilityIdlingResource idlingResource = new ViewVisibilityIdlingResource(activityTestRule.getActivity(), R.id.sv_issue_content, View.VISIBLE);
    IdlingRegistry.getInstance().register(idlingResource);
    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())));
    IdlingRegistry.getInstance().unregister(idlingResource);
}
Also used : ViewInteraction(androidx.test.espresso.ViewInteraction) ViewVisibilityIdlingResource(com.github.pockethub.android.tests.ViewVisibilityIdlingResource) Test(org.junit.Test)

Aggregations

ViewInteraction (androidx.test.espresso.ViewInteraction)1 ViewVisibilityIdlingResource (com.github.pockethub.android.tests.ViewVisibilityIdlingResource)1 Test (org.junit.Test)1