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

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

Issue 10827266: [Sync] Add SyncEncryptionHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 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"
44 45
45 namespace browser_sync { 46 namespace browser_sync {
46 47
47 using content::BrowserThread; 48 using content::BrowserThread;
48 using syncer::BaseNode; 49 using syncer::BaseNode;
49 using testing::_; 50 using testing::_;
50 using testing::InvokeWithoutArgs; 51 using testing::InvokeWithoutArgs;
51 using testing::Mock; 52 using testing::Mock;
52 using testing::StrictMock; 53 using testing::StrictMock;
53 54
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 model_(NULL) { 339 model_(NULL) {
339 } 340 }
340 341
341 virtual ~ProfileSyncServiceBookmarkTest() { 342 virtual ~ProfileSyncServiceBookmarkTest() {
342 StopSync(); 343 StopSync();
343 UnloadBookmarkModel(); 344 UnloadBookmarkModel();
344 } 345 }
345 346
346 virtual void SetUp() { 347 virtual void SetUp() {
347 test_user_share_.SetUp(); 348 test_user_share_.SetUp();
349 SetUpEncryption();
348 } 350 }
349 351
350 virtual void TearDown() { 352 virtual void TearDown() {
351 test_user_share_.TearDown(); 353 test_user_share_.TearDown();
352 } 354 }
353 355
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
354 // Load (or re-load) the bookmark model. |load| controls use of the 362 // Load (or re-load) the bookmark model. |load| controls use of the
355 // bookmarks file on disk. |save| controls whether the newly loaded 363 // bookmarks file on disk. |save| controls whether the newly loaded
356 // bookmark model will write out a bookmark file as it goes. 364 // bookmark model will write out a bookmark file as it goes.
357 void LoadBookmarkModel(LoadOption load, SaveOption save) { 365 void LoadBookmarkModel(LoadOption load, SaveOption save) {
358 bool delete_bookmarks = load == DELETE_EXISTING_STORAGE; 366 bool delete_bookmarks = load == DELETE_EXISTING_STORAGE;
359 profile_.CreateBookmarkModel(delete_bookmarks); 367 profile_.CreateBookmarkModel(delete_bookmarks);
360 model_ = BookmarkModelFactory::GetForProfile(&profile_); 368 model_ = BookmarkModelFactory::GetForProfile(&profile_);
361 // Wait for the bookmarks model to load. 369 // Wait for the bookmarks model to load.
362 profile_.BlockUntilBookmarkModelLoaded(); 370 profile_.BlockUntilBookmarkModelLoaded();
363 // This noticeably speeds up the unit tests that request it. 371 // This noticeably speeds up the unit tests that request it.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 content::TestBrowserThread file_thread_; 566 content::TestBrowserThread file_thread_;
559 567
560 TestingProfile profile_; 568 TestingProfile profile_;
561 scoped_ptr<TestBookmarkModelAssociator> model_associator_; 569 scoped_ptr<TestBookmarkModelAssociator> model_associator_;
562 570
563 protected: 571 protected:
564 BookmarkModel* model_; 572 BookmarkModel* model_;
565 syncer::TestUserShare test_user_share_; 573 syncer::TestUserShare test_user_share_;
566 scoped_ptr<BookmarkChangeProcessor> change_processor_; 574 scoped_ptr<BookmarkChangeProcessor> change_processor_;
567 StrictMock<DataTypeErrorHandlerMock> mock_error_handler_; 575 StrictMock<DataTypeErrorHandlerMock> mock_error_handler_;
576 syncer::FakeSyncEncryptionHandler fake_encryption_handler_;
568 }; 577 };
569 578
570 TEST_F(ProfileSyncServiceBookmarkTest, InitialState) { 579 TEST_F(ProfileSyncServiceBookmarkTest, InitialState) {
571 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); 580 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
572 StartSync(); 581 StartSync();
573 582
574 EXPECT_TRUE(other_bookmarks_id()); 583 EXPECT_TRUE(other_bookmarks_id());
575 EXPECT_TRUE(bookmark_bar_id()); 584 EXPECT_TRUE(bookmark_bar_id());
576 EXPECT_TRUE(mobile_bookmarks_id()); 585 EXPECT_TRUE(mobile_bookmarks_id());
577 586
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 TEST_F(ProfileSyncServiceBookmarkTestWithData, 1475 TEST_F(ProfileSyncServiceBookmarkTestWithData,
1467 RecoverAfterDeletingSyncDataDirectory) { 1476 RecoverAfterDeletingSyncDataDirectory) {
1468 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE); 1477 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE);
1469 StartSync(); 1478 StartSync();
1470 1479
1471 WriteTestDataToBookmarkModel(); 1480 WriteTestDataToBookmarkModel();
1472 1481
1473 StopSync(); 1482 StopSync();
1474 1483
1475 // Nuke the sync DB and reload. 1484 // Nuke the sync DB and reload.
1476 test_user_share_.TearDown(); 1485 TearDown();
1477 test_user_share_.SetUp(); 1486 SetUp();
1478 1487
1479 StartSync(); 1488 StartSync();
1480 1489
1481 // Make sure we're back in sync. In real life, the user would need 1490 // Make sure we're back in sync. In real life, the user would need
1482 // to reauthenticate before this happens, but in the test, authentication 1491 // to reauthenticate before this happens, but in the test, authentication
1483 // is sidestepped. 1492 // is sidestepped.
1484 ExpectBookmarkModelMatchesTestData(); 1493 ExpectBookmarkModelMatchesTestData();
1485 ExpectModelMatch(); 1494 ExpectModelMatch();
1486 } 1495 }
1487 1496
(...skipping 10 matching lines...) Expand all
1498 EXPECT_EQ(1, observer.get_started()); 1507 EXPECT_EQ(1, observer.get_started());
1499 EXPECT_EQ(0, observer.get_completed_count_at_started()); 1508 EXPECT_EQ(0, observer.get_completed_count_at_started());
1500 EXPECT_EQ(1, observer.get_completed()); 1509 EXPECT_EQ(1, observer.get_completed());
1501 1510
1502 model_->RemoveObserver(&observer); 1511 model_->RemoveObserver(&observer);
1503 } 1512 }
1504 1513
1505 } // namespace 1514 } // namespace
1506 1515
1507 } // namespace browser_sync 1516 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/profile_sync_service_password_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698