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

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

Issue 6905044: Refactor preference syncing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the previous fix Created 9 years, 7 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // TODO(akalin): This file is basically just a unit test for 5 // TODO(akalin): This file is basically just a unit test for
6 // BookmarkChangeProcessor. Write unit tests for 6 // BookmarkChangeProcessor. Write unit tests for
7 // BookmarkModelAssociator separately. 7 // BookmarkModelAssociator separately.
8 8
9 #include <stack> 9 #include <stack>
10 #include <vector> 10 #include <vector>
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // Wait for the bookmarks model to load. 307 // Wait for the bookmarks model to load.
308 profile_.BlockUntilBookmarkModelLoaded(); 308 profile_.BlockUntilBookmarkModelLoaded();
309 // This noticeably speeds up the unit tests that request it. 309 // This noticeably speeds up the unit tests that request it.
310 if (save == DONT_SAVE_TO_STORAGE) 310 if (save == DONT_SAVE_TO_STORAGE)
311 model_->ClearStore(); 311 model_->ClearStore();
312 message_loop_.RunAllPending(); 312 message_loop_.RunAllPending();
313 } 313 }
314 314
315 void StartSync() { 315 void StartSync() {
316 // Set up model associator. 316 // Set up model associator.
317 model_associator_.reset(new TestBookmarkModelAssociator( 317 model_associator_ = new TestBookmarkModelAssociator(
318 profile_.GetBookmarkModel(), 318 profile_.GetBookmarkModel(),
319 test_user_share_.user_share(), 319 test_user_share_.user_share(),
320 &mock_unrecoverable_error_handler_)); 320 &mock_unrecoverable_error_handler_);
321 EXPECT_TRUE(model_associator_->AssociateModels()); 321 EXPECT_TRUE(model_associator_->AssociateModels());
322 MessageLoop::current()->RunAllPending(); 322 MessageLoop::current()->RunAllPending();
323 323
324 // Set up change processor. 324 // Set up change processor.
325 change_processor_.reset( 325 change_processor_.reset(
326 new BookmarkChangeProcessor(model_associator_.get(), 326 new BookmarkChangeProcessor(model_associator_.get(),
327 &mock_unrecoverable_error_handler_)); 327 &mock_unrecoverable_error_handler_));
328 change_processor_->Start(&profile_, test_user_share_.user_share()); 328 change_processor_->Start(&profile_, test_user_share_.user_share());
329 } 329 }
330 330
331 void StopSync() { 331 void StopSync() {
332 change_processor_->Stop(); 332 change_processor_->Stop();
333 change_processor_.reset(); 333 change_processor_.reset();
334 334
335 EXPECT_TRUE(model_associator_->DisassociateModels()); 335 EXPECT_TRUE(model_associator_->DisassociateModels());
336 model_associator_.reset(); 336 model_associator_ = NULL;
337 337
338 message_loop_.RunAllPending(); 338 message_loop_.RunAllPending();
339 339
340 // TODO(akalin): Actually close the database and flush it to disk 340 // TODO(akalin): Actually close the database and flush it to disk
341 // (and make StartSync reload from disk). This would require 341 // (and make StartSync reload from disk). This would require
342 // refactoring TestUserShare. 342 // refactoring TestUserShare.
343 } 343 }
344 344
345 void UnloadBookmarkModel() { 345 void UnloadBookmarkModel() {
346 profile_.CreateBookmarkModel(false /* delete_bookmarks */); 346 profile_.CreateBookmarkModel(false /* delete_bookmarks */);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 492 }
493 493
494 private: 494 private:
495 // Used by both |ui_thread_| and |file_thread_|. 495 // Used by both |ui_thread_| and |file_thread_|.
496 MessageLoop message_loop_; 496 MessageLoop message_loop_;
497 BrowserThread ui_thread_; 497 BrowserThread ui_thread_;
498 // Needed by |model_|. 498 // Needed by |model_|.
499 BrowserThread file_thread_; 499 BrowserThread file_thread_;
500 500
501 TestingProfile profile_; 501 TestingProfile profile_;
502 scoped_ptr<TestBookmarkModelAssociator> model_associator_; 502 scoped_refptr<TestBookmarkModelAssociator> model_associator_;
503 503
504 protected: 504 protected:
505 BookmarkModel* model_; 505 BookmarkModel* model_;
506 TestUserShare test_user_share_; 506 TestUserShare test_user_share_;
507 scoped_ptr<BookmarkChangeProcessor> change_processor_; 507 scoped_ptr<BookmarkChangeProcessor> change_processor_;
508 StrictMock<MockUnrecoverableErrorHandler> mock_unrecoverable_error_handler_; 508 StrictMock<MockUnrecoverableErrorHandler> mock_unrecoverable_error_handler_;
509 }; 509 };
510 510
511 TEST_F(ProfileSyncServiceBookmarkTest, InitialState) { 511 TEST_F(ProfileSyncServiceBookmarkTest, InitialState) {
512 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); 512 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 // Make sure we're back in sync. In real life, the user would need 1353 // Make sure we're back in sync. In real life, the user would need
1354 // to reauthenticate before this happens, but in the test, authentication 1354 // to reauthenticate before this happens, but in the test, authentication
1355 // is sidestepped. 1355 // is sidestepped.
1356 ExpectBookmarkModelMatchesTestData(); 1356 ExpectBookmarkModelMatchesTestData();
1357 ExpectModelMatch(); 1357 ExpectModelMatch();
1358 } 1358 }
1359 1359
1360 } // namespace 1360 } // namespace
1361 1361
1362 } // namespace browser_sync 1362 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698