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

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: cleaner 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
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 search term extraction to work in
69 // InstantExtended.
70 data.SetURL(instant_url_.spec() + "?espv=1&q={searchTerms}");
sreeram 2013/02/01 22:03:24 I'd like to keep data.SetURL("http://does/not/exis
Mathieu 2013/02/04 20:37:36 Unfortunately the template URLs are looked up by d
71 data.alternate_urls.push_back(instant_url_.spec() +
72 "?espv=1#q={searchTerms}");
sreeram 2013/02/01 22:03:24 instant_url_.spec() already has "?espv=1" (in the
Mathieu 2013/02/04 20:37:36 Done.
73 data.search_terms_replacement_key = "espv";
sreeram 2013/02/01 22:03:24 Don't use "espv". Use some bogus value (here and i
Mathieu 2013/02/04 20:37:36 Done.
69 data.instant_url = instant_url_.spec(); 74 data.instant_url = instant_url_.spec();
70 75
71 TemplateURL* template_url = new TemplateURL(browser()->profile(), data); 76 TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
72 service->Add(template_url); // Takes ownership of |template_url|. 77 service->Add(template_url); // Takes ownership of |template_url|.
73 service->SetDefaultSearchProvider(template_url); 78 service->SetDefaultSearchProvider(template_url);
74 browser()->profile()->GetPrefs()->SetBoolean(prefs::kInstantEnabled, true); 79 browser()->profile()->GetPrefs()->SetBoolean(prefs::kInstantEnabled, true);
75 } 80 }
76 81
77 void InstantTestBase::KillInstantRenderView() { 82 void InstantTestBase::KillInstantRenderView() {
78 base::KillProcess( 83 base::KillProcess(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 143 }
139 144
140 bool InstantTestBase::CheckVisibilityIs(content::WebContents* contents, 145 bool InstantTestBase::CheckVisibilityIs(content::WebContents* contents,
141 bool expected) { 146 bool expected) {
142 bool actual = !expected; // Purposely start with a mis-match. 147 bool actual = !expected; // Purposely start with a mis-match.
143 // We can only use ASSERT_*() in a method that returns void, hence this 148 // We can only use ASSERT_*() in a method that returns void, hence this
144 // convoluted check. 149 // convoluted check.
145 return GetBoolFromJS(contents, "!document.webkitHidden", &actual) && 150 return GetBoolFromJS(contents, "!document.webkitHidden", &actual) &&
146 actual == expected; 151 actual == expected;
147 } 152 }
OLDNEW
« chrome/browser/instant/instant_test_utils.h ('K') | « chrome/browser/instant/instant_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698