Search in sources :

Example 16 with NoMatchingViewException

use of android.support.test.espresso.NoMatchingViewException in project storymaker by StoryMaker.

the class EndToEndVideoTest method doTest.

public boolean doTest(String mediaString, String accountString) {
    // obb file assumed to be present (test requires network access)
    // select "new" option
    onView(withText("New")).perform(click());
    Timber.d("CLICKED NEW BUTTON");
    // first selection
    onView(withText("An Event")).perform(click());
    Timber.d("CLICKED EVENT BUTTON");
    // second selection
    onView(withText("Show the best moments.")).perform(click());
    Timber.d("CLICKED HIGHLIGHTS BUTTON");
    // third selection
    onView(withText(mediaString)).perform(click());
    Timber.d("CLICKED MEDIA BUTTON");
    // get liger activity
    ActivityGetter ag = new ActivityGetter();
    getInstrumentation().runOnMainSync(ag);
    if (mMainActivity == null) {
        Timber.e("NO LIGER ACTIVITY ACCESS");
        return false;
    }
    // scroll to first capture card
    // UPDATE IF STORY PATH CHANGES
    ActivityScroller as1 = new ActivityScroller(4);
    mMainActivity.runOnUiThread(as1);
    stall(500, "WAIT FOR SCROLLING");
    // media capture
    onView(allOf(withText("Capture"), withParent(withParent(withTagValue(is((Object) "clip_card_0")))))).perform(click());
    Timber.d("CLICKED CAPTURE BUTTON");
    stall(500, "WAIT FOR MEDIA CAPTURE UPDATE");
    // scroll to bottom
    // UPDATE IF STORY PATH CHANGES
    ActivityScroller as2 = new ActivityScroller(18);
    mMainActivity.runOnUiThread(as2);
    stall(500, "WAIT FOR SCROLLING");
    // begin publish/upload steps
    try {
        onView(allOf(withText("Publish"), withParent(withTagValue(is((Object) "publish_card_1"))))).perform(click());
        Timber.d("CLICKED PUBLISH BUTTON");
    } catch (NoMatchingViewException nmve) {
        // implies no button was found (failure)
        Timber.d("NO PUBLISH BUTTON FOUND (FAIL)");
        return false;
    }
    // enter metadata
    onView(withId(R.id.fl_info_container)).perform(click());
    Timber.d("CLICKED METADATA FIELD");
    // get time for unique id
    Calendar now = new GregorianCalendar();
    onView(withId(R.id.et_story_info_title)).perform(clearText()).perform(typeText(mediaString.toUpperCase() + "/" + accountString.toUpperCase() + "/" + now.get(Calendar.HOUR) + ":" + now.get(Calendar.MINUTE)));
    Timber.d("ENTERED TITLE TEXT");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.et_story_info_description)).perform(clearText()).perform(typeText(mediaString + "/" + accountString));
    Timber.d("ENTERED DESCRIPTION TEXT");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.act_story_info_tag)).perform(clearText()).perform(typeText(mediaString.toLowerCase()));
    onView(withId(R.id.btn_add_tag)).perform(click());
    Timber.d("ENTERED FIRST TAG");
    onView(withId(R.id.act_story_info_tag)).perform(clearText()).perform(typeText(accountString.toLowerCase()));
    onView(withId(R.id.btn_add_tag)).perform(click());
    Timber.d("ENTERED SECOND TAG");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    // these seem problematic, will troubleshoot later
    /*
        onView(withId(R.id.sp_story_section)).perform(click());
        onView(withText("Travel")).perform(click());
        Timber.d("SELECTED SECTION");

        onView(withId(R.id.sp_story_location)).perform(click());
        onView(withText("Czech Republic")).perform(click());
        Timber.d("SELECTED LOCATION");
        */
    onView(withText("Save")).perform(click());
    Timber.d("SAVED METADATA");
    // select account and upload
    onView(withId(R.id.btnUpload)).perform(click());
    Timber.d("CLICKED UPLOAD BUTTON");
    // scroll to account
    onView(withText(accountString)).perform(scrollTo(), click());
    Timber.d("SCROLLED TO " + accountString + " BUTTON");
    // get name/password from xml file (add more later)
    String accountName = "";
    String accountPass = "";
    if (accountString.equals("SoundCloud")) {
        accountName = mHomeActivity.getApplicationContext().getString(R.string.soundcloud_name);
        accountPass = mHomeActivity.getApplicationContext().getString(R.string.soundcloud_pass);
    }
    // enter name/password
    onView(withId(R.id.etUsername)).perform(clearText()).perform(typeText(accountName));
    Timber.d("ENTERED USER NAME");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.etPassword)).perform(clearText()).perform(typeText(accountPass));
    Timber.d("ENTERED USER PASSWORD");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.btnSignIn)).perform(click());
    Timber.d("CLICKED SIGN IN BUTTON");
    onView(withId(R.id.switchStoryMaker)).perform(click());
    Timber.d("CLICKED STORYMAKER PUBLISH SWITCH");
    try {
        // TODO: re-enable once test points to beta server
        // onView(withText("Continue")).perform(click());
        Timber.d("CLICKED CONTINUE BUTTON");
    } catch (NoMatchingViewException nmve) {
        // implies no button was found (failure)
        Timber.d("NO CONTINUE BUTTON FOUND (FAIL)");
        return false;
    }
    // TODO: how to verify successful upload? (failure indicated by visible message)
    stall(30000, "WAITING FOR UPLOAD");
    Timber.d("TEST RUN COMPLETE (PASS)");
    return true;
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException)

