| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/glue/generic_change_processor.h" | 5 #include "chrome/browser/sync/glue/generic_change_processor.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "components/sync_driver/data_type_error_handler_mock.h" | 11 #include "components/sync_driver/data_type_error_handler_mock.h" |
| 12 #include "sync/api/attachments/fake_attachment_service.h" |
| 12 #include "sync/api/fake_syncable_service.h" | 13 #include "sync/api/fake_syncable_service.h" |
| 13 #include "sync/api/sync_change.h" | 14 #include "sync/api/sync_change.h" |
| 14 #include "sync/api/sync_merge_result.h" | 15 #include "sync/api/sync_merge_result.h" |
| 15 #include "sync/internal_api/public/base/model_type.h" | 16 #include "sync/internal_api/public/base/model_type.h" |
| 16 #include "sync/internal_api/public/read_node.h" | 17 #include "sync/internal_api/public/read_node.h" |
| 17 #include "sync/internal_api/public/read_transaction.h" | 18 #include "sync/internal_api/public/read_transaction.h" |
| 18 #include "sync/internal_api/public/test/test_user_share.h" | 19 #include "sync/internal_api/public/test/test_user_share.h" |
| 19 #include "sync/internal_api/public/user_share.h" | 20 #include "sync/internal_api/public/user_share.h" |
| 20 #include "sync/internal_api/public/write_node.h" | 21 #include "sync/internal_api/public/write_node.h" |
| 21 #include "sync/internal_api/public/write_transaction.h" | 22 #include "sync/internal_api/public/write_transaction.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 | 39 |
| 39 virtual void SetUp() OVERRIDE { | 40 virtual void SetUp() OVERRIDE { |
| 40 test_user_share_.SetUp(); | 41 test_user_share_.SetUp(); |
| 41 syncer::ModelTypeSet types = syncer::ProtocolTypes(); | 42 syncer::ModelTypeSet types = syncer::ProtocolTypes(); |
| 42 for (syncer::ModelTypeSet::Iterator iter = types.First(); iter.Good(); | 43 for (syncer::ModelTypeSet::Iterator iter = types.First(); iter.Good(); |
| 43 iter.Inc()) { | 44 iter.Inc()) { |
| 44 syncer::TestUserShare::CreateRoot(iter.Get(), | 45 syncer::TestUserShare::CreateRoot(iter.Get(), |
| 45 test_user_share_.user_share()); | 46 test_user_share_.user_share()); |
| 46 } | 47 } |
| 47 test_user_share_.encryption_handler()->Init(); | 48 test_user_share_.encryption_handler()->Init(); |
| 48 change_processor_.reset( | 49 change_processor_.reset(new GenericChangeProcessor( |
| 49 new GenericChangeProcessor( | 50 &data_type_error_handler_, |
| 50 &data_type_error_handler_, | 51 syncable_service_ptr_factory_.GetWeakPtr(), |
| 51 syncable_service_ptr_factory_.GetWeakPtr(), | 52 merge_result_ptr_factory_.GetWeakPtr(), |
| 52 merge_result_ptr_factory_.GetWeakPtr(), | 53 test_user_share_.user_share(), |
| 53 test_user_share_.user_share())); | 54 syncer::FakeAttachmentService::CreateForTest())); |
| 54 } | 55 } |
| 55 | 56 |
| 56 virtual void TearDown() OVERRIDE { | 57 virtual void TearDown() OVERRIDE { |
| 57 test_user_share_.TearDown(); | 58 test_user_share_.TearDown(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 void BuildChildNodes(int n) { | 61 void BuildChildNodes(int n) { |
| 61 syncer::WriteTransaction trans(FROM_HERE, user_share()); | 62 syncer::WriteTransaction trans(FROM_HERE, user_share()); |
| 62 syncer::ReadNode root(&trans); | 63 syncer::ReadNode root(&trans); |
| 63 ASSERT_EQ(syncer::BaseNode::INIT_OK, | 64 ASSERT_EQ(syncer::BaseNode::INIT_OK, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 base::StringPrintf("tag%i", i)), | 231 base::StringPrintf("tag%i", i)), |
| 231 syncer::BaseNode::INIT_OK); | 232 syncer::BaseNode::INIT_OK); |
| 232 ASSERT_EQ(node.GetTitle(), "encrypted"); | 233 ASSERT_EQ(node.GetTitle(), "encrypted"); |
| 233 const sync_pb::EntitySpecifics& raw_specifics = node.GetEntitySpecifics(); | 234 const sync_pb::EntitySpecifics& raw_specifics = node.GetEntitySpecifics(); |
| 234 ASSERT_TRUE(raw_specifics.has_password()); | 235 ASSERT_TRUE(raw_specifics.has_password()); |
| 235 ASSERT_TRUE(raw_specifics.password().has_encrypted()); | 236 ASSERT_TRUE(raw_specifics.password().has_encrypted()); |
| 236 ASSERT_FALSE(raw_specifics.password().has_client_only_encrypted_data()); | 237 ASSERT_FALSE(raw_specifics.password().has_client_only_encrypted_data()); |
| 237 } | 238 } |
| 238 } | 239 } |
| 239 | 240 |
| 241 // TODO(maniscalco): Add test cases that verify GenericChangeProcessor calls the |
| 242 // right methods on its AttachmentService at the right times. |
| 243 |
| 240 } // namespace | 244 } // namespace |
| 241 | 245 |
| 242 } // namespace browser_sync | 246 } // namespace browser_sync |
| 243 | |
| OLD | NEW |