Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: sync/internal_api/test/test_user_share.cc

Issue 10958007: sync: Refactor CreateRoot() test helper function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Found more stuff to clean up Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/internal_api/public/test/test_user_share.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
10 #include "sync/syncable/write_transaction.h"
9 #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"
10 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
11 14
12 namespace syncer { 15 namespace syncer {
13 16
14 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {} 17 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {}
15 18
16 TestUserShare::~TestUserShare() { 19 TestUserShare::~TestUserShare() {
17 if (user_share_.get()) 20 if (user_share_.get())
18 ADD_FAILURE() << "Should have called TestUserShare::TearDown()"; 21 ADD_FAILURE() << "Should have called TestUserShare::TearDown()";
19 } 22 }
(...skipping 16 matching lines...) Expand all
36 } 39 }
37 40
38 UserShare* TestUserShare::user_share() { 41 UserShare* TestUserShare::user_share() {
39 return user_share_.get(); 42 return user_share_.get();
40 } 43 }
41 44
42 SyncEncryptionHandler* TestUserShare::encryption_handler() { 45 SyncEncryptionHandler* TestUserShare::encryption_handler() {
43 return dir_maker_->encryption_handler(); 46 return dir_maker_->encryption_handler();
44 } 47 }
45 48
49 /* static */
50 bool TestUserShare::CreateRoot(ModelType model_type, UserShare* user_share) {
51 syncer::syncable::Directory* directory = user_share->directory.get();
52
53 std::string tag_name = syncer::ModelTypeToRootTag(model_type);
54
55 syncable::WriteTransaction wtrans(FROM_HERE, syncable::UNITTEST, directory);
56 syncable::MutableEntry node(&wtrans,
57 syncable::CREATE,
58 wtrans.root_id(),
59 tag_name);
60 node.Put(syncable::UNIQUE_SERVER_TAG, tag_name);
61 node.Put(syncable::IS_DIR, true);
62 node.Put(syncable::SERVER_IS_DIR, false);
63 node.Put(syncable::IS_UNSYNCED, false);
64 node.Put(syncable::IS_UNAPPLIED_UPDATE, false);
65 node.Put(syncable::SERVER_VERSION, 20);
66 node.Put(syncable::BASE_VERSION, 20);
67 node.Put(syncable::IS_DEL, false);
68 node.Put(syncable::ID, syncer::TestIdFactory::MakeServer(tag_name));
69 sync_pb::EntitySpecifics specifics;
70 syncer::AddDefaultFieldValue(model_type, &specifics);
71 node.Put(syncable::SPECIFICS, specifics);
72
73 return true;
74 }
75
46 } // namespace syncer 76 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/public/test/test_user_share.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698