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

Side by Side Diff: chrome/browser/ui/search/instant_test_utils.cc

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused. Created 7 years, 1 month 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 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"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/search/instant_service.h" 12 #include "chrome/browser/search/instant_service.h"
13 #include "chrome/browser/search/instant_service_factory.h" 13 #include "chrome/browser/search/instant_service_factory.h"
14 #include "chrome/browser/search_engines/template_url_service.h" 14 #include "chrome/browser/search_engines/template_url_service.h"
15 #include "chrome/browser/search_engines/template_url_service_factory.h" 15 #include "chrome/browser/search_engines/template_url_service_factory.h"
16 #include "chrome/browser/ui/omnibox/omnibox_view.h" 16 #include "chrome/browser/ui/omnibox/omnibox_view.h"
17 #include "chrome/browser/ui/search/instant_ntp.h" 17 #include "chrome/browser/ui/search/instant_ntp.h"
18 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h" 18 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/test/base/interactive_test_utils.h" 21 #include "chrome/test/base/interactive_test_utils.h"
22 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/variations/entropy_provider.h"
23 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "content/public/common/result_codes.h" 27 #include "content/public/common/result_codes.h"
27 #include "content/public/test/browser_test_utils.h" 28 #include "content/public/test/browser_test_utils.h"
28 29
29 namespace { 30 namespace {
30 31
31 std::string WrapScript(const std::string& script) { 32 std::string WrapScript(const std::string& script) {
32 return "domAutomationController.send(" + script + ")"; 33 return "domAutomationController.send(" + script + ")";
33 } 34 }
34 35
35 } // namespace 36 } // namespace
36 37
37 // InstantTestBase ----------------------------------------------------------- 38 // InstantTestBase -----------------------------------------------------------
38 39
40 InstantTestBase::InstantTestBase()
41 : https_test_server_(
42 net::SpawnedTestServer::TYPE_HTTPS,
43 net::BaseTestServer::SSLOptions(),
44 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))),
45 init_suggestions_url_(false) {
46 }
47
48 InstantTestBase::~InstantTestBase() {}
49
39 void InstantTestBase::SetupInstant(Browser* browser) { 50 void InstantTestBase::SetupInstant(Browser* browser) {
40 browser_ = browser; 51 browser_ = browser;
52
53 // TODO(samarth): update tests to work with cacheable NTP and remove this.
54 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
55 "InstantExtended", "Group1 use_cacheable_ntp:0"));
56
41 TemplateURLService* service = 57 TemplateURLService* service =
42 TemplateURLServiceFactory::GetForProfile(browser_->profile()); 58 TemplateURLServiceFactory::GetForProfile(browser_->profile());
43 ui_test_utils::WaitForTemplateURLServiceToLoad(service); 59 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
44 60
45 TemplateURLData data; 61 TemplateURLData data;
46 // Necessary to use exact URL for both the main URL and the alternate URL for 62 // Necessary to use exact URL for both the main URL and the alternate URL for
47 // search term extraction to work in InstantExtended. 63 // search term extraction to work in InstantExtended.
48 data.short_name = ASCIIToUTF16("name"); 64 data.short_name = ASCIIToUTF16("name");
49 data.SetURL(instant_url_.spec() + 65 data.SetURL(instant_url_.spec() +
50 "q={searchTerms}&is_search&{google:omniboxStartMarginParameter}"); 66 "q={searchTerms}&is_search&{google:omniboxStartMarginParameter}");
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); 190 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded);
175 } 191 }
176 192
177 string16 InstantTestBase::GetBlueText() { 193 string16 InstantTestBase::GetBlueText() {
178 size_t start = 0, end = 0; 194 size_t start = 0, end = 0;
179 omnibox()->GetSelectionBounds(&start, &end); 195 omnibox()->GetSelectionBounds(&start, &end);
180 if (start > end) 196 if (start > end)
181 std::swap(start, end); 197 std::swap(start, end);
182 return omnibox()->GetText().substr(start, end - start); 198 return omnibox()->GetText().substr(start, end - start);
183 } 199 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_test_utils.h ('k') | chrome/browser/ui/search/local_ntp_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698