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

Side by Side Diff: chrome/browser/sync/test/integration/search_engines_helper.cc

Issue 8571005: Add four new sync integration tests for custom search engines. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed remaining sync test issues. Created 9 years, 1 month 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/test/integration/two_client_search_engines_sync_test.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/test/integration/search_engines_helper.h" 5 #include "chrome/browser/sync/test/integration/search_engines_helper.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 bool ServiceMatchesVerifier(int profile) { 80 bool ServiceMatchesVerifier(int profile) {
81 TemplateURLService* verifier = GetVerifierService(); 81 TemplateURLService* verifier = GetVerifierService();
82 TemplateURLService* other = GetServiceForProfile(profile); 82 TemplateURLService* other = GetServiceForProfile(profile);
83 83
84 CHECK(verifier); 84 CHECK(verifier);
85 CHECK(other); 85 CHECK(other);
86 86
87 std::vector<const TemplateURL*> verifier_turls = verifier->GetTemplateURLs(); 87 std::vector<const TemplateURL*> verifier_turls = verifier->GetTemplateURLs();
88 if (verifier_turls.size() != other->GetTemplateURLs().size()) { 88 if (verifier_turls.size() != other->GetTemplateURLs().size()) {
89 LOG(ERROR) << "verifier and other service have a different count of TURLs: " 89 LOG(ERROR) << "Verifier and other service have a different count of TURLs: "
90 << verifier_turls.size() << " vs " 90 << verifier_turls.size() << " vs "
91 << other->GetTemplateURLs().size() << " respectively."; 91 << other->GetTemplateURLs().size() << " respectively.";
92 return false; 92 return false;
93 } 93 }
94 94
95 for (size_t i = 0; i < verifier_turls.size(); ++i) { 95 for (size_t i = 0; i < verifier_turls.size(); ++i) {
96 const TemplateURL* verifier_turl = verifier_turls.at(i); 96 const TemplateURL* verifier_turl = verifier_turls.at(i);
97 CHECK(verifier_turl); 97 CHECK(verifier_turl);
98 const TemplateURL* other_turl = other->GetTemplateURLForKeyword( 98 const TemplateURL* other_turl = other->GetTemplateURLForKeyword(
99 verifier_turl->keyword()); 99 verifier_turl->keyword());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } else { 149 } else {
150 LOG(INFO) << "A had default with URL: " << default_a->url()->url() 150 LOG(INFO) << "A had default with URL: " << default_a->url()->url()
151 << " and keyword: " << default_a->keyword(); 151 << " and keyword: " << default_a->keyword();
152 } 152 }
153 153
154 return true; 154 return true;
155 } 155 }
156 156
157 bool AllServicesMatch() { 157 bool AllServicesMatch() {
158 // Use 0 as the baseline. 158 // Use 0 as the baseline.
159 if (!ServiceMatchesVerifier(0)) 159 if (test()->use_verifier() && !ServiceMatchesVerifier(0)) {
160 LOG(ERROR) << "TemplateURLService 0 does not match verifier.";
160 return false; 161 return false;
162 }
161 163
162 for (int it = 0; it < test()->num_clients(); ++it) { 164 for (int it = 1; it < test()->num_clients(); ++it) {
163 if (!ServicesMatch(0, it)) { 165 if (!ServicesMatch(0, it)) {
164 LOG(ERROR) << "TemplateURLService " << it << " does not match with " 166 LOG(ERROR) << "TemplateURLService " << it << " does not match with "
165 << "service 0."; 167 << "service 0.";
166 return false; 168 return false;
167 } 169 }
168 } 170 }
169 return true; 171 return true;
170 } 172 }
171 173
172 // Convenience helper for consistently generating the same keyword for a given 174 // Convenience helper for consistently generating the same keyword for a given
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 236 }
235 } 237 }
236 238
237 void DeleteSearchEngineBySeed(int profile, int seed) { 239 void DeleteSearchEngineBySeed(int profile, int seed) {
238 DeleteSearchEngineByKeyword(profile, CreateKeyword(seed)); 240 DeleteSearchEngineByKeyword(profile, CreateKeyword(seed));
239 } 241 }
240 242
241 void ChangeDefaultSearchProvider(int profile, int seed) { 243 void ChangeDefaultSearchProvider(int profile, int seed) {
242 TemplateURLService* service = GetServiceForProfile(profile); 244 TemplateURLService* service = GetServiceForProfile(profile);
243 ASSERT_TRUE(service); 245 ASSERT_TRUE(service);
244 const TemplateURL* new_default = service->GetTemplateURLForKeyword( 246 const TemplateURL* turl = service->GetTemplateURLForKeyword(
245 CreateKeyword(seed)); 247 CreateKeyword(seed));
246 ASSERT_TRUE(new_default); 248 ASSERT_TRUE(turl);
247 service->SetDefaultSearchProvider(new_default); 249 service->SetDefaultSearchProvider(turl);
248 if (test()->use_verifier()) { 250 if (test()->use_verifier()) {
249 new_default = GetVerifierService()->GetTemplateURLForKeyword( 251 const TemplateURL* verifier_turl =
250 CreateKeyword(seed)); 252 GetVerifierService()->GetTemplateURLForKeyword(CreateKeyword(seed));
251 ASSERT_TRUE(new_default); 253 ASSERT_TRUE(verifier_turl);
252 GetVerifierService()->SetDefaultSearchProvider(new_default); 254 GetVerifierService()->SetDefaultSearchProvider(verifier_turl);
253 } 255 }
254 } 256 }
255 257
256 } // namespace search_engines_helper 258 } // namespace search_engines_helper
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698