| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 browser_ = browser; | 46 browser_ = browser; |
| 47 | 47 |
| 48 TemplateURLService* service = | 48 TemplateURLService* service = |
| 49 TemplateURLServiceFactory::GetForProfile(browser_->profile()); | 49 TemplateURLServiceFactory::GetForProfile(browser_->profile()); |
| 50 search_test_utils::WaitForTemplateURLServiceToLoad(service); | 50 search_test_utils::WaitForTemplateURLServiceToLoad(service); |
| 51 | 51 |
| 52 TemplateURLData data; | 52 TemplateURLData data; |
| 53 // Necessary to use exact URL for both the main URL and the alternate URL for | 53 // Necessary to use exact URL for both the main URL and the alternate URL for |
| 54 // search term extraction to work in InstantExtended. | 54 // search term extraction to work in InstantExtended. |
| 55 data.SetShortName(base::ASCIIToUTF16("name")); | 55 data.SetShortName(base::ASCIIToUTF16("name")); |
| 56 data.SetURL(instant_url_.spec() + | 56 data.SetURL(instant_url_.spec() + "q={searchTerms}&is_search"); |
| 57 "q={searchTerms}&is_search&{google:omniboxStartMarginParameter}"); | |
| 58 data.instant_url = instant_url_.spec(); | 57 data.instant_url = instant_url_.spec(); |
| 59 data.new_tab_url = ntp_url_.spec(); | 58 data.new_tab_url = ntp_url_.spec(); |
| 60 if (init_suggestions_url_) | 59 if (init_suggestions_url_) |
| 61 data.suggestions_url = instant_url_.spec() + "#q={searchTerms}"; | 60 data.suggestions_url = instant_url_.spec() + "#q={searchTerms}"; |
| 62 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}"); | 61 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}"); |
| 63 data.search_terms_replacement_key = "strk"; | 62 data.search_terms_replacement_key = "strk"; |
| 64 | 63 |
| 65 TemplateURL* template_url = new TemplateURL(data); | 64 TemplateURL* template_url = new TemplateURL(data); |
| 66 service->Add(template_url); // Takes ownership of |template_url|. | 65 service->Add(template_url); // Takes ownership of |template_url|. |
| 67 service->SetUserSelectedDefaultSearchProvider(template_url); | 66 service->SetUserSelectedDefaultSearchProvider(template_url); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); | 167 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); |
| 169 } | 168 } |
| 170 | 169 |
| 171 base::string16 InstantTestBase::GetBlueText() { | 170 base::string16 InstantTestBase::GetBlueText() { |
| 172 size_t start = 0, end = 0; | 171 size_t start = 0, end = 0; |
| 173 omnibox()->GetSelectionBounds(&start, &end); | 172 omnibox()->GetSelectionBounds(&start, &end); |
| 174 if (start > end) | 173 if (start > end) |
| 175 std::swap(start, end); | 174 std::swap(start, end); |
| 176 return omnibox()->GetText().substr(start, end - start); | 175 return omnibox()->GetText().substr(start, end - start); |
| 177 } | 176 } |
| OLD | NEW |