| 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> |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 }; | 279 }; |
| 280 | 280 |
| 281 class ProfileSyncServiceBookmarkTest : public testing::Test { | 281 class ProfileSyncServiceBookmarkTest : public testing::Test { |
| 282 protected: | 282 protected: |
| 283 enum LoadOption { LOAD_FROM_STORAGE, DELETE_EXISTING_STORAGE }; | 283 enum LoadOption { LOAD_FROM_STORAGE, DELETE_EXISTING_STORAGE }; |
| 284 enum SaveOption { SAVE_TO_STORAGE, DONT_SAVE_TO_STORAGE }; | 284 enum SaveOption { SAVE_TO_STORAGE, DONT_SAVE_TO_STORAGE }; |
| 285 | 285 |
| 286 ProfileSyncServiceBookmarkTest() | 286 ProfileSyncServiceBookmarkTest() |
| 287 : ui_thread_(BrowserThread::UI, &message_loop_), | 287 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 288 file_thread_(BrowserThread::FILE, &message_loop_), | 288 file_thread_(BrowserThread::FILE, &message_loop_), |
| 289 model_(NULL), | 289 model_(NULL) { |
| 290 original_command_line_(*CommandLine::ForCurrentProcess()) { | |
| 291 } | 290 } |
| 292 | 291 |
| 293 virtual ~ProfileSyncServiceBookmarkTest() { | 292 virtual ~ProfileSyncServiceBookmarkTest() { |
| 294 StopSync(); | 293 StopSync(); |
| 295 UnloadBookmarkModel(); | 294 UnloadBookmarkModel(); |
| 296 } | 295 } |
| 297 | 296 |
| 298 virtual void SetUp() { | 297 virtual void SetUp() { |
| 299 test_user_share_.SetUp(); | 298 test_user_share_.SetUp(); |
| 300 CommandLine::ForCurrentProcess()->AppendSwitch( | 299 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 301 switches::kEnableSyncedBookmarksFolder); | 300 switches::kEnableSyncedBookmarksFolder); |
| 302 } | 301 } |
| 303 | 302 |
| 304 virtual void TearDown() { | 303 virtual void TearDown() { |
| 305 test_user_share_.TearDown(); | 304 test_user_share_.TearDown(); |
| 306 *CommandLine::ForCurrentProcess() = original_command_line_; | |
| 307 } | 305 } |
| 308 | 306 |
| 309 // Load (or re-load) the bookmark model. |load| controls use of the | 307 // Load (or re-load) the bookmark model. |load| controls use of the |
| 310 // bookmarks file on disk. |save| controls whether the newly loaded | 308 // bookmarks file on disk. |save| controls whether the newly loaded |
| 311 // bookmark model will write out a bookmark file as it goes. | 309 // bookmark model will write out a bookmark file as it goes. |
| 312 void LoadBookmarkModel(LoadOption load, SaveOption save) { | 310 void LoadBookmarkModel(LoadOption load, SaveOption save) { |
| 313 bool delete_bookmarks = load == DELETE_EXISTING_STORAGE; | 311 bool delete_bookmarks = load == DELETE_EXISTING_STORAGE; |
| 314 profile_.CreateBookmarkModel(delete_bookmarks); | 312 profile_.CreateBookmarkModel(delete_bookmarks); |
| 315 model_ = profile_.GetBookmarkModel(); | 313 model_ = profile_.GetBookmarkModel(); |
| 316 // Wait for the bookmarks model to load. | 314 // Wait for the bookmarks model to load. |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 MessageLoop message_loop_; | 508 MessageLoop message_loop_; |
| 511 content::TestBrowserThread ui_thread_; | 509 content::TestBrowserThread ui_thread_; |
| 512 // Needed by |model_|. | 510 // Needed by |model_|. |
| 513 content::TestBrowserThread file_thread_; | 511 content::TestBrowserThread file_thread_; |
| 514 | 512 |
| 515 TestingProfile profile_; | 513 TestingProfile profile_; |
| 516 scoped_ptr<TestBookmarkModelAssociator> model_associator_; | 514 scoped_ptr<TestBookmarkModelAssociator> model_associator_; |
| 517 | 515 |
| 518 protected: | 516 protected: |
| 519 BookmarkModel* model_; | 517 BookmarkModel* model_; |
| 520 CommandLine original_command_line_; | |
| 521 TestUserShare test_user_share_; | 518 TestUserShare test_user_share_; |
| 522 scoped_ptr<BookmarkChangeProcessor> change_processor_; | 519 scoped_ptr<BookmarkChangeProcessor> change_processor_; |
| 523 StrictMock<MockUnrecoverableErrorHandler> mock_unrecoverable_error_handler_; | 520 StrictMock<MockUnrecoverableErrorHandler> mock_unrecoverable_error_handler_; |
| 524 }; | 521 }; |
| 525 | 522 |
| 526 TEST_F(ProfileSyncServiceBookmarkTest, InitialState) { | 523 TEST_F(ProfileSyncServiceBookmarkTest, InitialState) { |
| 527 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); | 524 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); |
| 528 StartSync(); | 525 StartSync(); |
| 529 | 526 |
| 530 EXPECT_TRUE(other_bookmarks_id()); | 527 EXPECT_TRUE(other_bookmarks_id()); |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 // 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 |
| 1433 // to reauthenticate before this happens, but in the test, authentication | 1430 // to reauthenticate before this happens, but in the test, authentication |
| 1434 // is sidestepped. | 1431 // is sidestepped. |
| 1435 ExpectBookmarkModelMatchesTestData(); | 1432 ExpectBookmarkModelMatchesTestData(); |
| 1436 ExpectModelMatch(); | 1433 ExpectModelMatch(); |
| 1437 } | 1434 } |
| 1438 | 1435 |
| 1439 } // namespace | 1436 } // namespace |
| 1440 | 1437 |
| 1441 } // namespace browser_sync | 1438 } // namespace browser_sync |
| OLD | NEW |