diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 06:48:15 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 06:48:15 +0000 |
commit | 6536c99fc129175331b21855f20c089c0cda44d6 (patch) | |
tree | f3698842574a52a51256329a7fff2376c8064a70 /chrome/browser/sync/profile_sync_service_unittest.cc | |
parent | 327344ef227af4c66b42cb7e948d4c4096eab83f (diff) | |
download | chromium_src-6536c99fc129175331b21855f20c089c0cda44d6.zip chromium_src-6536c99fc129175331b21855f20c089c0cda44d6.tar.gz chromium_src-6536c99fc129175331b21855f20c089c0cda44d6.tar.bz2 |
Make some improvements to sync model associator:
- Fail the load assocications if there the total number of
nodes in the bookmark model and the sync model don't match
(issue: 25542)
- Add a bookmark id index and use that during load assocications
instead of calling BookmarkModel::GetNodeByID since the latter
traverses the entier tree in DFS order until it finds the node
with the given ID.
- Add a unit test that would exercise the new model associator
load associations behavior.
BUG=25542
TEST=Unit test added.
Review URL: http://codereview.chromium.org/337037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/profile_sync_service_unittest.cc')
-rw-r--r-- | chrome/browser/sync/profile_sync_service_unittest.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc index 760f51f..30fea8b 100644 --- a/chrome/browser/sync/profile_sync_service_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_unittest.cc @@ -1235,6 +1235,26 @@ TEST_F(ProfileSyncServiceTestWithData, ModelAssociationPersistence) { ExpectModelMatch(); } +// Tests that when persisted model assocations are used, things work fine. +TEST_F(ProfileSyncServiceTestWithData, ModelAssociationInvalidPersistence) { + LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); + WriteTestDataToBookmarkModel(); + StartSyncService(); + ExpectModelMatch(); + // Force the sync service to shut down and write itself to disk. + StopSyncService(SAVE_TO_STORAGE); + // Change the bookmark model before restarting sync service to simulate + // the situation where bookmark model is different from sync model and + // make sure model associator correctly rebuilds associations. + const BookmarkNode* bookmark_bar_node = model_->GetBookmarkBarNode(); + model_->AddURL(bookmark_bar_node, 0, L"xtra", GURL("http://www.xtra.com")); + // Now restart the sync service. This time it will try to use the persistent + // associations and realize that they are invalid and hence will rebuild + // associations. + StartSyncService(); + ExpectModelMatch(); +} + TEST_F(ProfileSyncServiceTestWithData, SortChildren) { LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); StartSyncService(); |