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

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

Issue 8561031: Replace ScopedCommandLineOverride with TestSuite listener. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
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>
11 11
12 #include "base/command_line.h"
13 #include "base/file_path.h" 12 #include "base/file_path.h"
14 #include "base/file_util.h" 13 #include "base/file_util.h"
15 #include "base/location.h" 14 #include "base/location.h"
16 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop.h" 16 #include "base/message_loop.h"
18 #include "base/string16.h" 17 #include "base/string16.h"
19 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
20 #include "base/string_util.h" 19 #include "base/string_util.h"
21 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
22 #include "chrome/browser/bookmarks/bookmark_model.h" 21 #include "chrome/browser/bookmarks/bookmark_model.h"
23 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 22 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
24 #include "chrome/browser/sync/api/sync_error.h" 23 #include "chrome/browser/sync/api/sync_error.h"
25 #include "chrome/browser/sync/glue/bookmark_change_processor.h" 24 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
26 #include "chrome/browser/sync/glue/bookmark_model_associator.h" 25 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
27 #include "chrome/browser/sync/internal_api/change_record.h" 26 #include "chrome/browser/sync/internal_api/change_record.h"
28 #include "chrome/browser/sync/internal_api/read_node.h" 27 #include "chrome/browser/sync/internal_api/read_node.h"
29 #include "chrome/browser/sync/internal_api/read_transaction.h" 28 #include "chrome/browser/sync/internal_api/read_transaction.h"
30 #include "chrome/browser/sync/internal_api/write_node.h" 29 #include "chrome/browser/sync/internal_api/write_node.h"
31 #include "chrome/browser/sync/internal_api/write_transaction.h" 30 #include "chrome/browser/sync/internal_api/write_transaction.h"
32 #include "chrome/browser/sync/syncable/directory_manager.h" 31 #include "chrome/browser/sync/syncable/directory_manager.h"
33 #include "chrome/browser/sync/test/engine/test_id_factory.h" 32 #include "chrome/browser/sync/test/engine/test_id_factory.h"
34 #include "chrome/browser/sync/test/engine/test_user_share.h" 33 #include "chrome/browser/sync/test/engine/test_user_share.h"
35 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
35 #include "chrome/test/base/scoped_command_line_override.h"
36 #include "chrome/test/base/testing_profile.h" 36 #include "chrome/test/base/testing_profile.h"
37 #include "content/test/test_browser_thread.h" 37 #include "content/test/test_browser_thread.h"
38 #include "testing/gmock/include/gmock/gmock.h" 38 #include "testing/gmock/include/gmock/gmock.h"
39 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
40 40
41 namespace browser_sync { 41 namespace browser_sync {
42 42
43 using testing::_; 43 using testing::_;
44 using testing::InvokeWithoutArgs; 44 using testing::InvokeWithoutArgs;
45 using testing::Mock; 45 using testing::Mock;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()) { 290 override_(switches::kEnableSyncedBookmarksFolder) {
291 } 291 }
292 292
293 virtual ~ProfileSyncServiceBookmarkTest() { 293 virtual ~ProfileSyncServiceBookmarkTest() {
294 StopSync(); 294 StopSync();
295 UnloadBookmarkModel(); 295 UnloadBookmarkModel();
296 } 296 }
297 297
298 virtual void SetUp() { 298 virtual void SetUp() {
299 test_user_share_.SetUp(); 299 test_user_share_.SetUp();
300 CommandLine::ForCurrentProcess()->AppendSwitch(
301 switches::kEnableSyncedBookmarksFolder);
302 } 300 }
303 301
304 virtual void TearDown() { 302 virtual void TearDown() {
305 test_user_share_.TearDown(); 303 test_user_share_.TearDown();
306 *CommandLine::ForCurrentProcess() = original_command_line_;
307 } 304 }
308 305
309 // Load (or re-load) the bookmark model. |load| controls use of the 306 // Load (or re-load) the bookmark model. |load| controls use of the
310 // bookmarks file on disk. |save| controls whether the newly loaded 307 // bookmarks file on disk. |save| controls whether the newly loaded
311 // bookmark model will write out a bookmark file as it goes. 308 // bookmark model will write out a bookmark file as it goes.
312 void LoadBookmarkModel(LoadOption load, SaveOption save) { 309 void LoadBookmarkModel(LoadOption load, SaveOption save) {
313 bool delete_bookmarks = load == DELETE_EXISTING_STORAGE; 310 bool delete_bookmarks = load == DELETE_EXISTING_STORAGE;
314 profile_.CreateBookmarkModel(delete_bookmarks); 311 profile_.CreateBookmarkModel(delete_bookmarks);
315 model_ = profile_.GetBookmarkModel(); 312 model_ = profile_.GetBookmarkModel();
316 // Wait for the bookmarks model to load. 313 // Wait for the bookmarks model to load.
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 MessageLoop message_loop_; 507 MessageLoop message_loop_;
511 content::TestBrowserThread ui_thread_; 508 content::TestBrowserThread ui_thread_;
512 // Needed by |model_|. 509 // Needed by |model_|.
513 content::TestBrowserThread file_thread_; 510 content::TestBrowserThread file_thread_;
514 511
515 TestingProfile profile_; 512 TestingProfile profile_;
516 scoped_ptr<TestBookmarkModelAssociator> model_associator_; 513 scoped_ptr<TestBookmarkModelAssociator> model_associator_;
517 514
518 protected: 515 protected:
519 BookmarkModel* model_; 516 BookmarkModel* model_;
520 CommandLine original_command_line_; 517 ScopedCommandLineOverride override_;
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698