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

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

Issue 10033017: More misc. cleanups to minimize future refactoring diffs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
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 "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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 std::string GetTURLInfoString(const TemplateURL* turl) { 48 std::string GetTURLInfoString(const TemplateURL* turl) {
49 DCHECK(turl); 49 DCHECK(turl);
50 return "TemplateURL: shortname: " + UTF16ToASCII(turl->short_name()) + 50 return "TemplateURL: shortname: " + UTF16ToASCII(turl->short_name()) +
51 " keyword: " + UTF16ToASCII(turl->keyword()) + " url: " + turl->url(); 51 " keyword: " + UTF16ToASCII(turl->keyword()) + " url: " + turl->url();
52 } 52 }
53 53
54 bool TURLsMatch(const TemplateURL* turl1, const TemplateURL* turl2) { 54 bool TURLsMatch(const TemplateURL* turl1, const TemplateURL* turl2) {
55 CHECK(turl1); 55 CHECK(turl1);
56 CHECK(turl2); 56 CHECK(turl2);
57
58 bool result = (turl1->url() == turl2->url()) && 57 bool result = (turl1->url() == turl2->url()) &&
59 (turl1->keyword() == turl2->keyword()) && 58 (turl1->keyword() == turl2->keyword()) &&
60 (turl1->short_name() == turl2->short_name()); 59 (turl1->short_name() == turl2->short_name());
61 60
62 // Print some useful debug info. 61 // Print some useful debug info.
63 if (!result) { 62 if (!result) {
64 LOG(ERROR) << "TemplateURLs did not match: " << GetTURLInfoString(turl1) 63 LOG(ERROR) << "TemplateURLs did not match: " << GetTURLInfoString(turl1)
65 << " vs " << GetTURLInfoString(turl2); 64 << " vs " << GetTURLInfoString(turl2);
66 } 65 }
67 66
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 base::StringPrintf("http://www.test%d.com/", seed), sync_guid); 180 base::StringPrintf("http://www.test%d.com/", seed), sync_guid);
182 } 181 }
183 182
184 TemplateURL* CreateTestTemplateURL(int seed, 183 TemplateURL* CreateTestTemplateURL(int seed,
185 const string16& keyword, 184 const string16& keyword,
186 const std::string& url, 185 const std::string& url,
187 const std::string& sync_guid) { 186 const std::string& sync_guid) {
188 TemplateURLData data; 187 TemplateURLData data;
189 data.short_name = CreateKeyword(seed); 188 data.short_name = CreateKeyword(seed);
190 data.SetKeyword(keyword); 189 data.SetKeyword(keyword);
191 data.safe_for_autoreplace = true;
192 data.SetURL(url); 190 data.SetURL(url);
193 data.favicon_url = GURL("http://favicon.url"); 191 data.favicon_url = GURL("http://favicon.url");
192 data.safe_for_autoreplace = true;
194 data.date_created = base::Time::FromTimeT(100); 193 data.date_created = base::Time::FromTimeT(100);
195 data.last_modified = base::Time::FromTimeT(100); 194 data.last_modified = base::Time::FromTimeT(100);
196 data.prepopulate_id = 999999; 195 data.prepopulate_id = 999999;
197 data.sync_guid = sync_guid; 196 data.sync_guid = sync_guid;
198 return new TemplateURL(data); 197 return new TemplateURL(data);
199 } 198 }
200 199
201 void AddSearchEngine(int profile, int seed) { 200 void AddSearchEngine(int profile, int seed) {
202 GetServiceForProfile(profile)->Add(CreateTestTemplateURL(seed)); 201 GetServiceForProfile(profile)->Add(CreateTestTemplateURL(seed));
203 if (test()->use_verifier()) 202 if (test()->use_verifier())
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 service->SetDefaultSearchProvider(turl); 252 service->SetDefaultSearchProvider(turl);
254 if (test()->use_verifier()) { 253 if (test()->use_verifier()) {
255 const TemplateURL* verifier_turl = 254 const TemplateURL* verifier_turl =
256 GetVerifierService()->GetTemplateURLForKeyword(CreateKeyword(seed)); 255 GetVerifierService()->GetTemplateURLForKeyword(CreateKeyword(seed));
257 ASSERT_TRUE(verifier_turl); 256 ASSERT_TRUE(verifier_turl);
258 GetVerifierService()->SetDefaultSearchProvider(verifier_turl); 257 GetVerifierService()->SetDefaultSearchProvider(verifier_turl);
259 } 258 }
260 } 259 }
261 260
262 } // namespace search_engines_helper 261 } // namespace search_engines_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698