use of com.frostwire.android.test.utils.WaitUntilVisibleIdlingResource in project frostwire by frostwire.
the class DownloadTest method searchAudio_download.
@Test
public void searchAudio_download() {
// muckachina test part one (filtering Archive source)
// public void filterArchive() {
ViewInteraction linearLayout = onView(allOf(withContentDescription("FrostWire, Open navigation drawer"), withParent(allOf(withClassName(is("com.android.internal.widget.ActionBarView")), withParent(withClassName(is("com.android.internal.widget.ActionBarContainer"))))), isDisplayed()));
linearLayout.perform(click());
final ViewInteraction checkableRelativeLayout = onView(allOf(childAtPosition(allOf(withId(R.id.left_drawer), withParent(withId(R.id.activity_main_left_drawer))), 5), isDisplayed()));
checkableRelativeLayout.perform(click());
ViewInteraction linearLayout2 = onView(allOf(childAtPosition(allOf(withId(android.R.id.list), withParent(withClassName(is("android.widget.LinearLayout")))), 4), isDisplayed()));
linearLayout2.perform(click());
ViewInteraction selectAllInteraction = onView(allOf(withId(R.id.view_preference_checkbox_header_checkbox), isDisplayed()));
// Let's make sure Archive.org is the only one checked, by deselecting all, archive.org
// should remain checked.
selectAllInteraction.check(new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
CheckBox checkbox = (CheckBox) view;
mSelectAllIsChecked = checkbox.isChecked();
}
});
ensureArchiveOrgIsTheOnlyOne(selectAllInteraction);
ViewInteraction linearLayout3 = onView(allOf(withContentDescription("Search Settings, Navigate up"), withParent(allOf(withClassName(is("com.android.internal.widget.ActionBarView")), withParent(withClassName(is("com.android.internal.widget.ActionBarContainer"))))), isDisplayed()));
linearLayout3.perform(click());
ViewInteraction linearLayout4 = onView(allOf(withContentDescription("Settings, Navigate up"), withParent(allOf(withClassName(is("com.android.internal.widget.ActionBarView")), withParent(withClassName(is("com.android.internal.widget.ActionBarContainer"))))), isDisplayed()));
linearLayout4.perform(click());
// End muckachina test part one
// Layout: R.layout.fragment_search
onView(withId(R.id.fragment_search_input)).check(matches(isDisplayed()));
/*
* The textview is in FWAutoCompleteTextView, which is in the layout of the custom view ClearableEditTextView,
* which is in the custom view SearchInputView which is in the layout R.layout.fragment_search
*/
onView(allOf(withId(R.id.view_clearable_edit_text_input), isDescendantOfA(withId(R.id.fragment_search_input)))).check(matches(isDisplayed())).perform(typeText("Creative Commons")).perform(pressKey(KeyEvent.KEYCODE_ENTER));
WaitUntilVisibleIdlingResource resource = new WaitUntilVisibleIdlingResource(activityRule.getActivity().findViewById(R.id.fragment_search_list), activityRule.getActivity().findViewById(R.id.view_search_progress_text_no_results_feedback));
Espresso.registerIdlingResources(resource);
// Layout: R.layout.view_searchinput_radiogroup
onView(allOf(withId(R.id.view_search_input_radio_audio), isDescendantOfA(withId(R.id.fragment_search_input)))).check(matches(isDisplayed())).perform(click());
FirstFileSearchResultMatcher matchFirstFileSearchResult = new FirstFileSearchResultMatcher();
// Layout for items in the search results: R.layout.view_bittorrent_search_result_list_item
// Check that the file name contains "SoundCloud" and "Creative Commons"
onData(matchFirstFileSearchResult).inAdapterView(withId(R.id.fragment_search_list)).onChildView(withId(R.id.view_bittorrent_search_result_list_item_download_icon)).perform(click());
// The dialog should show asking us to confirm (NewTransferDialog)
// Layout: R.layout.dialog_default_checkbox
onView(withId(R.id.dialog_default_checkbox_button_yes)).check(matches(isDisplayed())).perform(click());
Espresso.unregisterIdlingResources(resource);
// Layout: R.layout.fragment_transfers
// Switch to the downloading list
onView(withId(R.id.fragment_transfers_button_select_downloading)).check(matches(isDisplayed())).perform(click());
// Layout of list item in list view inside of fragment_transfers: R.layout.view_transfer_item_list_item
// Make sure we're downloading the file we chose from the search
// Switch to the completed list
onView(withId(R.id.fragment_transfers_button_select_completed)).check(matches(isDisplayed())).perform(click());
// Register the idling resource to wait for the download to finish
WaitUntilListViewNotEmptyIdlingResource idlingResource = new WaitUntilListViewNotEmptyIdlingResource((ListView) activityRule.getActivity().findViewById(R.id.fragment_transfers_list));
Espresso.registerIdlingResources(idlingResource);
ExactFileSearchResultMatcher downloadingChosenResultMatcher = new ExactFileSearchResultMatcher(matchFirstFileSearchResult.mSearchResult);
onData(downloadingChosenResultMatcher).inAdapterView(withId(R.id.fragment_transfers_list)).check(matches(isDisplayed()));
onData(downloadingChosenResultMatcher).inAdapterView(withId(R.id.fragment_transfers_list)).check(matches(isDisplayed()));
Espresso.unregisterIdlingResources(idlingResource);
}
use of com.frostwire.android.test.utils.WaitUntilVisibleIdlingResource in project frostwire by frostwire.
the class SearchTest method search.
@Test
public void search() {
// Layout: R.layout.fragment_search
onView(withId(R.id.fragment_search_input)).check(matches(isDisplayed()));
/*
* The textview is in FWAutoCompleteTextView, which is in the layout of the custom view ClearableEditTextView,
* which is in the custom view SearchInputView which is in the layout R.layout.fragment_search
*/
onView(allOf(withId(R.id.view_clearable_edit_text_input), isDescendantOfA(withId(R.id.fragment_search_input)))).check(matches(isDisplayed())).perform(// Search android so I can get results on applications too
typeText("android")).perform(// press enter
pressKey(KeyEvent.KEYCODE_ENTER));
WaitUntilVisibleIdlingResource resource = new WaitUntilVisibleIdlingResource(activityRule.getActivity().findViewById(R.id.fragment_search_list), activityRule.getActivity().findViewById(R.id.view_search_progress_text_no_results_feedback));
Espresso.registerIdlingResources(resource);
// Layout: R.layout.view_searchinput_radiogroup
// Checking results in all labels
checkForAtLeastOneResult(R.id.view_search_input_radio_audio);
checkForAtLeastOneResult(R.id.view_search_input_radio_videos);
checkForAtLeastOneResult(R.id.view_search_input_radio_pictures);
checkForAtLeastOneResult(R.id.view_search_input_radio_applications);
checkForAtLeastOneResult(R.id.view_search_input_radio_documents);
checkForAtLeastOneResult(R.id.view_search_input_radio_torrents);
Espresso.unregisterIdlingResources(resource);
}
Aggregations