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

Side by Side Diff: chrome/browser/sync/abstract_profile_sync_service_test.h

Issue 3913005: sync: enable password sync by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/debug
Patch Set: fix mac again Created 10 years, 2 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 | « no previous file | chrome/browser/sync/glue/sync_backend_host.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ 5 #ifndef CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
6 #define CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ 6 #define CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 using syncable::SERVER_IS_DIR; 44 using syncable::SERVER_IS_DIR;
45 using syncable::SERVER_VERSION; 45 using syncable::SERVER_VERSION;
46 using syncable::SPECIFICS; 46 using syncable::SPECIFICS;
47 using syncable::ScopedDirLookup; 47 using syncable::ScopedDirLookup;
48 using syncable::UNIQUE_SERVER_TAG; 48 using syncable::UNIQUE_SERVER_TAG;
49 using syncable::UNITTEST; 49 using syncable::UNITTEST;
50 using syncable::WriteTransaction; 50 using syncable::WriteTransaction;
51 51
52 class ProfileSyncServiceTestHelper { 52 class ProfileSyncServiceTestHelper {
53 public: 53 public:
54 static const std::string GetTagForType(ModelType type) {
55 switch (type) {
56 case syncable::AUTOFILL:
57 return browser_sync::kAutofillTag;
58 case syncable::PREFERENCES:
59 return browser_sync::kPreferencesTag;
60 case syncable::PASSWORDS:
61 return browser_sync::kPasswordTag;
62 case syncable::NIGORI:
63 return browser_sync::kNigoriTag;
64 case syncable::TYPED_URLS:
65 return browser_sync::kTypedUrlTag;
66 case syncable::SESSIONS:
67 return browser_sync::kSessionsTag;
68 case syncable::BOOKMARKS:
69 return "google_chrome_bookmarks";
70 default:
71 NOTREACHED();
72 return std::string();
73 }
74 }
75
54 static bool CreateRoot(ModelType model_type, ProfileSyncService* service, 76 static bool CreateRoot(ModelType model_type, ProfileSyncService* service,
55 TestIdFactory* ids) { 77 TestIdFactory* ids) {
56 UserShare* user_share = service->backend()->GetUserShareHandle(); 78 UserShare* user_share = service->backend()->GetUserShareHandle();
57 DirectoryManager* dir_manager = user_share->dir_manager.get(); 79 DirectoryManager* dir_manager = user_share->dir_manager.get();
58 80
59 ScopedDirLookup dir(dir_manager, user_share->name); 81 ScopedDirLookup dir(dir_manager, user_share->name);
60 if (!dir.good()) 82 if (!dir.good())
61 return false; 83 return false;
62 84
63 std::string tag_name; 85 std::string tag_name = GetTagForType(model_type);
64 switch (model_type) {
65 case syncable::AUTOFILL:
66 tag_name = browser_sync::kAutofillTag;
67 break;
68 case syncable::PREFERENCES:
69 tag_name = browser_sync::kPreferencesTag;
70 break;
71 case syncable::PASSWORDS:
72 tag_name = browser_sync::kPasswordTag;
73 break;
74 case syncable::NIGORI:
75 tag_name = browser_sync::kNigoriTag;
76 break;
77 case syncable::TYPED_URLS:
78 tag_name = browser_sync::kTypedUrlTag;
79 break;
80 case syncable::SESSIONS:
81 tag_name = browser_sync::kSessionsTag;
82 break;
83 default:
84 return false;
85 }
86
87 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); 86 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__);
88 MutableEntry node(&wtrans, 87 MutableEntry node(&wtrans,
89 CREATE, 88 CREATE,
90 wtrans.root_id(), 89 wtrans.root_id(),
91 tag_name); 90 tag_name);
92 node.Put(UNIQUE_SERVER_TAG, tag_name); 91 node.Put(UNIQUE_SERVER_TAG, tag_name);
93 node.Put(IS_DIR, true); 92 node.Put(IS_DIR, true);
94 node.Put(SERVER_IS_DIR, false); 93 node.Put(SERVER_IS_DIR, false);
95 node.Put(IS_UNSYNCED, false); 94 node.Put(IS_UNSYNCED, false);
96 node.Put(IS_UNAPPLIED_UPDATE, false); 95 node.Put(IS_UNAPPLIED_UPDATE, false);
97 node.Put(SERVER_VERSION, 20); 96 node.Put(SERVER_VERSION, 20);
98 node.Put(BASE_VERSION, 20); 97 node.Put(BASE_VERSION, 20);
99 node.Put(IS_DEL, false); 98 node.Put(IS_DEL, false);
100 node.Put(syncable::ID, ids->MakeServer(tag_name)); 99 EXPECT_TRUE(node.Put(syncable::ID, ids->MakeServer(tag_name)));
101 sync_pb::EntitySpecifics specifics; 100 sync_pb::EntitySpecifics specifics;
102 syncable::AddDefaultExtensionValue(model_type, &specifics); 101 syncable::AddDefaultExtensionValue(model_type, &specifics);
103 node.Put(SPECIFICS, specifics); 102 node.Put(SPECIFICS, specifics);
104 103
105 return true; 104 return true;
106 } 105 }
107 }; 106 };
108 107
109 class AbstractProfileSyncServiceTest : public testing::Test { 108 class AbstractProfileSyncServiceTest : public testing::Test {
110 public: 109 public:
111 AbstractProfileSyncServiceTest() 110 AbstractProfileSyncServiceTest()
112 : ui_thread_(BrowserThread::UI, &message_loop_) {} 111 : ui_thread_(BrowserThread::UI, &message_loop_) {}
113 112
114 bool CreateRoot(ModelType model_type) { 113 bool CreateRoot(ModelType model_type) {
115 return ProfileSyncServiceTestHelper::CreateRoot(model_type, 114 return ProfileSyncServiceTestHelper::CreateRoot(model_type,
116 service_.get(), &ids_); 115 service_.get(),
116 service_->id_factory());
117 } 117 }
118 118
119 protected: 119 protected:
120 120
121 MessageLoopForUI message_loop_; 121 MessageLoopForUI message_loop_;
122 BrowserThread ui_thread_; 122 BrowserThread ui_thread_;
123 ProfileSyncFactoryMock factory_; 123 ProfileSyncFactoryMock factory_;
124 TokenService token_service_; 124 TokenService token_service_;
125 scoped_ptr<TestProfileSyncService> service_; 125 scoped_ptr<TestProfileSyncService> service_;
126 TestIdFactory ids_;
127 }; 126 };
128 127
129 class CreateRootTask : public Task { 128 class CreateRootTask : public Task {
130 public: 129 public:
131 CreateRootTask(AbstractProfileSyncServiceTest* test, ModelType model_type) 130 CreateRootTask(AbstractProfileSyncServiceTest* test, ModelType model_type)
132 : test_(test), model_type_(model_type), success_(false) { 131 : test_(test), model_type_(model_type), success_(false) {
133 } 132 }
134 133
135 virtual ~CreateRootTask() {} 134 virtual ~CreateRootTask() {}
136 virtual void Run() { 135 virtual void Run() {
137 success_ = test_->CreateRoot(model_type_); 136 success_ = test_->CreateRoot(model_type_);
138 } 137 }
139 138
140 bool success() { return success_; } 139 bool success() { return success_; }
141 140
142 private: 141 private:
143 AbstractProfileSyncServiceTest* test_; 142 AbstractProfileSyncServiceTest* test_;
144 ModelType model_type_; 143 ModelType model_type_;
145 bool success_; 144 bool success_;
146 }; 145 };
147 146
148 #endif // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ 147 #endif // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/glue/sync_backend_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698