OLD | NEW |
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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 } | 681 } |
682 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE { | 682 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE { |
683 delete http; | 683 delete http; |
684 } | 684 } |
685 }; | 685 }; |
686 | 686 |
687 class SyncManagerObserverMock : public SyncManager::Observer { | 687 class SyncManagerObserverMock : public SyncManager::Observer { |
688 public: | 688 public: |
689 MOCK_METHOD1(OnSyncCycleCompleted, | 689 MOCK_METHOD1(OnSyncCycleCompleted, |
690 void(const SyncSessionSnapshot&)); // NOLINT | 690 void(const SyncSessionSnapshot&)); // NOLINT |
691 MOCK_METHOD2(OnInitializationComplete, | 691 MOCK_METHOD3(OnInitializationComplete, |
692 void(const WeakHandle<JsBackend>&, bool)); // NOLINT | 692 void(const WeakHandle<JsBackend>&, bool, |
| 693 syncable::ModelTypeSet)); // NOLINT |
693 MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT | 694 MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT |
694 MOCK_METHOD2(OnPassphraseRequired, | 695 MOCK_METHOD2(OnPassphraseRequired, |
695 void(sync_api::PassphraseRequiredReason, | 696 void(sync_api::PassphraseRequiredReason, |
696 const sync_pb::EncryptedData&)); // NOLINT | 697 const sync_pb::EncryptedData&)); // NOLINT |
697 MOCK_METHOD0(OnPassphraseAccepted, void()); // NOLINT | 698 MOCK_METHOD0(OnPassphraseAccepted, void()); // NOLINT |
698 MOCK_METHOD1(OnBootstrapTokenUpdated, void(const std::string&)); // NOLINT | 699 MOCK_METHOD1(OnBootstrapTokenUpdated, void(const std::string&)); // NOLINT |
699 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT | 700 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT |
700 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT | 701 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT |
701 MOCK_METHOD0(OnClearServerDataFailed, void()); // NOLINT | 702 MOCK_METHOD0(OnClearServerDataFailed, void()); // NOLINT |
702 MOCK_METHOD0(OnClearServerDataSucceeded, void()); // NOLINT | 703 MOCK_METHOD0(OnClearServerDataSucceeded, void()); // NOLINT |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated("")); | 762 EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated("")); |
762 EXPECT_CALL(*sync_notifier_mock_, | 763 EXPECT_CALL(*sync_notifier_mock_, |
763 UpdateCredentials(credentials.email, credentials.sync_token)); | 764 UpdateCredentials(credentials.email, credentials.sync_token)); |
764 EXPECT_CALL(*sync_notifier_mock_, UpdateEnabledTypes(_)). | 765 EXPECT_CALL(*sync_notifier_mock_, UpdateEnabledTypes(_)). |
765 WillRepeatedly( | 766 WillRepeatedly( |
766 Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes)); | 767 Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes)); |
767 EXPECT_CALL(*sync_notifier_mock_, RemoveObserver(_)). | 768 EXPECT_CALL(*sync_notifier_mock_, RemoveObserver(_)). |
768 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver)); | 769 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver)); |
769 | 770 |
770 sync_manager_.AddObserver(&observer_); | 771 sync_manager_.AddObserver(&observer_); |
771 EXPECT_CALL(observer_, OnInitializationComplete(_, _)). | 772 EXPECT_CALL(observer_, OnInitializationComplete(_, _, _)). |
772 WillOnce(SaveArg<0>(&js_backend_)); | 773 WillOnce(SaveArg<0>(&js_backend_)); |
773 | 774 |
774 EXPECT_FALSE(sync_notifier_observer_); | 775 EXPECT_FALSE(sync_notifier_observer_); |
775 EXPECT_FALSE(js_backend_.IsInitialized()); | 776 EXPECT_FALSE(js_backend_.IsInitialized()); |
776 | 777 |
777 std::vector<ModelSafeWorker*> workers; | 778 std::vector<ModelSafeWorker*> workers; |
778 ModelSafeRoutingInfo routing_info; | 779 ModelSafeRoutingInfo routing_info; |
779 GetModelSafeRoutingInfo(&routing_info); | 780 GetModelSafeRoutingInfo(&routing_info); |
780 | 781 |
781 // Takes ownership of |sync_notifier_mock_|. | 782 // Takes ownership of |sync_notifier_mock_|. |
782 sync_manager_.Init(temp_dir_.path(), | 783 sync_manager_.Init(temp_dir_.path(), |
783 WeakHandle<JsEventHandler>(), | 784 WeakHandle<JsEventHandler>(), |
784 "bogus", 0, false, | 785 "bogus", 0, false, |
785 base::MessageLoopProxy::current(), | 786 base::MessageLoopProxy::current(), |
786 new TestHttpPostProviderFactory(), routing_info, workers, | 787 new TestHttpPostProviderFactory(), workers, |
787 &extensions_activity_monitor_, this, "bogus", | 788 &extensions_activity_monitor_, this, "bogus", |
788 credentials, | 789 credentials, |
789 sync_notifier_mock_, "", | 790 sync_notifier_mock_, "", |
790 sync_api::SyncManager::TEST_IN_MEMORY, | 791 sync_api::SyncManager::TEST_IN_MEMORY, |
791 &encryptor_, | 792 &encryptor_, |
792 &handler_, | 793 &handler_, |
793 NULL); | 794 NULL); |
794 | 795 |
795 EXPECT_TRUE(sync_notifier_observer_); | 796 EXPECT_TRUE(sync_notifier_observer_); |
796 EXPECT_TRUE(js_backend_.IsInitialized()); | 797 EXPECT_TRUE(js_backend_.IsInitialized()); |
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2501 EXPECT_EQ(title, node.GetTitle()); | 2502 EXPECT_EQ(title, node.GetTitle()); |
2502 EXPECT_EQ(GURL(url2), node.GetURL()); | 2503 EXPECT_EQ(GURL(url2), node.GetURL()); |
2503 const syncable::Entry* node_entry = node.GetEntry(); | 2504 const syncable::Entry* node_entry = node.GetEntry(); |
2504 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); | 2505 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); |
2505 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS); | 2506 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS); |
2506 EXPECT_TRUE(specifics.has_encrypted()); | 2507 EXPECT_TRUE(specifics.has_encrypted()); |
2507 } | 2508 } |
2508 } | 2509 } |
2509 | 2510 |
2510 } // namespace browser_sync | 2511 } // namespace browser_sync |
OLD | NEW |