use of org.mozilla.focus.autobot.BottomBarRobot 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.autobot.BottomBarRobot in project Rocket by mozilla-tw.
the class WebContextMenuTest method openLinkInNewTab.
/**
* Test case no: TC0081
* Test case name: Empty bookmarks list
* Steps:
* 1. Launch Rocket and visit a website with links
* 2. Long click to show pop context menu
* 3. Check "Open link in new tab" and "switch" displayed
* 4. Click switch
* 5. Check tab count is 2
*/
@Test
public void openLinkInNewTab() {
loadTestWebsiteAndOpenContextMenu();
// Click "Open link in new tab"
onView(withText(R.string.contextmenu_open_in_new_tab)).perform(click());
// Check if "New tab opened" text is shown in snack bar
onView(allOf(withId(com.google.android.material.R.id.snackbar_text), withText(R.string.new_background_tab_hint))).check(matches(isDisplayed()));
// Check if switch is shown in snack bar
onView(allOf(withId(R.id.snackbar_action), withText(R.string.new_background_tab_switch))).check(matches(isDisplayed()));
// Click switch
onView(allOf(withId(R.id.snackbar_action), withText(R.string.new_background_tab_switch))).check(matches(isDisplayed())).perform(click());
// Check tab count is 2
onView(allOf(withId(R.id.counter_text), isDescendantOfA(new BottomBarRobot().browserBottomBarItemView(R.id.bottom_bar_tab_counter)))).check(matches(withText("2")));
}
use of org.mozilla.focus.autobot.BottomBarRobot in project Rocket by mozilla-tw.
the class BookmarksTest method addAndRemoveBookmarks_bookmarkIsAddedAndRemoved.
/**
* Test case no: TC0099
* Test case name: Add a website to bookmarks and remove it from bookmarks
* Steps:
* 1. Launch app
* 2. Visit a website A
* 3. Tap browser menu button
* 4. Tap bookmark button
* 5. Show bookmark saved snackbar
* 6. Tap browser menu button
* 7. Tap bookmark list button
* 8. Tap the first item in bookmark list
* 9. Show website A
* 10. Tap browser menu button
* 11. Bookmark button is activated
* 12. Tap bookmark button
* 13. Show bookmark removed toast
*/
@Test
public void addAndRemoveBookmarks_bookmarkIsAddedAndRemoved() {
final String targetUrl = browsingPageAndBookmarkPage();
// Show bookmark saved snackbar
onView(allOf(withId(com.google.android.material.R.id.snackbar_text), withText(R.string.bookmark_saved))).check(matches(isDisplayed()));
onView(allOf(withId(com.google.android.material.R.id.snackbar_action), withText(R.string.bookmark_saved_edit))).check(matches(isDisplayed()));
// Tap browser menu button
// Since right now snackbar will overlap with menu bar and we don't want to wait until snackbar is dismissed
AndroidTestUtils.showMenu(activityTestRule);
// Tap bookmark list button
onView(withId(R.id.menu_bookmark)).perform(click());
// Tap the first item in bookmark list
onView(withId(R.id.recyclerview)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
// Show website A
IdlingRegistry.getInstance().register(sessionLoadedIdlingResource);
AndroidTestUtils.urlBarContainsText(targetUrl);
IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
// Tap browser menu button
// Since right now snackbar will overlap with menu bar and we don't want to wait until snackbar is dismissed
AndroidTestUtils.showMenu(activityTestRule);
// Bookmark button is activated, and tap it
onView(new BottomBarRobot().menuBottomBarItemView(R.id.bottom_bar_bookmark)).check(matches(CustomViewMatcher.isActivate())).perform(click());
// Show bookmark removed toast
onView(withText(R.string.bookmark_removed)).inRoot(withDecorView(not(activityTestRule.getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));
}
Aggregations