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