| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "sync/engine/apply_updates_command.h" | 11 #include "sync/engine/apply_updates_command.h" |
| 12 #include "sync/engine/nigori_util.h" | 12 #include "sync/engine/nigori_util.h" |
| 13 #include "sync/engine/syncer.h" | 13 #include "sync/engine/syncer.h" |
| 14 #include "sync/engine/syncer_util.h" | 14 #include "sync/engine/syncer_util.h" |
| 15 #include "sync/internal_api/public/test/test_entry_factory.h" | 15 #include "sync/internal_api/public/test/test_entry_factory.h" |
| 16 #include "sync/protocol/bookmark_specifics.pb.h" | 16 #include "sync/protocol/bookmark_specifics.pb.h" |
| 17 #include "sync/protocol/password_specifics.pb.h" | 17 #include "sync/protocol/password_specifics.pb.h" |
| 18 #include "sync/sessions/sync_session.h" | 18 #include "sync/sessions/sync_session.h" |
| 19 #include "sync/syncable/mutable_entry.h" | 19 #include "sync/syncable/mutable_entry.h" |
| 20 #include "sync/syncable/read_transaction.h" | 20 #include "sync/syncable/read_transaction.h" |
| 21 #include "sync/syncable/syncable_id.h" | 21 #include "sync/syncable/syncable_id.h" |
| 22 #include "sync/syncable/write_transaction.h" | 22 #include "sync/syncable/write_transaction.h" |
| 23 #include "sync/test/engine/fake_model_worker.h" | 23 #include "sync/test/engine/fake_model_worker.h" |
| 24 #include "sync/test/engine/syncer_command_test.h" | 24 #include "sync/test/engine/syncer_command_test.h" |
| 25 #include "sync/test/engine/test_id_factory.h" | 25 #include "sync/test/engine/test_id_factory.h" |
| 26 #include "sync/test/fake_encryptor.h" | 26 #include "sync/test/fake_encryptor.h" |
| 27 #include "sync/util/cryptographer.h" | 27 #include "sync/util/cryptographer.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 namespace csync { | 30 namespace syncer { |
| 31 | 31 |
| 32 using sessions::SyncSession; | 32 using sessions::SyncSession; |
| 33 using std::string; | 33 using std::string; |
| 34 using syncable::Id; | 34 using syncable::Id; |
| 35 using syncable::MutableEntry; | 35 using syncable::MutableEntry; |
| 36 using syncable::UNITTEST; | 36 using syncable::UNITTEST; |
| 37 using syncable::WriteTransaction; | 37 using syncable::WriteTransaction; |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 sync_pb::EntitySpecifics DefaultBookmarkSpecifics() { | 40 sync_pb::EntitySpecifics DefaultBookmarkSpecifics() { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { | 373 TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { |
| 374 // Decryptable password updates should be applied. | 374 // Decryptable password updates should be applied. |
| 375 Cryptographer* cryptographer; | 375 Cryptographer* cryptographer; |
| 376 { | 376 { |
| 377 // Storing the cryptographer separately is bad, but for this test we | 377 // Storing the cryptographer separately is bad, but for this test we |
| 378 // know it's safe. | 378 // know it's safe. |
| 379 syncable::ReadTransaction trans(FROM_HERE, directory()); | 379 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 380 cryptographer = directory()->GetCryptographer(&trans); | 380 cryptographer = directory()->GetCryptographer(&trans); |
| 381 } | 381 } |
| 382 | 382 |
| 383 csync::KeyParams params = {"localhost", "dummy", "foobar"}; | 383 syncer::KeyParams params = {"localhost", "dummy", "foobar"}; |
| 384 cryptographer->AddKey(params); | 384 cryptographer->AddKey(params); |
| 385 | 385 |
| 386 sync_pb::EntitySpecifics specifics; | 386 sync_pb::EntitySpecifics specifics; |
| 387 sync_pb::PasswordSpecificsData data; | 387 sync_pb::PasswordSpecificsData data; |
| 388 data.set_origin("http://example.com"); | 388 data.set_origin("http://example.com"); |
| 389 | 389 |
| 390 cryptographer->Encrypt(data, | 390 cryptographer->Encrypt(data, |
| 391 specifics.mutable_password()->mutable_encrypted()); | 391 specifics.mutable_password()->mutable_encrypted()); |
| 392 entry_factory_->CreateUnappliedNewItem("item", specifics, false); | 392 entry_factory_->CreateUnappliedNewItem("item", specifics, false); |
| 393 | 393 |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 syncable::ModelTypeSet().All())); | 849 syncable::ModelTypeSet().All())); |
| 850 EXPECT_FALSE(cryptographer->is_ready()); | 850 EXPECT_FALSE(cryptographer->is_ready()); |
| 851 EXPECT_TRUE(cryptographer->has_pending_keys()); | 851 EXPECT_TRUE(cryptographer->has_pending_keys()); |
| 852 | 852 |
| 853 Syncer::UnsyncedMetaHandles handles; | 853 Syncer::UnsyncedMetaHandles handles; |
| 854 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 854 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
| 855 EXPECT_EQ(2*batch_s+1, handles.size()); | 855 EXPECT_EQ(2*batch_s+1, handles.size()); |
| 856 } | 856 } |
| 857 } | 857 } |
| 858 | 858 |
| 859 } // namespace csync | 859 } // namespace syncer |
| OLD | NEW |