Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 337037: Make some improvements to sync model associator:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/glue/model_associator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if defined(BROWSER_SYNC) 5 #if defined(BROWSER_SYNC)
6 6
7 #include <stack> 7 #include <stack>
8 #include <vector> 8 #include <vector>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 StartSyncService(); 1230 StartSyncService();
1231 ExpectModelMatch(); 1231 ExpectModelMatch();
1232 // Force the sync service to shut down and write itself to disk. 1232 // Force the sync service to shut down and write itself to disk.
1233 StopSyncService(SAVE_TO_STORAGE); 1233 StopSyncService(SAVE_TO_STORAGE);
1234 // Now restart the sync service. This time it should use the persistent 1234 // Now restart the sync service. This time it should use the persistent
1235 // assocations. 1235 // assocations.
1236 StartSyncService(); 1236 StartSyncService();
1237 ExpectModelMatch(); 1237 ExpectModelMatch();
1238 } 1238 }
1239 1239
1240 // Tests that when persisted model assocations are used, things work fine.
1241 TEST_F(ProfileSyncServiceTestWithData, ModelAssociationInvalidPersistence) {
1242 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
1243 WriteTestDataToBookmarkModel();
1244 StartSyncService();
1245 ExpectModelMatch();
1246 // Force the sync service to shut down and write itself to disk.
1247 StopSyncService(SAVE_TO_STORAGE);
1248 // Change the bookmark model before restarting sync service to simulate
1249 // the situation where bookmark model is different from sync model and
1250 // make sure model associator correctly rebuilds associations.
1251 const BookmarkNode* bookmark_bar_node = model_->GetBookmarkBarNode();
1252 model_->AddURL(bookmark_bar_node, 0, L"xtra", GURL("http://www.xtra.com"));
1253 // Now restart the sync service. This time it will try to use the persistent
1254 // associations and realize that they are invalid and hence will rebuild
1255 // associations.
1256 StartSyncService();
1257 ExpectModelMatch();
1258 }
1259
1240 TEST_F(ProfileSyncServiceTestWithData, SortChildren) { 1260 TEST_F(ProfileSyncServiceTestWithData, SortChildren) {
1241 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); 1261 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
1242 StartSyncService(); 1262 StartSyncService();
1243 1263
1244 // Write test data to bookmark model and verify that the models match. 1264 // Write test data to bookmark model and verify that the models match.
1245 WriteTestDataToBookmarkModel(); 1265 WriteTestDataToBookmarkModel();
1246 const BookmarkNode* folder_added = model_->other_node()->GetChild(0); 1266 const BookmarkNode* folder_added = model_->other_node()->GetChild(0);
1247 ASSERT_TRUE(folder_added); 1267 ASSERT_TRUE(folder_added);
1248 ASSERT_TRUE(folder_added->is_folder()); 1268 ASSERT_TRUE(folder_added->is_folder());
1249 1269
(...skipping 27 matching lines...) Expand all
1277 StartSyncService(); 1297 StartSyncService();
1278 1298
1279 // Make sure we're back in sync. In real life, the user would need 1299 // Make sure we're back in sync. In real life, the user would need
1280 // to reauthenticate before this happens, but in the test, authentication 1300 // to reauthenticate before this happens, but in the test, authentication
1281 // is sidestepped. 1301 // is sidestepped.
1282 ExpectBookmarkModelMatchesTestData(); 1302 ExpectBookmarkModelMatchesTestData();
1283 ExpectModelMatch(); 1303 ExpectModelMatch();
1284 } 1304 }
1285 1305
1286 #endif // defined(BROWSER_SYNC) 1306 #endif // defined(BROWSER_SYNC)
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/model_associator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698