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

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

Issue 10844005: [Sync] Refactor GetEncryptedTypes usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + add dcheck Created 8 years, 4 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) 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 23 matching lines...) Expand all
34 #include "sync/internal_api/public/change_record.h" 34 #include "sync/internal_api/public/change_record.h"
35 #include "sync/internal_api/public/read_node.h" 35 #include "sync/internal_api/public/read_node.h"
36 #include "sync/internal_api/public/read_transaction.h" 36 #include "sync/internal_api/public/read_transaction.h"
37 #include "sync/internal_api/public/test/test_user_share.h" 37 #include "sync/internal_api/public/test/test_user_share.h"
38 #include "sync/internal_api/public/write_node.h" 38 #include "sync/internal_api/public/write_node.h"
39 #include "sync/internal_api/public/write_transaction.h" 39 #include "sync/internal_api/public/write_transaction.h"
40 #include "sync/syncable/mutable_entry.h" // TODO(tim): Remove. Bug 131130. 40 #include "sync/syncable/mutable_entry.h" // TODO(tim): Remove. Bug 131130.
41 #include "sync/test/engine/test_id_factory.h" 41 #include "sync/test/engine/test_id_factory.h"
42 #include "testing/gmock/include/gmock/gmock.h" 42 #include "testing/gmock/include/gmock/gmock.h"
43 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
44 #include "sync/test/fake_sync_encryption_handler.h"
45 44
46 namespace browser_sync { 45 namespace browser_sync {
47 46
48 using content::BrowserThread; 47 using content::BrowserThread;
49 using syncer::BaseNode; 48 using syncer::BaseNode;
50 using testing::_; 49 using testing::_;
51 using testing::InvokeWithoutArgs; 50 using testing::InvokeWithoutArgs;
52 using testing::Mock; 51 using testing::Mock;
53 using testing::StrictMock; 52 using testing::StrictMock;
54 53
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 model_(NULL) { 338 model_(NULL) {
340 } 339 }
341 340
342 virtual ~ProfileSyncServiceBookmarkTest() { 341 virtual ~ProfileSyncServiceBookmarkTest() {
343 StopSync(); 342 StopSync();
344 UnloadBookmarkModel(); 343 UnloadBookmarkModel();
345 } 344 }
346 345
347 virtual void SetUp() { 346 virtual void SetUp() {
348 test_user_share_.SetUp(); 347 test_user_share_.SetUp();
349 SetUpEncryption();
350 } 348 }
351 349
352 virtual void TearDown() { 350 virtual void TearDown() {
353 test_user_share_.TearDown(); 351 test_user_share_.TearDown();
354 } 352 }
355 353
356 void SetUpEncryption() {
357 syncer::ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
358 fake_encryption_handler_.set_cryptographer(trans.GetCryptographer());
359 trans.GetCryptographer()->SetNigoriHandler(&fake_encryption_handler_);
360 }
361
362 // Load (or re-load) the bookmark model. |load| controls use of the 354 // Load (or re-load) the bookmark model. |load| controls use of the
363 // bookmarks file on disk. |save| controls whether the newly loaded 355 // bookmarks file on disk. |save| controls whether the newly loaded
364 // bookmark model will write out a bookmark file as it goes. 356 // bookmark model will write out a bookmark file as it goes.
365 void LoadBookmarkModel(LoadOption load, SaveOption save) { 357 void LoadBookmarkModel(LoadOption load, SaveOption save) {
366 bool delete_bookmarks = load == DELETE_EXISTING_STORAGE; 358 bool delete_bookmarks = load == DELETE_EXISTING_STORAGE;
367 profile_.CreateBookmarkModel(delete_bookmarks); 359 profile_.CreateBookmarkModel(delete_bookmarks);
368 model_ = BookmarkModelFactory::GetForProfile(&profile_); 360 model_ = BookmarkModelFactory::GetForProfile(&profile_);
369 // Wait for the bookmarks model to load. 361 // Wait for the bookmarks model to load.
370 profile_.BlockUntilBookmarkModelLoaded(); 362 profile_.BlockUntilBookmarkModelLoaded();
371 // This noticeably speeds up the unit tests that request it. 363 // This noticeably speeds up the unit tests that request it.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 content::TestBrowserThread file_thread_; 558 content::TestBrowserThread file_thread_;
567 559
568 TestingProfile profile_; 560 TestingProfile profile_;
569 scoped_ptr<TestBookmarkModelAssociator> model_associator_; 561 scoped_ptr<TestBookmarkModelAssociator> model_associator_;
570 562
571 protected: 563 protected:
572 BookmarkModel* model_; 564 BookmarkModel* model_;
573 syncer::TestUserShare test_user_share_; 565 syncer::TestUserShare test_user_share_;
574 scoped_ptr<BookmarkChangeProcessor> change_processor_; 566 scoped_ptr<BookmarkChangeProcessor> change_processor_;
575 StrictMock<DataTypeErrorHandlerMock> mock_error_handler_; 567 StrictMock<DataTypeErrorHandlerMock> mock_error_handler_;
576 syncer::FakeSyncEncryptionHandler fake_encryption_handler_;
577 }; 568 };
578 569
579 TEST_F(ProfileSyncServiceBookmarkTest, InitialState) { 570 TEST_F(ProfileSyncServiceBookmarkTest, InitialState) {
580 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); 571 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
581 StartSync(); 572 StartSync();
582 573
583 EXPECT_TRUE(other_bookmarks_id()); 574 EXPECT_TRUE(other_bookmarks_id());
584 EXPECT_TRUE(bookmark_bar_id()); 575 EXPECT_TRUE(bookmark_bar_id());
585 EXPECT_TRUE(mobile_bookmarks_id()); 576 EXPECT_TRUE(mobile_bookmarks_id());
586 577
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 EXPECT_EQ(1, observer.get_started()); 1498 EXPECT_EQ(1, observer.get_started());
1508 EXPECT_EQ(0, observer.get_completed_count_at_started()); 1499 EXPECT_EQ(0, observer.get_completed_count_at_started());
1509 EXPECT_EQ(1, observer.get_completed()); 1500 EXPECT_EQ(1, observer.get_completed());
1510 1501
1511 model_->RemoveObserver(&observer); 1502 model_->RemoveObserver(&observer);
1512 } 1503 }
1513 1504
1514 } // namespace 1505 } // namespace
1515 1506
1516 } // namespace browser_sync 1507 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/typed_url_model_associator.cc ('k') | sync/engine/apply_updates_command_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698