Java Code Examples for org.hamcrest.core.StringStartsWith

Following code examples demonstrate how to use org.hamcrest.core.StringStartsWithfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.hamcrest.core.StringStartsWithand various code implementation of this class.

    public void testMatchesStringAtStart() {
        assertMatches(stringStartsWith, EXCERPT + "END");
        assertDoesNotMatch(stringStartsWith, "START" + EXCERPT);
        assertDoesNotMatch(stringStartsWith, "START" + EXCERPT + "END");
        assertMatches(stringStartsWith, EXCERPT);
        assertDoesNotMatch(stringStartsWith, EXCERPT.toLowerCase());
        assertMatches(stringStartsWith, EXCERPT + EXCERPT);
        assertDoesNotMatch(stringStartsWith, "EXCER");

        assertDescription("a string starting with \"EXCERPT\"", stringStartsWith);
        assertMismatchDescription("was \"Something else\"", stringStartsWith, "Something else");
    } 


    public void sayHello() {
        onView(withId(R.id.activity_test_et_pw)).perform(typeText("123456"), clearText(), typeText("654321"), pressKey(KeyEvent.KEYCODE_A));

        onData(StringStartsWith.startsWith("item")).inAdapterView(withId(R.id.activity_test_lv)).atPosition(0).perform(click());
        SystemClock.sleep(1000);
        onView(withText("cancel")).perform(click());
        SystemClock.sleep(1000);
        onData(StringStartsWith.startsWith("item")).inAdapterView(withId(R.id.activity_test_lv)).atPosition(3).perform(click());
        SystemClock.sleep(1000);
        onView(withText("cancel")).perform(click());
        SystemClock.sleep(1000);
        onData(StringStartsWith.startsWith("item")).inAdapterView(withId(R.id.activity_test_lv)).atPosition(4).perform(click());
        SystemClock.sleep(1000);
        onView(withText("cancel")).perform(click());
        SystemClock.sleep(1000);
        onData(StringStartsWith.startsWith("item")).inAdapterView(withId(R.id.activity_test_lv)).atPosition(5).perform(click());
        onView(withText("cancel")).perform(click());
        SystemClock.sleep(5000);

    } 

Advertisement
Javadoc
Tests if the argument is a string that contains a substring.
Advertisement