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

Side by Side Diff: chrome/browser/sync/notifier/chrome_invalidation_client_unittest.cc

Issue 8919021: [Sync] Rename ModelEnumSet to ModelTypeSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/sync/notifier/chrome_invalidation_client.h" 8 #include "chrome/browser/sync/notifier/chrome_invalidation_client.h"
9 #include "chrome/browser/sync/notifier/state_writer.h" 9 #include "chrome/browser/sync/notifier/state_writer.h"
10 #include "chrome/browser/sync/syncable/model_type.h" 10 #include "chrome/browser/sync/syncable/model_type.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 namespace { 136 namespace {
137 137
138 syncable::ModelTypePayloadMap MakeMap(syncable::ModelType model_type, 138 syncable::ModelTypePayloadMap MakeMap(syncable::ModelType model_type,
139 const std::string& payload) { 139 const std::string& payload) {
140 syncable::ModelTypePayloadMap type_payloads; 140 syncable::ModelTypePayloadMap type_payloads;
141 type_payloads[model_type] = payload; 141 type_payloads[model_type] = payload;
142 return type_payloads; 142 return type_payloads;
143 } 143 }
144 144
145 syncable::ModelTypePayloadMap MakeMapFromSet(syncable::ModelEnumSet types, 145 syncable::ModelTypePayloadMap MakeMapFromSet(syncable::ModelTypeSet types,
146 const std::string& payload) { 146 const std::string& payload) {
147 return syncable::ModelTypePayloadMapFromEnumSet(types, payload); 147 return syncable::ModelTypePayloadMapFromEnumSet(types, payload);
148 } 148 }
149 149
150 } // namespace 150 } // namespace
151 151
152 TEST_F(ChromeInvalidationClientTest, InvalidateBadObjectId) { 152 TEST_F(ChromeInvalidationClientTest, InvalidateBadObjectId) {
153 syncable::ModelEnumSet types(syncable::BOOKMARKS, syncable::APPS); 153 syncable::ModelTypeSet types(syncable::BOOKMARKS, syncable::APPS);
154 client_.RegisterTypes(types); 154 client_.RegisterTypes(types);
155 EXPECT_CALL(mock_listener_, OnInvalidate(MakeMapFromSet(types, ""))); 155 EXPECT_CALL(mock_listener_, OnInvalidate(MakeMapFromSet(types, "")));
156 FireInvalidate("bad", 1, NULL); 156 FireInvalidate("bad", 1, NULL);
157 message_loop_.RunAllPending(); 157 message_loop_.RunAllPending();
158 } 158 }
159 159
160 TEST_F(ChromeInvalidationClientTest, InvalidateNoPayload) { 160 TEST_F(ChromeInvalidationClientTest, InvalidateNoPayload) {
161 EXPECT_CALL(mock_listener_, 161 EXPECT_CALL(mock_listener_,
162 OnInvalidate(MakeMap(syncable::BOOKMARKS, ""))); 162 OnInvalidate(MakeMap(syncable::BOOKMARKS, "")));
163 EXPECT_CALL(mock_invalidation_version_tracker_, 163 EXPECT_CALL(mock_invalidation_version_tracker_,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 .Times(2); 196 .Times(2);
197 197
198 // Should trigger twice. 198 // Should trigger twice.
199 FireInvalidateUnknownVersion("EXTENSION"); 199 FireInvalidateUnknownVersion("EXTENSION");
200 FireInvalidateUnknownVersion("EXTENSION"); 200 FireInvalidateUnknownVersion("EXTENSION");
201 } 201 }
202 202
203 TEST_F(ChromeInvalidationClientTest, InvalidateVersionMultipleTypes) { 203 TEST_F(ChromeInvalidationClientTest, InvalidateVersionMultipleTypes) {
204 using ::testing::Mock; 204 using ::testing::Mock;
205 205
206 syncable::ModelEnumSet types(syncable::BOOKMARKS, syncable::APPS); 206 syncable::ModelTypeSet types(syncable::BOOKMARKS, syncable::APPS);
207 client_.RegisterTypes(types); 207 client_.RegisterTypes(types);
208 208
209 EXPECT_CALL(mock_listener_, 209 EXPECT_CALL(mock_listener_,
210 OnInvalidate(MakeMap(syncable::APPS, ""))); 210 OnInvalidate(MakeMap(syncable::APPS, "")));
211 EXPECT_CALL(mock_listener_, 211 EXPECT_CALL(mock_listener_,
212 OnInvalidate(MakeMap(syncable::EXTENSIONS, ""))); 212 OnInvalidate(MakeMap(syncable::EXTENSIONS, "")));
213 213
214 EXPECT_CALL(mock_invalidation_version_tracker_, 214 EXPECT_CALL(mock_invalidation_version_tracker_,
215 SetMaxVersion(syncable::APPS, 3)); 215 SetMaxVersion(syncable::APPS, 3));
216 EXPECT_CALL(mock_invalidation_version_tracker_, 216 EXPECT_CALL(mock_invalidation_version_tracker_,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 EXPECT_CALL(mock_invalidation_version_tracker_, 251 EXPECT_CALL(mock_invalidation_version_tracker_,
252 SetMaxVersion(syncable::APPS, 4)); 252 SetMaxVersion(syncable::APPS, 4));
253 253
254 // Should trigger all three. 254 // Should trigger all three.
255 FireInvalidate("PREFERENCE", 5, NULL); 255 FireInvalidate("PREFERENCE", 5, NULL);
256 FireInvalidate("EXTENSION", 3, NULL); 256 FireInvalidate("EXTENSION", 3, NULL);
257 FireInvalidate("APP", 4, NULL); 257 FireInvalidate("APP", 4, NULL);
258 } 258 }
259 259
260 TEST_F(ChromeInvalidationClientTest, InvalidateAll) { 260 TEST_F(ChromeInvalidationClientTest, InvalidateAll) {
261 syncable::ModelEnumSet types(syncable::PREFERENCES, syncable::EXTENSIONS); 261 syncable::ModelTypeSet types(syncable::PREFERENCES, syncable::EXTENSIONS);
262 client_.RegisterTypes(types); 262 client_.RegisterTypes(types);
263 EXPECT_CALL(mock_listener_, OnInvalidate(MakeMapFromSet(types, ""))); 263 EXPECT_CALL(mock_listener_, OnInvalidate(MakeMapFromSet(types, "")));
264 FireInvalidateAll(); 264 FireInvalidateAll();
265 } 265 }
266 266
267 TEST_F(ChromeInvalidationClientTest, RegisterTypes) { 267 TEST_F(ChromeInvalidationClientTest, RegisterTypes) {
268 syncable::ModelEnumSet types(syncable::PREFERENCES, syncable::EXTENSIONS); 268 syncable::ModelTypeSet types(syncable::PREFERENCES, syncable::EXTENSIONS);
269 client_.RegisterTypes(types); 269 client_.RegisterTypes(types);
270 // Registered types should be preserved across Stop/Start. 270 // Registered types should be preserved across Stop/Start.
271 TearDown(); 271 TearDown();
272 SetUp(); 272 SetUp();
273 EXPECT_CALL(mock_listener_, OnInvalidate(MakeMapFromSet(types, ""))); 273 EXPECT_CALL(mock_listener_, OnInvalidate(MakeMapFromSet(types, "")));
274 FireInvalidateAll(); 274 FireInvalidateAll();
275 } 275 }
276 276
277 // TODO(akalin): Flesh out unit tests. 277 // TODO(akalin): Flesh out unit tests.
278 278
279 } // namespace sync_notifier 279 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/chrome_invalidation_client.cc ('k') | chrome/browser/sync/notifier/invalidation_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698