зеркало из https://github.com/mozilla/gecko-dev.git
Bug 781745 - Robocop: wait for list update in testBookmarksTab; r=jmaher
This commit is contained in:
Родитель
5def479303
Коммит
2554d5a4dc
|
@ -4,6 +4,7 @@ package @ANDROID_PACKAGE_NAME@.tests;
|
|||
import @ANDROID_PACKAGE_NAME@.*;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentUris;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ExpandableListView;
|
||||
|
@ -22,18 +23,19 @@ import java.util.Arrays;
|
|||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
|
||||
/* Tests opening the all pages tab, that items look correct, clicking on an item
|
||||
/* Tests opening the bookmarks tab, that items look correct, clicking on an item
|
||||
and long tapping on an item
|
||||
*/
|
||||
|
||||
public class testBookmarksTab extends BaseTest {
|
||||
private static final String ABOUT_HOME_URL = "about:home";
|
||||
private static final int WAIT_FOR_CHILD_TIMEOUT = 2000;
|
||||
private String[] defaultBookmarksUrls = new String[] {
|
||||
"about:firefox",
|
||||
"about:home",
|
||||
"http://support.mozilla.org/en-US/mobile",
|
||||
"https://addons.mozilla.org/en-US/android/"
|
||||
};
|
||||
private View mFirstChild;
|
||||
|
||||
@Override
|
||||
protected int getTestType() {
|
||||
|
@ -51,9 +53,11 @@ public class testBookmarksTab extends BaseTest {
|
|||
testContextMenu(url);
|
||||
}
|
||||
|
||||
private ListView list;
|
||||
|
||||
private void testList(String url) {
|
||||
View child;
|
||||
ListView list = getBookmarksList();
|
||||
list = getBookmarksList();
|
||||
|
||||
// Clear VKB so that list is not obscured
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
|
@ -102,35 +106,67 @@ public class testBookmarksTab extends BaseTest {
|
|||
}
|
||||
|
||||
private void testContextMenu(String url) {
|
||||
ListView list = getBookmarksList();
|
||||
|
||||
list = getBookmarksList();
|
||||
// Clear VKB so that list is not obscured
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
|
||||
mSolo.waitForText(url);
|
||||
|
||||
// test long tap on a folder, this should fail but will still open the folder
|
||||
View child = list.getChildAt(0);
|
||||
mSolo.clickLongOnView(child);
|
||||
mAsserter.is(mSolo.waitForText("Open in New Tab"), false, "Folders have no context menu");
|
||||
// pressing back should exit the folder
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
// wait for the bookmarks list to be populated
|
||||
mFirstChild = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
mFirstChild = list.getChildAt(1);
|
||||
if (mFirstChild == null) {
|
||||
return false;
|
||||
}
|
||||
if (mFirstChild instanceof android.view.ViewGroup) {
|
||||
ViewGroup group = (ViewGroup)mFirstChild;
|
||||
if (group.getChildCount() < 1) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < group.getChildCount(); i++) {
|
||||
View grandChild = group.getChildAt(i);
|
||||
if (grandChild instanceof android.widget.TextView) {
|
||||
mAsserter.ok(true, "found TextView:", ((android.widget.TextView)grandChild).getText().toString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mAsserter.dumpLog("first child not a ViewGroup: "+mFirstChild);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, WAIT_FOR_CHILD_TIMEOUT);
|
||||
if (success == true && mFirstChild != null) {
|
||||
mAsserter.dumpLog("clickLongOnView: "+mFirstChild);
|
||||
|
||||
// long tap on a bookmark should show a context menu with an edit option
|
||||
child = list.getChildAt(1);
|
||||
mSolo.clickLongOnView(child);
|
||||
// long tap on a bookmark should show a context menu with an edit option
|
||||
mSolo.clickLongOnView(mFirstChild);
|
||||
|
||||
// TODO: Test clicking these does the right thing
|
||||
mAsserter.ok(mSolo.waitForText("Open in New Tab"), "Context menu has New Tab option", "Open in New Tab");
|
||||
mAsserter.ok(mSolo.searchText("Share", true), "Context menu has Share option", "Share");
|
||||
mAsserter.ok(mSolo.searchText("Edit", true), "Context menu has Edit option", "Edit");
|
||||
mAsserter.ok(mSolo.searchText("Remove", true), "Context menu has Remove option", "Remove");
|
||||
mAsserter.ok(mSolo.searchText("Add to Home Screen", true), "Context menu has Add to Home Screen option", "Add to Home Screen");
|
||||
// TODO: Test clicking these does the right thing
|
||||
mAsserter.ok(mSolo.waitForText("Open in New Tab"), "Context menu has New Tab option", "Open in New Tab");
|
||||
mAsserter.ok(mSolo.searchText("Share", true), "Context menu has Share option", "Share");
|
||||
mAsserter.ok(mSolo.searchText("Edit", true), "Context menu has Edit option", "Edit");
|
||||
mAsserter.ok(mSolo.searchText("Remove", true), "Context menu has Remove option", "Remove");
|
||||
mAsserter.ok(mSolo.searchText("Add to Home Screen", true), "Context menu has Add to Home Screen option", "Add to Home Screen");
|
||||
|
||||
// press back to exit the context menu
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
|
||||
// test long tap on a folder, this should fail but will still open the folder
|
||||
View child = list.getChildAt(0);
|
||||
mSolo.clickLongOnView(child);
|
||||
mAsserter.is(mSolo.waitForText("Open in New Tab"), false, "Folders have no context menu");
|
||||
|
||||
// pressing back should exit the folder
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
|
||||
} else {
|
||||
mAsserter.ok(false, "waiting for bookmark item", "bookmark item available");
|
||||
}
|
||||
|
||||
// press back to exit the context menu
|
||||
// back again to exit the awesomebar
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
}
|
||||
|
||||
private void compareRow(View child, int numTextViews, int numImageViews) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче