Bug 820276 - Robocop: Make editBookmark and checkBookmarkEdit methods available to other tests. r=jmaher

This commit is contained in:
Adrian Tamas 2013-03-19 16:12:43 +02:00
Родитель cba34e54de
Коммит 00b3454b12
2 изменённых файлов: 69 добавлений и 62 удалений

Просмотреть файл

@ -566,6 +566,69 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
hitEnterAndWait(); hitEnterAndWait();
} }
/**
* This method will edit the bookmark with index = bookmarkIndex from the list of bookmarks
* For the field index:
* fieldIndex = 1 - the Bookmark name
* fieldIndex = 2 - the Bookmark url
* fieldIndex = 3 - the Bookmark keyword
*/
public void editBookmark(int bookmarkIndex, int fieldIndex, String addedText, ListView list) {
// Open the Edit Bookmark context menu
View child;
mSolo.clickOnText("Bookmarks");
child = list.getChildAt(bookmarkIndex);
mAsserter.ok(child != null, "edit item can be retrieved", child != null ? child.toString() : "null!");
waitForText("about:home|Firefox");
mSolo.clickLongOnView(child);
waitForText("Open in New Tab");
mSolo.clickOnText("Edit");
waitForText("Edit Bookmark");
// Clear the Field
mSolo.clearEditText(fieldIndex);
// Enter the new text
mSolo.clickOnEditText(fieldIndex);
mActions.sendKeys(addedText);
mSolo.clickOnText("OK");
waitForText("Bookmark updated");
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
}
public boolean checkBookmarkEdit(int bookmarkIndex, String addedText, ListView list) {
Device mDevice = new Device();
// Open the Edit Bookmark context menu
View child;
mSolo.clickOnText("Bookmarks");
child = list.getChildAt(bookmarkIndex);
mAsserter.ok(child != null, "check item can be retrieved", child != null ? child.toString() : "null!");
waitForText("about:home|Firefox");
mSolo.clickLongOnView(child);
waitForText("Open in New Tab");
mSolo.clickOnText("Edit");
waitForText("Edit Bookmark");
// If the OS is not Gingerbread the vkb will be opened so we need to close it in order to press the "Cancel" button
if (!(mDevice.version.equals("2.x"))) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
}
// Check if the new text was added
if (mSolo.searchText(addedText)) {
mSolo.clickOnText("Cancel");
waitForText("about:home");
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
return true;
} else {
mSolo.clickOnText("Cancel");
waitForText("about:home");
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
return false;
}
}
class Device { class Device {
Build.VERSION mBuildVersion; Build.VERSION mBuildVersion;
public String version; // 2.x or 3.x or 4.x public String version; // 2.x or 3.x or 4.x

Просмотреть файл

@ -143,16 +143,16 @@ public class testBookmarksTab extends BaseTest {
list = getBookmarksList(url); list = getBookmarksList(url);
// Test edit bookmark name // Test edit bookmark name
editBookmark(1,0," Bookmark Name "); editBookmark(1,0," Bookmark Name ",list);
mAsserter.is(checkBookmarkEdit(1," Bookmark Name "), true, "Bookmark Name was changed"); mAsserter.is(checkBookmarkEdit(1," Bookmark Name ",list), true, "Bookmark Name was changed");
// Test edit bookmark link // Test edit bookmark link
editBookmark(1,1," Bookmark Link "); editBookmark(1,1," Bookmark Link ",list);
mAsserter.is(checkBookmarkEdit(1,"Bookmark Link"), true, "Bookmark Link was changed"); mAsserter.is(checkBookmarkEdit(1,"Bookmark Link",list), true, "Bookmark Link was changed");
// Test edit bookmark keyword // Test edit bookmark keyword
editBookmark(1,2," Bookmark Keyword "); editBookmark(1,2," Bookmark Keyword ",list);
mAsserter.is(checkBookmarkEdit(1,"Bookmark Keyword"), true, "Bookmark Keyword was changed"); mAsserter.is(checkBookmarkEdit(1,"Bookmark Keyword",list), true, "Bookmark Keyword was changed");
// Remove Bookmark from Context Menu // Remove Bookmark from Context Menu
waitForText("Bookmarks"); waitForText("Bookmarks");
@ -177,62 +177,6 @@ public class testBookmarksTab extends BaseTest {
mActions.sendSpecialKey(Actions.SpecialKey.BACK); mActions.sendSpecialKey(Actions.SpecialKey.BACK);
} }
private void editBookmark(int bookmarkIndex, int fieldIndex, String addedText) {
// Open the Edit Bookmark context menu
View child;
mSolo.clickOnText("Bookmarks");
child = list.getChildAt(bookmarkIndex);
mAsserter.ok(child != null, "edit item can be retrieved", child != null ? child.toString() : "null!");
waitForText("about:home");
mSolo.clickLongOnView(child);
waitForText("Open in New Tab");
mSolo.clickOnText("Edit");
waitForText("Edit Bookmark");
// Clear the Field
mSolo.clearEditText(fieldIndex);
// Enter the new text
mSolo.clickOnEditText(fieldIndex);
mActions.sendKeys(addedText);
mSolo.clickOnText("OK");
waitForText("Bookmark updated");
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
}
private boolean checkBookmarkEdit(int bookmarkIndex, String addedText) {
Device mDevice = new Device();
// Open the Edit Bookmark context menu
View child;
mSolo.clickOnText("Bookmarks");
child = list.getChildAt(bookmarkIndex);
mAsserter.ok(child != null, "check item can be retrieved", child != null ? child.toString() : "null!");
waitForText("about:home");
mSolo.clickLongOnView(child);
waitForText("Open in New Tab");
mSolo.clickOnText("Edit");
waitForText("Edit Bookmark");
// If the OS is not Gingerbread the vkb will be opened so we need to close it in order to press the "Cancel" button
if (!(mDevice.version.equals("2.x"))) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
}
// Check if the new text was added
if (mSolo.searchText(addedText)) {
mSolo.clickOnText("Cancel");
waitForText("about:home");
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
return true;
} else {
mSolo.clickOnText("Cancel");
waitForText("about:home");
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
return false;
}
}
private void compareRow(View child, int numTextViews, int numImageViews) { private void compareRow(View child, int numTextViews, int numImageViews) {
if (child == null) { if (child == null) {
// this list item may be obscured or offscreen // this list item may be obscured or offscreen