| 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 "sync/internal_api/public/test/test_user_share.h" | 5 #include "sync/internal_api/public/test/test_user_share.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "sync/syncable/directory.h" | 8 #include "sync/syncable/directory.h" |
| 9 #include "sync/syncable/mutable_entry.h" | 9 #include "sync/syncable/mutable_entry.h" |
| 10 #include "sync/syncable/write_transaction.h" | 10 #include "sync/syncable/write_transaction.h" |
| 11 #include "sync/test/engine/test_directory_setter_upper.h" | 11 #include "sync/test/engine/test_directory_setter_upper.h" |
| 12 #include "sync/test/engine/test_id_factory.h" | 12 #include "sync/test/engine/test_id_factory.h" |
| 13 #include "sync/test/engine/test_syncable_utils.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace syncer { | 16 namespace syncer { |
| 16 | 17 |
| 17 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {} | 18 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {} |
| 18 | 19 |
| 19 TestUserShare::~TestUserShare() { | 20 TestUserShare::~TestUserShare() { |
| 20 if (user_share_.get()) | 21 if (user_share_.get()) |
| 21 ADD_FAILURE() << "Should have called TestUserShare::TearDown()"; | 22 ADD_FAILURE() << "Should have called TestUserShare::TearDown()"; |
| 22 } | 23 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 return dir_maker_->encryption_handler(); | 47 return dir_maker_->encryption_handler(); |
| 47 } | 48 } |
| 48 | 49 |
| 49 syncable::TestTransactionObserver* TestUserShare::transaction_observer() { | 50 syncable::TestTransactionObserver* TestUserShare::transaction_observer() { |
| 50 return dir_maker_->transaction_observer(); | 51 return dir_maker_->transaction_observer(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 /* static */ | 54 /* static */ |
| 54 bool TestUserShare::CreateRoot(ModelType model_type, UserShare* user_share) { | 55 bool TestUserShare::CreateRoot(ModelType model_type, UserShare* user_share) { |
| 55 syncer::syncable::Directory* directory = user_share->directory.get(); | 56 syncer::syncable::Directory* directory = user_share->directory.get(); |
| 56 | |
| 57 std::string tag_name = syncer::ModelTypeToRootTag(model_type); | |
| 58 | |
| 59 syncable::WriteTransaction wtrans(FROM_HERE, syncable::UNITTEST, directory); | 57 syncable::WriteTransaction wtrans(FROM_HERE, syncable::UNITTEST, directory); |
| 60 syncable::MutableEntry node(&wtrans, | 58 CreateTypeRoot(&wtrans, directory, model_type); |
| 61 syncable::CREATE, | |
| 62 wtrans.root_id(), | |
| 63 tag_name); | |
| 64 node.Put(syncable::UNIQUE_SERVER_TAG, tag_name); | |
| 65 node.Put(syncable::IS_DIR, true); | |
| 66 node.Put(syncable::SERVER_IS_DIR, false); | |
| 67 node.Put(syncable::IS_UNSYNCED, false); | |
| 68 node.Put(syncable::IS_UNAPPLIED_UPDATE, false); | |
| 69 node.Put(syncable::SERVER_VERSION, 20); | |
| 70 node.Put(syncable::BASE_VERSION, 20); | |
| 71 node.Put(syncable::IS_DEL, false); | |
| 72 node.Put(syncable::ID, syncer::TestIdFactory::MakeServer(tag_name)); | |
| 73 sync_pb::EntitySpecifics specifics; | |
| 74 syncer::AddDefaultFieldValue(model_type, &specifics); | |
| 75 node.Put(syncable::SPECIFICS, specifics); | |
| 76 | |
| 77 return true; | 59 return true; |
| 78 } | 60 } |
| 79 | 61 |
| 80 } // namespace syncer | 62 } // namespace syncer |
| OLD | NEW |