OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <cstddef> | 5 #include <cstddef> |
6 #include <map> | 6 #include <map> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 : kBookmarksId_(kChromeSyncSourceId, "BOOKMARK"), | 257 : kBookmarksId_(kChromeSyncSourceId, "BOOKMARK"), |
258 kPreferencesId_(kChromeSyncSourceId, "PREFERENCE"), | 258 kPreferencesId_(kChromeSyncSourceId, "PREFERENCE"), |
259 kExtensionsId_(kChromeSyncSourceId, "EXTENSION"), | 259 kExtensionsId_(kChromeSyncSourceId, "EXTENSION"), |
260 kAppsId_(kChromeSyncSourceId, "APP"), | 260 kAppsId_(kChromeSyncSourceId, "APP"), |
261 fake_push_client_(new notifier::FakePushClient()), | 261 fake_push_client_(new notifier::FakePushClient()), |
262 fake_invalidation_client_(NULL), | 262 fake_invalidation_client_(NULL), |
263 listener_(scoped_ptr<SyncNetworkChannel>(new PushClientChannel( | 263 listener_(scoped_ptr<SyncNetworkChannel>(new PushClientChannel( |
264 scoped_ptr<notifier::PushClient>(fake_push_client_)))), | 264 scoped_ptr<notifier::PushClient>(fake_push_client_)))), |
265 fake_delegate_(&listener_) {} | 265 fake_delegate_(&listener_) {} |
266 | 266 |
267 virtual void SetUp() { | 267 void SetUp() override { |
268 StartClient(); | 268 StartClient(); |
269 | 269 |
270 registered_ids_.insert(kBookmarksId_); | 270 registered_ids_.insert(kBookmarksId_); |
271 registered_ids_.insert(kPreferencesId_); | 271 registered_ids_.insert(kPreferencesId_); |
272 listener_.UpdateRegisteredIds(registered_ids_); | 272 listener_.UpdateRegisteredIds(registered_ids_); |
273 } | 273 } |
274 | 274 |
275 virtual void TearDown() { | 275 void TearDown() override { StopClient(); } |
276 StopClient(); | |
277 } | |
278 | 276 |
279 // Restart client without re-registering IDs. | 277 // Restart client without re-registering IDs. |
280 void RestartClient() { | 278 void RestartClient() { |
281 StopClient(); | 279 StopClient(); |
282 StartClient(); | 280 StartClient(); |
283 } | 281 } |
284 | 282 |
285 void StartClient() { | 283 void StartClient() { |
286 fake_invalidation_client_ = NULL; | 284 fake_invalidation_client_ = NULL; |
287 listener_.Start( | 285 listener_.Start( |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 | 1053 |
1056 EXPECT_EQ(INVALIDATIONS_ENABLED, GetInvalidatorState()); | 1054 EXPECT_EQ(INVALIDATIONS_ENABLED, GetInvalidatorState()); |
1057 } | 1055 } |
1058 | 1056 |
1059 // A variant of SyncInvalidationListenerTest that starts with some initial | 1057 // A variant of SyncInvalidationListenerTest that starts with some initial |
1060 // state. We make not attempt to abstract away the contents of this state. The | 1058 // state. We make not attempt to abstract away the contents of this state. The |
1061 // tests that make use of this harness depend on its implementation details. | 1059 // tests that make use of this harness depend on its implementation details. |
1062 class SyncInvalidationListenerTest_WithInitialState | 1060 class SyncInvalidationListenerTest_WithInitialState |
1063 : public SyncInvalidationListenerTest { | 1061 : public SyncInvalidationListenerTest { |
1064 public: | 1062 public: |
1065 virtual void SetUp() { | 1063 void SetUp() override { |
1066 UnackedInvalidationSet bm_state(kBookmarksId_); | 1064 UnackedInvalidationSet bm_state(kBookmarksId_); |
1067 UnackedInvalidationSet ext_state(kExtensionsId_); | 1065 UnackedInvalidationSet ext_state(kExtensionsId_); |
1068 | 1066 |
1069 Invalidation bm_unknown = Invalidation::InitUnknownVersion(kBookmarksId_); | 1067 Invalidation bm_unknown = Invalidation::InitUnknownVersion(kBookmarksId_); |
1070 Invalidation bm_v100 = Invalidation::Init(kBookmarksId_, 100, "hundred"); | 1068 Invalidation bm_v100 = Invalidation::Init(kBookmarksId_, 100, "hundred"); |
1071 bm_state.Add(bm_unknown); | 1069 bm_state.Add(bm_unknown); |
1072 bm_state.Add(bm_v100); | 1070 bm_state.Add(bm_v100); |
1073 | 1071 |
1074 Invalidation ext_v10 = Invalidation::Init(kExtensionsId_, 10, "ten"); | 1072 Invalidation ext_v10 = Invalidation::Init(kExtensionsId_, 10, "ten"); |
1075 Invalidation ext_v20 = Invalidation::Init(kExtensionsId_, 20, "twenty"); | 1073 Invalidation ext_v20 = Invalidation::Init(kExtensionsId_, 20, "twenty"); |
(...skipping 30 matching lines...) Expand all Loading... |
1106 ids.insert(kExtensionsId_); | 1104 ids.insert(kExtensionsId_); |
1107 listener_.UpdateRegisteredIds(ids); | 1105 listener_.UpdateRegisteredIds(ids); |
1108 | 1106 |
1109 ASSERT_EQ(3U, GetInvalidationCount(kExtensionsId_)); | 1107 ASSERT_EQ(3U, GetInvalidationCount(kExtensionsId_)); |
1110 EXPECT_EQ(30, GetVersion(kExtensionsId_)); | 1108 EXPECT_EQ(30, GetVersion(kExtensionsId_)); |
1111 } | 1109 } |
1112 | 1110 |
1113 } // namespace | 1111 } // namespace |
1114 | 1112 |
1115 } // namespace syncer | 1113 } // namespace syncer |
OLD | NEW |