2013-11-07 08:18:51 -08:00
|
|
|
package org.mozilla.gecko.tests;
|
2011-12-16 11:27:52 -08:00
|
|
|
|
2013-08-19 07:11:09 -07:00
|
|
|
|
|
|
|
public class testBookmark extends AboutHomeTest {
|
|
|
|
private static String BOOKMARK_URL;
|
|
|
|
private static int WAIT_FOR_BOOKMARKED_TIMEOUT = 10000;
|
|
|
|
|
2012-01-05 07:20:22 -08:00
|
|
|
public void testBookmark() {
|
2013-08-19 07:11:09 -07:00
|
|
|
BOOKMARK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
|
|
|
|
runAboutHomeTest();
|
2012-03-23 17:38:50 -07:00
|
|
|
runMenuTest();
|
|
|
|
}
|
2012-02-10 06:44:06 -08:00
|
|
|
|
2012-03-23 17:38:50 -07:00
|
|
|
public void runMenuTest() {
|
2013-08-19 07:11:09 -07:00
|
|
|
mAsserter.is(mDatabaseHelper.isBookmark(BOOKMARK_URL), false, "Page is not bookmarked initially");
|
|
|
|
setUpBookmark(); // loads the page, taps the star button, and waits for the "Bookmark Added" message
|
|
|
|
waitForBookmarked(true);
|
2012-03-23 17:38:50 -07:00
|
|
|
|
2013-08-19 07:11:09 -07:00
|
|
|
cleanUpBookmark(); // loads the page, taps the star button, and waits for the "Bookmark Removed" message
|
|
|
|
waitForBookmarked(false);
|
|
|
|
}
|
2012-08-23 08:20:42 -07:00
|
|
|
|
2013-08-19 07:11:09 -07:00
|
|
|
public void runAboutHomeTest() {
|
2012-10-25 12:37:39 -07:00
|
|
|
blockForGeckoReady();
|
2013-08-19 07:11:09 -07:00
|
|
|
for (String url:StringHelper.DEFAULT_BOOKMARKS_URLS) {
|
|
|
|
mAsserter.ok(mDatabaseHelper.isBookmark(url), "Checking that " + url + " is bookmarked by default", url + " is bookmarked");
|
2012-03-23 17:38:50 -07:00
|
|
|
}
|
|
|
|
|
2013-08-19 07:11:09 -07:00
|
|
|
mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, BOOKMARK_URL);
|
|
|
|
waitForBookmarked(true);
|
2013-07-12 10:51:41 -07:00
|
|
|
|
2013-08-20 00:26:55 -07:00
|
|
|
isBookmarkDisplayed(BOOKMARK_URL);
|
2013-08-19 07:11:09 -07:00
|
|
|
loadBookmark(BOOKMARK_URL);
|
|
|
|
waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
|
|
|
|
verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
|
2012-02-23 10:48:48 -08:00
|
|
|
|
2013-08-19 07:11:09 -07:00
|
|
|
mDatabaseHelper.deleteBookmark(BOOKMARK_URL);
|
|
|
|
waitForBookmarked(false);
|
2012-03-23 17:38:50 -07:00
|
|
|
}
|
|
|
|
|
2013-08-19 07:11:09 -07:00
|
|
|
private void waitForBookmarked(final boolean isBookmarked) {
|
|
|
|
boolean bookmarked = waitForTest(new BooleanTest() {
|
2013-02-26 21:48:00 -08:00
|
|
|
@Override
|
2012-03-23 17:38:50 -07:00
|
|
|
public boolean test() {
|
2013-10-14 11:05:08 -07:00
|
|
|
return (isBookmarked) ?
|
|
|
|
mDatabaseHelper.isBookmark(BOOKMARK_URL) :
|
|
|
|
!mDatabaseHelper.isBookmark(BOOKMARK_URL);
|
2012-03-23 17:38:50 -07:00
|
|
|
}
|
2013-08-19 07:11:09 -07:00
|
|
|
}, WAIT_FOR_BOOKMARKED_TIMEOUT);
|
2013-10-14 11:05:08 -07:00
|
|
|
mAsserter.is(bookmarked, true, BOOKMARK_URL + " was " + (isBookmarked ? "added as a bookmark" : "removed from bookmarks"));
|
2012-02-23 10:48:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void setUpBookmark() {
|
|
|
|
// Bookmark a page for the test
|
2013-08-19 07:11:09 -07:00
|
|
|
loadUrl(BOOKMARK_URL);
|
|
|
|
waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
|
2013-10-23 07:13:53 -07:00
|
|
|
toggleBookmark();
|
2013-08-19 07:11:09 -07:00
|
|
|
mAsserter.is(waitForText(StringHelper.BOOKMARK_ADDED_LABEL), true, "bookmark added successfully");
|
2012-02-23 10:48:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void cleanUpBookmark() {
|
|
|
|
// Go back to the page we bookmarked
|
2013-08-19 07:11:09 -07:00
|
|
|
loadUrl(BOOKMARK_URL);
|
|
|
|
waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
|
2013-10-23 07:13:53 -07:00
|
|
|
toggleBookmark();
|
2013-08-19 07:11:09 -07:00
|
|
|
mAsserter.is(waitForText(StringHelper.BOOKMARK_REMOVED_LABEL), true, "bookmark removed successfully");
|
2012-01-05 07:20:22 -08:00
|
|
|
}
|
2011-12-16 11:27:52 -08:00
|
|
|
}
|