зеркало из 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_PACKAGE_NAME@.*;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ExpandableListView;
|
import android.widget.ExpandableListView;
|
||||||
|
@ -22,18 +23,19 @@ import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.io.File;
|
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
|
and long tapping on an item
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class testBookmarksTab extends BaseTest {
|
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[] {
|
private String[] defaultBookmarksUrls = new String[] {
|
||||||
"about:firefox",
|
"about:firefox",
|
||||||
"about:home",
|
"about:home",
|
||||||
"http://support.mozilla.org/en-US/mobile",
|
"http://support.mozilla.org/en-US/mobile",
|
||||||
"https://addons.mozilla.org/en-US/android/"
|
"https://addons.mozilla.org/en-US/android/"
|
||||||
};
|
};
|
||||||
|
private View mFirstChild;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getTestType() {
|
protected int getTestType() {
|
||||||
|
@ -51,9 +53,11 @@ public class testBookmarksTab extends BaseTest {
|
||||||
testContextMenu(url);
|
testContextMenu(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ListView list;
|
||||||
|
|
||||||
private void testList(String url) {
|
private void testList(String url) {
|
||||||
View child;
|
View child;
|
||||||
ListView list = getBookmarksList();
|
list = getBookmarksList();
|
||||||
|
|
||||||
// Clear VKB so that list is not obscured
|
// Clear VKB so that list is not obscured
|
||||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||||
|
@ -102,35 +106,67 @@ public class testBookmarksTab extends BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testContextMenu(String url) {
|
private void testContextMenu(String url) {
|
||||||
ListView list = getBookmarksList();
|
list = getBookmarksList();
|
||||||
|
|
||||||
// Clear VKB so that list is not obscured
|
// Clear VKB so that list is not obscured
|
||||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||||
|
|
||||||
mSolo.waitForText(url);
|
mSolo.waitForText(url);
|
||||||
|
|
||||||
// test long tap on a folder, this should fail but will still open the folder
|
// wait for the bookmarks list to be populated
|
||||||
View child = list.getChildAt(0);
|
mFirstChild = null;
|
||||||
mSolo.clickLongOnView(child);
|
boolean success = waitForTest(new BooleanTest() {
|
||||||
mAsserter.is(mSolo.waitForText("Open in New Tab"), false, "Folders have no context menu");
|
public boolean test() {
|
||||||
// pressing back should exit the folder
|
mFirstChild = list.getChildAt(1);
|
||||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
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
|
// long tap on a bookmark should show a context menu with an edit option
|
||||||
child = list.getChildAt(1);
|
mSolo.clickLongOnView(mFirstChild);
|
||||||
mSolo.clickLongOnView(child);
|
|
||||||
|
|
||||||
// TODO: Test clicking these does the right thing
|
// 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.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("Share", true), "Context menu has Share option", "Share");
|
||||||
mAsserter.ok(mSolo.searchText("Edit", true), "Context menu has Edit option", "Edit");
|
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("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");
|
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
|
// back again to exit the awesomebar
|
||||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void compareRow(View child, int numTextViews, int numImageViews) {
|
private void compareRow(View child, int numTextViews, int numImageViews) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче