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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model_unittest.cc

Issue 13877028: Renderer initiated navigations from non instant process should not fall into instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplifying ToolbarModelTest fix. Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/toolbar/toolbar_model.h" 5 #include "chrome/browser/ui/toolbar/toolbar_model.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 144 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
145 profile(), &TemplateURLServiceFactory::BuildInstanceFor); 145 profile(), &TemplateURLServiceFactory::BuildInstanceFor);
146 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( 146 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse(
147 profile(), &AutocompleteClassifierFactory::BuildInstanceFor); 147 profile(), &AutocompleteClassifierFactory::BuildInstanceFor);
148 } 148 }
149 virtual void TearDown() OVERRIDE { BrowserWithTestWindowTest::TearDown(); } 149 virtual void TearDown() OVERRIDE { BrowserWithTestWindowTest::TearDown(); }
150 150
151 protected: 151 protected:
152 152
153 void ResetDefaultTemplateURL() { 153 void ResetDefaultTemplateURL() {
154 ResetTemplateURLForInstant(GURL("http://does/not/exist"));
155 }
156
157 void ResetTemplateURLForInstant(const GURL instant_url) {
sreeram 2013/05/01 21:59:50 const GURL&
Shishir 2013/05/01 23:42:16 Done.
154 TemplateURLData data; 158 TemplateURLData data;
159 data.short_name = ASCIIToUTF16("Google");
155 data.SetURL("http://google.com/search?q={searchTerms}"); 160 data.SetURL("http://google.com/search?q={searchTerms}");
156 data.instant_url = "http://does/not/exist"; 161 data.instant_url = instant_url.spec();
157 data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}"; 162 data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}";
158 TemplateURL* search_template_url = new TemplateURL(profile(), data); 163 TemplateURL* search_template_url = new TemplateURL(profile(), data);
159 TemplateURLService* template_url_service = 164 TemplateURLService* template_url_service =
160 TemplateURLServiceFactory::GetForProfile(profile()); 165 TemplateURLServiceFactory::GetForProfile(profile());
161 template_url_service->Add(search_template_url); 166 template_url_service->Add(search_template_url);
162 template_url_service->SetDefaultSearchProvider(search_template_url); 167 template_url_service->SetDefaultSearchProvider(search_template_url);
163 ASSERT_NE(0, search_template_url->id()); 168 ASSERT_NE(0, search_template_url->id());
164 template_url_service->Load(); 169 template_url_service->Load();
165 } 170 }
166 171
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 search_terms_type, true); 203 search_terms_type, true);
199 } 204 }
200 } 205 }
201 206
202 private: 207 private:
203 void NavigateAndCheckTextImpl(const GURL& url, 208 void NavigateAndCheckTextImpl(const GURL& url,
204 bool can_replace, 209 bool can_replace,
205 const string16 expected_text, 210 const string16 expected_text,
206 ToolbarModel::SearchTermsType search_terms_type, 211 ToolbarModel::SearchTermsType search_terms_type,
207 bool should_display) { 212 bool should_display) {
213 // The URL being navigate to should be treated as the Instant URL. Else
sreeram 2013/05/01 21:59:50 navigate -> navigated
Shishir 2013/05/01 23:42:16 Done.
214 // there will be no search term extraction.
215 ResetTemplateURLForInstant(url);
216
208 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); 217 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0);
209 browser()->OpenURL(OpenURLParams( 218 browser()->OpenURL(OpenURLParams(
210 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, 219 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
211 false)); 220 false));
212 221
213 // Query terms replacement requires that the renderer process be a
214 // recognized Instant renderer. Fake it.
215 InstantService* instant_service =
216 InstantServiceFactory::GetForProfile(profile());
217 int process_id = contents->GetRenderProcessHost()->GetID();
218 instant_service->AddInstantProcess(process_id);
219
220 ToolbarModel* toolbar_model = browser()->toolbar_model(); 222 ToolbarModel* toolbar_model = browser()->toolbar_model();
221 223
222 // Check while loading. 224 // Check while loading.
223 contents->GetController().GetVisibleEntry()->GetSSL().security_style = 225 contents->GetController().GetVisibleEntry()->GetSSL().security_style =
224 content::SECURITY_STYLE_AUTHENTICATED; 226 content::SECURITY_STYLE_AUTHENTICATED;
225 EXPECT_EQ(should_display, toolbar_model->ShouldDisplayURL()); 227 EXPECT_EQ(should_display, toolbar_model->ShouldDisplayURL());
226 EXPECT_EQ(expected_text, toolbar_model->GetText(can_replace)); 228 EXPECT_EQ(expected_text, toolbar_model->GetText(can_replace));
227 EXPECT_EQ(search_terms_type, toolbar_model->GetSearchTermsType()); 229 EXPECT_EQ(search_terms_type, toolbar_model->GetSearchTermsType());
228 230
229 // Check after commit. 231 // Check after commit.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // Verify that URL search terms are correctly identified. 319 // Verify that URL search terms are correctly identified.
318 TEST_F(ToolbarModelTest, ProminentSearchTerm) { 320 TEST_F(ToolbarModelTest, ProminentSearchTerm) {
319 static const char* const kQueries[] = { 321 static const char* const kQueries[] = {
320 "example.com" 322 "example.com"
321 }; 323 };
322 browser()->toolbar_model()->SetSupportsExtractionOfURLLikeSearchTerms(true); 324 browser()->toolbar_model()->SetSupportsExtractionOfURLLikeSearchTerms(true);
323 NavigateAndCheckQueries( 325 NavigateAndCheckQueries(
324 std::vector<const char*>(&kQueries[0], &kQueries[arraysize(kQueries)]), 326 std::vector<const char*>(&kQueries[0], &kQueries[arraysize(kQueries)]),
325 ToolbarModel::URL_LIKE_SEARCH_TERMS); 327 ToolbarModel::URL_LIKE_SEARCH_TERMS);
326 } 328 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_loader.cc ('k') | content/browser/web_contents/render_view_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698