use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class NavigationTest method browsingWebsiteBackAndForward_backAndFrowardToWebsite.
/**
* Test case no: TC_0013
* Test case name: Navigation and back and forth to previous site
* Steps:
* 1. Launch Rocket
* 2. Visit a website_1
* 3. Visit a website_2
* 4. Press Back button
* 5. check website_1 is displayed
* 6. open menu to click next button
* 7. check website_2 is displayed
*/
@FlakyTest
@Test
public void browsingWebsiteBackAndForward_backAndFrowardToWebsite() {
final SessionLoadedIdlingResource loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
// Click search field
onView(withId(R.id.home_fragment_fake_input)).perform(click());
// Enter site 1 url
onView(withId(R.id.url_edit)).check(matches(isDisplayed()));
onView(withId(R.id.url_edit)).perform(typeText(TARGET_URL_SITE_1));
onView(withId(R.id.url_edit)).perform(pressKey(KeyEvent.KEYCODE_ENTER));
// Check if site 1 url is loaded
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_1)));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
// Click search button and clear existing text in search field
onView(withId(R.id.bottom_bar_search)).perform(click());
onView(withId(R.id.url_edit)).perform(clearText());
// Enter site 2 url
onView(withId(R.id.url_edit)).perform(typeText(TARGET_URL_SITE_2));
onView(withId(R.id.url_edit)).perform(pressKey(KeyEvent.KEYCODE_ENTER));
// Check if site 2 url is loaded
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_2)));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
// Press back and check if go back to site 1
Espresso.pressBack();
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_1)));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
// Open menu and click next button
AndroidTestUtils.tapBrowserMenuButton();
new BottomBarRobot().clickMenuBottomBarItem(R.id.bottom_bar_next);
// Check if site 2 is loaded again
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_2)));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
// Press back and check if site 1 is loading again
Espresso.pressBack();
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_1)));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class DownloadTest method browsePageAndDownload.
private void browsePageAndDownload() {
// Start the activity
activityRule.launchActivity(new Intent());
final SessionLoadedIdlingResource sessionLoadedIdlingResource = new SessionLoadedIdlingResource(activityRule.getActivity());
// Click and prepare to enter the URL
onView(withId(R.id.home_fragment_fake_input)).perform(click());
// Enter URL and load the page
onView(withId(R.id.url_edit)).perform(replaceText(webServer.url(TEST_PATH).toString()), pressImeActionButton());
// Waiting for page loading completes
IdlingRegistry.getInstance().register(sessionLoadedIdlingResource);
// Find the element in HTML with id "download" after the page is loaded
onWebView().withElement(findElement(Locator.ID, HTML_ELEMENT_ID_DOWNLOAD)).perform(webClick());
// Unregister session loaded idling resource
IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class ScreenNavigatorTest method assertNewPageLoaded.
private void assertNewPageLoaded(ScreenNavigatorWrapper navigator, String url) {
final SessionLoadedIdlingResource loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
navigator.showBrowserScreen(url);
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(withId(R.id.display_url)).check(matches(isDisplayed()));
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(url)));
Assert.assertEquals(true, navigator.isBrowserInForeground());
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class BookmarksTest method browsingPageAndBookmarkPage.
private String browsingPageAndBookmarkPage() {
final String targetUrl = webServer.url(TEST_SITE_1).toString();
sessionLoadedIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
// Visit a website A
AndroidTestUtils.tapHomeSearchField();
AndroidTestUtils.typeTextInSearchFieldAndGo(targetUrl);
// Check if target url is loaded
IdlingRegistry.getInstance().register(sessionLoadedIdlingResource);
AndroidTestUtils.urlBarContainsText(targetUrl);
IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
// Tap browser menu button
AndroidTestUtils.tapBrowserMenuButton();
// Tap bookmark button
new BottomBarRobot().clickMenuBottomBarItem(R.id.bottom_bar_bookmark);
return targetUrl;
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class BrowsingHistoryTest method browsingWebsiteThenTapTheFirstHistoryItem_browsingHistoryRecordCorrectly.
@Test
public void browsingWebsiteThenTapTheFirstHistoryItem_browsingHistoryRecordCorrectly() {
activityTestRule.launchActivity(new Intent());
// loadingIdlingResource needs to be initialized here cause activity only exist till above line is called.
loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
final String targerUrl = webServer.url(TEST_PATH).toString();
// Click search field
onView(withId(R.id.home_fragment_fake_input)).perform(click());
// Enter target url
onView(allOf(withId(R.id.url_edit), isDisplayed())).perform(replaceText(targerUrl), pressImeActionButton());
// Check if target url is loaded
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(allOf(withId(R.id.display_url), isDisplayed())).check(matches(withText(targerUrl)));
// Open menu
onView(allOf(withId(R.id.btn_menu), isDisplayed())).perform(click());
// Open history panel
onView(allOf(withId(R.id.menu_history), isDisplayed())).perform(click());
// Click the first item in history panel
onView(ViewMatchers.withId(R.id.browsing_history_recycler_view)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
// Check if this history record is target url and loaded again
onView(allOf(withId(R.id.display_url), isDisplayed())).check(matches(withText(targerUrl)));
}
Aggregations