| 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 #include "chrome/browser/sync/glue/bridged_sync_notifier.h" | 5 #include "chrome/browser/sync/glue/bridged_sync_notifier.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 class MockSyncNotifier : public sync_notifier::SyncNotifier { | 42 class MockSyncNotifier : public sync_notifier::SyncNotifier { |
| 43 public: | 43 public: |
| 44 MockSyncNotifier() {} | 44 MockSyncNotifier() {} |
| 45 virtual ~MockSyncNotifier() {} | 45 virtual ~MockSyncNotifier() {} |
| 46 | 46 |
| 47 MOCK_METHOD1(AddObserver, void(sync_notifier::SyncNotifierObserver*)); | 47 MOCK_METHOD1(AddObserver, void(sync_notifier::SyncNotifierObserver*)); |
| 48 MOCK_METHOD1(RemoveObserver, void(sync_notifier::SyncNotifierObserver*)); | 48 MOCK_METHOD1(RemoveObserver, void(sync_notifier::SyncNotifierObserver*)); |
| 49 MOCK_METHOD1(SetUniqueId, void(const std::string&)); | 49 MOCK_METHOD1(SetUniqueId, void(const std::string&)); |
| 50 MOCK_METHOD1(SetState, void(const std::string&)); | 50 MOCK_METHOD1(SetStateDeprecated, void(const std::string&)); |
| 51 MOCK_METHOD2(UpdateCredentials, void(const std::string&, const std::string&)); | 51 MOCK_METHOD2(UpdateCredentials, void(const std::string&, const std::string&)); |
| 52 MOCK_METHOD1(UpdateEnabledTypes, void(syncable::ModelTypeSet)); | 52 MOCK_METHOD1(UpdateEnabledTypes, void(syncable::ModelTypeSet)); |
| 53 MOCK_METHOD1(SendNotification, void(syncable::ModelTypeSet)); | 53 MOCK_METHOD1(SendNotification, void(syncable::ModelTypeSet)); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // All tests just verify that each call is passed through to the delegate, with | 56 // All tests just verify that each call is passed through to the delegate, with |
| 57 // the exception of AddObserver/RemoveObserver, which also verify the observer | 57 // the exception of AddObserver/RemoveObserver, which also verify the observer |
| 58 // is registered with the bridge. | 58 // is registered with the bridge. |
| 59 class BridgedSyncNotifierTest : public testing::Test { | 59 class BridgedSyncNotifierTest : public testing::Test { |
| 60 public: | 60 public: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 85 EXPECT_CALL(*mock_delegate_, RemoveObserver(&observer)); | 85 EXPECT_CALL(*mock_delegate_, RemoveObserver(&observer)); |
| 86 bridged_notifier_.RemoveObserver(&observer); | 86 bridged_notifier_.RemoveObserver(&observer); |
| 87 } | 87 } |
| 88 | 88 |
| 89 TEST_F(BridgedSyncNotifierTest, SetUniqueId) { | 89 TEST_F(BridgedSyncNotifierTest, SetUniqueId) { |
| 90 std::string unique_id = "unique id"; | 90 std::string unique_id = "unique id"; |
| 91 EXPECT_CALL(*mock_delegate_, SetUniqueId(unique_id)); | 91 EXPECT_CALL(*mock_delegate_, SetUniqueId(unique_id)); |
| 92 bridged_notifier_.SetUniqueId(unique_id); | 92 bridged_notifier_.SetUniqueId(unique_id); |
| 93 } | 93 } |
| 94 | 94 |
| 95 TEST_F(BridgedSyncNotifierTest, SetState) { | 95 TEST_F(BridgedSyncNotifierTest, SetStateDeprecated) { |
| 96 std::string state = "state"; | 96 std::string state = "state"; |
| 97 EXPECT_CALL(*mock_delegate_, SetState(state)); | 97 EXPECT_CALL(*mock_delegate_, SetStateDeprecated(state)); |
| 98 bridged_notifier_.SetState(state); | 98 bridged_notifier_.SetStateDeprecated(state); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TEST_F(BridgedSyncNotifierTest, UpdateCredentials) { | 101 TEST_F(BridgedSyncNotifierTest, UpdateCredentials) { |
| 102 std::string email = "email"; | 102 std::string email = "email"; |
| 103 std::string token = "token"; | 103 std::string token = "token"; |
| 104 EXPECT_CALL(*mock_delegate_, UpdateCredentials(email, token)); | 104 EXPECT_CALL(*mock_delegate_, UpdateCredentials(email, token)); |
| 105 bridged_notifier_.UpdateCredentials(email, token); | 105 bridged_notifier_.UpdateCredentials(email, token); |
| 106 } | 106 } |
| 107 | 107 |
| 108 TEST_F(BridgedSyncNotifierTest, UpdateEnabledTypes) { | 108 TEST_F(BridgedSyncNotifierTest, UpdateEnabledTypes) { |
| 109 syncable::ModelTypeSet enabled_types(syncable::BOOKMARKS, | 109 syncable::ModelTypeSet enabled_types(syncable::BOOKMARKS, |
| 110 syncable::PREFERENCES); | 110 syncable::PREFERENCES); |
| 111 EXPECT_CALL(*mock_delegate_, | 111 EXPECT_CALL(*mock_delegate_, |
| 112 UpdateEnabledTypes(HasModelTypes(enabled_types))); | 112 UpdateEnabledTypes(HasModelTypes(enabled_types))); |
| 113 bridged_notifier_.UpdateEnabledTypes(enabled_types); | 113 bridged_notifier_.UpdateEnabledTypes(enabled_types); |
| 114 } | 114 } |
| 115 | 115 |
| 116 TEST_F(BridgedSyncNotifierTest, SendNotification) { | 116 TEST_F(BridgedSyncNotifierTest, SendNotification) { |
| 117 syncable::ModelTypeSet changed_types(syncable::SESSIONS, | 117 syncable::ModelTypeSet changed_types(syncable::SESSIONS, |
| 118 syncable::EXTENSIONS); | 118 syncable::EXTENSIONS); |
| 119 EXPECT_CALL(*mock_delegate_, SendNotification(HasModelTypes(changed_types))); | 119 EXPECT_CALL(*mock_delegate_, SendNotification(HasModelTypes(changed_types))); |
| 120 bridged_notifier_.SendNotification(changed_types); | 120 bridged_notifier_.SendNotification(changed_types); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace | 123 } // namespace |
| 124 } // namespace browser_sync | 124 } // namespace browser_sync |
| OLD | NEW |