Commit 44547d35 authored by maxbogue's avatar maxbogue Committed by Commit bot

[Sync] Break up the Android BookmarksTest cases more.

This change addresses some concerns raised post-submit in my
previous CL: http://crrev.com/1151833003

BUG=480604

Review URL: https://codereview.chromium.org/1156573006

Cr-Commit-Position: refs/heads/master@{#333082}
parent 422456f9
...@@ -37,6 +37,7 @@ public class BookmarksTest extends SyncTestBase { ...@@ -37,6 +37,7 @@ public class BookmarksTest extends SyncTestBase {
private BookmarksBridge mBookmarksBridge; private BookmarksBridge mBookmarksBridge;
// A container to store bookmark information for data verification.
private static class Bookmark { private static class Bookmark {
public final String id; public final String id;
public final String title; public final String title;
...@@ -56,18 +57,22 @@ public class BookmarksTest extends SyncTestBase { ...@@ -56,18 +57,22 @@ public class BookmarksTest extends SyncTestBase {
@Override @Override
public void run() { public void run() {
mBookmarksBridge = new BookmarksBridge(Profile.getLastUsedProfile()); mBookmarksBridge = new BookmarksBridge(Profile.getLastUsedProfile());
// The BookmarksBridge needs to know how to handle partner bookmarks.
// Without this call to fake that knowledge for testing, it crashes.
mBookmarksBridge.loadEmptyPartnerBookmarkShimForTesting(); mBookmarksBridge.loadEmptyPartnerBookmarkShimForTesting();
} }
}); });
setupTestAccountAndSignInToSync(CLIENT_ID);
// Make sure initial state is clean.
assertClientBookmarkCount(0);
assertServerBookmarkCountWithName(0, TITLE);
assertServerBookmarkCountWithName(0, MODIFIED_TITLE);
} }
// Test syncing bookmark data from server to client: a new bookmark and a tombstone. // Test syncing a new bookmark from server to client.
@LargeTest @LargeTest
@Feature({"Sync"}) @Feature({"Sync"})
public void testDownloadAndDeleteBookmark() throws Exception { public void testDownloadBookmark() throws Exception {
setupTestAccountAndSignInToSync(CLIENT_ID);
assertClientBookmarkCount(0);
addServerBookmarkAndSync(TITLE, URL); addServerBookmarkAndSync(TITLE, URL);
List<Bookmark> bookmarks = getClientBookmarks(); List<Bookmark> bookmarks = getClientBookmarks();
assertEquals("Only the injected bookmark should exist on the client.", assertEquals("Only the injected bookmark should exist on the client.",
...@@ -75,23 +80,39 @@ public class BookmarksTest extends SyncTestBase { ...@@ -75,23 +80,39 @@ public class BookmarksTest extends SyncTestBase {
Bookmark bookmark = bookmarks.get(0); Bookmark bookmark = bookmarks.get(0);
assertEquals("The wrong title was found for the bookmark.", TITLE, bookmark.title); assertEquals("The wrong title was found for the bookmark.", TITLE, bookmark.title);
assertEquals("The wrong URL was found for the bookmark.", URL, bookmark.url); assertEquals("The wrong URL was found for the bookmark.", URL, bookmark.url);
}
// Test syncing a bookmark tombstone from server to client.
@LargeTest
@Feature({"Sync"})
public void testDownloadBookmarkTombstone() throws Exception {
// Add the entity to test deleting.
addServerBookmarkAndSync(TITLE, URL);
waitForServerBookmarkCountWithName(1, TITLE);
waitForClientBookmarkCount(1);
// Delete on server, sync, and verify deleted locally.
Bookmark bookmark = getClientBookmarks().get(0);
mFakeServerHelper.deleteEntity(bookmark.id); mFakeServerHelper.deleteEntity(bookmark.id);
waitForServerBookmarkCountWithName(0, TITLE); waitForServerBookmarkCountWithName(0, TITLE);
SyncTestUtil.triggerSyncAndWaitForCompletion(mContext); SyncTestUtil.triggerSyncAndWaitForCompletion(mContext);
waitForClientBookmarkCount(0); waitForClientBookmarkCount(0);
} }
// Test syncing bookmark data from client to server: a new bookmark, a modification, // Test syncing a new bookmark from client to server.
// and a tombstone.
@LargeTest @LargeTest
@Feature({"Sync"}) @Feature({"Sync"})
public void testUploadModifyAndDeleteBookmark() throws Exception { public void testUploadBookmark() throws Exception {
setupTestAccountAndSignInToSync(CLIENT_ID); addClientBookmark(TITLE, URL);
assertClientBookmarkCount(0); waitForClientBookmarkCount(1);
assertServerBookmarkCountWithName(0, TITLE); waitForServerBookmarkCountWithName(1, TITLE);
assertServerBookmarkCountWithName(0, MODIFIED_TITLE); }
// Test syncing a bookmark modification from client to server.
@LargeTest
@Feature({"Sync"})
public void testUploadBookmarkModification() throws Exception {
// Add the entity to test modifying.
BookmarkId bookmarkId = addClientBookmark(TITLE, URL); BookmarkId bookmarkId = addClientBookmark(TITLE, URL);
waitForClientBookmarkCount(1); waitForClientBookmarkCount(1);
waitForServerBookmarkCountWithName(1, TITLE); waitForServerBookmarkCountWithName(1, TITLE);
...@@ -99,6 +120,16 @@ public class BookmarksTest extends SyncTestBase { ...@@ -99,6 +120,16 @@ public class BookmarksTest extends SyncTestBase {
setClientBookmarkTitle(bookmarkId, MODIFIED_TITLE); setClientBookmarkTitle(bookmarkId, MODIFIED_TITLE);
waitForServerBookmarkCountWithName(1, MODIFIED_TITLE); waitForServerBookmarkCountWithName(1, MODIFIED_TITLE);
assertServerBookmarkCountWithName(0, TITLE); assertServerBookmarkCountWithName(0, TITLE);
}
// Test syncing a bookmark tombstone from client to server.
@LargeTest
@Feature({"Sync"})
public void testUploadBookmarkTombstone() throws Exception {
// Add the entity to test deleting.
BookmarkId bookmarkId = addClientBookmark(TITLE, URL);
waitForClientBookmarkCount(1);
waitForServerBookmarkCountWithName(1, TITLE);
deleteClientBookmark(bookmarkId); deleteClientBookmark(bookmarkId);
waitForClientBookmarkCount(0); waitForClientBookmarkCount(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment