mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
Bug 769919: Allow retry when getting awesomebar ListView in robocop tests; r=jmaher
This commit is contained in:
parent
2ea3681082
commit
4af4f096f4
@ -37,6 +37,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";
|
||||
private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
|
||||
private static final int VERIFY_URL_TIMEOUT = 2000;
|
||||
private static final int MAX_LIST_ATTEMPTS = 3;
|
||||
public static final int MAX_WAIT_MS = 3000;
|
||||
|
||||
private static Class<Activity> mLauncherActivityClass;
|
||||
@ -406,55 +407,74 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
mAsserter.is(tabCountInt, expectedTabCount, "The correct number of tabs are opened");
|
||||
}
|
||||
|
||||
/**
|
||||
* Click on the awesome bar, and return the ListView for the
|
||||
* All Pages ("Top Sites") tab.
|
||||
*/
|
||||
protected ListView getAllPagesList(String waitText) {
|
||||
Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
waitForText(waitText);
|
||||
|
||||
ArrayList<ListView> views = mSolo.getCurrentListViews();
|
||||
for (ListView view : views) {
|
||||
if (view.getTag() == "allPages") {
|
||||
return view;
|
||||
private ListView getAwesomeList(String waitText, int expectedChildCount,
|
||||
String clickText, String tagName, String callerName) {
|
||||
ArrayList<ListView> views;
|
||||
ListView tabView = null;
|
||||
int childCount = 0;
|
||||
for (int i = 0; i < MAX_LIST_ATTEMPTS; i++) {
|
||||
tabView = null;
|
||||
childCount = 0;
|
||||
Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
mSolo.clickOnText(clickText);
|
||||
if (waitForText(waitText)) {
|
||||
views = mSolo.getCurrentListViews();
|
||||
for (ListView view : views) {
|
||||
if (view.getTag().equals(tagName)) {
|
||||
tabView = view;
|
||||
childCount = view.getAdapter().getCount();
|
||||
if (expectedChildCount < 0 || expectedChildCount == childCount) {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tabView == null) {
|
||||
mAsserter.dumpLog(callerName+" did not find ListView");
|
||||
} else if (expectedChildCount >= 0) {
|
||||
mAsserter.dumpLog(callerName+" found ListView with "+childCount+" children");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Click on the awesome bar, click on the Top Sites tab, and return
|
||||
* the ListView for the All Pages ("Top Sites") tab.
|
||||
*/
|
||||
protected ListView getAllPagesList(String waitText, int expectedChildCount) {
|
||||
return getAwesomeList(waitText, expectedChildCount,
|
||||
"Top Sites", "allPages", "getAllPagesList");
|
||||
}
|
||||
|
||||
protected ListView getAllPagesList(String waitText) {
|
||||
return getAllPagesList(waitText, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click on the awesome bar, click on the Bookmarks tab, and return
|
||||
* the ListView for the Bookmarks tab.
|
||||
*/
|
||||
protected ListView getBookmarksList() {
|
||||
Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
mSolo.clickOnText("Bookmarks");
|
||||
protected ListView getBookmarksList(String waitText, int expectedChildCount) {
|
||||
return getAwesomeList(waitText, expectedChildCount,
|
||||
"Bookmarks", "bookmarks", "getBookmarksList");
|
||||
}
|
||||
|
||||
ArrayList<ListView> views = mSolo.getCurrentListViews();
|
||||
for (ListView view : views) {
|
||||
if (view.getTag().equals("bookmarks")) {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
protected ListView getBookmarksList(String waitText) {
|
||||
return getBookmarksList(waitText, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click on the awesome bar, click on the History tab, and return
|
||||
* the ListView for the History tab.
|
||||
*/
|
||||
protected ListView getHistoryList() {
|
||||
Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
mSolo.clickOnText("History");
|
||||
waitForText("Today|Yesterday");
|
||||
ArrayList<ListView> views = mSolo.getCurrentListViews();
|
||||
for (ListView view : views) {
|
||||
if (view.getTag().equals("history")) {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
protected ListView getHistoryList(String waitText, int expectedChildCount) {
|
||||
return getAwesomeList(waitText, expectedChildCount,
|
||||
"History", "history", "getHistoryList");
|
||||
}
|
||||
|
||||
protected ListView getHistoryList(String waitText) {
|
||||
return getHistoryList(waitText, -1);
|
||||
}
|
||||
|
||||
public long addOrUpdateBookmark(String title, String url, boolean bookmarklet) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
# [testAllPagesTab] # see bug 825152
|
||||
[testAllPagesTab]
|
||||
[testHistoryTab]
|
||||
[testBookmarksTab]
|
||||
[testAwesomebar]
|
||||
|
@ -56,7 +56,7 @@ public class testAllPagesTab extends BaseTest {
|
||||
}
|
||||
|
||||
private void testList(String url) {
|
||||
final ListView list = getAllPagesList(bookmarks[0]);
|
||||
final ListView list = getAllPagesList(bookmarks[0], 5);
|
||||
|
||||
// some basic checks for the tab strip
|
||||
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
||||
@ -68,9 +68,8 @@ public class testAllPagesTab extends BaseTest {
|
||||
// This test fails, only when we're running tests
|
||||
// mAsserter.is(host.getCurrentTab(), 0, "All pages tab is selected in tab strip");
|
||||
|
||||
mAsserter.isnot(list, null, "checking that all pages list exists");
|
||||
mAsserter.isnot(list, null, "checking that all pages list exists and has 5 children (the default bookmarks)");
|
||||
final int count = list.getAdapter().getCount();
|
||||
mAsserter.is(count, 5, "all pages list has 5 children (the default bookmarks)");
|
||||
|
||||
String loadUrl = "";
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
|
@ -76,18 +76,12 @@ public class testBookmark extends PixelTest {
|
||||
blockForGeckoReady();
|
||||
|
||||
// Open the bookmark list and check the root folder view
|
||||
ListView bookmarksList = getBookmarksList();
|
||||
ListView bookmarksList = getBookmarksList(ABOUT_HOME_URL, 4);
|
||||
|
||||
// Wait for bookmark to appear in list
|
||||
waitForText(ABOUT_HOME_URL);
|
||||
|
||||
mAsserter.ok(bookmarksList != null, "checking that bookmarks list exists", "bookmarks list exists");
|
||||
mAsserter.ok(bookmarksList != null, "checking that bookmarks list exists", "bookmarks list exists and has 4 children (the default bookmarks)");
|
||||
|
||||
// No folders should be visible if no desktop bookmarks exist
|
||||
int count = bookmarksList.getAdapter().getCount();
|
||||
mAsserter.is(count, 4,
|
||||
"bookmarks list has 4 children (the default bookmarks)");
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
Cursor c = (Cursor)bookmarksList.getItemAtPosition(i);
|
||||
String url = c.getString(c.getColumnIndexOrThrow("url"));
|
||||
|
@ -43,12 +43,12 @@ public class testBookmarklets extends PixelTest {
|
||||
addOrUpdateBookmark(title, js, true);
|
||||
|
||||
// verify that bookmarklets clicked in awesomescreen work
|
||||
ListView bookmarks = getBookmarksList();
|
||||
ListView bookmarks = getBookmarksList(title);
|
||||
|
||||
Boolean found = false;
|
||||
if (bookmarks == null) {
|
||||
mAsserter.is(true, true, "Did not find the bookmarks section in the awesomebar");
|
||||
} else if (mSolo.waitForText(title)) {
|
||||
} else {
|
||||
for (int i = 0; i < bookmarks.getAdapter().getCount(); i++) {
|
||||
Cursor c = (Cursor)bookmarks.getItemAtPosition(i);
|
||||
String turl = c.getString(c.getColumnIndexOrThrow("url"));
|
||||
@ -58,8 +58,6 @@ public class testBookmarklets extends PixelTest {
|
||||
mSolo.clickOnView(bookmarks.getChildAt(i));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mAsserter.is(true, true, "Did not find the title '" + title + "' of the bookmark in the list");
|
||||
}
|
||||
if (!found) {
|
||||
mAsserter.is(found, true, "Found the bookmark: " + js + " and clicked on it");
|
||||
|
@ -18,7 +18,7 @@ import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Tests the Bookamrks Tab
|
||||
* Tests the Bookmarks Tab
|
||||
* - opening the bookmarks tab
|
||||
* - items look correct
|
||||
* - clicking on an item
|
||||
@ -26,7 +26,6 @@ import java.io.File;
|
||||
* - editing the name, url and keyword of a bookmark from the context menu
|
||||
* - removing a bookmark
|
||||
*/
|
||||
|
||||
public class testBookmarksTab extends BaseTest {
|
||||
private View mFirstChild;
|
||||
private ListView list;
|
||||
@ -49,14 +48,10 @@ public class testBookmarksTab extends BaseTest {
|
||||
|
||||
private void testList(String url) {
|
||||
View child;
|
||||
ListView list = getBookmarksList();
|
||||
|
||||
waitForText("Desktop Bookmarks");
|
||||
mAsserter.isnot(list, null, "checking that bookmarks list exists");
|
||||
ListView list = getBookmarksList("about:firefox", 5);
|
||||
mAsserter.isnot(list, null, "checking that bookmarks list exists and has 5 children (defaults + a folder)");
|
||||
|
||||
int count = list.getAdapter().getCount();
|
||||
mAsserter.is(count, 5, "bookmarks list has 5 children (defaults + a folder)");
|
||||
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
child = list.getChildAt(i);
|
||||
compareRow(child, i == 0 ? 1 : 2, 1);
|
||||
@ -95,9 +90,7 @@ public class testBookmarksTab extends BaseTest {
|
||||
}
|
||||
|
||||
private void testContextMenu(String url) {
|
||||
list = getBookmarksList();
|
||||
waitForText(url);
|
||||
|
||||
list = getBookmarksList(url);
|
||||
// wait for the bookmarks list to be populated
|
||||
View child;
|
||||
mFirstChild = null;
|
||||
@ -150,7 +143,7 @@ public class testBookmarksTab extends BaseTest {
|
||||
mAsserter.ok(false, "waiting for bookmark item", "bookmark item available");
|
||||
}
|
||||
|
||||
list = getBookmarksList();
|
||||
list = getBookmarksList(url);
|
||||
|
||||
// Test edit bookmark name
|
||||
editBookmark(1,0," Bookmark Name ");
|
||||
@ -191,7 +184,7 @@ public class testBookmarksTab extends BaseTest {
|
||||
View child;
|
||||
mSolo.clickOnText("Bookmarks");
|
||||
child = list.getChildAt(bookmarkIndex);
|
||||
waitForText("Desktop Bookmarks");
|
||||
waitForText("about:firefox");
|
||||
mSolo.clickLongOnView(child);
|
||||
waitForText("Open in New Tab");
|
||||
mSolo.clickOnText("Edit");
|
||||
@ -214,7 +207,7 @@ public class testBookmarksTab extends BaseTest {
|
||||
View child;
|
||||
mSolo.clickOnText("Bookmarks");
|
||||
child = list.getChildAt(bookmarkIndex);
|
||||
waitForText("Desktop Bookmarks");
|
||||
waitForText("about:firefox");
|
||||
mSolo.clickLongOnView(child);
|
||||
waitForText("Open in New Tab");
|
||||
mSolo.clickOnText("Edit");
|
||||
@ -228,12 +221,12 @@ public class testBookmarksTab extends BaseTest {
|
||||
// Check if the new text was added
|
||||
if (mSolo.searchText(addedText)) {
|
||||
mSolo.clickOnText("Cancel");
|
||||
waitForText("Desktop Bookmarks");
|
||||
waitForText("about:firefox");
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
|
||||
return true;
|
||||
} else {
|
||||
mSolo.clickOnText("Cancel");
|
||||
waitForText("Desktop Bookmarks");
|
||||
waitForText("about:firefox");
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
|
||||
return false;
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ public class testClearPrivateData extends PixelTest {
|
||||
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
loadAndPaint(url);
|
||||
|
||||
// Checking that the history list in not empty
|
||||
ListView hList = getHistoryList();
|
||||
// Checking that the history list is not empty
|
||||
ListView hList = getHistoryList("Today|Yesterday");
|
||||
mAsserter.ok(hList.getAdapter().getCount() > 0,"checking history exists","history exists");
|
||||
|
||||
// Quit the awesomescreen
|
||||
@ -46,7 +46,7 @@ public class testClearPrivateData extends PixelTest {
|
||||
mAsserter.is(mSolo.waitForText("Private data cleared"),true,"private data cleared successfully");
|
||||
|
||||
// Checking that history list is empty
|
||||
hList = getHistoryList();
|
||||
mAsserter.ok(hList.getAdapter().getCount() == 0,"checking history is cleared ","history is cleared");
|
||||
hList = getHistoryList("History", 0);
|
||||
mAsserter.ok(hList != null,"checking history is cleared ","history is cleared");
|
||||
}
|
||||
}
|
||||
|
@ -98,25 +98,14 @@ public class testHistoryTab extends PixelTest {
|
||||
}
|
||||
|
||||
private void testList(String url) {
|
||||
listview = getHistoryList();
|
||||
|
||||
// Around midnight we will switch from Today -> Yesterday, account for both
|
||||
if (!mSolo.waitForText("Today")) {
|
||||
waitForText("Yesterday");
|
||||
}
|
||||
|
||||
mAsserter.isnot(listview, null, "checking that history list exists");
|
||||
|
||||
listview = getHistoryList("Today|Yesterday", 3);
|
||||
mAsserter.isnot(listview, null, "checking that history list exists and has 3 children");
|
||||
final int count = listview.getAdapter().getCount();
|
||||
mAsserter.is(count, 3, "history list has 3 children");
|
||||
|
||||
String loadUrl = "";
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
View child = listview.getChildAt(i);
|
||||
|
||||
ArrayList<View> views = mSolo.getViews(child);
|
||||
ArrayList<ImageView> imageViews = new ArrayList<ImageView>();
|
||||
|
||||
int expectedImages = 1;
|
||||
for (int j = 0; j < views.size(); j++) {
|
||||
View v = views.get(j);
|
||||
@ -160,7 +149,7 @@ public class testHistoryTab extends PixelTest {
|
||||
}
|
||||
|
||||
private void testContextMenu(String url) {
|
||||
listview = getHistoryList();
|
||||
listview = getHistoryList("Today|Yesterday");
|
||||
waitForText(url);
|
||||
|
||||
// wait for the history list to be populated
|
||||
@ -213,8 +202,7 @@ public class testHistoryTab extends PixelTest {
|
||||
}
|
||||
|
||||
private void testClick(String url) {
|
||||
listview = getHistoryList();
|
||||
|
||||
listview = getHistoryList("Today|Yesterday");
|
||||
waitForText(url);
|
||||
|
||||
View child = listview.getChildAt(0);
|
||||
|
@ -79,15 +79,13 @@ public class testShareLink extends BaseTest {
|
||||
}
|
||||
|
||||
// Test the share popup in the Bookmarks tab
|
||||
ListView blist = getBookmarksList();
|
||||
mSolo.clickOnText("Bookmarks");
|
||||
ListView blist = getBookmarksList("about:firefox");
|
||||
View bookmark = blist.getChildAt(1); // Getting child at 1 because 0 might be the Desktop folder
|
||||
mSolo.clickLongOnView(bookmark);
|
||||
verifySharePopup(shareOptions,"bookmarks");
|
||||
|
||||
// Test the share popup in the History tab
|
||||
ListView hlist = getHistoryList();
|
||||
mSolo.clickOnText("History");
|
||||
ListView hlist = getHistoryList("Today|Yesterday");
|
||||
View history = hlist.getChildAt(1); // Getting child at 1 because 0 might be the "Today" label
|
||||
mSolo.clickLongOnView(history);
|
||||
verifySharePopup(shareOptions,"history");
|
||||
|
Loading…
Reference in New Issue
Block a user