OLD | NEW |
---|---|
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 Loading... | |
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 map = ModelTypeBitSetToTypePayloadMap(types, payload); | |
akalin
2011/01/26 10:35:26
Best not to name a variable the same as an existin
| |
258 EXPECT_TRUE(map.empty()); | |
259 | |
260 types[syncable::BOOKMARKS] = true; | |
261 types[syncable::PASSWORDS] = true; | |
262 types[syncable::AUTOFILL] = true; | |
263 payload = "test2"; | |
264 map = ModelTypeBitSetToTypePayloadMap(types, payload); | |
265 | |
266 ASSERT_EQ(3U, map.size()); | |
267 EXPECT_TRUE(map[syncable::BOOKMARKS] == payload); | |
akalin
2011/01/26 10:35:26
use EXPECT_EQ
| |
268 EXPECT_TRUE(map[syncable::PASSWORDS] == payload); | |
269 EXPECT_TRUE(map[syncable::AUTOFILL] == payload); | |
270 } | |
271 | |
272 TEST_F(SyncSessionTest, RoutingInfoToTypePayloadMap) { | |
273 std::string payload = "test"; | |
274 TypePayloadMap map = RoutingInfoToTypePayloadMap(routes_, payload); | |
275 ASSERT_EQ(routes_.size(), map.size()); | |
276 for (ModelSafeRoutingInfo::iterator iter = routes_.begin(); | |
277 iter != routes_.end(); | |
278 ++iter) { | |
279 EXPECT_EQ(payload, map[iter->first]); | |
280 } | |
281 } | |
282 | |
283 TEST_F(SyncSessionTest, CoalescePayloads) { | |
284 TypePayloadMap original; | |
285 std::string empty_payload; | |
286 std::string payload1 = "payload1"; | |
287 std::string payload2 = "payload2"; | |
288 std::string payload3 = "payload3"; | |
289 original[syncable::BOOKMARKS] = empty_payload; | |
290 original[syncable::PASSWORDS] = payload1; | |
291 original[syncable::AUTOFILL] = payload2; | |
292 original[syncable::THEMES] = payload3; | |
293 | |
294 TypePayloadMap update; | |
295 update[syncable::BOOKMARKS] = empty_payload; // Same. | |
296 update[syncable::PASSWORDS] = empty_payload; // Overwrite with empty. | |
297 update[syncable::AUTOFILL] = payload1; // Overwrite with non-empty. | |
298 update[syncable::SESSIONS] = payload2; // New. | |
299 // Themes untouched. | |
300 | |
301 CoalescePayloads(&original, update); | |
302 ASSERT_EQ(5U, original.size()); | |
303 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); | |
304 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); | |
305 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); | |
306 EXPECT_EQ(payload2, original[syncable::SESSIONS]); | |
307 EXPECT_EQ(payload3, original[syncable::THEMES]); | |
308 } | |
309 | |
253 } // namespace | 310 } // namespace |
254 } // namespace sessions | 311 } // namespace sessions |
255 } // namespace browser_sync | 312 } // namespace browser_sync |
OLD | NEW |