OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "chrome/browser/search_engines/template_url_service_factory.h" |
18 #include "chrome/browser/sync/test/integration/await_match_status_change_checker
.h" | |
19 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 18 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
20 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 19 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
21 #include "chrome/browser/sync/test/integration/sync_test.h" | 20 #include "chrome/browser/sync/test/integration/sync_test.h" |
22 #include "components/search_engines/template_url.h" | 21 #include "components/search_engines/template_url.h" |
23 #include "components/search_engines/template_url_service.h" | 22 #include "components/search_engines/template_url_service.h" |
24 | 23 |
25 using sync_datatype_helper::test; | 24 using sync_datatype_helper::test; |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 << verifier_turl->keyword(); | 155 << verifier_turl->keyword(); |
157 return false; | 156 return false; |
158 } | 157 } |
159 if (!TURLsMatch(verifier_turl, other_turl)) | 158 if (!TURLsMatch(verifier_turl, other_turl)) |
160 return false; | 159 return false; |
161 } | 160 } |
162 | 161 |
163 return true; | 162 return true; |
164 } | 163 } |
165 | 164 |
166 bool AwaitAllServicesMatch() { | |
167 AwaitMatchStatusChangeChecker checker(base::Bind(AllServicesMatch), | |
168 "All search engines match"); | |
169 checker.Wait(); | |
170 return !checker.TimedOut(); | |
171 } | |
172 | |
173 bool AllServicesMatch() { | 165 bool AllServicesMatch() { |
174 // Use 0 as the baseline. | 166 // Use 0 as the baseline. |
175 if (test()->use_verifier() && !ServiceMatchesVerifier(0)) { | 167 if (test()->use_verifier() && !ServiceMatchesVerifier(0)) { |
176 DVLOG(1) << "TemplateURLService 0 does not match verifier."; | 168 DVLOG(1) << "TemplateURLService 0 does not match verifier."; |
177 return false; | 169 return false; |
178 } | 170 } |
179 | 171 |
180 for (int it = 1; it < test()->num_clients(); ++it) { | 172 for (int it = 1; it < test()->num_clients(); ++it) { |
181 if (!ServicesMatch(0, it)) { | 173 if (!ServicesMatch(0, it)) { |
182 DVLOG(1) << "TemplateURLService " << it << " does not match with " | 174 DVLOG(1) << "TemplateURLService " << it << " does not match with " |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 271 } |
280 | 272 |
281 bool HasSearchEngine(int profile_index, int seed) { | 273 bool HasSearchEngine(int profile_index, int seed) { |
282 TemplateURLService* service = GetServiceForBrowserContext(profile_index); | 274 TemplateURLService* service = GetServiceForBrowserContext(profile_index); |
283 base::string16 keyword(CreateKeyword(seed)); | 275 base::string16 keyword(CreateKeyword(seed)); |
284 TemplateURL* turl = service->GetTemplateURLForKeyword(keyword); | 276 TemplateURL* turl = service->GetTemplateURLForKeyword(keyword); |
285 return turl != nullptr; | 277 return turl != nullptr; |
286 } | 278 } |
287 | 279 |
288 } // namespace search_engines_helper | 280 } // namespace search_engines_helper |
| 281 |
| 282 SearchEnginesMatchChecker::SearchEnginesMatchChecker() |
| 283 : AwaitMatchStatusChangeChecker( |
| 284 base::Bind(search_engines_helper::AllServicesMatch), |
| 285 "All search engines match") {} |
OLD | NEW |