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_invalidator.h" | 5 #include "chrome/browser/sync/glue/bridged_invalidator.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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" | 13 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" |
14 #include "chrome/test/base/profile_mock.h" | 14 #include "chrome/test/base/profile_mock.h" |
15 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
16 #include "google/cacheinvalidation/include/types.h" | 16 #include "google/cacheinvalidation/include/types.h" |
17 #include "sync/internal_api/public/base/model_type.h" | 17 #include "sync/internal_api/public/base/model_type.h" |
18 #include "sync/internal_api/public/base/model_type_test_util.h" | 18 #include "sync/internal_api/public/base/model_type_test_util.h" |
19 #include "sync/notifier/fake_invalidation_handler.h" | 19 #include "sync/notifier/fake_invalidation_handler.h" |
20 #include "sync/notifier/fake_invalidator.h" | 20 #include "sync/notifier/fake_invalidator.h" |
21 #include "sync/notifier/invalidator_test_template.h" | 21 #include "sync/notifier/invalidator_test_template.h" |
22 #include "sync/notifier/object_id_state_map_test_util.h" | 22 #include "sync/notifier/object_id_invalidation_map_test_util.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 namespace syncer { | 26 namespace syncer { |
27 class InvalidationStateTracker; | 27 class InvalidationStateTracker; |
28 } // namespace syncer | 28 } // namespace syncer |
29 | 29 |
30 namespace browser_sync { | 30 namespace browser_sync { |
31 | 31 |
32 // BridgedInvalidatorTestDelegate has to be visible from the syncer | 32 // BridgedInvalidatorTestDelegate has to be visible from the syncer |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 void WaitForInvalidator() { | 78 void WaitForInvalidator() { |
79 // Do nothing. | 79 // Do nothing. |
80 } | 80 } |
81 | 81 |
82 void TriggerOnInvalidatorStateChange(syncer::InvalidatorState state) { | 82 void TriggerOnInvalidatorStateChange(syncer::InvalidatorState state) { |
83 fake_delegate_->EmitOnInvalidatorStateChange(state); | 83 fake_delegate_->EmitOnInvalidatorStateChange(state); |
84 } | 84 } |
85 | 85 |
86 void TriggerOnIncomingInvalidation( | 86 void TriggerOnIncomingInvalidation( |
87 const syncer::ObjectIdStateMap& id_state_map, | 87 const syncer::ObjectIdInvalidationMap& invalidation_map, |
88 syncer::IncomingInvalidationSource source) { | 88 syncer::IncomingInvalidationSource source) { |
89 fake_delegate_->EmitOnIncomingInvalidation(id_state_map, source); | 89 fake_delegate_->EmitOnIncomingInvalidation(invalidation_map, source); |
90 } | 90 } |
91 | 91 |
92 static bool InvalidatorHandlesDeprecatedState() { | 92 static bool InvalidatorHandlesDeprecatedState() { |
93 return false; | 93 return false; |
94 } | 94 } |
95 | 95 |
96 private: | 96 private: |
97 MessageLoop ui_loop_; | 97 MessageLoop ui_loop_; |
98 content::TestBrowserThread ui_thread_; | 98 content::TestBrowserThread ui_thread_; |
99 ::testing::NiceMock<ProfileMock> mock_profile_; | 99 ::testing::NiceMock<ProfileMock> mock_profile_; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 const std::string& token = "token"; | 163 const std::string& token = "token"; |
164 delegate_.GetInvalidator()->UpdateCredentials(email, token); | 164 delegate_.GetInvalidator()->UpdateCredentials(email, token); |
165 EXPECT_EQ(email, delegate_.GetFakeDelegate()->GetCredentialsEmail()); | 165 EXPECT_EQ(email, delegate_.GetFakeDelegate()->GetCredentialsEmail()); |
166 EXPECT_EQ(token, delegate_.GetFakeDelegate()->GetCredentialsToken()); | 166 EXPECT_EQ(token, delegate_.GetFakeDelegate()->GetCredentialsToken()); |
167 } | 167 } |
168 | 168 |
169 TEST_F(BridgedInvalidatorTest, SendInvalidation) { | 169 TEST_F(BridgedInvalidatorTest, SendInvalidation) { |
170 syncer::ObjectIdSet ids; | 170 syncer::ObjectIdSet ids; |
171 ids.insert(invalidation::ObjectId(1, "id1")); | 171 ids.insert(invalidation::ObjectId(1, "id1")); |
172 ids.insert(invalidation::ObjectId(2, "id2")); | 172 ids.insert(invalidation::ObjectId(2, "id2")); |
173 const syncer::ObjectIdStateMap& id_state_map = | 173 const syncer::ObjectIdInvalidationMap& invalidation_map = |
174 syncer::ObjectIdSetToStateMap(ids, "payload"); | 174 syncer::ObjectIdSetToInvalidationMap(ids, "payload"); |
175 delegate_.GetInvalidator()->SendInvalidation(id_state_map); | 175 delegate_.GetInvalidator()->SendInvalidation(invalidation_map); |
176 EXPECT_THAT(id_state_map, | 176 EXPECT_THAT(invalidation_map, |
177 Eq(delegate_.GetFakeDelegate()->GetLastSentIdStateMap())); | 177 Eq(delegate_.GetFakeDelegate()->GetLastSentInvalidationMap())); |
178 } | 178 } |
179 | 179 |
180 } // namespace | 180 } // namespace |
181 } // namespace browser_sync | 181 } // namespace browser_sync |
182 | 182 |
183 namespace syncer { | 183 namespace syncer { |
184 namespace { | 184 namespace { |
185 | 185 |
186 INSTANTIATE_TYPED_TEST_CASE_P( | 186 INSTANTIATE_TYPED_TEST_CASE_P( |
187 BridgedInvalidatorTest, InvalidatorTest, | 187 BridgedInvalidatorTest, InvalidatorTest, |
188 ::browser_sync::BridgedInvalidatorTestDelegate); | 188 ::browser_sync::BridgedInvalidatorTestDelegate); |
189 | 189 |
190 } // namespace | 190 } // namespace |
191 } // namespace syncer | 191 } // namespace syncer |
OLD | NEW |