Search in sources :

Example 6 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project boxing by Bilibili.

the class PickerFragmentTest method showMedia.

@Test
public void showMedia() {
    ViewInteraction container = onView(withId(R.id.container));
    container.check(new ViewAssertion() {

        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            assertNotNull(view);
            assertTrue(view.getVisibility() == View.VISIBLE);
        }
    });
    ViewInteraction empty = onView(withId(R.id.empty_txt));
    empty.check(new ViewAssertion() {

        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            assertNotNull(view);
        }
    });
}
Also used : ViewAssertion(android.support.test.espresso.ViewAssertion) ViewInteraction(android.support.test.espresso.ViewInteraction) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException) Espresso.onView(android.support.test.espresso.Espresso.onView) View(android.view.View) Test(org.junit.Test)

Example 7 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project ChipsLayoutManager by BelooS.

the class FewChipsRowTest method deleteItemInTheFirstLine_ItemHasMaximumHeight_SameStartPadding.

@Test
public void deleteItemInTheFirstLine_ItemHasMaximumHeight_SameStartPadding() throws Exception {
    //arrange
    //just adapt input items list to required start values
    items.remove(1);
    activity.runOnUiThread(() -> activity.initialize());
    ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
    InstrumentalUtil.waitForIdle();
    View second = layoutManager.getChildAt(1);
    int startHeight = second.getHeight();
    double expectedY = second.getY();
    //act
    recyclerView.perform(actionDelegate(((uiController, view) -> items.remove(1))), notifyItemRemovedAction(1));
    InstrumentalUtil.waitForIdle();
    second = layoutManager.getChildAt(1);
    int endHeight = second.getHeight();
    double resultY = second.getY();
    //assert
    //check test behaviour
    assumeTrue(startHeight > endHeight);
    assertNotEquals(0, expectedY, 0.01);
    assertNotEquals(0, resultY, 0.01);
    assertEquals(resultY, expectedY, 0.01);
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Espresso.onView(android.support.test.espresso.Espresso.onView) Test(org.junit.Test)

Example 8 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project dobby-android by InceptAi.

the class WifiExpertUITests method wifiExpertRunWifiAnalysisOnly.

@Test
public void wifiExpertRunWifiAnalysisOnly() {
    // Added a sleep statement to match the app's execution delay.
    // The recommended way to handle such scenarios is to use Espresso idling resources:
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    Utils.safeSleep(5000);
    checkIdleState(true);
    //Press slow internet
    ViewInteraction button4 = onView(allOf(withText("Slow internet"), withParent(allOf(withId(R.id.action_menu), withParent(withId(R.id.scrollview_buttons))))));
    button4.perform(scrollTo(), click());
    Utils.safeSleep(2000);
    checkShowingWifiAnalysisState();
    //Press yes for running full tests
    ViewInteraction button7 = onView(allOf(withText("No"), withParent(allOf(withId(R.id.action_menu), withParent(withId(R.id.scrollview_buttons))))));
    button7.perform(scrollTo(), click());
    Utils.safeSleep(1000);
    checkDecliningFullSpeedTestState();
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 9 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project dobby-android by InceptAi.

the class WifiExpertUITests method checkShowingWifiAnalysisState.

private void checkShowingWifiAnalysisState() {
    captureScreenshot("wifi_analysis_state");
    ViewInteraction frameLayout = onView(withId(R.id.net_cardview));
    frameLayout.check(matches(isDisplayed()));
    ViewInteraction textView2 = onView(allOf(withId(R.id.dobbyTextTv), withText(containsString("You are"))));
    textView2.check(matches(withText(containsString("You are connected and online via wifi network:"))));
    textView2.check(matches(isDisplayed()));
    ViewInteraction button5 = onView(allOf(withText("Yes"), childAtPosition(allOf(withId(R.id.action_menu), childAtPosition(withId(R.id.scrollview_buttons), 0)), 0), isDisplayed()));
    button5.check(matches(isDisplayed()));
    ViewInteraction button6 = onView(allOf(withText("No"), childAtPosition(allOf(withId(R.id.action_menu), childAtPosition(withId(R.id.scrollview_buttons), 0)), 1), isDisplayed()));
    button6.check(matches(isDisplayed()));
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction)

Example 10 with ViewInteraction

use of android.support.test.espresso.ViewInteraction in project dobby-android by InceptAi.

the class WifiExpertUITests method checkShowingDetailedSuggestionState.

private void checkShowingDetailedSuggestionState() {
    captureScreenshot("detailed_suggestion_state");
    ViewInteraction frameLayout = onView(withId(R.id.custom));
    frameLayout.check(matches(isDisplayed()));
    ViewInteraction button4 = onView(withId(R.id.more_suggestions_dismiss_button));
    button4.check(matches(isDisplayed()));
    ViewInteraction listView = onView(withId(R.id.more_suggest_listview));
    listView.check(matches(isDisplayed()));
    ViewInteraction textView = onView(withText(containsString("Summary and suggestions")));
    textView.check(matches(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