| Index: chrome/browser/sync/engine/apply_updates_command_unittest.cc
|
| diff --git a/chrome/browser/sync/engine/apply_updates_command_unittest.cc b/chrome/browser/sync/engine/apply_updates_command_unittest.cc
|
| index b3ca18c09369a1f21d72ea00ebeb9f36cc1aaeda..e651c356f34d998bf979d85d8c5b5b778944b7f5 100644
|
| --- a/chrome/browser/sync/engine/apply_updates_command_unittest.cc
|
| +++ b/chrome/browser/sync/engine/apply_updates_command_unittest.cc
|
| @@ -255,14 +255,26 @@ TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) {
|
| }
|
|
|
| TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) {
|
| + syncable::ModelTypeSet encrypted_types;
|
| + {
|
| + ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
|
| + ASSERT_TRUE(dir.good());
|
| + ReadTransaction trans(dir, __FILE__, __LINE__);
|
| + EXPECT_EQ(encrypted_types, trans.GetEncryptedDatatypes());
|
| + }
|
| +
|
| // Nigori node updates should update the Cryptographer.
|
| Cryptographer other_cryptographer;
|
| KeyParams params = {"localhost", "dummy", "foobar"};
|
| other_cryptographer.AddKey(params);
|
|
|
| sync_pb::EntitySpecifics specifics;
|
| - other_cryptographer.GetKeys(
|
| - specifics.MutableExtension(sync_pb::nigori)->mutable_encrypted());
|
| + sync_pb::NigoriSpecifics* nigori =
|
| + specifics.MutableExtension(sync_pb::nigori);
|
| + other_cryptographer.GetKeys(nigori->mutable_encrypted());
|
| + nigori->set_encrypt_bookmarks(true);
|
| + encrypted_types.insert(syncable::BOOKMARKS);
|
| + encrypted_types.insert(syncable::PASSWORDS); // Will get set by default.
|
|
|
| CreateUnappliedNewItem("item", specifics);
|
|
|
| @@ -285,4 +297,51 @@ TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) {
|
| EXPECT_TRUE(cryptographer->has_pending_keys());
|
| }
|
|
|
| +TEST_F(ApplyUpdatesCommandTest, NigoriUpdateWithUnsyncedChange) {
|
| + syncable::ModelTypeSet encrypted_types;
|
| + {
|
| + ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
|
| + ASSERT_TRUE(dir.good());
|
| + ReadTransaction trans(dir, __FILE__, __LINE__);
|
| + EXPECT_EQ(encrypted_types, trans.GetEncryptedDatatypes());
|
| + }
|
| +
|
| + // Create an unapplied bookmark node without encryption.
|
| + string root_server_id = syncable::kNullId.GetServerId();
|
| + CreateUnappliedNewItemWithParent("parent", root_server_id);
|
| +
|
| + // Nigori node updates should update the Cryptographer.
|
| + Cryptographer other_cryptographer;
|
| + KeyParams params = {"localhost", "dummy", "foobar"};
|
| + other_cryptographer.AddKey(params);
|
| +
|
| + sync_pb::EntitySpecifics specifics;
|
| + sync_pb::NigoriSpecifics* nigori =
|
| + specifics.MutableExtension(sync_pb::nigori);
|
| + other_cryptographer.GetKeys(nigori->mutable_encrypted());
|
| + nigori->set_encrypt_bookmarks(true);
|
| + encrypted_types.insert(syncable::BOOKMARKS);
|
| + encrypted_types.insert(syncable::PASSWORDS); // Will get set by default.
|
| +
|
| + CreateUnappliedNewItem("item", specifics);
|
| +
|
| + Cryptographer* cryptographer =
|
| + session()->context()->directory_manager()->cryptographer();
|
| + EXPECT_FALSE(cryptographer->has_pending_keys());
|
| +
|
| + apply_updates_command_.ExecuteImpl(session());
|
| +
|
| + sessions::StatusController* status = session()->status_controller();
|
| + sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE);
|
| + EXPECT_EQ(2, status->update_progress().AppliedUpdatesSize())
|
| + << "All updates should have been attempted";
|
| + EXPECT_EQ(0, status->conflict_progress().ConflictingItemsSize())
|
| + << "The nigori update shouldn't be in conflict";
|
| + EXPECT_EQ(2, status->update_progress().SuccessfullyAppliedUpdateCount())
|
| + << "The nigori update should be applied";
|
| +
|
| + EXPECT_FALSE(cryptographer->is_ready());
|
| + EXPECT_TRUE(cryptographer->has_pending_keys());
|
| +}
|
| +
|
| } // namespace browser_sync
|
|
|