use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class DownloadScreenshot method setUp.
@Before
public void setUp() {
context = InstrumentationRegistry.getInstrumentation().getTargetContext();
new BeforeTestTask.Builder().build().execute();
// Start main activity
activityRule.launchActivity(new Intent());
Screengrab.setDefaultScreenshotStrategy(new FalconScreenshotStrategy(activityRule.getActivity()));
sessionLoadedIdlingResource = new SessionLoadedIdlingResource(activityRule.getActivity());
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class MyShotScreenshot method setUp.
@Before
public void setUp() {
new BeforeTestTask.Builder().build().execute();
activityTestRule.launchActivity(new Intent());
sessionLoadedIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
Screengrab.setDefaultScreenshotStrategy(new FalconScreenshotStrategy(activityTestRule.getActivity()));
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class SearchFieldTest method typeSpecialCharactersInSearchField_searchIsPerformingAccordingly.
/**
* Test case no: TC0011
* Test case name: Search special characters
* Steps:
* 1. Launch app
* 2. Tap search field
* 3. Type Greek special character
* 4. wait for page loaded
* 5. check url matches with SearchEngine.buildSearchUrl()
* 6. check search button
* 7. type some text and press back twice
* 8. check we are on homepage
* 9. click search field again
* 10. Type some science characters
* 11. Wait for the page is loaded
* 12. Check if current url is matched with SearchEngine.buildSearchUrl()
*/
@Test
public void typeSpecialCharactersInSearchField_searchIsPerformingAccordingly() {
// Get the default search engine
final SearchEngine defaultSearchEngine = SearchEngineManager.getInstance().getDefaultSearchEngine(InstrumentationRegistry.getInstrumentation().getTargetContext());
loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
// Click home search field
onView(allOf(withId(R.id.home_fragment_fake_input), isDisplayed())).perform(click());
// Type some greek characters
onView(allOf(withId(R.id.url_edit), isDisplayed())).perform(replaceText(TYPED_GREEK_TEXT), pressImeActionButton());
// Wait for the page is loaded
IdlingRegistry.getInstance().register(loadingIdlingResource);
// Check if current url is matched with SearchEngine.buildSearchUrl()
onView(AllOf.allOf(withId(R.id.display_url), isDisplayed())).check(matches(withText(defaultSearchEngine.buildSearchUrl((TYPED_GREEK_TEXT)))));
// Since we will click search button later and UrlInputFragment will be displayed so we need to unregister IdlingResource here
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
// Click search button
new BottomBarRobot().clickBrowserBottomBarItem(R.id.bottom_bar_search);
// Type some science characters
onView(withId(R.id.url_edit)).perform(clearText()).perform(replaceText(TYPED_SCIENCE_SYMBOLS_TEXT), pressImeActionButton());
// Wait for the page is loaded
IdlingRegistry.getInstance().register(loadingIdlingResource);
// Check if current url is matched with SearchEngine.buildSearchUrl()
onView(AllOf.allOf(withId(R.id.display_url), isDisplayed())).check(matches(withText(defaultSearchEngine.buildSearchUrl((TYPED_SCIENCE_SYMBOLS_TEXT)))));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class WebContextMenuTest method loadTestWebsiteAndOpenContextMenu.
private void loadTestWebsiteAndOpenContextMenu() {
sessionLoadedIdlingResource = new SessionLoadedIdlingResource(intentsTestRule.getActivity());
// Click home search field
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 the page is loaded
IdlingRegistry.getInstance().register(sessionLoadedIdlingResource);
// Since test web page has a fullscreen image, we simulate the long click event by clicking at the center of image
// Long click on image with popup context menu
final DisplayMetrics displayMetrics = intentsTestRule.getActivity().getResources().getDisplayMetrics();
final int displayWidth = displayMetrics.widthPixels;
final int displayHeight = displayMetrics.heightPixels;
onView(withId(R.id.main_content)).check(matches(isDisplayed())).perform(AndroidTestUtils.clickXY(displayWidth / 2, displayHeight / 2, Tap.LONG));
IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
}
Aggregations