Search in sources :

Example 16 with SessionLoadedIdlingResource

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());
}
Also used : SessionLoadedIdlingResource(org.mozilla.focus.helper.SessionLoadedIdlingResource) Intent(android.content.Intent) FalconScreenshotStrategy(tools.fastlane.screengrab.FalconScreenshotStrategy) Before(org.junit.Before)

Example 17 with SessionLoadedIdlingResource

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()));
}
Also used : SessionLoadedIdlingResource(org.mozilla.focus.helper.SessionLoadedIdlingResource) Intent(android.content.Intent) FalconScreenshotStrategy(tools.fastlane.screengrab.FalconScreenshotStrategy) Before(org.junit.Before)

Example 18 with SessionLoadedIdlingResource

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);
}
Also used : BottomBarRobot(org.mozilla.focus.autobot.BottomBarRobot) SearchEngine(org.mozilla.focus.search.SearchEngine) SessionLoadedIdlingResource(org.mozilla.focus.helper.SessionLoadedIdlingResource) Test(org.junit.Test)

Example 19 with SessionLoadedIdlingResource

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);
}
Also used : SessionLoadedIdlingResource(org.mozilla.focus.helper.SessionLoadedIdlingResource) DisplayMetrics(android.util.DisplayMetrics)

Aggregations

SessionLoadedIdlingResource (org.mozilla.focus.helper.SessionLoadedIdlingResource)19 Intent (android.content.Intent)11 Test (org.junit.Test)10 BottomBarRobot (org.mozilla.focus.autobot.BottomBarRobot)4 Before (org.junit.Before)3 SearchEngine (org.mozilla.focus.search.SearchEngine)3 FalconScreenshotStrategy (tools.fastlane.screengrab.FalconScreenshotStrategy)2 DisplayMetrics (android.util.DisplayMetrics)1 FlakyTest (androidx.test.filters.FlakyTest)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 BeforeTestTask (org.mozilla.focus.helper.BeforeTestTask)1 Site (org.mozilla.focus.history.model.Site)1 SessionManager (org.mozilla.rocket.tabs.SessionManager)1