OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 model_->ClearStore(); | 353 model_->ClearStore(); |
354 message_loop_.RunAllPending(); | 354 message_loop_.RunAllPending(); |
355 } | 355 } |
356 | 356 |
357 void StartSync() { | 357 void StartSync() { |
358 // Set up model associator. | 358 // Set up model associator. |
359 model_associator_.reset(new TestBookmarkModelAssociator( | 359 model_associator_.reset(new TestBookmarkModelAssociator( |
360 profile_.GetBookmarkModel(), | 360 profile_.GetBookmarkModel(), |
361 test_user_share_.user_share(), | 361 test_user_share_.user_share(), |
362 &mock_error_handler_)); | 362 &mock_error_handler_)); |
363 SyncError error; | 363 SyncError error = model_associator_->AssociateModels(); |
364 EXPECT_TRUE(model_associator_->AssociateModels(&error)); | 364 EXPECT_FALSE(error.IsSet()); |
365 MessageLoop::current()->RunAllPending(); | 365 MessageLoop::current()->RunAllPending(); |
366 | 366 |
367 // Set up change processor. | 367 // Set up change processor. |
368 change_processor_.reset( | 368 change_processor_.reset( |
369 new BookmarkChangeProcessor(model_associator_.get(), | 369 new BookmarkChangeProcessor(model_associator_.get(), |
370 &mock_error_handler_)); | 370 &mock_error_handler_)); |
371 change_processor_->Start(&profile_, test_user_share_.user_share()); | 371 change_processor_->Start(&profile_, test_user_share_.user_share()); |
372 } | 372 } |
373 | 373 |
374 void StopSync() { | 374 void StopSync() { |
375 change_processor_->Stop(); | 375 change_processor_->Stop(); |
376 change_processor_.reset(); | 376 change_processor_.reset(); |
377 SyncError error; | 377 SyncError error = model_associator_->DisassociateModels(); |
378 EXPECT_TRUE(model_associator_->DisassociateModels(&error)); | 378 EXPECT_FALSE(error.IsSet()); |
379 model_associator_.reset(); | 379 model_associator_.reset(); |
380 | 380 |
381 message_loop_.RunAllPending(); | 381 message_loop_.RunAllPending(); |
382 | 382 |
383 // TODO(akalin): Actually close the database and flush it to disk | 383 // TODO(akalin): Actually close the database and flush it to disk |
384 // (and make StartSync reload from disk). This would require | 384 // (and make StartSync reload from disk). This would require |
385 // refactoring TestUserShare. | 385 // refactoring TestUserShare. |
386 } | 386 } |
387 | 387 |
388 void UnloadBookmarkModel() { | 388 void UnloadBookmarkModel() { |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 EXPECT_EQ(1, observer.get_started()); | 1486 EXPECT_EQ(1, observer.get_started()); |
1487 EXPECT_EQ(0, observer.get_completed_count_at_started()); | 1487 EXPECT_EQ(0, observer.get_completed_count_at_started()); |
1488 EXPECT_EQ(1, observer.get_completed()); | 1488 EXPECT_EQ(1, observer.get_completed()); |
1489 | 1489 |
1490 model_->RemoveObserver(&observer); | 1490 model_->RemoveObserver(&observer); |
1491 } | 1491 } |
1492 | 1492 |
1493 } // namespace | 1493 } // namespace |
1494 | 1494 |
1495 } // namespace browser_sync | 1495 } // namespace browser_sync |
OLD | NEW |