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

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

Issue 6249006: Turn password sync on by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 using syncable::SERVER_IS_DIR; 45 using syncable::SERVER_IS_DIR;
46 using syncable::SERVER_VERSION; 46 using syncable::SERVER_VERSION;
47 using syncable::SPECIFICS; 47 using syncable::SPECIFICS;
48 using syncable::ScopedDirLookup; 48 using syncable::ScopedDirLookup;
49 using syncable::UNIQUE_SERVER_TAG; 49 using syncable::UNIQUE_SERVER_TAG;
50 using syncable::UNITTEST; 50 using syncable::UNITTEST;
51 using syncable::WriteTransaction; 51 using syncable::WriteTransaction;
52 52
53 class ProfileSyncServiceTestHelper { 53 class ProfileSyncServiceTestHelper {
54 public: 54 public:
55 static const std::string GetTagForType(ModelType model_type) {
56 switch (model_type) {
57 case syncable::AUTOFILL:
58 return browser_sync::kAutofillTag;
59 case syncable::AUTOFILL_PROFILE:
60 return browser_sync::kAutofillProfileTag;
61 case syncable::PREFERENCES:
62 return browser_sync::kPreferencesTag;
63 case syncable::PASSWORDS:
64 return browser_sync::kPasswordTag;
65 case syncable::NIGORI:
66 return browser_sync::kNigoriTag;
67 case syncable::TYPED_URLS:
68 return browser_sync::kTypedUrlTag;
69 case syncable::SESSIONS:
70 return browser_sync::kSessionsTag;
71 case syncable::BOOKMARKS:
72 return "google_chrome_bookmarks";
73 default:
74 NOTREACHED();
75 }
76 return std::string();
77 }
78
55 static bool CreateRoot(ModelType model_type, ProfileSyncService* service, 79 static bool CreateRoot(ModelType model_type, ProfileSyncService* service,
56 TestIdFactory* ids) { 80 TestIdFactory* ids) {
57 UserShare* user_share = service->backend()->GetUserShareHandle(); 81 UserShare* user_share = service->backend()->GetUserShareHandle();
58 DirectoryManager* dir_manager = user_share->dir_manager.get(); 82 DirectoryManager* dir_manager = user_share->dir_manager.get();
59 83
60 ScopedDirLookup dir(dir_manager, user_share->name); 84 ScopedDirLookup dir(dir_manager, user_share->name);
61 if (!dir.good()) 85 if (!dir.good())
62 return false; 86 return false;
63 87
64 std::string tag_name; 88 std::string tag_name = GetTagForType(model_type);
65 switch (model_type) {
66 case syncable::AUTOFILL:
67 tag_name = browser_sync::kAutofillTag;
68 break;
69 case syncable::AUTOFILL_PROFILE:
70 tag_name = browser_sync::kAutofillProfileTag;
71 break;
72 case syncable::PREFERENCES:
73 tag_name = browser_sync::kPreferencesTag;
74 break;
75 case syncable::PASSWORDS:
76 tag_name = browser_sync::kPasswordTag;
77 break;
78 case syncable::NIGORI:
79 tag_name = browser_sync::kNigoriTag;
80 break;
81 case syncable::TYPED_URLS:
82 tag_name = browser_sync::kTypedUrlTag;
83 break;
84 case syncable::SESSIONS:
85 tag_name = browser_sync::kSessionsTag;
86 break;
87 default:
88 return false;
89 }
90 89
91 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); 90 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__);
92 MutableEntry node(&wtrans, 91 MutableEntry node(&wtrans,
93 CREATE, 92 CREATE,
94 wtrans.root_id(), 93 wtrans.root_id(),
95 tag_name); 94 tag_name);
96 node.Put(UNIQUE_SERVER_TAG, tag_name); 95 node.Put(UNIQUE_SERVER_TAG, tag_name);
97 node.Put(IS_DIR, true); 96 node.Put(IS_DIR, true);
98 node.Put(SERVER_IS_DIR, false); 97 node.Put(SERVER_IS_DIR, false);
99 node.Put(IS_UNSYNCED, false); 98 node.Put(IS_UNSYNCED, false);
(...skipping 10 matching lines...) Expand all
110 } 109 }
111 }; 110 };
112 111
113 class AbstractProfileSyncServiceTest : public testing::Test { 112 class AbstractProfileSyncServiceTest : public testing::Test {
114 public: 113 public:
115 AbstractProfileSyncServiceTest() 114 AbstractProfileSyncServiceTest()
116 : ui_thread_(BrowserThread::UI, &message_loop_) {} 115 : ui_thread_(BrowserThread::UI, &message_loop_) {}
117 116
118 bool CreateRoot(ModelType model_type) { 117 bool CreateRoot(ModelType model_type) {
119 return ProfileSyncServiceTestHelper::CreateRoot(model_type, 118 return ProfileSyncServiceTestHelper::CreateRoot(model_type,
120 service_.get(), &ids_); 119 service_.get(),
120 service_->id_factory());
121 } 121 }
122 122
123 protected: 123 protected:
124 124
125 MessageLoopForUI message_loop_; 125 MessageLoopForUI message_loop_;
126 BrowserThread ui_thread_; 126 BrowserThread ui_thread_;
127 ProfileSyncFactoryMock factory_; 127 ProfileSyncFactoryMock factory_;
128 TokenService token_service_; 128 TokenService token_service_;
129 scoped_ptr<TestProfileSyncService> service_; 129 scoped_ptr<TestProfileSyncService> service_;
130 TestIdFactory ids_;
131 }; 130 };
132 131
133 class CreateRootTask : public Task { 132 class CreateRootTask : public Task {
134 public: 133 public:
135 CreateRootTask(AbstractProfileSyncServiceTest* test, ModelType model_type) 134 CreateRootTask(AbstractProfileSyncServiceTest* test, ModelType model_type)
136 : test_(test), model_type_(model_type), success_(false) { 135 : test_(test), model_type_(model_type), success_(false) {
137 } 136 }
138 137
139 virtual ~CreateRootTask() {} 138 virtual ~CreateRootTask() {}
140 virtual void Run() { 139 virtual void Run() {
141 success_ = test_->CreateRoot(model_type_); 140 success_ = test_->CreateRoot(model_type_);
142 } 141 }
143 142
144 bool success() { return success_; } 143 bool success() { return success_; }
145 144
146 private: 145 private:
147 AbstractProfileSyncServiceTest* test_; 146 AbstractProfileSyncServiceTest* test_;
148 ModelType model_type_; 147 ModelType model_type_;
149 bool success_; 148 bool success_;
150 }; 149 };
151 150
152 #endif // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ 151 #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