Example 17 with NoMatchingViewException

use of android.support.test.espresso.NoMatchingViewException in project storymaker by StoryMaker.

the class CompleteTest method doTest.

public boolean doTest(String mediaString, String accountString) {
    // obb file assumed to be present (test requires network access)
    // select "new" option
    onView(withText("New")).perform(click());
    Timber.d("CLICKED NEW BUTTON");
    // first selection
    onView(withText("An Event")).perform(click());
    Timber.d("CLICKED EVENT BUTTON");
    // second selection
    onView(withText("Show the best moments.")).perform(click());
    Timber.d("CLICKED HIGHLIGHTS BUTTON");
    // third selection
    onView(withText(mediaString)).perform(click());
    Timber.d("CLICKED MEDIA BUTTON");
    // get liger activity
    ActivityGetter ag = new ActivityGetter();
    getInstrumentation().runOnMainSync(ag);
    if (mMainActivity == null) {
        Timber.e("NO LIGER ACTIVITY ACCESS");
        return false;
    }
    // scroll to first capture card
    // UPDATE IF STORY PATH CHANGES
    ActivityScroller as1 = new ActivityScroller(4);
    mMainActivity.runOnUiThread(as1);
    stall(500, "WAIT FOR SCROLLING");
    // media capture
    onView(allOf(withText("Capture"), withParent(withParent(withTagValue(is((Object) "clip_card_0")))))).perform(click());
    Timber.d("CLICKED CAPTURE BUTTON");
    stall(500, "WAIT FOR MEDIA CAPTURE UPDATE");
    // scroll to bottom
    // UPDATE IF STORY PATH CHANGES
    ActivityScroller as2 = new ActivityScroller(18);
    mMainActivity.runOnUiThread(as2);
    stall(500, "WAIT FOR SCROLLING");
    // begin publish/upload steps
    try {
        onView(allOf(withText("Publish"), withParent(withTagValue(is((Object) "publish_card_1"))))).perform(click());
        Timber.d("CLICKED PUBLISH BUTTON");
    } catch (NoMatchingViewException nmve) {
        // implies no button was found (failure)
        Timber.d("NO PUBLISH BUTTON FOUND (FAIL)");
        return false;
    }
    // enter metadata
    onView(withId(R.id.fl_info_container)).perform(click());
    Timber.d("CLICKED METADATA FIELD");
    // get time for unique id
    Calendar now = new GregorianCalendar();
    onView(withId(R.id.et_story_info_title)).perform(clearText()).perform(typeText(mediaString.toUpperCase() + "/" + accountString.toUpperCase() + "/" + now.get(Calendar.HOUR) + ":" + now.get(Calendar.MINUTE)));
    Timber.d("ENTERED TITLE TEXT");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.et_story_info_description)).perform(clearText()).perform(typeText(mediaString + "/" + accountString));
    Timber.d("ENTERED DESCRIPTION TEXT");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.act_story_info_tag)).perform(clearText()).perform(typeText(mediaString.toLowerCase()));
    onView(withId(R.id.btn_add_tag)).perform(click());
    Timber.d("ENTERED FIRST TAG");
    onView(withId(R.id.act_story_info_tag)).perform(clearText()).perform(typeText(accountString.toLowerCase()));
    onView(withId(R.id.btn_add_tag)).perform(click());
    Timber.d("ENTERED SECOND TAG");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    // these seem problematic, will troubleshoot later
    /*
        onView(withId(R.id.sp_story_section)).perform(click());
        onView(withText("Travel")).perform(click());
        Timber.d("SELECTED SECTION");

        onView(withId(R.id.sp_story_location)).perform(click());
        onView(withText("Czech Republic")).perform(click());
        Timber.d("SELECTED LOCATION");
        */
    onView(withText("Save")).perform(click());
    Timber.d("SAVED METADATA");
    // select account and upload
    onView(withId(R.id.btnUpload)).perform(click());
    Timber.d("CLICKED UPLOAD BUTTON");
    // scroll to account
    onView(withText(accountString)).perform(scrollTo(), click());
    Timber.d("SCROLLED TO " + accountString + " BUTTON");
    // get name/password from xml file (add more later)
    String accountName = "";
    String accountPass = "";
    if (accountString.equals("SoundCloud")) {
        accountName = mHomeActivity.getApplicationContext().getString(R.string.soundcloud_name);
        accountPass = mHomeActivity.getApplicationContext().getString(R.string.soundcloud_pass);
    }
    // enter name/password
    onView(withId(R.id.etUsername)).perform(clearText()).perform(typeText(accountName));
    Timber.d("ENTERED USER NAME");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.etPassword)).perform(clearText()).perform(typeText(accountPass));
    Timber.d("ENTERED USER PASSWORD");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.btnSignIn)).perform(click());
    Timber.d("CLICKED SIGN IN BUTTON");
    onView(withId(R.id.switchStoryMaker)).perform(click());
    Timber.d("CLICKED STORYMAKER PUBLISH SWITCH");
    try {
        // TODO: re-enable once test points to beta server
        onView(withText("Continue")).perform(click());
        Timber.d("CLICKED CONTINUE BUTTON");
    } catch (NoMatchingViewException nmve) {
        // implies no button was found (failure)
        Timber.d("NO CONTINUE BUTTON FOUND (FAIL)");
        return false;
    }
    // TODO: how to verify successful upload? (failure indicated by visible message)
    stall(30000, "WAITING FOR UPLOAD");
    Timber.d("TEST RUN COMPLETE (PASS)");
    return true;
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException)

