OLD | NEW |
---|---|
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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 MOCK_METHOD2(OnInitializationComplete, | 622 MOCK_METHOD2(OnInitializationComplete, |
623 void(const WeakHandle<JsBackend>&, bool)); // NOLINT | 623 void(const WeakHandle<JsBackend>&, bool)); // NOLINT |
624 MOCK_METHOD1(OnAuthError, void(const GoogleServiceAuthError&)); // NOLINT | 624 MOCK_METHOD1(OnAuthError, void(const GoogleServiceAuthError&)); // NOLINT |
625 MOCK_METHOD1(OnPassphraseRequired, | 625 MOCK_METHOD1(OnPassphraseRequired, |
626 void(sync_api::PassphraseRequiredReason)); // NOLINT | 626 void(sync_api::PassphraseRequiredReason)); // NOLINT |
627 MOCK_METHOD1(OnPassphraseAccepted, void(const std::string&)); // NOLINT | 627 MOCK_METHOD1(OnPassphraseAccepted, void(const std::string&)); // NOLINT |
628 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT | 628 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT |
629 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT | 629 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT |
630 MOCK_METHOD0(OnClearServerDataFailed, void()); // NOLINT | 630 MOCK_METHOD0(OnClearServerDataFailed, void()); // NOLINT |
631 MOCK_METHOD0(OnClearServerDataSucceeded, void()); // NOLINT | 631 MOCK_METHOD0(OnClearServerDataSucceeded, void()); // NOLINT |
632 MOCK_METHOD1(OnEncryptionComplete, void(const ModelTypeSet&)); // NOLINT | 632 MOCK_METHOD2(OnEncryptedTypesChanged, |
633 void(const ModelTypeSet&, bool)); // NOLINT | |
634 MOCK_METHOD0(OnEncryptionComplete, void()); // NOLINT | |
633 MOCK_METHOD1(OnActionableError, | 635 MOCK_METHOD1(OnActionableError, |
634 void(const browser_sync::SyncProtocolError&)); // NOLINT | 636 void(const browser_sync::SyncProtocolError&)); // NOLINT |
635 }; | 637 }; |
636 | 638 |
637 class SyncNotifierMock : public sync_notifier::SyncNotifier { | 639 class SyncNotifierMock : public sync_notifier::SyncNotifier { |
638 public: | 640 public: |
639 MOCK_METHOD1(AddObserver, void(sync_notifier::SyncNotifierObserver*)); | 641 MOCK_METHOD1(AddObserver, void(sync_notifier::SyncNotifierObserver*)); |
640 MOCK_METHOD1(RemoveObserver, void(sync_notifier::SyncNotifierObserver*)); | 642 MOCK_METHOD1(RemoveObserver, void(sync_notifier::SyncNotifierObserver*)); |
641 MOCK_METHOD1(SetUniqueId, void(const std::string&)); | 643 MOCK_METHOD1(SetUniqueId, void(const std::string&)); |
642 MOCK_METHOD1(SetState, void(const std::string&)); | 644 MOCK_METHOD1(SetState, void(const std::string&)); |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1188 sync_manager_.TriggerOnIncomingNotificationForTest(model_types); | 1190 sync_manager_.TriggerOnIncomingNotificationForTest(model_types); |
1189 | 1191 |
1190 // Should trigger the replies. | 1192 // Should trigger the replies. |
1191 PumpLoop(); | 1193 PumpLoop(); |
1192 } | 1194 } |
1193 | 1195 |
1194 TEST_F(SyncManagerTest, RefreshEncryptionReady) { | 1196 TEST_F(SyncManagerTest, RefreshEncryptionReady) { |
1195 EXPECT_TRUE(SetUpEncryption()); | 1197 EXPECT_TRUE(SetUpEncryption()); |
1196 sync_manager_.RefreshEncryption(); | 1198 sync_manager_.RefreshEncryption(); |
1197 syncable::ModelTypeSet encrypted_types = | 1199 syncable::ModelTypeSet encrypted_types = |
1198 sync_manager_.GetEncryptedDataTypes(); | 1200 sync_manager_.GetEncryptedDataTypesForTest(); |
1199 EXPECT_EQ(1U, encrypted_types.count(syncable::PASSWORDS)); | 1201 EXPECT_EQ(1U, encrypted_types.count(syncable::PASSWORDS)); |
1200 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabled()); | 1202 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest()); |
1201 } | 1203 } |
1202 | 1204 |
1203 // Attempt to refresh encryption when nigori not downloaded. | 1205 // Attempt to refresh encryption when nigori not downloaded. |
1204 TEST_F(SyncManagerTest, RefreshEncryptionNotReady) { | 1206 TEST_F(SyncManagerTest, RefreshEncryptionNotReady) { |
1205 // Don't set up encryption (no nigori node created). | 1207 // Don't set up encryption (no nigori node created). |
1206 sync_manager_.RefreshEncryption(); // Should fail. | 1208 sync_manager_.RefreshEncryption(); // Should fail. |
1207 syncable::ModelTypeSet encrypted_types = | 1209 syncable::ModelTypeSet encrypted_types = |
1208 sync_manager_.GetEncryptedDataTypes(); | 1210 sync_manager_.GetEncryptedDataTypesForTest(); |
1209 EXPECT_EQ(1U, encrypted_types.count(syncable::PASSWORDS)); // Hardcoded. | 1211 EXPECT_EQ(1U, encrypted_types.count(syncable::PASSWORDS)); // Hardcoded. |
1210 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabled()); | 1212 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest()); |
1211 } | 1213 } |
1212 | 1214 |
1213 TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) { | 1215 TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) { |
1214 EXPECT_TRUE(SetUpEncryption()); | 1216 EXPECT_TRUE(SetUpEncryption()); |
1215 EXPECT_CALL(observer_, OnEncryptionComplete(GetAllRealModelTypes())); | 1217 EXPECT_CALL(observer_, OnEncryptedTypesChanged( |
1218 GetAllRealModelTypes(), true)).Times(3); | |
Nicolas Zea
2011/10/21 14:29:07
Enforcing the number of times this gets hit (here
akalin
2011/10/22 03:28:38
Should be fixed by the change to only emit the not
| |
1219 EXPECT_CALL(observer_, OnEncryptionComplete()); | |
1216 sync_manager_.EnableEncryptEverything(); | 1220 sync_manager_.EnableEncryptEverything(); |
1217 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabled()); | 1221 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest()); |
1218 } | 1222 } |
1219 | 1223 |
1220 TEST_F(SyncManagerTest, EncryptDataTypesWithData) { | 1224 TEST_F(SyncManagerTest, EncryptDataTypesWithData) { |
1221 size_t batch_size = 5; | 1225 size_t batch_size = 5; |
1222 EXPECT_TRUE(SetUpEncryption()); | 1226 EXPECT_TRUE(SetUpEncryption()); |
1223 | 1227 |
1224 // Create some unencrypted unsynced data. | 1228 // Create some unencrypted unsynced data. |
1225 int64 folder = MakeFolderWithParent(sync_manager_.GetUserShare(), | 1229 int64 folder = MakeFolderWithParent(sync_manager_.GetUserShare(), |
1226 syncable::BOOKMARKS, | 1230 syncable::BOOKMARKS, |
1227 GetIdForDataType(syncable::BOOKMARKS), | 1231 GetIdForDataType(syncable::BOOKMARKS), |
(...skipping 27 matching lines...) Expand all Loading... | |
1255 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1259 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1256 trans.GetCryptographer(), | 1260 trans.GetCryptographer(), |
1257 syncable::SESSIONS, | 1261 syncable::SESSIONS, |
1258 false /* not encrypted */)); | 1262 false /* not encrypted */)); |
1259 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1263 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1260 trans.GetCryptographer(), | 1264 trans.GetCryptographer(), |
1261 syncable::THEMES, | 1265 syncable::THEMES, |
1262 false /* not encrypted */)); | 1266 false /* not encrypted */)); |
1263 } | 1267 } |
1264 | 1268 |
1265 EXPECT_CALL(observer_, OnEncryptionComplete(GetAllRealModelTypes())); | 1269 EXPECT_CALL(observer_, OnEncryptedTypesChanged( |
1270 GetAllRealModelTypes(), true)).Times(3); | |
1271 EXPECT_CALL(observer_, OnEncryptionComplete()); | |
1266 sync_manager_.EnableEncryptEverything(); | 1272 sync_manager_.EnableEncryptEverything(); |
1267 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabled()); | 1273 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest()); |
1268 { | 1274 { |
1269 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1275 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1270 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); | 1276 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); |
1271 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1277 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1272 trans.GetCryptographer(), | 1278 trans.GetCryptographer(), |
1273 syncable::BOOKMARKS, | 1279 syncable::BOOKMARKS, |
1274 true /* is encrypted */)); | 1280 true /* is encrypted */)); |
1275 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1281 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1276 trans.GetCryptographer(), | 1282 trans.GetCryptographer(), |
1277 syncable::SESSIONS, | 1283 syncable::SESSIONS, |
1278 true /* is encrypted */)); | 1284 true /* is encrypted */)); |
1279 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1285 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1280 trans.GetCryptographer(), | 1286 trans.GetCryptographer(), |
1281 syncable::THEMES, | 1287 syncable::THEMES, |
1282 true /* is encrypted */)); | 1288 true /* is encrypted */)); |
1283 } | 1289 } |
1284 | 1290 |
1285 // Trigger's a ReEncryptEverything with new passphrase. | 1291 // Trigger's a ReEncryptEverything with new passphrase. |
1286 testing::Mock::VerifyAndClearExpectations(&observer_); | 1292 testing::Mock::VerifyAndClearExpectations(&observer_); |
1287 EXPECT_CALL(observer_, OnPassphraseAccepted(_)).Times(1); | 1293 EXPECT_CALL(observer_, OnPassphraseAccepted(_)); |
1288 EXPECT_CALL(observer_, OnEncryptionComplete(GetAllRealModelTypes())).Times(1); | 1294 EXPECT_CALL(observer_, OnEncryptedTypesChanged( |
1295 GetAllRealModelTypes(), true)); | |
1296 EXPECT_CALL(observer_, OnEncryptionComplete()); | |
1289 sync_manager_.SetPassphrase("new_passphrase", true); | 1297 sync_manager_.SetPassphrase("new_passphrase", true); |
1290 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabled()); | 1298 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest()); |
1291 { | 1299 { |
1292 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1300 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1293 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); | 1301 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); |
1294 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1302 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1295 trans.GetCryptographer(), | 1303 trans.GetCryptographer(), |
1296 syncable::BOOKMARKS, | 1304 syncable::BOOKMARKS, |
1297 true /* is encrypted */)); | 1305 true /* is encrypted */)); |
1298 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1306 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1299 trans.GetCryptographer(), | 1307 trans.GetCryptographer(), |
1300 syncable::SESSIONS, | 1308 syncable::SESSIONS, |
1301 true /* is encrypted */)); | 1309 true /* is encrypted */)); |
1302 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1310 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1303 trans.GetCryptographer(), | 1311 trans.GetCryptographer(), |
1304 syncable::THEMES, | 1312 syncable::THEMES, |
1305 true /* is encrypted */)); | 1313 true /* is encrypted */)); |
1306 } | 1314 } |
1307 // Calling EncryptDataTypes with an empty encrypted types should not trigger | 1315 // Calling EncryptDataTypes with an empty encrypted types should not trigger |
1308 // a reencryption and should just notify immediately. | 1316 // a reencryption and should just notify immediately. |
1309 // TODO(zea): add logic to ensure nothing was written. | 1317 // TODO(zea): add logic to ensure nothing was written. |
1310 testing::Mock::VerifyAndClearExpectations(&observer_); | 1318 testing::Mock::VerifyAndClearExpectations(&observer_); |
1311 EXPECT_CALL(observer_, OnPassphraseAccepted(_)).Times(0); | 1319 EXPECT_CALL(observer_, OnPassphraseAccepted(_)).Times(0); |
1312 EXPECT_CALL(observer_, OnEncryptionComplete(GetAllRealModelTypes())).Times(1); | 1320 EXPECT_CALL(observer_, OnEncryptedTypesChanged( |
1321 GetAllRealModelTypes(), true)).Times(3); | |
1322 EXPECT_CALL(observer_, OnEncryptionComplete()); | |
1313 sync_manager_.EnableEncryptEverything(); | 1323 sync_manager_.EnableEncryptEverything(); |
1314 } | 1324 } |
1315 | 1325 |
1316 TEST_F(SyncManagerTest, SetPassphraseWithPassword) { | 1326 TEST_F(SyncManagerTest, SetPassphraseWithPassword) { |
1317 EXPECT_TRUE(SetUpEncryption()); | 1327 EXPECT_TRUE(SetUpEncryption()); |
1318 { | 1328 { |
1319 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1329 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1320 ReadNode root_node(&trans); | 1330 ReadNode root_node(&trans); |
1321 root_node.InitByRootLookup(); | 1331 root_node.InitByRootLookup(); |
1322 | 1332 |
1323 WriteNode password_node(&trans); | 1333 WriteNode password_node(&trans); |
1324 EXPECT_TRUE(password_node.InitUniqueByCreation(syncable::PASSWORDS, | 1334 EXPECT_TRUE(password_node.InitUniqueByCreation(syncable::PASSWORDS, |
1325 root_node, "foo")); | 1335 root_node, "foo")); |
1326 sync_pb::PasswordSpecificsData data; | 1336 sync_pb::PasswordSpecificsData data; |
1327 data.set_password_value("secret"); | 1337 data.set_password_value("secret"); |
1328 password_node.SetPasswordSpecifics(data); | 1338 password_node.SetPasswordSpecifics(data); |
1329 } | 1339 } |
1330 EXPECT_CALL(observer_, OnPassphraseAccepted(_)); | 1340 EXPECT_CALL(observer_, OnPassphraseAccepted(_)); |
1331 EXPECT_CALL(observer_, OnEncryptionComplete(_)); | 1341 EXPECT_CALL(observer_, OnEncryptedTypesChanged( |
1342 browser_sync::Cryptographer::SensitiveTypes(), false)); | |
1343 EXPECT_CALL(observer_, OnEncryptionComplete()); | |
1332 sync_manager_.SetPassphrase("new_passphrase", true); | 1344 sync_manager_.SetPassphrase("new_passphrase", true); |
1333 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabled()); | 1345 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest()); |
1334 { | 1346 { |
1335 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1347 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1336 ReadNode password_node(&trans); | 1348 ReadNode password_node(&trans); |
1337 EXPECT_TRUE(password_node.InitByClientTagLookup(syncable::PASSWORDS, | 1349 EXPECT_TRUE(password_node.InitByClientTagLookup(syncable::PASSWORDS, |
1338 "foo")); | 1350 "foo")); |
1339 const sync_pb::PasswordSpecificsData& data = | 1351 const sync_pb::PasswordSpecificsData& data = |
1340 password_node.GetPasswordSpecifics(); | 1352 password_node.GetPasswordSpecifics(); |
1341 EXPECT_EQ("secret", data.password_value()); | 1353 EXPECT_EQ("secret", data.password_value()); |
1342 } | 1354 } |
1343 } | 1355 } |
1344 | 1356 |
1345 TEST_F(SyncManagerTest, SetPassphraseWithEmptyPasswordNode) { | 1357 TEST_F(SyncManagerTest, SetPassphraseWithEmptyPasswordNode) { |
1346 EXPECT_TRUE(SetUpEncryption()); | 1358 EXPECT_TRUE(SetUpEncryption()); |
1347 int64 node_id = 0; | 1359 int64 node_id = 0; |
1348 std::string tag = "foo"; | 1360 std::string tag = "foo"; |
1349 { | 1361 { |
1350 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1362 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1351 ReadNode root_node(&trans); | 1363 ReadNode root_node(&trans); |
1352 root_node.InitByRootLookup(); | 1364 root_node.InitByRootLookup(); |
1353 | 1365 |
1354 WriteNode password_node(&trans); | 1366 WriteNode password_node(&trans); |
1355 EXPECT_TRUE(password_node.InitUniqueByCreation(syncable::PASSWORDS, | 1367 EXPECT_TRUE(password_node.InitUniqueByCreation(syncable::PASSWORDS, |
1356 root_node, tag)); | 1368 root_node, tag)); |
1357 node_id = password_node.GetId(); | 1369 node_id = password_node.GetId(); |
1358 } | 1370 } |
1359 EXPECT_CALL(observer_, OnPassphraseAccepted(_)); | 1371 EXPECT_CALL(observer_, OnPassphraseAccepted(_)); |
1360 EXPECT_CALL(observer_, OnEncryptionComplete(_)); | 1372 EXPECT_CALL(observer_, OnEncryptedTypesChanged( |
1373 browser_sync::Cryptographer::SensitiveTypes(), false)); | |
1374 EXPECT_CALL(observer_, OnEncryptionComplete()); | |
1361 sync_manager_.SetPassphrase("new_passphrase", true); | 1375 sync_manager_.SetPassphrase("new_passphrase", true); |
1362 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabled()); | 1376 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest()); |
1363 { | 1377 { |
1364 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1378 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1365 ReadNode password_node(&trans); | 1379 ReadNode password_node(&trans); |
1366 EXPECT_FALSE(password_node.InitByClientTagLookup(syncable::PASSWORDS, | 1380 EXPECT_FALSE(password_node.InitByClientTagLookup(syncable::PASSWORDS, |
1367 tag)); | 1381 tag)); |
1368 } | 1382 } |
1369 { | 1383 { |
1370 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1384 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1371 ReadNode password_node(&trans); | 1385 ReadNode password_node(&trans); |
1372 EXPECT_FALSE(password_node.InitByIdLookup(node_id)); | 1386 EXPECT_FALSE(password_node.InitByIdLookup(node_id)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1438 } | 1452 } |
1439 | 1453 |
1440 { | 1454 { |
1441 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1455 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1442 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1456 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1443 trans.GetCryptographer(), | 1457 trans.GetCryptographer(), |
1444 syncable::BOOKMARKS, | 1458 syncable::BOOKMARKS, |
1445 false /* not encrypted */)); | 1459 false /* not encrypted */)); |
1446 } | 1460 } |
1447 | 1461 |
1448 EXPECT_CALL(observer_, OnEncryptionComplete(GetAllRealModelTypes())); | 1462 EXPECT_CALL(observer_, OnEncryptedTypesChanged( |
1463 GetAllRealModelTypes(), true)).Times(3); | |
1464 EXPECT_CALL(observer_, OnEncryptionComplete()); | |
1449 sync_manager_.EnableEncryptEverything(); | 1465 sync_manager_.EnableEncryptEverything(); |
1450 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabled()); | 1466 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest()); |
1451 | 1467 |
1452 { | 1468 { |
1453 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1469 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1454 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); | 1470 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); |
1455 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1471 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1456 trans.GetCryptographer(), | 1472 trans.GetCryptographer(), |
1457 syncable::BOOKMARKS, | 1473 syncable::BOOKMARKS, |
1458 true /* is encrypted */)); | 1474 true /* is encrypted */)); |
1459 | 1475 |
1460 ReadNode node(&trans); | 1476 ReadNode node(&trans); |
1461 EXPECT_TRUE(node.InitByIdLookup(node_id1)); | 1477 EXPECT_TRUE(node.InitByIdLookup(node_id1)); |
1462 EXPECT_EQ(syncable::BOOKMARKS, node.GetModelType()); | 1478 EXPECT_EQ(syncable::BOOKMARKS, node.GetModelType()); |
1463 EXPECT_EQ(title, node.GetTitle()); | 1479 EXPECT_EQ(title, node.GetTitle()); |
1464 EXPECT_EQ(title, node.GetBookmarkSpecifics().title()); | 1480 EXPECT_EQ(title, node.GetBookmarkSpecifics().title()); |
1465 EXPECT_EQ(url, node.GetBookmarkSpecifics().url()); | 1481 EXPECT_EQ(url, node.GetBookmarkSpecifics().url()); |
1466 | 1482 |
1467 ReadNode node2(&trans); | 1483 ReadNode node2(&trans); |
1468 EXPECT_TRUE(node2.InitByIdLookup(node_id2)); | 1484 EXPECT_TRUE(node2.InitByIdLookup(node_id2)); |
1469 EXPECT_EQ(syncable::BOOKMARKS, node2.GetModelType()); | 1485 EXPECT_EQ(syncable::BOOKMARKS, node2.GetModelType()); |
1470 // We should de-canonicalize the title in GetTitle(), but the title in the | 1486 // We should de-canonicalize the title in GetTitle(), but the title in the |
1471 // specifics should be stored in the server legal form. | 1487 // specifics should be stored in the server legal form. |
1472 EXPECT_EQ(raw_title2, node2.GetTitle()); | 1488 EXPECT_EQ(raw_title2, node2.GetTitle()); |
1473 EXPECT_EQ(title2, node2.GetBookmarkSpecifics().title()); | 1489 EXPECT_EQ(title2, node2.GetBookmarkSpecifics().title()); |
1474 EXPECT_EQ(url2, node2.GetBookmarkSpecifics().url()); | 1490 EXPECT_EQ(url2, node2.GetBookmarkSpecifics().url()); |
1475 } | 1491 } |
1476 } | 1492 } |
1477 | 1493 |
1478 } // namespace browser_sync | 1494 } // namespace browser_sync |
OLD | NEW |