mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 907734 - Create the DataBaseHelper and StringHelper classes. r=margaret
This commit is contained in:
parent
19e1c6c1dc
commit
32d16e45a3
@ -24,36 +24,12 @@ import java.util.ArrayList;
|
||||
* To use any of these methods in your test make sure it extends AboutHomeTest instead of BaseTest
|
||||
*/
|
||||
abstract class AboutHomeTest extends BaseTest {
|
||||
protected enum BrowserDataType {BOOKMARKS, HISTORY};
|
||||
protected enum AboutHomeTabs {MOST_VISITED, MOST_RECENT, TABS_FROM_LAST_TIME, BOOKMARKS, READING_LIST};
|
||||
protected ArrayList<String> aboutHomeTabs = new ArrayList<String>() {{
|
||||
add("HISTORY");
|
||||
add("BOOKMARKS");
|
||||
add("READING_LIST");
|
||||
}};
|
||||
|
||||
// Labels for the about:home tabs
|
||||
protected static final String HISTORY_LABEL = "HISTORY";
|
||||
protected static final String BOOKMARKS_LABEL = "BOOKMARKS";
|
||||
protected static final String READING_LIST_LABEL = "READING LIST";
|
||||
protected static final String MOST_RECENT_LABEL = "Most recent";
|
||||
protected static final String TABS_FROM_LAST_TIME_LABEL = "Open all tabs from last time";
|
||||
|
||||
/**
|
||||
* This method can be used to check if an URL is present in the bookmarks database
|
||||
*/
|
||||
protected boolean isBookmark(String url) {
|
||||
try {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
ClassLoader classLoader = getActivity().getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method isBookmarked = browserDB.getMethod("isBookmark", ContentResolver.class, String.class);
|
||||
return (Boolean)isBookmarked.invoke(null, resolver, url);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception while checking if url is bookmarked: ", e.toString()); // Fail before returning
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME: Write new versions of these methods and update their consumers to use the new about:home pages.
|
||||
@ -65,18 +41,6 @@ abstract class AboutHomeTest extends BaseTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Uri buildUri(BrowserDataType dataType) {
|
||||
Uri uri = null;
|
||||
if (dataType == BrowserDataType.BOOKMARKS || dataType == BrowserDataType.HISTORY) {
|
||||
uri = Uri.parse("content://@ANDROID_PACKAGE_NAME@.db.browser/" + dataType.toString().toLowerCase());
|
||||
} else {
|
||||
mAsserter.ok(false, "The wrong data type has been provided = " + dataType.toString(), "Please provide a BrowserDataType value");
|
||||
}
|
||||
uri = uri.buildUpon().appendQueryParameter("profile", "default")
|
||||
.appendQueryParameter("sync", "true").build();
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the given ListView to have a non-empty adapter.
|
||||
*
|
||||
@ -121,157 +85,6 @@ abstract class AboutHomeTest extends BaseTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a bookmark, or updates the bookmark title if the url already exists.
|
||||
*
|
||||
* The LocalBrowserDB.addBookmark implementation handles updating existing bookmarks.
|
||||
* Since we don't modify bookmark keywords in tests, we don't need a separate
|
||||
* implemention of updateBookmark.
|
||||
*/
|
||||
protected void addOrUpdateMobileBookmark(String title, String url) {
|
||||
try {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
ClassLoader classLoader = getActivity().getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method addBookmark = browserDB.getMethod("addBookmark", ContentResolver.class, String.class, String.class);
|
||||
addBookmark.invoke(null, resolver, title, url);
|
||||
mAsserter.ok(true, "Inserting/updating a new bookmark", "Inserting/updating the bookmark with the title = " + title + " and the url = " + url);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception adding bookmark: ", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the title and keyword of a bookmark with the given URL.
|
||||
*
|
||||
* Warning: This method assumes that there's only one bookmark with the given URL.
|
||||
*/
|
||||
protected void updateBookmark(String url, String title, String keyword) {
|
||||
try {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
ClassLoader classLoader = getActivity().getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method getBookmarkForUrl = browserDB.getMethod("getBookmarkForUrl", ContentResolver.class, String.class);
|
||||
|
||||
// Get the id for the bookmark with the given URL.
|
||||
Cursor c = null;
|
||||
try {
|
||||
c = (Cursor) getBookmarkForUrl.invoke(null, resolver, url);
|
||||
if (!c.moveToFirst()) {
|
||||
mAsserter.ok(false, "Getting bookmark with url", "Couldn't find bookmark with url = " + url);
|
||||
return;
|
||||
}
|
||||
|
||||
int id = c.getInt(c.getColumnIndexOrThrow("_id"));
|
||||
Method updateBookmark = browserDB.getMethod("updateBookmark", ContentResolver.class, int.class, String.class, String.class, String.class);
|
||||
updateBookmark.invoke(null, resolver, id, url, title, keyword);
|
||||
|
||||
mAsserter.ok(true, "Updating bookmark", "Updating bookmark with url = " + url);
|
||||
} finally {
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception updating bookmark: ", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteBookmark(String url) {
|
||||
try {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
ClassLoader classLoader = getActivity().getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method removeBookmark = browserDB.getMethod("removeBookmarksWithURL", ContentResolver.class, String.class);
|
||||
removeBookmark.invoke(null, resolver, url);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception deleting bookmark: ", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteHistoryItem(String url) {
|
||||
try {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
ClassLoader classLoader = getActivity().getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method removeHistory = browserDB.getMethod("removeHistoryEntry", ContentResolver.class, String.class);
|
||||
removeHistory.invoke(null, resolver, url);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception deleting history item: ", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected Long getFolderId(String guid) {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
Long folderId = Long.valueOf(-1);
|
||||
Uri bookmarksUri = buildUri(BrowserDataType.BOOKMARKS);
|
||||
Cursor c = null;
|
||||
try {
|
||||
c = resolver.query(bookmarksUri,
|
||||
new String[] { "_id" },
|
||||
"guid = ?",
|
||||
new String[] { guid },
|
||||
null);
|
||||
if (c.moveToFirst()) {
|
||||
folderId = c.getLong(c.getColumnIndexOrThrow("_id"));
|
||||
}
|
||||
if (folderId == -1) {
|
||||
mAsserter.ok(false, "Making sure that we got the correct folder", "We didn't get the correct folder id");
|
||||
}
|
||||
} finally {
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
return folderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param a BrowserDataType value - either HISTORY or BOOKMARKS
|
||||
* @return an ArrayList of the urls in the Firefox for Android Bookmarks or History databases
|
||||
*/
|
||||
protected ArrayList<String> getBrowserDBUrls(BrowserDataType dataType) {
|
||||
ArrayList<String> browserData = new ArrayList<String>();
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
ClassLoader classLoader = getActivity().getClassLoader();
|
||||
Cursor cursor = null;
|
||||
Uri uri = buildUri(dataType);
|
||||
if (dataType == BrowserDataType.HISTORY) {
|
||||
try {
|
||||
Class browserDBClass = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method getAllVisitedHistory = browserDBClass.getMethod("getAllVisitedHistory", ContentResolver.class);
|
||||
cursor = (Cursor)getAllVisitedHistory.invoke(null, resolver);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception while getting history", e.toString());
|
||||
}
|
||||
} else if (dataType == BrowserDataType.BOOKMARKS) {
|
||||
try {
|
||||
Class browserDBClass = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method getBookmarks = browserDBClass.getMethod("getBookmarksInFolder", ContentResolver.class, Long.TYPE);
|
||||
cursor = (Cursor)getBookmarks.invoke(null, resolver, getFolderId("mobile"));
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception while getting bookmarks", e.toString());
|
||||
}
|
||||
}
|
||||
if (cursor != null) {
|
||||
cursor.moveToFirst();
|
||||
for (int i = 0; i < cursor.getCount(); i++ ) {
|
||||
// The url field may be null for folders in the structure of the Bookmarks table for Firefox so we should eliminate those
|
||||
if (cursor.getString(cursor.getColumnIndex("url")) != null) {
|
||||
browserData.add(cursor.getString(cursor.getColumnIndex("url")));
|
||||
}
|
||||
if(!cursor.isLast()) {
|
||||
cursor.moveToNext();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mAsserter.ok(false, "We could not retrieve any data from the database", "The cursor was null");
|
||||
}
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
return browserData;
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME: rewrite this to work with fig when rewriting the testBookmarksTab test
|
||||
@ -352,44 +165,44 @@ abstract class AboutHomeTest extends BaseTest {
|
||||
ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
|
||||
switch (tab) {
|
||||
case BOOKMARKS : {
|
||||
mSolo.clickOnText(BOOKMARKS_LABEL);
|
||||
mSolo.clickOnText(StringHelper.BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(tab.toString()));
|
||||
break;
|
||||
}
|
||||
case MOST_RECENT: {
|
||||
mSolo.clickOnText(BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(BOOKMARKS_LABEL));
|
||||
mSolo.clickOnText(StringHelper.BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.BOOKMARKS_LABEL));
|
||||
mActions.drag(0, halfWidth, halfHeight, halfHeight);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(HISTORY_LABEL));
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.HISTORY_LABEL));
|
||||
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
||||
mSolo.clickOnView(tabwidget.getChildAt(1));
|
||||
mAsserter.ok(waitForText(MOST_RECENT_LABEL), "Checking that we are in the most recent tab of about:home", "We are in the most recent tab");
|
||||
mAsserter.ok(waitForText(StringHelper.MOST_RECENT_LABEL), "Checking that we are in the most recent tab of about:home", "We are in the most recent tab");
|
||||
break;
|
||||
}
|
||||
case READING_LIST: {
|
||||
mSolo.clickOnText(BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(BOOKMARKS_LABEL));
|
||||
mSolo.clickOnText(StringHelper.BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.BOOKMARKS_LABEL));
|
||||
mActions.drag(halfWidth, 0, halfHeight, halfHeight);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(tab.toString()));
|
||||
break;
|
||||
}
|
||||
case MOST_VISITED: {
|
||||
mSolo.clickOnText(BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(BOOKMARKS_LABEL));
|
||||
mSolo.clickOnText(StringHelper.BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.BOOKMARKS_LABEL));
|
||||
mActions.drag(0, halfWidth, halfHeight, halfHeight);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(HISTORY_LABEL));
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.HISTORY_LABEL));
|
||||
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
||||
mSolo.clickOnView(tabwidget.getChildAt(0));
|
||||
break;
|
||||
}
|
||||
case TABS_FROM_LAST_TIME: {
|
||||
mSolo.clickOnText(BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(BOOKMARKS_LABEL));
|
||||
mSolo.clickOnText(StringHelper.BOOKMARKS_LABEL);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.BOOKMARKS_LABEL));
|
||||
mActions.drag(0, halfWidth, halfHeight, halfHeight);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(HISTORY_LABEL));
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.HISTORY_LABEL));
|
||||
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
||||
mSolo.clickOnView(tabwidget.getChildAt(2));
|
||||
mAsserter.ok(waitForText(TABS_FROM_LAST_TIME_LABEL), "Checking that we are in the Tabs from last time tab of about:home", "We are in the Tabs from last time tab");
|
||||
mAsserter.ok(waitForText(StringHelper.TABS_FROM_LAST_TIME_LABEL), "Checking that we are in the Tabs from last time tab of about:home", "We are in the Tabs from last time tab");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -52,28 +52,11 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
private static final int MAX_WAIT_HOME_PAGER_HIDDEN_MS = 10000;
|
||||
public static final int MAX_WAIT_MS = 3000;
|
||||
|
||||
// Note: DEFAULT_BOOKMARKS_TITLES.length == DEFAULT_BOOKMARKS_URLS.length
|
||||
protected static final String[] DEFAULT_BOOKMARKS_TITLES = new String[] {
|
||||
"Firefox: About your browser",
|
||||
"Firefox: Support",
|
||||
"Firefox: Customize with add-ons"
|
||||
};
|
||||
protected static final String[] DEFAULT_BOOKMARKS_URLS = new String[] {
|
||||
"about:firefox",
|
||||
"http://support.mozilla.org/en-US/products/mobile",
|
||||
"https://addons.mozilla.org/en-US/android/"
|
||||
};
|
||||
protected static final int DEFAULT_BOOKMARKS_COUNT = DEFAULT_BOOKMARKS_TITLES.length;
|
||||
|
||||
// IDs for UI views
|
||||
private static final String BROWSER_TOOLBAR_ID = "browser_toolbar";
|
||||
protected static final String URL_EDIT_TEXT_ID = "url_edit_text";
|
||||
protected static final String URL_BAR_TITLE_ID = "url_bar_title";
|
||||
|
||||
// Settings menu paths
|
||||
protected static final String PRIVACY_LABEL = "Privacy";
|
||||
protected static final String CLEAR_PRIVATE_DATA_LABEL = "Clear private data";
|
||||
|
||||
private static Class<Activity> mLauncherActivityClass;
|
||||
private Activity mActivity;
|
||||
protected Solo mSolo;
|
||||
@ -85,6 +68,8 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
private String mLogFile;
|
||||
protected String mProfile;
|
||||
public Device mDevice;
|
||||
protected DatabaseHelper mDatabaseHelper;
|
||||
protected StringHelper mStringHelper;
|
||||
|
||||
protected void blockForGeckoReady() {
|
||||
try {
|
||||
@ -154,6 +139,8 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
mDriver = new FennecNativeDriver(mActivity, mSolo, rootPath);
|
||||
mActions = new FennecNativeActions(mActivity, mSolo, getInstrumentation(), mAsserter);
|
||||
mDevice = new Device();
|
||||
mDatabaseHelper = new DatabaseHelper(mActivity, mAsserter);
|
||||
mStringHelper = new StringHelper();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -617,7 +604,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
}
|
||||
|
||||
public void clearPrivateData() {
|
||||
selectSettingsItem(PRIVACY_LABEL, CLEAR_PRIVATE_DATA_LABEL);
|
||||
selectSettingsItem(StringHelper.PRIVACY_SECTION_LABEL, StringHelper.CLEAR_PRIVATE_DATA_LABEL);
|
||||
Actions.EventExpecter clearData = mActions.expectGeckoEvent("Sanitize:Finished");
|
||||
mSolo.clickOnText("Clear data");
|
||||
clearData.blockForEvent();
|
||||
|
@ -10,7 +10,7 @@ import java.lang.reflect.Method;
|
||||
/**
|
||||
* This class covers interactions with the context menu opened from web content
|
||||
*/
|
||||
abstract class ContentContextMenuTest extends AboutHomeTest {
|
||||
abstract class ContentContextMenuTest extends BaseTest {
|
||||
private static final int MAX_TEST_TIMEOUT = 10000;
|
||||
|
||||
// This method opens the context menu of any web content. It assumes that the page is already loaded
|
||||
@ -88,6 +88,6 @@ abstract class ContentContextMenuTest extends AboutHomeTest {
|
||||
openWebContentContextMenu(bookmarkOption);
|
||||
mSolo.clickOnText(bookmarkOption);
|
||||
mAsserter.ok(waitForText("Bookmark added"), "Waiting for the Bookmark added toaster notification", "The notification has been displayed");
|
||||
mAsserter.ok(isBookmark(link), "Checking if the link has been added as a bookmark", "The link has been bookmarked");
|
||||
mAsserter.ok(mDatabaseHelper.isBookmark(link), "Checking if the link has been added as a bookmark", "The link has been bookmarked");
|
||||
}
|
||||
}
|
||||
|
201
mobile/android/base/tests/DatabaseHelper.java.in
Normal file
201
mobile/android/base/tests/DatabaseHelper.java.in
Normal file
@ -0,0 +1,201 @@
|
||||
#filter substitution
|
||||
package @ANDROID_PACKAGE_NAME@.tests;
|
||||
|
||||
import @ANDROID_PACKAGE_NAME@.*;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class DatabaseHelper {
|
||||
protected enum BrowserDataType {BOOKMARKS, HISTORY};
|
||||
private Activity mActivity;
|
||||
private Assert mAsserter;
|
||||
|
||||
public DatabaseHelper(Activity activity, Assert asserter) {
|
||||
mActivity = activity;
|
||||
mAsserter = asserter;
|
||||
}
|
||||
/**
|
||||
* This method can be used to check if an URL is present in the bookmarks database
|
||||
*/
|
||||
protected boolean isBookmark(String url) {
|
||||
try {
|
||||
ContentResolver resolver = mActivity.getContentResolver();
|
||||
ClassLoader classLoader = mActivity.getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method isBookmarked = browserDB.getMethod("isBookmark", ContentResolver.class, String.class);
|
||||
return (Boolean)isBookmarked.invoke(null, resolver, url);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception while checking if url is bookmarked", e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected Uri buildUri(BrowserDataType dataType) {
|
||||
Uri uri = null;
|
||||
if (dataType == BrowserDataType.BOOKMARKS || dataType == BrowserDataType.HISTORY) {
|
||||
uri = Uri.parse("content://@ANDROID_PACKAGE_NAME@.db.browser/" + dataType.toString().toLowerCase());
|
||||
} else {
|
||||
mAsserter.ok(false, "The wrong data type has been provided = " + dataType.toString(), "Please provide the correct data type");
|
||||
}
|
||||
uri = uri.buildUpon().appendQueryParameter("profile", "default")
|
||||
.appendQueryParameter("sync", "true").build();
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a bookmark, or updates the bookmark title if the url already exists.
|
||||
*
|
||||
* The LocalBrowserDB.addBookmark implementation handles updating existing bookmarks.
|
||||
*/
|
||||
protected void addOrUpdateMobileBookmark(String title, String url) {
|
||||
try {
|
||||
ContentResolver resolver = mActivity.getContentResolver();
|
||||
ClassLoader classLoader = mActivity.getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method addBookmark = browserDB.getMethod("addBookmark", ContentResolver.class, String.class, String.class);
|
||||
addBookmark.invoke(null, resolver, title, url);
|
||||
mAsserter.ok(true, "Inserting/updating a new bookmark", "Inserting/updating the bookmark with the title = " + title + " and the url = " + url);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception adding bookmark: ", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the title and keyword of a bookmark with the given URL.
|
||||
*
|
||||
* Warning: This method assumes that there's only one bookmark with the given URL.
|
||||
*/
|
||||
protected void updateBookmark(String url, String title, String keyword) {
|
||||
try {
|
||||
ContentResolver resolver = mActivity.getContentResolver();
|
||||
ClassLoader classLoader = mActivity.getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method getBookmarkForUrl = browserDB.getMethod("getBookmarkForUrl", ContentResolver.class, String.class);
|
||||
|
||||
// Get the id for the bookmark with the given URL.
|
||||
Cursor c = null;
|
||||
try {
|
||||
c = (Cursor) getBookmarkForUrl.invoke(null, resolver, url);
|
||||
if (!c.moveToFirst()) {
|
||||
mAsserter.ok(false, "Getting bookmark with url", "Couldn't find bookmark with url = " + url);
|
||||
return;
|
||||
}
|
||||
|
||||
int id = c.getInt(c.getColumnIndexOrThrow("_id"));
|
||||
Method updateBookmark = browserDB.getMethod("updateBookmark", ContentResolver.class, int.class, String.class, String.class, String.class);
|
||||
updateBookmark.invoke(null, resolver, id, url, title, keyword);
|
||||
|
||||
mAsserter.ok(true, "Updating bookmark", "Updating bookmark with url = " + url);
|
||||
} finally {
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception updating bookmark: ", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteBookmark(String url) {
|
||||
try {
|
||||
ContentResolver resolver = mActivity.getContentResolver();
|
||||
ClassLoader classLoader = mActivity.getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method removeBookmark = browserDB.getMethod("removeBookmarksWithURL", ContentResolver.class, String.class);
|
||||
removeBookmark.invoke(null, resolver, url);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception deleting bookmark", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteHistoryItem(String url) {
|
||||
try {
|
||||
ContentResolver resolver = mActivity.getContentResolver();
|
||||
ClassLoader classLoader = mActivity.getClassLoader();
|
||||
Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method removeHistory = browserDB.getMethod("removeHistoryEntry", ContentResolver.class, String.class);
|
||||
removeHistory.invoke(null, resolver, url);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception deleting history item", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// About the same implementation as getFolderIdFromGuid from LocalBrowserDB because it is declared private and we can't use reflections to access it
|
||||
protected long getFolderIdFromGuid(String guid) {
|
||||
ContentResolver resolver = mActivity.getContentResolver();
|
||||
long folderId = Long.valueOf(-1);
|
||||
Uri bookmarksUri = buildUri(BrowserDataType.BOOKMARKS);
|
||||
Cursor c = null;
|
||||
try {
|
||||
c = resolver.query(bookmarksUri,
|
||||
new String[] { "_id" },
|
||||
"guid = ?",
|
||||
new String[] { guid },
|
||||
null);
|
||||
if (c.moveToFirst()) {
|
||||
folderId = c.getLong(c.getColumnIndexOrThrow("_id"));
|
||||
}
|
||||
if (folderId == -1) {
|
||||
mAsserter.ok(false, "Trying to get the folder id" ,"We did not get the correct folder id");
|
||||
}
|
||||
} finally {
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
return folderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param a BrowserDataType value - either HISTORY or BOOKMARKS
|
||||
* @return an ArrayList of the urls in the Firefox for Android Bookmarks or History databases
|
||||
*/
|
||||
protected ArrayList<String> getBrowserDBUrls(BrowserDataType dataType) {
|
||||
ArrayList<String> browserData = new ArrayList<String>();
|
||||
ContentResolver resolver = mActivity.getContentResolver();
|
||||
ClassLoader classLoader = mActivity.getClassLoader();
|
||||
Cursor cursor = null;
|
||||
Uri uri = buildUri(dataType);
|
||||
if (dataType == BrowserDataType.HISTORY) {
|
||||
try {
|
||||
Class browserDBClass = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method getAllVisitedHistory = browserDBClass.getMethod("getAllVisitedHistory", ContentResolver.class);
|
||||
cursor = (Cursor)getAllVisitedHistory.invoke(null, resolver);
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception while getting history", e.toString());
|
||||
}
|
||||
} else if (dataType == BrowserDataType.BOOKMARKS) {
|
||||
try {
|
||||
Class browserDBClass = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
|
||||
Method getBookmarks = browserDBClass.getMethod("getBookmarksInFolder", ContentResolver.class, Long.TYPE);
|
||||
cursor = (Cursor)getBookmarks.invoke(null, resolver, getFolderIdFromGuid("mobile"));
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "Exception while getting bookmarks", e.toString());
|
||||
}
|
||||
}
|
||||
if (cursor != null) {
|
||||
cursor.moveToFirst();
|
||||
for (int i = 0; i < cursor.getCount(); i++ ) {
|
||||
// The url field may be null for folders in the structure of the Bookmarks table for Firefox so we should eliminate those
|
||||
if (cursor.getString(cursor.getColumnIndex("url")) != null) {
|
||||
browserData.add(cursor.getString(cursor.getColumnIndex("url")));
|
||||
}
|
||||
if(!cursor.isLast()) {
|
||||
cursor.moveToNext();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mAsserter.ok(false, "We could not retrieve any data from the database", "The cursor was null");
|
||||
}
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
return browserData;
|
||||
}
|
||||
}
|
125
mobile/android/base/tests/StringHelper.java.in
Normal file
125
mobile/android/base/tests/StringHelper.java.in
Normal file
@ -0,0 +1,125 @@
|
||||
#filter substitution
|
||||
package @ANDROID_PACKAGE_NAME@.tests;
|
||||
|
||||
import @ANDROID_PACKAGE_NAME@.*;
|
||||
|
||||
class StringHelper {
|
||||
// Note: DEFAULT_BOOKMARKS_TITLES.length == DEFAULT_BOOKMARKS_URLS.length
|
||||
public static final String[] DEFAULT_BOOKMARKS_TITLES = new String[] {
|
||||
"Firefox: About your browser",
|
||||
"Firefox: Support",
|
||||
"Firefox: Customize with add-ons"
|
||||
};
|
||||
public static final String[] DEFAULT_BOOKMARKS_URLS = new String[] {
|
||||
"about:firefox",
|
||||
"http://support.mozilla.org/en-US/products/mobile",
|
||||
"https://addons.mozilla.org/en-US/android/"
|
||||
};
|
||||
public static final int DEFAULT_BOOKMARKS_COUNT = DEFAULT_BOOKMARKS_TITLES.length;
|
||||
|
||||
// Robocop page urls
|
||||
// Note: please use getAbsoluteUrl(String url) on each robocop url to get the correct url
|
||||
public static final String ROBOCOP_BIG_LINK_URL = "/robocop/robocop_big_link.html";
|
||||
public static final String ROBOCOP_BIG_MAILTO_URL = "/robocop/robocop_big_mailto.html";
|
||||
public static final String ROBOCOP_BLANK_PAGE_01_URL = "/robocop/robocop_blank_01.html";
|
||||
public static final String ROBOCOP_BLANK_PAGE_02_URL = "/robocop/robocop_blank_02.html";
|
||||
public static final String ROBOCOP_BLANK_PAGE_03_URL = "/robocop/robocop_blank_03.html";
|
||||
public static final String ROBOCOP_BOXES_URL = "/robocop/robocop_boxes.html";
|
||||
public static final String ROBOCOP_GEOLOCATION_URL = "/robocop/robocop_geolocation.html";
|
||||
public static final String ROBOCOP_LOGIN_URL = "/robocop/robocop_login.html";
|
||||
public static final String ROBOCOP_OFFLINE_STORAGE_URL = "/robocop/robocop_offline_storage.html";
|
||||
public static final String ROBOCOP_PICTURE_LINK_URL = "/robocop/robocop_picture_link.html";
|
||||
public static final String ROBOCOP_SEARCH_URL = "/robocop/robocop_search.html";
|
||||
public static final String ROBOCOP_TEXT_PAGE_URL = "/robocop/robocop_text_page.html";
|
||||
|
||||
// Robocop page titles
|
||||
public static final String ROBOCOP_BIG_LINK_TITLE = "Big Link";
|
||||
public static final String ROBOCOP_BIG_MAILTO_TITLE = "Big Mailto";
|
||||
public static final String ROBOCOP_BLANK_PAGE_01_TITLE = "Browser Blank Page 01";
|
||||
public static final String ROBOCOP_BLANK_PAGE_02_TITLE = "Browser Blank Page 02";
|
||||
public static final String ROBOCOP_BLANK_PAGE_03_TITLE = "Browser Blank Page 03";
|
||||
public static final String ROBOCOP_BOXES_TITLE = "Browser Box test";
|
||||
public static final String ROBOCOP_GEOLOCATION_TITLE = "Geolocation Test Page";
|
||||
public static final String ROBOCOP_LOGIN_TITLE = "Robocop Login";
|
||||
public static final String ROBOCOP_OFFLINE_STORAGE_TITLE = "Robocop offline storage";
|
||||
public static final String ROBOCOP_PICTURE_LINK_TITLE = "Picture Link";
|
||||
public static final String ROBOCOP_SEARCH_TITLE = "Robocop Search Engine";
|
||||
public static final String ROBOCOP_TEXT_PAGE_TITLE = "Robocop Text Page";
|
||||
|
||||
// Settings menu strings
|
||||
// Section labels - ordered as found in the settings menu
|
||||
public static final String CUSTOMIZE_SECTION_LABEL = "Customize";
|
||||
public static final String DISPLAY_SECTION_LABEL = "Display";
|
||||
public static final String PRIVACY_SECTION_LABEL = "Privacy";
|
||||
public static final String MOZILLA_SECTION_LABEL = "Mozilla";
|
||||
public static final String DEVELOPER_TOOLS_SECTION_LABEL = "Developer tools";
|
||||
|
||||
// Option labels
|
||||
// Customize
|
||||
public static final String SYNC_LABEL = "Sync";
|
||||
public static final String SEARCH_SETTINGS_LABEL = "Search settings";
|
||||
public static final String IMPORT_FROM_ANDROID_LABEL = "Import from Android";
|
||||
public static final String TABS_LABEL = "Tabs";
|
||||
|
||||
// Display
|
||||
public static final String TEXT_SIZE_LABEL = "Text size";
|
||||
public static final String TITLE_BAR_LABEL = "Title bar";
|
||||
public static final String TEXT_REFLOW_LABEL = "Text reflow";
|
||||
public static final String CHARACTER_ENCODING_LABEL = "Character encoding";
|
||||
public static final String PLUGINS_LABEL = "Plugins";
|
||||
|
||||
// Privacy
|
||||
public static final String TRACKING_LABEL = "Tracking";
|
||||
public static final String COOKIES_LABEL = "Cookies";
|
||||
public static final String REMEMBER_PASSWORDS_LABEL = "Remeber passwords";
|
||||
public static final String MASTER_PASWSWORD_LABEL = "Use master password";
|
||||
public static final String CLEAR_PRIVATE_DATA_LABEL = "Clear private data";
|
||||
|
||||
// Mozilla
|
||||
public static final String ABOUT_LABEL = "About (Fennec|Nightly|Aurora|Firefox Beta|Firefox)";
|
||||
public static final String FAQS_LABEL = "FAQs";
|
||||
public static final String FEEDBACK_LABEL = "Give feedback";
|
||||
public static final String PRODUCT_ANNOUNCEMENTS_LABEL = "Show product announcements";
|
||||
public static final String LOCATION_SERVICES_LABEL = "Mozilla location services";
|
||||
public static final String HELTH_REPORT_LABEL = "(Fennec|Nightly|Aurora|Firefox Beta|Firefox) Health Report";
|
||||
public static final String MY_HEALTH_REPORT_LABEL = "View my Health Report";
|
||||
|
||||
// Developer tools
|
||||
public static final String REMOTE_DEBUGGING_LABEL = "Remote debugging";
|
||||
public static final String LEARN_MORE_LABEL = "Learn more";
|
||||
|
||||
// Labels for the about:home tabs
|
||||
public static final String HISTORY_LABEL = "HISTORY";
|
||||
public static final String BOOKMARKS_LABEL = "BOOKMARKS";
|
||||
public static final String READING_LIST_LABEL = "READING LIST";
|
||||
public static final String MOST_RECENT_LABEL = "Most recent";
|
||||
public static final String TABS_FROM_LAST_TIME_LABEL = "Open all tabs from last time";
|
||||
|
||||
// Desktop default bookmarks folders
|
||||
public static final String DESKTOP_FOLDER_LABEL = "Desktop Bookmarks";
|
||||
public static final String TOOLBAR_FOLDER_LABEL = "Bookmarks Toolbar";
|
||||
public static final String BOOKMARKS_MENU_FOLDER_LABEL = "Bookmarks Menu";
|
||||
public static final String UNSORTED_FOLDER_LABEL = "Unsorted Bookmarks";
|
||||
|
||||
// Menu items - some of the items are found only on android 2.3 and lower and some only on android 3.0+
|
||||
public static final String NEW_TAB_LABEL = "New Tab";
|
||||
public static final String NEW_PRIVATE_TAB_LABEL = "New Private Tab";
|
||||
public static final String SHARE_LABEL = "Share";
|
||||
public static final String FIND_IN_PAGE_LABEL = "Find in Page";
|
||||
public static final String DESKTOP_SITE_LABEL = "Request Desktop Site";
|
||||
public static final String PDF_LABEL = "Save as PDF";
|
||||
public static final String DOWNLOADS_LABEL = "Downloads";
|
||||
public static final String ADDONS_LABEL = "Add-ons";
|
||||
public static final String APPS_LABEL = "Apps";
|
||||
public static final String SETTINGS_LABEL = "Settings";
|
||||
public static final String GUEST_MODE_LABEL = "New Guest Session";
|
||||
|
||||
// Android 3.0+
|
||||
public static final String TOOLS_LABEL = "Tools";
|
||||
|
||||
// Android 2.3 and lower only
|
||||
public static final String MORE_LABEL = "More";
|
||||
public static final String RELOAD_LABEL = "Reload";
|
||||
public static final String FORWARD_LABEL = "Forward";
|
||||
public static final String BOOKMARK_LABEL = "Bookmark";
|
||||
}
|
@ -13,24 +13,23 @@ public class testBookmarkKeyword extends AboutHomeTest {
|
||||
public void testBookmarkKeyword() {
|
||||
blockForGeckoReady();
|
||||
|
||||
final String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
final String title = "Browser Blank Page 01";
|
||||
final String url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
|
||||
final String keyword = "testkeyword";
|
||||
|
||||
// Add a bookmark, and update it to have a keyword.
|
||||
addOrUpdateMobileBookmark(title, url);
|
||||
updateBookmark(url, title, keyword);
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, url);
|
||||
mDatabaseHelper.updateBookmark(url, StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, keyword);
|
||||
|
||||
// Enter the keyword in the urlbar.
|
||||
inputAndLoadUrl(keyword);
|
||||
|
||||
// Wait for the page to load.
|
||||
waitForText(title);
|
||||
waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
|
||||
|
||||
// Make sure the title of the page appeared.
|
||||
verifyPageTitle(title);
|
||||
verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
|
||||
|
||||
// Delete the bookmark to clean up.
|
||||
deleteBookmark(url);
|
||||
mDatabaseHelper.deleteBookmark(url);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class testBookmarklets extends AboutHomeTest {
|
||||
}
|
||||
|
||||
public void testBookmarklets() {
|
||||
final String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
final String url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
|
||||
final String title = "alertBookmarklet";
|
||||
final String js = "javascript:alert(12 + .34)";
|
||||
boolean alerted;
|
||||
@ -23,7 +23,7 @@ public class testBookmarklets extends AboutHomeTest {
|
||||
|
||||
// load a standard page so bookmarklets work
|
||||
inputAndLoadUrl(url);
|
||||
verifyPageTitle("Browser Blank Page 01"); // Waiting for page title to ensure the page is loaded
|
||||
verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); // Waiting for page title to ensure the page is loaded
|
||||
|
||||
// verify that user-entered bookmarklets do *not* work
|
||||
enterUrl(js);
|
||||
@ -38,7 +38,7 @@ public class testBookmarklets extends AboutHomeTest {
|
||||
|
||||
// add the bookmarklet to the database. there's currently no way to
|
||||
// add this using the UI, so we go through the content provider.
|
||||
addOrUpdateMobileBookmark(title, js);
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark(title, js);
|
||||
|
||||
// Open about:home in the Bookmarks page
|
||||
openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
|
||||
@ -77,6 +77,6 @@ public class testBookmarklets extends AboutHomeTest {
|
||||
mAsserter.is(alerted, true, "Alert was shown for clicked bookmarklet");
|
||||
|
||||
// remove the bookmarklet
|
||||
deleteBookmark(js);
|
||||
mDatabaseHelper.deleteBookmark(js);
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,7 @@ package @ANDROID_PACKAGE_NAME@.tests;
|
||||
import @ANDROID_PACKAGE_NAME@.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class testClearPrivateData extends AboutHomeTest {
|
||||
private final String BLANK1_TITLE = "Browser Blank Page 01";
|
||||
private final String BLANK2_TITLE = "Browser Blank Page 02";
|
||||
public class testClearPrivateData extends PixelTest {
|
||||
private final int TEST_WAIT_MS = 10000;
|
||||
|
||||
@Override
|
||||
@ -21,13 +19,13 @@ public class testClearPrivateData extends AboutHomeTest {
|
||||
|
||||
private void clearHistory() {
|
||||
// Loading a page and adding a second one as bookmark to have user made bookmarks and history
|
||||
String blank1 = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
String blank2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
|
||||
String blank1 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
|
||||
String blank2 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL);
|
||||
|
||||
inputAndLoadUrl(blank1);
|
||||
waitForText(BLANK1_TITLE);
|
||||
loadAndPaint(blank1);
|
||||
waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
|
||||
|
||||
addOrUpdateMobileBookmark(BLANK2_TITLE, blank2);
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, blank2);
|
||||
|
||||
// Checking that the history list is not empty
|
||||
verifyHistoryCount(1);
|
||||
@ -37,13 +35,13 @@ public class testClearPrivateData extends AboutHomeTest {
|
||||
verifyHistoryCount(0);
|
||||
|
||||
// Checking that the user made bookmark is not removed
|
||||
mAsserter.ok(isBookmark(blank2), "Checking that bookmarks have not been removed", "User made bookmarks were not removed with private data");
|
||||
mAsserter.ok(mDatabaseHelper.isBookmark(blank2), "Checking that bookmarks have not been removed", "User made bookmarks were not removed with private data");
|
||||
}
|
||||
|
||||
private void verifyHistoryCount(final int expectedCount) {
|
||||
boolean match = waitForTest( new BooleanTest() {
|
||||
public boolean test() {
|
||||
return (getBrowserDBUrls(BrowserDataType.HISTORY).size() == expectedCount);
|
||||
return (mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.HISTORY).size() == expectedCount);
|
||||
}
|
||||
}, TEST_WAIT_MS);
|
||||
mAsserter.ok(match, "Checking that the number of history items is correct", String.valueOf(expectedCount) + " history items present in the database");
|
||||
|
@ -42,15 +42,15 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
addData();
|
||||
|
||||
// Get the initial bookmarks and history
|
||||
oldFirefoxBookmarks = getBrowserDBUrls(BrowserDataType.BOOKMARKS);
|
||||
oldFirefoxHistory = getBrowserDBUrls(BrowserDataType.HISTORY);
|
||||
oldFirefoxBookmarks = mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.BOOKMARKS);
|
||||
oldFirefoxHistory = mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.HISTORY);
|
||||
|
||||
// Import the bookmarks and history
|
||||
importDataFromAndroid();
|
||||
|
||||
// Get the Android history and the Firefox bookmarks and history lists
|
||||
firefoxHistory = getBrowserDBUrls(BrowserDataType.HISTORY);
|
||||
firefoxBookmarks = getBrowserDBUrls(BrowserDataType.BOOKMARKS);
|
||||
firefoxHistory = mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.HISTORY);
|
||||
firefoxBookmarks = mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.BOOKMARKS);
|
||||
|
||||
/**
|
||||
* Add a delay to make sure the imported items are added to the array lists
|
||||
@ -90,7 +90,7 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
|
||||
// Verify bookmarks are not duplicated
|
||||
ArrayList<String> verifiedBookmarks = new ArrayList<String>();
|
||||
firefoxBookmarks = getBrowserDBUrls(BrowserDataType.BOOKMARKS);
|
||||
firefoxBookmarks = mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.BOOKMARKS);
|
||||
for (String url:firefoxBookmarks) {
|
||||
if (verifiedBookmarks.contains(url)) {
|
||||
mAsserter.ok(false, "Bookmark " + url + " should not be duplicated", "Bookmark is duplicated");
|
||||
@ -101,7 +101,7 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
}
|
||||
|
||||
// Verify history count is not increased after the second import
|
||||
mAsserter.ok(firefoxHistory.size() == getBrowserDBUrls(BrowserDataType.HISTORY).size(), "The number of history entries was not increased", "None of the items were duplicated");
|
||||
mAsserter.ok(firefoxHistory.size() == mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.HISTORY).size(), "The number of history entries was not increased", "None of the items were duplicated");
|
||||
}
|
||||
|
||||
private void addData() {
|
||||
@ -111,7 +111,7 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
for (String url:androidBookmarks) {
|
||||
// Add every 3rd bookmark to Firefox Mobile
|
||||
if ((androidBookmarks.indexOf(url) % 3) == 0) {
|
||||
addOrUpdateMobileBookmark("Bookmark Number " + String.valueOf(androidBookmarks.indexOf(url)), url);
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark("Bookmark Number" + String.valueOf(androidBookmarks.indexOf(url)), url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
|
||||
private void importDataFromAndroid() {
|
||||
waitForText("Enter Search or Address");
|
||||
selectSettingsItem("Customize", "Import from Android");
|
||||
selectSettingsItem(StringHelper.CUSTOMIZE_SECTION_LABEL, StringHelper.IMPORT_FROM_ANDROID_LABEL);
|
||||
|
||||
// Wait for the Import form Android pop-up to be opened. It has the same title as the option so waiting for the "Cancel" button
|
||||
waitForText("Cancel");
|
||||
@ -153,7 +153,7 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
// Import has finished. Waiting to get back to the Settings Menu and looking for the Import&Export subsection
|
||||
if ("phone".equals(mDevice.type)) {
|
||||
// Phones don't have headers like tablets, so we need to pop up one more level.
|
||||
waitForText("Import from Android");
|
||||
waitForText(StringHelper.IMPORT_FROM_ANDROID_LABEL);
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
}
|
||||
waitForText("Privacy"); // Settings is a header for the settings menu page. Waiting for Privacy ensures we are back in the top Settings view
|
||||
@ -196,11 +196,11 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
// Bookmarks
|
||||
ArrayList<String> androidBookmarks = getAndroidUrls("bookmarks");
|
||||
for (String url:androidBookmarks) {
|
||||
deleteBookmark(url);
|
||||
mDatabaseHelper.deleteBookmark(url);
|
||||
}
|
||||
// History
|
||||
for (String url:androidData) {
|
||||
deleteHistoryItem(url);
|
||||
mDatabaseHelper.deleteHistoryItem(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class testLinkContextMenu extends ContentContextMenuTest {
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
deleteBookmark(BLANK_PAGE_URL);
|
||||
mDatabaseHelper.deleteBookmark(BLANK_PAGE_URL);
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +33,10 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
|
||||
verifyShareOption(photoMenuItems[7], PICTURE_PAGE_TITLE); // Test the "Share Link" option
|
||||
verifyBookmarkLinkOption(photoMenuItems[8],BLANK_PAGE_URL); // Test the "Bookmark Link" option
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
mDatabaseHelper.deleteBookmark(BLANK_PAGE_URL);
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user