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

Side by Side Diff: chrome/browser/sync/internal_api/syncapi_unittest.cc

Issue 8851006: [Sync] Replace all instances of ModelTypeSet with ModelEnumSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup 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 // 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 28 matching lines...) Expand all
39 #include "chrome/browser/sync/js/js_test_util.h" 39 #include "chrome/browser/sync/js/js_test_util.h"
40 #include "chrome/browser/sync/notifier/sync_notifier.h" 40 #include "chrome/browser/sync/notifier/sync_notifier.h"
41 #include "chrome/browser/sync/notifier/sync_notifier_observer.h" 41 #include "chrome/browser/sync/notifier/sync_notifier_observer.h"
42 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 42 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
43 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 43 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
44 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 44 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
45 #include "chrome/browser/sync/protocol/proto_value_conversions.h" 45 #include "chrome/browser/sync/protocol/proto_value_conversions.h"
46 #include "chrome/browser/sync/protocol/sync.pb.h" 46 #include "chrome/browser/sync/protocol/sync.pb.h"
47 #include "chrome/browser/sync/sessions/sync_session.h" 47 #include "chrome/browser/sync/sessions/sync_session.h"
48 #include "chrome/browser/sync/syncable/directory_manager.h" 48 #include "chrome/browser/sync/syncable/directory_manager.h"
49 #include "chrome/browser/sync/syncable/model_type_test_util.h"
49 #include "chrome/browser/sync/syncable/syncable.h" 50 #include "chrome/browser/sync/syncable/syncable.h"
50 #include "chrome/browser/sync/syncable/syncable_id.h" 51 #include "chrome/browser/sync/syncable/syncable_id.h"
51 #include "chrome/browser/sync/test/engine/test_user_share.h" 52 #include "chrome/browser/sync/test/engine/test_user_share.h"
52 #include "chrome/browser/sync/util/cryptographer.h" 53 #include "chrome/browser/sync/util/cryptographer.h"
53 #include "chrome/browser/sync/util/time.h" 54 #include "chrome/browser/sync/util/time.h"
54 #include "chrome/test/base/values_test_util.h" 55 #include "chrome/test/base/values_test_util.h"
55 #include "content/test/test_browser_thread.h" 56 #include "content/test/test_browser_thread.h"
56 #include "testing/gmock/include/gmock/gmock.h" 57 #include "testing/gmock/include/gmock/gmock.h"
57 #include "testing/gtest/include/gtest/gtest.h" 58 #include "testing/gtest/include/gtest/gtest.h"
58 59
59 using browser_sync::Cryptographer; 60 using browser_sync::Cryptographer;
60 using browser_sync::HasArgsAsList; 61 using browser_sync::HasArgsAsList;
61 using browser_sync::HasDetailsAsDictionary; 62 using browser_sync::HasDetailsAsDictionary;
62 using browser_sync::KeyParams; 63 using browser_sync::KeyParams;
63 using browser_sync::JsArgList; 64 using browser_sync::JsArgList;
64 using browser_sync::JsBackend; 65 using browser_sync::JsBackend;
65 using browser_sync::JsEventHandler; 66 using browser_sync::JsEventHandler;
66 using browser_sync::JsReplyHandler; 67 using browser_sync::JsReplyHandler;
67 using browser_sync::MockJsEventHandler; 68 using browser_sync::MockJsEventHandler;
68 using browser_sync::MockJsReplyHandler; 69 using browser_sync::MockJsReplyHandler;
69 using browser_sync::ModelSafeRoutingInfo; 70 using browser_sync::ModelSafeRoutingInfo;
70 using browser_sync::ModelSafeWorker; 71 using browser_sync::ModelSafeWorker;
71 using browser_sync::ModelSafeWorkerRegistrar; 72 using browser_sync::ModelSafeWorkerRegistrar;
72 using browser_sync::sessions::SyncSessionSnapshot; 73 using browser_sync::sessions::SyncSessionSnapshot;
73 using browser_sync::WeakHandle; 74 using browser_sync::WeakHandle;
74 using content::BrowserThread; 75 using content::BrowserThread;
75 using syncable::GetAllRealModelTypes;
76 using syncable::kEncryptedString; 76 using syncable::kEncryptedString;
77 using syncable::ModelEnumSet;
77 using syncable::ModelType; 78 using syncable::ModelType;
78 using syncable::ModelTypeSet;
79 using test::ExpectDictStringValue; 79 using test::ExpectDictStringValue;
80 using testing::_; 80 using testing::_;
81 using testing::AnyNumber; 81 using testing::AnyNumber;
82 using testing::AtLeast; 82 using testing::AtLeast;
83 using testing::InSequence; 83 using testing::InSequence;
84 using testing::Invoke; 84 using testing::Invoke;
85 using testing::SaveArg; 85 using testing::SaveArg;
86 using testing::StrictMock; 86 using testing::StrictMock;
87 87
88 namespace sync_api { 88 namespace sync_api {
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 void(const WeakHandle<JsBackend>&, bool)); // NOLINT 625 void(const WeakHandle<JsBackend>&, bool)); // NOLINT
626 MOCK_METHOD1(OnAuthError, void(const GoogleServiceAuthError&)); // NOLINT 626 MOCK_METHOD1(OnAuthError, void(const GoogleServiceAuthError&)); // NOLINT
627 MOCK_METHOD1(OnPassphraseRequired, 627 MOCK_METHOD1(OnPassphraseRequired,
628 void(sync_api::PassphraseRequiredReason)); // NOLINT 628 void(sync_api::PassphraseRequiredReason)); // NOLINT
629 MOCK_METHOD1(OnPassphraseAccepted, void(const std::string&)); // NOLINT 629 MOCK_METHOD1(OnPassphraseAccepted, void(const std::string&)); // NOLINT
630 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT 630 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT
631 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT 631 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT
632 MOCK_METHOD0(OnClearServerDataFailed, void()); // NOLINT 632 MOCK_METHOD0(OnClearServerDataFailed, void()); // NOLINT
633 MOCK_METHOD0(OnClearServerDataSucceeded, void()); // NOLINT 633 MOCK_METHOD0(OnClearServerDataSucceeded, void()); // NOLINT
634 MOCK_METHOD2(OnEncryptedTypesChanged, 634 MOCK_METHOD2(OnEncryptedTypesChanged,
635 void(const ModelTypeSet&, bool)); // NOLINT 635 void(ModelEnumSet, bool)); // NOLINT
636 MOCK_METHOD0(OnEncryptionComplete, void()); // NOLINT 636 MOCK_METHOD0(OnEncryptionComplete, void()); // NOLINT
637 MOCK_METHOD1(OnActionableError, 637 MOCK_METHOD1(OnActionableError,
638 void(const browser_sync::SyncProtocolError&)); // NOLINT 638 void(const browser_sync::SyncProtocolError&)); // NOLINT
639 }; 639 };
640 640
641 class SyncNotifierMock : public sync_notifier::SyncNotifier { 641 class SyncNotifierMock : public sync_notifier::SyncNotifier {
642 public: 642 public:
643 MOCK_METHOD1(AddObserver, void(sync_notifier::SyncNotifierObserver*)); 643 MOCK_METHOD1(AddObserver, void(sync_notifier::SyncNotifierObserver*));
644 MOCK_METHOD1(RemoveObserver, void(sync_notifier::SyncNotifierObserver*)); 644 MOCK_METHOD1(RemoveObserver, void(sync_notifier::SyncNotifierObserver*));
645 MOCK_METHOD1(SetUniqueId, void(const std::string&)); 645 MOCK_METHOD1(SetUniqueId, void(const std::string&));
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 sync_manager_.TriggerOnIncomingNotificationForTest(model_types); 1190 sync_manager_.TriggerOnIncomingNotificationForTest(model_types);
1191 1191
1192 // Should trigger the replies. 1192 // Should trigger the replies.
1193 PumpLoop(); 1193 PumpLoop();
1194 } 1194 }
1195 1195
1196 TEST_F(SyncManagerTest, RefreshEncryptionReady) { 1196 TEST_F(SyncManagerTest, RefreshEncryptionReady) {
1197 EXPECT_TRUE(SetUpEncryption(true)); 1197 EXPECT_TRUE(SetUpEncryption(true));
1198 EXPECT_CALL(observer_, OnEncryptionComplete()); 1198 EXPECT_CALL(observer_, OnEncryptionComplete());
1199 sync_manager_.RefreshEncryption(); 1199 sync_manager_.RefreshEncryption();
1200 syncable::ModelTypeSet encrypted_types = 1200 syncable::ModelEnumSet encrypted_types =
1201 sync_manager_.GetEncryptedDataTypesForTest(); 1201 sync_manager_.GetEncryptedDataTypesForTest();
1202 EXPECT_EQ(1U, encrypted_types.count(syncable::PASSWORDS)); 1202 EXPECT_TRUE(encrypted_types.Has(syncable::PASSWORDS));
1203 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest()); 1203 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest());
1204 { 1204 {
1205 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1205 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1206 ReadNode node(&trans); 1206 ReadNode node(&trans);
1207 EXPECT_TRUE(node.InitByIdLookup(GetIdForDataType(syncable::NIGORI))); 1207 EXPECT_TRUE(node.InitByIdLookup(GetIdForDataType(syncable::NIGORI)));
1208 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics(); 1208 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
1209 EXPECT_TRUE(nigori.has_encrypted()); 1209 EXPECT_TRUE(nigori.has_encrypted());
1210 Cryptographer* cryptographer = trans.GetCryptographer(); 1210 Cryptographer* cryptographer = trans.GetCryptographer();
1211 EXPECT_TRUE(cryptographer->is_ready()); 1211 EXPECT_TRUE(cryptographer->is_ready());
1212 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted())); 1212 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted()));
1213 } 1213 }
1214 } 1214 }
1215 1215
1216 // Attempt to refresh encryption when nigori not downloaded. 1216 // Attempt to refresh encryption when nigori not downloaded.
1217 TEST_F(SyncManagerTest, RefreshEncryptionNotReady) { 1217 TEST_F(SyncManagerTest, RefreshEncryptionNotReady) {
1218 // Don't set up encryption (no nigori node created). 1218 // Don't set up encryption (no nigori node created).
1219 sync_manager_.RefreshEncryption(); // Should fail. 1219 sync_manager_.RefreshEncryption(); // Should fail.
1220 syncable::ModelTypeSet encrypted_types = 1220 syncable::ModelEnumSet encrypted_types =
1221 sync_manager_.GetEncryptedDataTypesForTest(); 1221 sync_manager_.GetEncryptedDataTypesForTest();
1222 EXPECT_EQ(1U, encrypted_types.count(syncable::PASSWORDS)); // Hardcoded. 1222 EXPECT_TRUE(encrypted_types.Has(syncable::PASSWORDS)); // Hardcoded.
1223 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest()); 1223 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest());
1224 } 1224 }
1225 1225
1226 // Attempt to refresh encryption when nigori is empty. 1226 // Attempt to refresh encryption when nigori is empty.
1227 TEST_F(SyncManagerTest, RefreshEncryptionEmptyNigori) { 1227 TEST_F(SyncManagerTest, RefreshEncryptionEmptyNigori) {
1228 EXPECT_TRUE(SetUpEncryption(false)); 1228 EXPECT_TRUE(SetUpEncryption(false));
1229 EXPECT_CALL(observer_, OnEncryptionComplete()); 1229 EXPECT_CALL(observer_, OnEncryptionComplete());
1230 sync_manager_.RefreshEncryption(); // Should write to nigori. 1230 sync_manager_.RefreshEncryption(); // Should write to nigori.
1231 syncable::ModelTypeSet encrypted_types = 1231 syncable::ModelEnumSet encrypted_types =
1232 sync_manager_.GetEncryptedDataTypesForTest(); 1232 sync_manager_.GetEncryptedDataTypesForTest();
1233 EXPECT_EQ(1U, encrypted_types.count(syncable::PASSWORDS)); // Hardcoded. 1233 EXPECT_TRUE(encrypted_types.Has(syncable::PASSWORDS)); // Hardcoded.
1234 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest()); 1234 EXPECT_FALSE(sync_manager_.EncryptEverythingEnabledForTest());
1235 { 1235 {
1236 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1236 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1237 ReadNode node(&trans); 1237 ReadNode node(&trans);
1238 EXPECT_TRUE(node.InitByIdLookup(GetIdForDataType(syncable::NIGORI))); 1238 EXPECT_TRUE(node.InitByIdLookup(GetIdForDataType(syncable::NIGORI)));
1239 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics(); 1239 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
1240 EXPECT_TRUE(nigori.has_encrypted()); 1240 EXPECT_TRUE(nigori.has_encrypted());
1241 Cryptographer* cryptographer = trans.GetCryptographer(); 1241 Cryptographer* cryptographer = trans.GetCryptographer();
1242 EXPECT_TRUE(cryptographer->is_ready()); 1242 EXPECT_TRUE(cryptographer->is_ready());
1243 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted())); 1243 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted()));
1244 } 1244 }
1245 } 1245 }
1246 1246
1247 TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) { 1247 TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) {
1248 EXPECT_TRUE(SetUpEncryption(true)); 1248 EXPECT_TRUE(SetUpEncryption(true));
1249 EXPECT_CALL(observer_, 1249 EXPECT_CALL(observer_,
1250 OnEncryptedTypesChanged(GetAllRealModelTypes(), true)); 1250 OnEncryptedTypesChanged(
1251 HasModelTypes(syncable::ModelEnumSet::All()), true));
1251 EXPECT_CALL(observer_, OnEncryptionComplete()); 1252 EXPECT_CALL(observer_, OnEncryptionComplete());
1252 sync_manager_.EnableEncryptEverything(); 1253 sync_manager_.EnableEncryptEverything();
1253 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest()); 1254 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest());
1254 } 1255 }
1255 1256
1256 TEST_F(SyncManagerTest, EncryptDataTypesWithData) { 1257 TEST_F(SyncManagerTest, EncryptDataTypesWithData) {
1257 size_t batch_size = 5; 1258 size_t batch_size = 5;
1258 EXPECT_TRUE(SetUpEncryption(true)); 1259 EXPECT_TRUE(SetUpEncryption(true));
1259 1260
1260 // Create some unencrypted unsynced data. 1261 // Create some unencrypted unsynced data.
(...skipping 15 matching lines...) Expand all
1276 } 1277 }
1277 // Last batch_size nodes are a third type that will not need encryption. 1278 // Last batch_size nodes are a third type that will not need encryption.
1278 for (; i < 3*batch_size; ++i) { 1279 for (; i < 3*batch_size; ++i) {
1279 MakeNodeWithParent(sync_manager_.GetUserShare(), syncable::THEMES, 1280 MakeNodeWithParent(sync_manager_.GetUserShare(), syncable::THEMES,
1280 base::StringPrintf("%"PRIuS"", i), 1281 base::StringPrintf("%"PRIuS"", i),
1281 GetIdForDataType(syncable::THEMES)); 1282 GetIdForDataType(syncable::THEMES));
1282 } 1283 }
1283 1284
1284 { 1285 {
1285 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1286 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1286 EXPECT_EQ(Cryptographer::SensitiveTypes(), GetEncryptedTypes(&trans)); 1287 EXPECT_TRUE(Cryptographer::SensitiveTypes().Equals(
1288 GetEncryptedTypes(&trans)));
1287 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1289 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1288 trans.GetWrappedTrans(), 1290 trans.GetWrappedTrans(),
1289 trans.GetCryptographer(), 1291 trans.GetCryptographer(),
1290 syncable::BOOKMARKS, 1292 syncable::BOOKMARKS,
1291 false /* not encrypted */)); 1293 false /* not encrypted */));
1292 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1294 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1293 trans.GetWrappedTrans(), 1295 trans.GetWrappedTrans(),
1294 trans.GetCryptographer(), 1296 trans.GetCryptographer(),
1295 syncable::SESSIONS, 1297 syncable::SESSIONS,
1296 false /* not encrypted */)); 1298 false /* not encrypted */));
1297 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1299 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1298 trans.GetWrappedTrans(), 1300 trans.GetWrappedTrans(),
1299 trans.GetCryptographer(), 1301 trans.GetCryptographer(),
1300 syncable::THEMES, 1302 syncable::THEMES,
1301 false /* not encrypted */)); 1303 false /* not encrypted */));
1302 } 1304 }
1303 1305
1304 EXPECT_CALL(observer_, 1306 EXPECT_CALL(observer_,
1305 OnEncryptedTypesChanged(GetAllRealModelTypes(), true)); 1307 OnEncryptedTypesChanged(
1308 HasModelTypes(syncable::ModelEnumSet::All()), true));
1306 EXPECT_CALL(observer_, OnEncryptionComplete()); 1309 EXPECT_CALL(observer_, OnEncryptionComplete());
1307 sync_manager_.EnableEncryptEverything(); 1310 sync_manager_.EnableEncryptEverything();
1308 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest()); 1311 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest());
1309 { 1312 {
1310 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1313 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1311 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); 1314 EXPECT_TRUE(GetEncryptedTypes(&trans)
Nicolas Zea 2011/12/08 01:49:37 make consistent with below lines
akalin 2011/12/09 19:10:10 Done.
1315 .Equals(syncable::ModelEnumSet::All()));
1312 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1316 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1313 trans.GetWrappedTrans(), 1317 trans.GetWrappedTrans(),
1314 trans.GetCryptographer(), 1318 trans.GetCryptographer(),
1315 syncable::BOOKMARKS, 1319 syncable::BOOKMARKS,
1316 true /* is encrypted */)); 1320 true /* is encrypted */));
1317 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1321 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1318 trans.GetWrappedTrans(), 1322 trans.GetWrappedTrans(),
1319 trans.GetCryptographer(), 1323 trans.GetCryptographer(),
1320 syncable::SESSIONS, 1324 syncable::SESSIONS,
1321 true /* is encrypted */)); 1325 true /* is encrypted */));
1322 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1326 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1323 trans.GetWrappedTrans(), 1327 trans.GetWrappedTrans(),
1324 trans.GetCryptographer(), 1328 trans.GetCryptographer(),
1325 syncable::THEMES, 1329 syncable::THEMES,
1326 true /* is encrypted */)); 1330 true /* is encrypted */));
1327 } 1331 }
1328 1332
1329 // Trigger's a ReEncryptEverything with new passphrase. 1333 // Trigger's a ReEncryptEverything with new passphrase.
1330 testing::Mock::VerifyAndClearExpectations(&observer_); 1334 testing::Mock::VerifyAndClearExpectations(&observer_);
1331 EXPECT_CALL(observer_, OnPassphraseAccepted(_)); 1335 EXPECT_CALL(observer_, OnPassphraseAccepted(_));
1332 EXPECT_CALL(observer_, OnEncryptionComplete()); 1336 EXPECT_CALL(observer_, OnEncryptionComplete());
1333 sync_manager_.SetPassphrase("new_passphrase", true); 1337 sync_manager_.SetPassphrase("new_passphrase", true);
1334 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest()); 1338 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest());
1335 { 1339 {
1336 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1340 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1337 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); 1341 EXPECT_TRUE(syncable::ModelEnumSet::All().Equals(
1342 GetEncryptedTypes(&trans)));
1338 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1343 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1339 trans.GetWrappedTrans(), 1344 trans.GetWrappedTrans(),
1340 trans.GetCryptographer(), 1345 trans.GetCryptographer(),
1341 syncable::BOOKMARKS, 1346 syncable::BOOKMARKS,
1342 true /* is encrypted */)); 1347 true /* is encrypted */));
1343 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1348 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1344 trans.GetWrappedTrans(), 1349 trans.GetWrappedTrans(),
1345 trans.GetCryptographer(), 1350 trans.GetCryptographer(),
1346 syncable::SESSIONS, 1351 syncable::SESSIONS,
1347 true /* is encrypted */)); 1352 true /* is encrypted */));
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 { 1492 {
1488 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1493 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1489 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1494 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1490 trans.GetWrappedTrans(), 1495 trans.GetWrappedTrans(),
1491 trans.GetCryptographer(), 1496 trans.GetCryptographer(),
1492 syncable::BOOKMARKS, 1497 syncable::BOOKMARKS,
1493 false /* not encrypted */)); 1498 false /* not encrypted */));
1494 } 1499 }
1495 1500
1496 EXPECT_CALL(observer_, 1501 EXPECT_CALL(observer_,
1497 OnEncryptedTypesChanged(GetAllRealModelTypes(), true)); 1502 OnEncryptedTypesChanged(
1503 HasModelTypes(syncable::ModelEnumSet::All()), true));
1498 EXPECT_CALL(observer_, OnEncryptionComplete()); 1504 EXPECT_CALL(observer_, OnEncryptionComplete());
1499 sync_manager_.EnableEncryptEverything(); 1505 sync_manager_.EnableEncryptEverything();
1500 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest()); 1506 EXPECT_TRUE(sync_manager_.EncryptEverythingEnabledForTest());
1501 1507
1502 { 1508 {
1503 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1509 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1504 EXPECT_EQ(GetAllRealModelTypes(), GetEncryptedTypes(&trans)); 1510 EXPECT_TRUE(syncable::ModelEnumSet::All().Equals(
1511 GetEncryptedTypes(&trans)));
1505 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1512 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1506 trans.GetWrappedTrans(), 1513 trans.GetWrappedTrans(),
1507 trans.GetCryptographer(), 1514 trans.GetCryptographer(),
1508 syncable::BOOKMARKS, 1515 syncable::BOOKMARKS,
1509 true /* is encrypted */)); 1516 true /* is encrypted */));
1510 1517
1511 ReadNode node(&trans); 1518 ReadNode node(&trans);
1512 EXPECT_TRUE(node.InitByIdLookup(node_id1)); 1519 EXPECT_TRUE(node.InitByIdLookup(node_id1));
1513 EXPECT_EQ(syncable::BOOKMARKS, node.GetModelType()); 1520 EXPECT_EQ(syncable::BOOKMARKS, node.GetModelType());
1514 EXPECT_EQ(title, node.GetTitle()); 1521 EXPECT_EQ(title, node.GetTitle());
1515 EXPECT_EQ(title, node.GetBookmarkSpecifics().title()); 1522 EXPECT_EQ(title, node.GetBookmarkSpecifics().title());
1516 EXPECT_EQ(url, node.GetBookmarkSpecifics().url()); 1523 EXPECT_EQ(url, node.GetBookmarkSpecifics().url());
1517 1524
1518 ReadNode node2(&trans); 1525 ReadNode node2(&trans);
1519 EXPECT_TRUE(node2.InitByIdLookup(node_id2)); 1526 EXPECT_TRUE(node2.InitByIdLookup(node_id2));
1520 EXPECT_EQ(syncable::BOOKMARKS, node2.GetModelType()); 1527 EXPECT_EQ(syncable::BOOKMARKS, node2.GetModelType());
1521 // We should de-canonicalize the title in GetTitle(), but the title in the 1528 // We should de-canonicalize the title in GetTitle(), but the title in the
1522 // specifics should be stored in the server legal form. 1529 // specifics should be stored in the server legal form.
1523 EXPECT_EQ(raw_title2, node2.GetTitle()); 1530 EXPECT_EQ(raw_title2, node2.GetTitle());
1524 EXPECT_EQ(title2, node2.GetBookmarkSpecifics().title()); 1531 EXPECT_EQ(title2, node2.GetBookmarkSpecifics().title());
1525 EXPECT_EQ(url2, node2.GetBookmarkSpecifics().url()); 1532 EXPECT_EQ(url2, node2.GetBookmarkSpecifics().url());
1526 } 1533 }
1527 } 1534 }
1528 1535
1529 } // namespace browser_sync 1536 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698