Example 18 with NoMatchingViewException

use of android.support.test.espresso.NoMatchingViewException in project storymaker by StoryMaker.

the class TorEndToEndTest method doTest.

public boolean doTest(String mediaString, String accountString) {
    // obb file assumed to be present (test requires network access)
    // select "new" option
    onView(withText("New")).perform(click());
    Timber.d("CLICKED NEW BUTTON");
    // first selection
    onView(withText("An Event")).perform(click());
    Timber.d("CLICKED EVENT BUTTON");
    // second selection
    onView(withText("Show the best moments.")).perform(click());
    Timber.d("CLICKED HIGHLIGHTS BUTTON");
    // third selection
    onView(withText(mediaString)).perform(click());
    Timber.d("CLICKED MEDIA BUTTON");
    // get liger activity
    ActivityGetter ag = new ActivityGetter();
    getInstrumentation().runOnMainSync(ag);
    if (mMainActivity == null) {
        Timber.e("NO LIGER ACTIVITY ACCESS");
        return false;
    }
    // scroll to first capture card
    // UPDATE IF STORY PATH CHANGES
    ActivityScroller as1 = new ActivityScroller(4);
    mMainActivity.runOnUiThread(as1);
    stall(500, "WAIT FOR SCROLLING");
    if (mediaString.equals("Video")) {
        onView(allOf(withText("Capture"), withParent(withParent(withTagValue(is((Object) "clip_card_0")))))).perform(click());
        Timber.d("CLICKED CAPTURE BUTTON");
        stall(500, "WAIT FOR MEDIA CAPTURE UPDATE");
    } else if (mediaString.equals("Audio")) {
        // audio captured by the card itself, record a 10 second clip
        onView(allOf(withText("Capture"), withParent(withParent(withTagValue(is((Object) "clip_card_0")))))).perform(click());
        Timber.d("CLICKED CAPTURE BUTTON");
        stall(10000, "WAIT FOR 10 SECONDS OF AUDIO");
        onView(allOf(withText("STOP RECORDING"), withParent(withParent(withTagValue(is((Object) "clip_card_0")))))).perform(click());
        Timber.d("CLICKED STOP BUTTON");
        stall(500, "WAIT FOR MEDIA CAPTURE UPDATE");
    } else {
        Timber.d("TEST DOES NOT HANDLE MEDIA TYPE " + mediaString);
        return false;
    }
    // scroll to bottom
    // UPDATE IF STORY PATH CHANGES
    ActivityScroller as2 = new ActivityScroller(18);
    mMainActivity.runOnUiThread(as2);
    stall(500, "WAIT FOR SCROLLING");
    // begin publish/upload steps
    try {
        onView(allOf(withText("Publish"), withParent(withTagValue(is((Object) "publish_card_1"))))).perform(click());
        Timber.d("CLICKED PUBLISH BUTTON");
    } catch (NoMatchingViewException nmve) {
        // implies no button was found (failure)
        Timber.d("NO PUBLISH BUTTON FOUND (FAIL)");
        return false;
    }
    // enter metadata
    onView(withId(R.id.fl_info_container)).perform(click());
    Timber.d("CLICKED METADATA FIELD");
    // get time for unique id
    Calendar now = new GregorianCalendar();
    onView(withId(R.id.et_story_info_title)).perform(clearText()).perform(typeText(mediaString.toUpperCase() + "/" + accountString.toUpperCase() + "/" + now.get(Calendar.HOUR) + ":" + now.get(Calendar.MINUTE)));
    Timber.d("ENTERED TITLE TEXT");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.et_story_info_description)).perform(clearText()).perform(typeText(mediaString + "/" + accountString));
    Timber.d("ENTERED DESCRIPTION TEXT");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    onView(withId(R.id.act_story_info_tag)).perform(clearText()).perform(typeText(mediaString.toLowerCase()));
    onView(withId(R.id.btn_add_tag)).perform(click());
    Timber.d("ENTERED FIRST TAG");
    onView(withId(R.id.act_story_info_tag)).perform(clearText()).perform(typeText(accountString.toLowerCase()));
    onView(withId(R.id.btn_add_tag)).perform(click());
    Timber.d("ENTERED SECOND TAG");
    pressBack();
    stall(500, "PAUSE TO CLEAR KEYBOARD");
    // these seem problematic, will troubleshoot later
    /*
        onView(withId(R.id.sp_story_section)).perform(click());
        onView(withText("Travel")).perform(click());
        Timber.d("SELECTED SECTION");

        onView(withId(R.id.sp_story_location)).perform(click());
        onView(withText("Czech Republic")).perform(click());
        Timber.d("SELECTED LOCATION");
        */
    onView(withText("Save")).perform(click());
    Timber.d("SAVED METADATA");
    // select account and upload
    onView(withId(R.id.btnUpload)).perform(click());
    Timber.d("CLICKED UPLOAD BUTTON");
    // scroll to account
    onView(withText(accountString)).perform(scrollTo(), click());
    Timber.d("SCROLLED TO " + accountString + " BUTTON");
    // only login on the first time through the loop
    if ((accountString.equals("SoundCloud")) && (!soundcloudConnected)) {
        // get name/password from xml file (add more later)
        String accountName = "";
        String accountPass = "";
        if (accountString.equals("SoundCloud")) {
            accountName = mHomeActivity.getApplicationContext().getString(R.string.soundcloud_name);
            accountPass = mHomeActivity.getApplicationContext().getString(R.string.soundcloud_pass);
        }
        // enter name/password
        onView(withId(R.id.etUsername)).perform(clearText()).perform(typeText(accountName));
        Timber.d("ENTERED USER NAME");
        pressBack();
        stall(500, "PAUSE TO CLEAR KEYBOARD");
        onView(withId(R.id.etPassword)).perform(clearText()).perform(typeText(accountPass));
        Timber.d("ENTERED USER PASSWORD");
        pressBack();
        stall(500, "PAUSE TO CLEAR KEYBOARD");
        onView(withId(R.id.btnSignIn)).perform(click());
        Timber.d("CLICKED SIGN IN BUTTON");
        soundcloudConnected = true;
    } else {
        Timber.d("ALREADY LOGGED IN TO " + accountString);
    }
    // already toggled to "on" based on app settings
    // onView(withId(R.id.switchTor)).perform(click());
    // Timber.d("CLICKED TOR UPLOAD SWITCH");
    // onView(withId(R.id.switchStoryMaker)).perform(click());
    Timber.d("CLICKED STORYMAKER PUBLISH SWITCH");
    try {
        // TODO: re-enable once test points to beta server
        onView(withText("Continue")).perform(click());
        Timber.d("CLICKED CONTINUE BUTTON");
    } catch (NoMatchingViewException nmve) {
        // implies no button was found (failure)
        Timber.d("NO CONTINUE BUTTON FOUND (FAIL)");
        return false;
    }
    // TODO: how to verify successful upload? (failure indicated by visible message)
    stall(30000, "WAITING FOR UPLOAD");
    Timber.d("TEST RUN COMPLETE (PASS)");
    return true;
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException)

