| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/search/instant_test_utils.h" | 5 #include "chrome/browser/ui/search/instant_test_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}"); | 51 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}"); |
| 52 data.search_terms_replacement_key = "strk"; | 52 data.search_terms_replacement_key = "strk"; |
| 53 | 53 |
| 54 TemplateURL* template_url = new TemplateURL(browser_->profile(), data); | 54 TemplateURL* template_url = new TemplateURL(browser_->profile(), data); |
| 55 service->Add(template_url); // Takes ownership of |template_url|. | 55 service->Add(template_url); // Takes ownership of |template_url|. |
| 56 service->SetDefaultSearchProvider(template_url); | 56 service->SetDefaultSearchProvider(template_url); |
| 57 | 57 |
| 58 InstantService* instant_service = | 58 InstantService* instant_service = |
| 59 InstantServiceFactory::GetForProfile(browser_->profile()); | 59 InstantServiceFactory::GetForProfile(browser_->profile()); |
| 60 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 60 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 61 instant_service->ntp_prerenderer()->ReloadStaleNTP(); | 61 instant_service->ntp_prerenderer()->ReloadInstantNTP(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void InstantTestBase::SetInstantURL(const std::string& url) { | 64 void InstantTestBase::SetInstantURL(const std::string& url) { |
| 65 TemplateURLService* service = | 65 TemplateURLService* service = |
| 66 TemplateURLServiceFactory::GetForProfile(browser_->profile()); | 66 TemplateURLServiceFactory::GetForProfile(browser_->profile()); |
| 67 ui_test_utils::WaitForTemplateURLServiceToLoad(service); | 67 ui_test_utils::WaitForTemplateURLServiceToLoad(service); |
| 68 | 68 |
| 69 TemplateURLData data; | 69 TemplateURLData data; |
| 70 data.SetURL(url); | 70 data.SetURL(url); |
| 71 data.instant_url = url; | 71 data.instant_url = url; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); | 169 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); |
| 170 } | 170 } |
| 171 | 171 |
| 172 string16 InstantTestBase::GetBlueText() { | 172 string16 InstantTestBase::GetBlueText() { |
| 173 size_t start = 0, end = 0; | 173 size_t start = 0, end = 0; |
| 174 omnibox()->GetSelectionBounds(&start, &end); | 174 omnibox()->GetSelectionBounds(&start, &end); |
| 175 if (start > end) | 175 if (start > end) |
| 176 std::swap(start, end); | 176 std::swap(start, end); |
| 177 return omnibox()->GetText().substr(start, end - start); | 177 return omnibox()->GetText().substr(start, end - start); |
| 178 } | 178 } |
| OLD | NEW |