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

Side by Side Diff: chrome/browser/instant/instant_test_utils.cc

Issue 12114050: [Instant] Instant Extended tests for search term extraction. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: reupload Created 7 years, 10 months 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
« no previous file with comments | « chrome/browser/instant/instant_test_utils.h ('k') | chrome/test/data/instant_extended.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/instant/instant_test_utils.h" 5 #include "chrome/browser/instant/instant_test_utils.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 switches::kInstantURL, instant_url_.spec()); 58 switches::kInstantURL, instant_url_.spec());
59 SetupInstantUsingTemplateURL(); 59 SetupInstantUsingTemplateURL();
60 } 60 }
61 61
62 void InstantTestBase::SetupInstantUsingTemplateURL() { 62 void InstantTestBase::SetupInstantUsingTemplateURL() {
63 TemplateURLService* service = 63 TemplateURLService* service =
64 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 64 TemplateURLServiceFactory::GetForProfile(browser()->profile());
65 ui_test_utils::WaitForTemplateURLServiceToLoad(service); 65 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
66 66
67 TemplateURLData data; 67 TemplateURLData data;
68 data.SetURL("http://does/not/exist?q={searchTerms}"); 68 // Necessary to use exact URL for both the main URL and the alternate URL for
69 // search term extraction to work in InstantExtended.
70 data.SetURL(instant_url_.spec() + "q={searchTerms}");
69 data.instant_url = instant_url_.spec(); 71 data.instant_url = instant_url_.spec();
72 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}");
73 data.search_terms_replacement_key = "strk";
70 74
71 TemplateURL* template_url = new TemplateURL(browser()->profile(), data); 75 TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
72 service->Add(template_url); // Takes ownership of |template_url|. 76 service->Add(template_url); // Takes ownership of |template_url|.
73 service->SetDefaultSearchProvider(template_url); 77 service->SetDefaultSearchProvider(template_url);
74 browser()->profile()->GetPrefs()->SetBoolean(prefs::kInstantEnabled, true); 78 browser()->profile()->GetPrefs()->SetBoolean(prefs::kInstantEnabled, true);
75 } 79 }
76 80
77 void InstantTestBase::KillInstantRenderView() { 81 void InstantTestBase::KillInstantRenderView() {
78 base::KillProcess( 82 base::KillProcess(
79 instant()->GetPreviewContents()->GetRenderProcessHost()->GetHandle(), 83 instant()->GetPreviewContents()->GetRenderProcessHost()->GetHandle(),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 142 }
139 143
140 bool InstantTestBase::CheckVisibilityIs(content::WebContents* contents, 144 bool InstantTestBase::CheckVisibilityIs(content::WebContents* contents,
141 bool expected) { 145 bool expected) {
142 bool actual = !expected; // Purposely start with a mis-match. 146 bool actual = !expected; // Purposely start with a mis-match.
143 // We can only use ASSERT_*() in a method that returns void, hence this 147 // We can only use ASSERT_*() in a method that returns void, hence this
144 // convoluted check. 148 // convoluted check.
145 return GetBoolFromJS(contents, "!document.webkitHidden", &actual) && 149 return GetBoolFromJS(contents, "!document.webkitHidden", &actual) &&
146 actual == expected; 150 actual == expected;
147 } 151 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_test_utils.h ('k') | chrome/test/data/instant_extended.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698