Example 19 with NoMatchingViewException

use of android.support.test.espresso.NoMatchingViewException 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 20 with NoMatchingViewException

use of android.support.test.espresso.NoMatchingViewException in project cameraview by google.

the class CameraViewTest method showingPreview.

private static ViewAssertion showingPreview() {
    return new ViewAssertion() {

        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            CameraView cameraView = (CameraView) view;
            TextureView textureView = cameraView.findViewById(R.id.texture_view);
            Bitmap bitmap = textureView.getBitmap();
            int topLeft = bitmap.getPixel(0, 0);
            int center = bitmap.getPixel(bitmap.getWidth() / 2, bitmap.getHeight() / 2);
            int bottomRight = bitmap.getPixel(bitmap.getWidth() - 1, bitmap.getHeight() - 1);
            assertFalse("Preview possibly blank: " + Integer.toHexString(topLeft), topLeft == center && center == bottomRight);
        }
    };
}
Also used : Bitmap(android.graphics.Bitmap) ViewAssertion(android.support.test.espresso.ViewAssertion) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException) TextureView(android.view.TextureView) View(android.view.View) TextureView(android.view.TextureView) Espresso.onView(android.support.test.espresso.Espresso.onView)

Aggregations

NoMatchingViewException (android.support.test.espresso.NoMatchingViewException)34 ViewAssertion (android.support.test.espresso.ViewAssertion)23 View (android.view.View)23 Espresso.onView (android.support.test.espresso.Espresso.onView)16 TextView (android.widget.TextView)9 ViewInteraction (android.support.test.espresso.ViewInteraction)7 RootMatchers.withDecorView (android.support.test.espresso.matcher.RootMatchers.withDecorView)7 AssertionFailedError (junit.framework.AssertionFailedError)7 Test (org.junit.Test)7 TypedArray (android.content.res.TypedArray)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Spanned (android.text.Spanned)5 TextPaint (android.text.TextPaint)5 SuggestionSpan (android.text.style.SuggestionSpan)5 TextAppearanceSpan (android.text.style.TextAppearanceSpan)5 DragHandleUtils.onHandleView (android.widget.espresso.DragHandleUtils.onHandleView)5 Calendar (java.util.Calendar)5 GregorianCalendar (java.util.GregorianCalendar)5 PerformException (android.support.test.espresso.PerformException)3 NoMatchingRootException (android.support.test.espresso.NoMatchingRootException)2