diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-24 18:45:09 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-24 18:45:09 +0000 |
commit | 550110450015f04eda1952f591a80ef2c1d22105 (patch) | |
tree | 746827b4a8c6c3d7a085831289a36651ec6a84c3 /sync | |
parent | 74f45dda73cf3707524942508474e7b37fe6e711 (diff) | |
download | chromium_src-550110450015f04eda1952f591a80ef2c1d22105.zip chromium_src-550110450015f04eda1952f591a80ef2c1d22105.tar.gz chromium_src-550110450015f04eda1952f591a80ef2c1d22105.tar.bz2 |
sync: Refactor CreateRoot() test helper function
Move the function's definition so we can eventually make use of it in
FakeSyncManager to test the DEVICE_INFO type. This change also removes
the unnecessary TestIdFactory parameter.
BUG=122825
Review URL: https://chromiumcodereview.appspot.com/10958007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/internal_api/public/test/test_user_share.h | 6 | ||||
-rw-r--r-- | sync/internal_api/test/test_user_share.cc | 30 |
2 files changed, 35 insertions, 1 deletions
diff --git a/sync/internal_api/public/test/test_user_share.h b/sync/internal_api/public/test/test_user_share.h index 5322d90..507a2ed 100644 --- a/sync/internal_api/public/test/test_user_share.h +++ b/sync/internal_api/public/test/test_user_share.h @@ -31,12 +31,12 @@ #define SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_ #include "base/basictypes.h" +#include "sync/internal_api/public/base/model_type.h" #include "sync/internal_api/public/user_share.h" namespace syncer { class SyncEncryptionHandler; - class TestDirectorySetterUpper; class TestUserShare { @@ -61,6 +61,10 @@ class TestUserShare { // methods normally handled via the SyncBackendHost SyncEncryptionHandler* encryption_handler(); + // A helper function to pretend to download this type's root node. + static bool CreateRoot(syncer::ModelType model_type, + syncer::UserShare* service); + private: scoped_ptr<TestDirectorySetterUpper> dir_maker_; scoped_ptr<UserShare> user_share_; diff --git a/sync/internal_api/test/test_user_share.cc b/sync/internal_api/test/test_user_share.cc index ef93b18..1533d63 100644 --- a/sync/internal_api/test/test_user_share.cc +++ b/sync/internal_api/test/test_user_share.cc @@ -6,7 +6,10 @@ #include "base/compiler_specific.h" #include "sync/syncable/directory.h" +#include "sync/syncable/mutable_entry.h" +#include "sync/syncable/write_transaction.h" #include "sync/test/engine/test_directory_setter_upper.h" +#include "sync/test/engine/test_id_factory.h" #include "testing/gtest/include/gtest/gtest.h" namespace syncer { @@ -43,4 +46,31 @@ SyncEncryptionHandler* TestUserShare::encryption_handler() { return dir_maker_->encryption_handler(); } +/* static */ +bool TestUserShare::CreateRoot(ModelType model_type, UserShare* user_share) { + syncer::syncable::Directory* directory = user_share->directory.get(); + + std::string tag_name = syncer::ModelTypeToRootTag(model_type); + + syncable::WriteTransaction wtrans(FROM_HERE, syncable::UNITTEST, directory); + syncable::MutableEntry node(&wtrans, + syncable::CREATE, + wtrans.root_id(), + tag_name); + node.Put(syncable::UNIQUE_SERVER_TAG, tag_name); + node.Put(syncable::IS_DIR, true); + node.Put(syncable::SERVER_IS_DIR, false); + node.Put(syncable::IS_UNSYNCED, false); + node.Put(syncable::IS_UNAPPLIED_UPDATE, false); + node.Put(syncable::SERVER_VERSION, 20); + node.Put(syncable::BASE_VERSION, 20); + node.Put(syncable::IS_DEL, false); + node.Put(syncable::ID, syncer::TestIdFactory::MakeServer(tag_name)); + sync_pb::EntitySpecifics specifics; + syncer::AddDefaultFieldValue(model_type, &specifics); + node.Put(syncable::SPECIFICS, specifics); + + return true; +} + } // namespace syncer |