Bug 897481 - Update testShareLink for new about:home (r=margaret)

This commit is contained in:
Lucas Rocha 2013-09-04 21:55:13 +01:00
parent d65e8b5717
commit d56ccbfff2

View File

@ -21,7 +21,7 @@ import java.util.List;
* This test covers the opening and content of the Share Link pop-up list * This test covers the opening and content of the Share Link pop-up list
* The test opens the Share menu from the app menu, the URL bar, a link context menu and the Awesomescreen tabs * The test opens the Share menu from the app menu, the URL bar, a link context menu and the Awesomescreen tabs
*/ */
public class testShareLink extends BaseTest { public class testShareLink extends AboutHomeTest {
String url; String url;
String urlTitle = "Big Link"; String urlTitle = "Big Link";
@ -36,7 +36,8 @@ public class testShareLink extends BaseTest {
blockForGeckoReady(); blockForGeckoReady();
inputAndLoadUrl(url); inputAndLoadUrl(url);
waitForText(urlTitle); // Waiting for page title to ensure the page is loaded verifyPageTitle(urlTitle); // Waiting for page title to ensure the page is loaded
selectMenuItem("Share"); selectMenuItem("Share");
if (Build.VERSION.SDK_INT >= 14) { if (Build.VERSION.SDK_INT >= 14) {
// Check for our own sync in the submenu. // Check for our own sync in the submenu.
@ -66,47 +67,54 @@ public class testShareLink extends BaseTest {
float top = mDriver.getGeckoTop() + 30 * dm.density; float top = mDriver.getGeckoTop() + 30 * dm.density;
float left = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() / 2; float left = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() / 2;
mSolo.clickLongOnScreen(left, top); mSolo.clickLongOnScreen(left, top);
verifySharePopup(shareOptions,"Link"); verifySharePopup("Share Link",shareOptions,"Link");
/* FIXME: disabled on fig - bug 880060 // Test the share popup in the Bookmarks page
// Removed by Bug 896576 - [fig] Remove [getAllPagesList] from BaseTest openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
// Test share popup in Top Sites
ListView tslist = getAllPagesList(url);
// Make sure the keyboard is closed since a back here would just close the Awesomebar ListView bookmarksList = findListViewWithTag("bookmarks");
mSolo.clickOnText("Bookmarks"); mAsserter.is(waitForListToLoad(bookmarksList), true, "list is properly loaded");
mSolo.clickOnText("Sites");
waitForText("Big Link");
View allpages = tslist.getChildAt(1); int width = mDriver.getGeckoWidth();
if (allpages != null) { int height = mDriver.getGeckoHeight();
mSolo.clickLongOnView(allpages);
verifySharePopup(shareOptions,"Top Sites");
} else {
// The view should not be null but sometimes getChildAt fails
// TODO: Investigate why this fails
mAsserter.todo_isnot(allpages, null, "View should not be null but sometimes it is");
}
// Removed by Bug 896576 - [fig] Remove [getBookmarksList] from BaseTest // Scroll down a bit so that the bookmarks list has more
// Test the share popup in the Bookmarks tab // items on screen.
ListView blist = getBookmarksList("about:firefox"); mActions.drag(width / 2, width / 2, height - 10, height / 2);
View bookmark = blist.getChildAt(1); // Getting child at 1 because 0 might be the Desktop folder
mSolo.clickLongOnView(bookmark); View bookmarksItem = bookmarksList.getChildAt(bookmarksList.getHeaderViewsCount());
mSolo.clickLongOnView(bookmarksItem);
verifySharePopup(shareOptions,"bookmarks"); verifySharePopup(shareOptions,"bookmarks");
// Removed by Bug 896576 - [fig] Remove [getHistoryList] from BaseTest // Test the share popup in the Most Visited tab
// Test the share popup in the History tab openAboutHomeTab(AboutHomeTabs.MOST_VISITED);
ListView hlist = getHistoryList("Today|Yesterday");
View history = hlist.getChildAt(1); // Getting child at 1 because 0 might be the "Today" label ListView mostVisitedList = findListViewWithTag("most_visited");
mSolo.clickLongOnView(history); mAsserter.is(waitForListToLoad(mostVisitedList), true, "list is properly loaded");
verifySharePopup(shareOptions,"history");
*/ View mostVisitedItem = mostVisitedList.getChildAt(mostVisitedList.getHeaderViewsCount());
mSolo.clickLongOnView(mostVisitedItem);
verifySharePopup(shareOptions,"most visited");
// Test the share popup in the Most Recent tab
openAboutHomeTab(AboutHomeTabs.MOST_RECENT);
ListView mostRecentList = findListViewWithTag("most_recent");
mAsserter.is(waitForListToLoad(mostRecentList), true, "list is properly loaded");
// Getting second child after header views because the first is the "Today" label
View mostRecentItem = mostRecentList.getChildAt(mostRecentList.getHeaderViewsCount() + 1);
mSolo.clickLongOnView(mostRecentItem);
verifySharePopup(shareOptions,"most recent");
} }
public void verifySharePopup(ArrayList<String> shareOptions, String openedFrom) { public void verifySharePopup(ArrayList<String> shareOptions, String openedFrom) {
waitForText("Share"); verifySharePopup("Share", shareOptions, openedFrom);
mSolo.clickOnText("Share"); }
public void verifySharePopup(String shareItemText, ArrayList<String> shareOptions, String openedFrom) {
waitForText(shareItemText);
mSolo.clickOnText(shareItemText);
waitForText("Share via"); waitForText("Share via");
ArrayList<String> displayedOptions = getSharePopupOption(); ArrayList<String> displayedOptions = getSharePopupOption();
for (String option:shareOptions) { for (String option:shareOptions) {