use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class BrowsingHistoryTest method setUp.
@Before
public void setUp() {
new BeforeTestTask.Builder().clearBrowsingHistory().build().execute();
activityTestRule.launchActivity(new Intent());
// loadingIdlingResource needs to be initialized here cause activity only exist till above line is called.
loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class BrowsingIntentTest method appHasOneTabAndReceiveBrowsingIntent_tabIncreasedAndBrowse.
@Test
public void appHasOneTabAndReceiveBrowsingIntent_tabIncreasedAndBrowse() {
// Launch activity
activityTestRule.launchActivity(new Intent());
// Click search field
onView(withId(R.id.home_fragment_fake_input)).perform(click());
loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
// Browsing site 2
onView(allOf(withId(R.id.url_edit), isDisplayed())).perform(replaceText(TARGET_URL_SITE_2), pressImeActionButton());
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_2)));
SessionManager sessionManager = TabsSessionProvider.getOrThrow(activityTestRule.getActivity());
final int tabCount = sessionManager.getTabsCount();
// Receive browsing intent
sendBrowsingIntent();
// Check if browser fragment is launched
onView(withId(R.id.display_url)).check(matches(isDisplayed()));
// Check if target url is resolved and site 1 is loaded
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_1)));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
// Check if tab count is increased
sessionManager = TabsSessionProvider.getOrThrow(activityTestRule.getActivity());
Assert.assertTrue(sessionManager.getTabsCount() == tabCount + 1);
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class RateAppPromotionTest method showRateAppPromotionAndClickFeedback_openFeedbackUrl.
/**
* Test case no: TC_0062
* Test case name: In-app promotion - Press FEEDBACK to Mozilla feedback site
* Steps:
* 1. tap close button
* 2. Press feedback button
* 3. check feedback page url matches expectation
*/
@Test
public void showRateAppPromotionAndClickFeedback_openFeedbackUrl() {
sessionLoadedIdlingResource = new SessionLoadedIdlingResource(intentTestRule.getActivity());
// Check share app dialog is displayed and click the feedback button
onView(withId(R.id.negative_button)).check(matches(isDisplayed())).perform(click());
// Wait the feedback web page is loaded
IdlingRegistry.getInstance().register(sessionLoadedIdlingResource);
// Check if feedback url is matched
final String feedbackUrl = InstrumentationRegistry.getInstrumentation().getTargetContext().getString(R.string.rate_app_feedback_url);
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(feedbackUrl)));
IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class SearchSuggestionTest method clickSearchSuggestion_browseByDefaultSearchEngine.
/**
* Test case no: TC0008
* Test case name: Search suggestion
* Steps:
* 1. Launch app
* 2. Tap search field
* 3. while typing, search suggestion is displayed at most 5
* 4. tap first suggestion
* 5. check current url is matched with defaultSearchEngine.buildSearchUrl()
*/
@Test
public void clickSearchSuggestion_browseByDefaultSearchEngine() throws UiObjectNotFoundException, UnsupportedEncodingException {
activityTestRule.launchActivity(new Intent());
// Get the default search engine
final SearchEngine defaultSearchEngine = SearchEngineManager.getInstance().getDefaultSearchEngine(context);
final SessionLoadedIdlingResource loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
// Click search field
onView(allOf(withId(R.id.home_fragment_fake_input), isDisplayed())).perform(click());
// Type search text
onView(allOf(withId(R.id.url_edit), isDisplayed())).perform(typeText("zerda"));
// Check if the suggestion count is shown at most 5
onView(allOf(withId(R.id.search_suggestion), isDisplayed())).check(matches(CountChildViewMatcher.withChildViewCount(5, withId(R.id.suggestion_item))));
// Pick a suggestion to click
final String text = GetTextViewMatcher.getText(GetNthChildViewMatcher.nthChildOf(withId(R.id.search_suggestion), 0));
onView(allOf(withId(R.id.suggestion_item), withText(text), isDisplayed())).perform(click());
// Wait for page is loaded
IdlingRegistry.getInstance().register(loadingIdlingResource);
// Check if current url is matched with SearchEngine.buildSearchUrl()
onView(allOf(withId(R.id.display_url), isDisplayed())).check(matches(withText(defaultSearchEngine.buildSearchUrl((text)))));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
use of org.mozilla.focus.helper.SessionLoadedIdlingResource in project Rocket by mozilla-tw.
the class SwitchSearchEngineTest method switchSearchEngine_searchViaSearchEngineAccordingly.
/**
* Test case no: TC_0004
* Test case name: Change default search engine
* Steps:
* 1. Launch Rocket
* 2. Tap on Menu and then Settings
* 3. Tap on "Default search engine"
* 4. Change a different search engine
* 5. Back to home and search for something
* 6. Search result is provided by selected search engine
* 7. Repeat 2~6 for different search engines
*/
@Test
public void switchSearchEngine_searchViaSearchEngineAccordingly() {
activityTestRule.launchActivity(new Intent());
final SearchEngine defaultSearchEngine = SearchEngineManager.getInstance().getDefaultSearchEngine(InstrumentationRegistry.getInstrumentation().getTargetContext());
loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
for (SearchEngine searchEngine : searchEngines) {
switchSearchEngine(searchEngine);
// Tap search field
AndroidTestUtils.tapHomeSearchField();
// Type search keyword and browse
AndroidTestUtils.typeTextInSearchFieldAndGo(SEARCH_KEYWORD);
IdlingRegistry.getInstance().register(loadingIdlingResource);
// Check is url contains search keyword
AndroidTestUtils.urlBarContainsText(SEARCH_KEYWORD);
// Check is url contains search engine host name
AndroidTestUtils.urlBarContainsText(getHostName(searchEngine.getSearchForm()));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
// Remove tab and back to home
AndroidTestUtils.removeNewAddedTab();
}
// Restore default search engine setting
switchSearchEngine(defaultSearchEngine);
}
Aggregations