OLD | NEW |
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> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
17 #include "base/string16.h" | 17 #include "base/string16.h" |
18 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/tracked.h" | 20 #include "base/tracked.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
22 #include "chrome/browser/bookmarks/bookmark_model.h" | 22 #include "chrome/browser/bookmarks/bookmark_model.h" |
23 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 23 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
24 #include "chrome/browser/sync/api/sync_error.h" | |
25 #include "chrome/browser/sync/engine/syncapi.h" | 24 #include "chrome/browser/sync/engine/syncapi.h" |
26 #include "chrome/browser/sync/glue/bookmark_change_processor.h" | 25 #include "chrome/browser/sync/glue/bookmark_change_processor.h" |
27 #include "chrome/browser/sync/glue/bookmark_model_associator.h" | 26 #include "chrome/browser/sync/glue/bookmark_model_associator.h" |
28 #include "chrome/browser/sync/syncable/directory_manager.h" | 27 #include "chrome/browser/sync/syncable/directory_manager.h" |
29 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/test/sync/engine/test_id_factory.h" | 29 #include "chrome/test/sync/engine/test_id_factory.h" |
31 #include "chrome/test/sync/engine/test_user_share.h" | 30 #include "chrome/test/sync/engine/test_user_share.h" |
32 #include "chrome/test/testing_profile.h" | 31 #include "chrome/test/testing_profile.h" |
33 #include "content/browser/browser_thread.h" | 32 #include "content/browser/browser_thread.h" |
34 #include "testing/gmock/include/gmock/gmock.h" | 33 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 model_->ClearStore(); | 318 model_->ClearStore(); |
320 message_loop_.RunAllPending(); | 319 message_loop_.RunAllPending(); |
321 } | 320 } |
322 | 321 |
323 void StartSync() { | 322 void StartSync() { |
324 // Set up model associator. | 323 // Set up model associator. |
325 model_associator_.reset(new TestBookmarkModelAssociator( | 324 model_associator_.reset(new TestBookmarkModelAssociator( |
326 profile_.GetBookmarkModel(), | 325 profile_.GetBookmarkModel(), |
327 test_user_share_.user_share(), | 326 test_user_share_.user_share(), |
328 &mock_unrecoverable_error_handler_)); | 327 &mock_unrecoverable_error_handler_)); |
329 SyncError error; | 328 EXPECT_TRUE(model_associator_->AssociateModels()); |
330 EXPECT_TRUE(model_associator_->AssociateModels(&error)); | |
331 MessageLoop::current()->RunAllPending(); | 329 MessageLoop::current()->RunAllPending(); |
332 | 330 |
333 // Set up change processor. | 331 // Set up change processor. |
334 change_processor_.reset( | 332 change_processor_.reset( |
335 new BookmarkChangeProcessor(model_associator_.get(), | 333 new BookmarkChangeProcessor(model_associator_.get(), |
336 &mock_unrecoverable_error_handler_)); | 334 &mock_unrecoverable_error_handler_)); |
337 change_processor_->Start(&profile_, test_user_share_.user_share()); | 335 change_processor_->Start(&profile_, test_user_share_.user_share()); |
338 } | 336 } |
339 | 337 |
340 void StopSync() { | 338 void StopSync() { |
341 change_processor_->Stop(); | 339 change_processor_->Stop(); |
342 change_processor_.reset(); | 340 change_processor_.reset(); |
343 SyncError error; | 341 |
344 EXPECT_TRUE(model_associator_->DisassociateModels(&error)); | 342 EXPECT_TRUE(model_associator_->DisassociateModels()); |
345 model_associator_.reset(); | 343 model_associator_.reset(); |
346 | 344 |
347 message_loop_.RunAllPending(); | 345 message_loop_.RunAllPending(); |
348 | 346 |
349 // TODO(akalin): Actually close the database and flush it to disk | 347 // TODO(akalin): Actually close the database and flush it to disk |
350 // (and make StartSync reload from disk). This would require | 348 // (and make StartSync reload from disk). This would require |
351 // refactoring TestUserShare. | 349 // refactoring TestUserShare. |
352 } | 350 } |
353 | 351 |
354 void UnloadBookmarkModel() { | 352 void UnloadBookmarkModel() { |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 // Make sure we're back in sync. In real life, the user would need | 1429 // Make sure we're back in sync. In real life, the user would need |
1432 // to reauthenticate before this happens, but in the test, authentication | 1430 // to reauthenticate before this happens, but in the test, authentication |
1433 // is sidestepped. | 1431 // is sidestepped. |
1434 ExpectBookmarkModelMatchesTestData(); | 1432 ExpectBookmarkModelMatchesTestData(); |
1435 ExpectModelMatch(); | 1433 ExpectModelMatch(); |
1436 } | 1434 } |
1437 | 1435 |
1438 } // namespace | 1436 } // namespace |
1439 | 1437 |
1440 } // namespace browser_sync | 1438 } // namespace browser_sync |
OLD | NEW |