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

Side by Side Diff: chrome/browser/sync/sessions/sync_session_unittest.cc

Issue 6182004: [SYNC] Refactor SyncSourceInfo and add support in chrome invalidation client ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Done! Created 9 years, 10 months 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/sessions/sync_session.h" 5 #include "chrome/browser/sync/sessions/sync_session.h"
6 6
7 #include "chrome/browser/sync/engine/conflict_resolver.h" 7 #include "chrome/browser/sync/engine/conflict_resolver.h"
8 #include "chrome/browser/sync/engine/syncer_types.h" 8 #include "chrome/browser/sync/engine/syncer_types.h"
9 #include "chrome/browser/sync/engine/syncer_util.h" 9 #include "chrome/browser/sync/engine/syncer_util.h"
10 #include "chrome/browser/sync/syncable/directory_manager.h" 10 #include "chrome/browser/sync/syncable/directory_manager.h"
11 #include "chrome/browser/sync/syncable/model_type.h"
11 #include "chrome/browser/sync/syncable/syncable.h" 12 #include "chrome/browser/sync/syncable/syncable.h"
12 #include "chrome/test/sync/engine/test_directory_setter_upper.h" 13 #include "chrome/test/sync/engine/test_directory_setter_upper.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 using syncable::WriteTransaction; 16 using syncable::WriteTransaction;
16 17
17 namespace browser_sync { 18 namespace browser_sync {
18 namespace sessions { 19 namespace sessions {
19 namespace { 20 namespace {
20 21
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 244 }
244 245
245 TEST_F(SyncSessionTest, MoreToSyncIfConflictsResolved) { 246 TEST_F(SyncSessionTest, MoreToSyncIfConflictsResolved) {
246 // Conflict resolution happens after get updates and commit, 247 // Conflict resolution happens after get updates and commit,
247 // so we need to loop back and get updates / commit again now 248 // so we need to loop back and get updates / commit again now
248 // that we have made forward progress. 249 // that we have made forward progress.
249 status()->update_conflicts_resolved(true); 250 status()->update_conflicts_resolved(true);
250 EXPECT_TRUE(session_->HasMoreToSync()); 251 EXPECT_TRUE(session_->HasMoreToSync());
251 } 252 }
252 253
254 TEST_F(SyncSessionTest, ModelTypeBitSetToTypePayloadMap) {
255 syncable::ModelTypeBitSet types;
256 std::string payload = "test";
257 TypePayloadMap types_with_payloads =
258 ModelTypeBitSetToTypePayloadMap(types, payload);
259 EXPECT_TRUE(types_with_payloads.empty());
260
261 types[syncable::BOOKMARKS] = true;
262 types[syncable::PASSWORDS] = true;
263 types[syncable::AUTOFILL] = true;
264 payload = "test2";
265 types_with_payloads = ModelTypeBitSetToTypePayloadMap(types, payload);
266
267 ASSERT_EQ(3U, types_with_payloads.size());
268 EXPECT_EQ(types_with_payloads[syncable::BOOKMARKS], payload);
269 EXPECT_EQ(types_with_payloads[syncable::PASSWORDS], payload);
270 EXPECT_EQ(types_with_payloads[syncable::AUTOFILL], payload);
271 }
272
273 TEST_F(SyncSessionTest, RoutingInfoToTypePayloadMap) {
274 std::string payload = "test";
275 TypePayloadMap types_with_payloads
276 = RoutingInfoToTypePayloadMap(routes_, payload);
277 ASSERT_EQ(routes_.size(), types_with_payloads.size());
278 for (ModelSafeRoutingInfo::iterator iter = routes_.begin();
279 iter != routes_.end();
280 ++iter) {
281 EXPECT_EQ(payload, types_with_payloads[iter->first]);
282 }
283 }
284
285 TEST_F(SyncSessionTest, CoalescePayloads) {
286 TypePayloadMap original;
287 std::string empty_payload;
288 std::string payload1 = "payload1";
289 std::string payload2 = "payload2";
290 std::string payload3 = "payload3";
291 original[syncable::BOOKMARKS] = empty_payload;
292 original[syncable::PASSWORDS] = payload1;
293 original[syncable::AUTOFILL] = payload2;
294 original[syncable::THEMES] = payload3;
295
296 TypePayloadMap update;
297 update[syncable::BOOKMARKS] = empty_payload; // Same.
298 update[syncable::PASSWORDS] = empty_payload; // Overwrite with empty.
299 update[syncable::AUTOFILL] = payload1; // Overwrite with non-empty.
300 update[syncable::SESSIONS] = payload2; // New.
301 // Themes untouched.
302
303 CoalescePayloads(&original, update);
304 ASSERT_EQ(5U, original.size());
305 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]);
306 EXPECT_EQ(payload1, original[syncable::PASSWORDS]);
307 EXPECT_EQ(payload1, original[syncable::AUTOFILL]);
308 EXPECT_EQ(payload2, original[syncable::SESSIONS]);
309 EXPECT_EQ(payload3, original[syncable::THEMES]);
310 }
311
253 } // namespace 312 } // namespace
254 } // namespace sessions 313 } // namespace sessions
255 } // namespace browser_sync 314 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/sessions/sync_session.cc ('k') | chrome/browser/sync/tools/sync_listen_notifications.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698