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

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

Issue 132733002: InstantExtended: remove dead code related to the non-cacheable NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 11 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 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_base.h" 8 #include "base/metrics/histogram_base.h"
9 #include "base/metrics/histogram_samples.h" 9 #include "base/metrics/histogram_samples.h"
10 #include "base/metrics/statistics_recorder.h" 10 #include "base/metrics/statistics_recorder.h"
(...skipping 28 matching lines...) Expand all
39 #include "chrome/browser/search/search.h" 39 #include "chrome/browser/search/search.h"
40 #include "chrome/browser/search_engines/template_url_service.h" 40 #include "chrome/browser/search_engines/template_url_service.h"
41 #include "chrome/browser/search_engines/template_url_service_factory.h" 41 #include "chrome/browser/search_engines/template_url_service_factory.h"
42 #include "chrome/browser/task_manager/task_manager.h" 42 #include "chrome/browser/task_manager/task_manager.h"
43 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" 43 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
44 #include "chrome/browser/themes/theme_service.h" 44 #include "chrome/browser/themes/theme_service.h"
45 #include "chrome/browser/themes/theme_service_factory.h" 45 #include "chrome/browser/themes/theme_service_factory.h"
46 #include "chrome/browser/ui/browser_list.h" 46 #include "chrome/browser/ui/browser_list.h"
47 #include "chrome/browser/ui/browser_tabstrip.h" 47 #include "chrome/browser/ui/browser_tabstrip.h"
48 #include "chrome/browser/ui/omnibox/omnibox_view.h" 48 #include "chrome/browser/ui/omnibox/omnibox_view.h"
49 #include "chrome/browser/ui/search/instant_ntp.h"
50 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h"
51 #include "chrome/browser/ui/search/instant_tab.h" 49 #include "chrome/browser/ui/search/instant_tab.h"
52 #include "chrome/browser/ui/search/instant_test_utils.h" 50 #include "chrome/browser/ui/search/instant_test_utils.h"
53 #include "chrome/browser/ui/search/search_tab_helper.h" 51 #include "chrome/browser/ui/search/search_tab_helper.h"
54 #include "chrome/browser/ui/tabs/tab_strip_model.h" 52 #include "chrome/browser/ui/tabs/tab_strip_model.h"
55 #include "chrome/browser/ui/webui/theme_source.h" 53 #include "chrome/browser/ui/webui/theme_source.h"
56 #include "chrome/common/chrome_switches.h" 54 #include "chrome/common/chrome_switches.h"
57 #include "chrome/common/instant_types.h" 55 #include "chrome/common/instant_types.h"
58 #include "chrome/common/pref_names.h" 56 #include "chrome/common/pref_names.h"
59 #include "chrome/common/thumbnail_score.h" 57 #include "chrome/common/thumbnail_score.h"
60 #include "chrome/common/url_constants.h" 58 #include "chrome/common/url_constants.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 on_focus_changed_calls_(0), 144 on_focus_changed_calls_(0),
147 is_focused_(false), 145 is_focused_(false),
148 on_toggle_voice_search_calls_(0) { 146 on_toggle_voice_search_calls_(0) {
149 } 147 }
150 protected: 148 protected:
151 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 149 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
152 chrome::EnableQueryExtractionForTesting(); 150 chrome::EnableQueryExtractionForTesting();
153 ASSERT_TRUE(https_test_server().Start()); 151 ASSERT_TRUE(https_test_server().Start());
154 GURL instant_url = https_test_server().GetURL( 152 GURL instant_url = https_test_server().GetURL(
155 "files/instant_extended.html?strk=1&"); 153 "files/instant_extended.html?strk=1&");
156 InstantTestBase::Init(instant_url, false); 154 GURL ntp_url = https_test_server().GetURL(
155 "files/instant_extended_ntp.html?strk=1&");
156 InstantTestBase::Init(instant_url, ntp_url, false);
157 } 157 }
158 158
159 int64 GetHistogramCount(const char* name) { 159 int64 GetHistogramCount(const char* name) {
160 base::HistogramBase* histogram = 160 base::HistogramBase* histogram =
161 base::StatisticsRecorder::FindHistogram(name); 161 base::StatisticsRecorder::FindHistogram(name);
162 if (!histogram) { 162 if (!histogram) {
163 // If no histogram is found, it's possible that no values have been 163 // If no histogram is found, it's possible that no values have been
164 // recorded yet. Assume that the value is zero. 164 // recorded yet. Assume that the value is zero.
165 return 0; 165 return 0;
166 } 166 }
167 return histogram->SnapshotSamples()->TotalCount(); 167 return histogram->SnapshotSamples()->TotalCount();
168 } 168 }
169 169
170 void SendDownArrow() {
171 omnibox()->model()->OnUpOrDownKeyPressed(1);
172 // Wait for JavaScript to run the key handler by executing a blank script.
173 EXPECT_TRUE(ExecuteScript(std::string()));
174 }
175
176 void SendUpArrow() {
177 omnibox()->model()->OnUpOrDownKeyPressed(-1);
178 // Wait for JavaScript to run the key handler by executing a blank script.
179 EXPECT_TRUE(ExecuteScript(std::string()));
180 }
181
182 void SendEscape() {
183 omnibox()->model()->OnEscapeKeyPressed();
184 // Wait for JavaScript to run the key handler by executing a blank script.
185 EXPECT_TRUE(ExecuteScript(std::string()));
186 }
187
188 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT { 170 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT {
189 return GetIntFromJS(contents, "onMostVisitedChangedCalls", 171 return GetIntFromJS(contents, "onMostVisitedChangedCalls",
190 &on_most_visited_change_calls_) && 172 &on_most_visited_change_calls_) &&
191 GetIntFromJS(contents, "mostVisitedItemsCount", 173 GetIntFromJS(contents, "mostVisitedItemsCount",
192 &most_visited_items_count_) && 174 &most_visited_items_count_) &&
193 GetIntFromJS(contents, "firstMostVisitedItemId", 175 GetIntFromJS(contents, "firstMostVisitedItemId",
194 &first_most_visited_item_id_) && 176 &first_most_visited_item_id_) &&
195 GetIntFromJS(contents, "onNativeSuggestionsCalls", 177 GetIntFromJS(contents, "onNativeSuggestionsCalls",
196 &on_native_suggestions_calls_) && 178 &on_native_suggestions_calls_) &&
197 GetIntFromJS(contents, "onChangeCalls", 179 GetIntFromJS(contents, "onChangeCalls",
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 InstantExtendedPrefetchTest() 254 InstantExtendedPrefetchTest()
273 : factory_(new net::URLFetcherImplFactory()), 255 : factory_(new net::URLFetcherImplFactory()),
274 fake_factory_(new net::FakeURLFetcherFactory(factory_.get())) { 256 fake_factory_(new net::FakeURLFetcherFactory(factory_.get())) {
275 } 257 }
276 258
277 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 259 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
278 chrome::EnableQueryExtractionForTesting(); 260 chrome::EnableQueryExtractionForTesting();
279 ASSERT_TRUE(https_test_server().Start()); 261 ASSERT_TRUE(https_test_server().Start());
280 GURL instant_url = https_test_server().GetURL( 262 GURL instant_url = https_test_server().GetURL(
281 "files/instant_extended.html?strk=1&"); 263 "files/instant_extended.html?strk=1&");
282 InstantTestBase::Init(instant_url, true); 264 GURL ntp_url = https_test_server().GetURL(
265 "files/instant_extended_ntp.html?strk=1&");
266 InstantTestBase::Init(instant_url, ntp_url, true);
283 } 267 }
284 268
285 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 269 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
286 command_line->AppendSwitchASCII( 270 command_line->AppendSwitchASCII(
287 switches::kForceFieldTrials, 271 switches::kForceFieldTrials,
288 "EmbeddedSearch/Group11 prefetch_results_srp:1 use_cacheable_ntp:0/"); 272 "EmbeddedSearch/Group11 prefetch_results_srp:1/");
289 } 273 }
290 274
291 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); } 275 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); }
292 276
293 private: 277 private:
294 // Used to instantiate FakeURLFetcherFactory. 278 // Used to instantiate FakeURLFetcherFactory.
295 scoped_ptr<net::URLFetcherImplFactory> factory_; 279 scoped_ptr<net::URLFetcherImplFactory> factory_;
296 280
297 // Used to mock default search provider suggest response. 281 // Used to mock default search provider suggest response.
298 scoped_ptr<net::FakeURLFetcherFactory> fake_factory_; 282 scoped_ptr<net::FakeURLFetcherFactory> fake_factory_;
(...skipping 29 matching lines...) Expand all
328 // loads a theme that provides a background image. 312 // loads a theme that provides a background image.
329 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { 313 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase {
330 public: 314 public:
331 InstantPolicyTest() {} 315 InstantPolicyTest() {}
332 316
333 protected: 317 protected:
334 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 318 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
335 ASSERT_TRUE(https_test_server().Start()); 319 ASSERT_TRUE(https_test_server().Start());
336 GURL instant_url = https_test_server().GetURL( 320 GURL instant_url = https_test_server().GetURL(
337 "files/instant_extended.html?strk=1&"); 321 "files/instant_extended.html?strk=1&");
338 InstantTestBase::Init(instant_url, false); 322 GURL ntp_url = https_test_server().GetURL(
323 "files/instant_extended_ntp.html?strk=1&");
324 InstantTestBase::Init(instant_url, ntp_url, false);
339 } 325 }
340 326
341 void InstallThemeSource() { 327 void InstallThemeSource() {
342 ThemeSource* theme = new ThemeSource(profile()); 328 ThemeSource* theme = new ThemeSource(profile());
343 content::URLDataSource::Add(profile(), theme); 329 content::URLDataSource::Add(profile(), theme);
344 } 330 }
345 331
346 void InstallThemeAndVerify(const std::string& theme_dir, 332 void InstallThemeAndVerify(const std::string& theme_dir,
347 const std::string& theme_name) { 333 const std::string& theme_name) {
348 const extensions::Extension* theme = 334 const extensions::Extension* theme =
(...skipping 10 matching lines...) Expand all
359 ThemeServiceFactory::GetThemeForProfile( 345 ThemeServiceFactory::GetThemeForProfile(
360 ExtensionBrowserTest::browser()->profile()); 346 ExtensionBrowserTest::browser()->profile());
361 ASSERT_NE(static_cast<extensions::Extension*>(NULL), new_theme); 347 ASSERT_NE(static_cast<extensions::Extension*>(NULL), new_theme);
362 ASSERT_EQ(new_theme->name(), theme_name); 348 ASSERT_EQ(new_theme->name(), theme_name);
363 } 349 }
364 350
365 private: 351 private:
366 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); 352 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest);
367 }; 353 };
368 354
369 IN_PROC_BROWSER_TEST_F(InstantExtendedNetworkTest, NTPReactsToNetworkChanges) {
370 // Setup Instant.
371 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
372 FocusOmniboxAndWaitForInstantNTPSupport();
373
374 InstantService* instant_service =
375 InstantServiceFactory::GetForProfile(browser()->profile());
376 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
377
378 // The setup first initializes the platform specific NetworkChangeNotifier.
379 // The InstantExtendedNetworkTest replaces it with a fake, but by the time,
380 // InstantNTPPrerenderer has already registered itself. So the
381 // InstantNTPPrerenderer needs to register itself as NetworkChangeObserver
382 // again.
383 net::NetworkChangeNotifier::AddNetworkChangeObserver(
384 instant_service->ntp_prerenderer());
385
386 // The fake network change notifier will provide the network state to be
387 // offline, so the ntp will be local.
388 ASSERT_NE(static_cast<InstantNTP*>(NULL),
389 instant_service->ntp_prerenderer()->ntp());
390 EXPECT_TRUE(instant_service->ntp_prerenderer()->ntp()->IsLocal());
391
392 // Change the connect state, and wait for the notifications to be run, and NTP
393 // support to be determined.
394 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET);
395 FocusOmniboxAndWaitForInstantNTPSupport();
396
397 // Verify the network state is fine, and InstantNTPPrerenderer doesn't want
398 // to switch to local NTP anymore.
399 EXPECT_FALSE(net::NetworkChangeNotifier::IsOffline());
400 EXPECT_FALSE(instant_service->ntp_prerenderer()->ShouldSwitchToLocalNTP());
401
402 // Open new tab.
403 ui_test_utils::NavigateToURLWithDisposition(
404 browser(),
405 GURL(chrome::kChromeUINewTabURL),
406 NEW_FOREGROUND_TAB,
407 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
408 content::WebContents* active_tab =
409 browser()->tab_strip_model()->GetActiveWebContents();
410
411 // Verify new NTP is not local.
412 EXPECT_TRUE(chrome::IsInstantNTP(active_tab));
413 EXPECT_NE(instant_service->ntp_prerenderer()->GetLocalInstantURL(),
414 active_tab->GetURL().spec());
415 ASSERT_NE(static_cast<InstantNTP*>(NULL),
416 instant_service->ntp_prerenderer()->ntp());
417 EXPECT_FALSE(instant_service->ntp_prerenderer()->ntp()->IsLocal());
418
419 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE);
420 FocusOmniboxAndWaitForInstantNTPSupport();
421
422 // Verify the network state is fine, and InstantNTPPrerenderer doesn't want
423 // to switch to local NTP anymore.
424 EXPECT_TRUE(net::NetworkChangeNotifier::IsOffline());
425 EXPECT_TRUE(instant_service->ntp_prerenderer()->ShouldSwitchToLocalNTP());
426
427 // Open new tab. Preloaded NTP contents should have been used.
428 ui_test_utils::NavigateToURLWithDisposition(
429 browser(),
430 GURL(chrome::kChromeUINewTabURL),
431 NEW_FOREGROUND_TAB,
432 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
433 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
434
435 // Verify new NTP is not local.
436 EXPECT_TRUE(chrome::IsInstantNTP(active_tab));
437 EXPECT_EQ(instant_service->ntp_prerenderer()->GetLocalInstantURL(),
438 active_tab->GetURL().spec());
439 ASSERT_NE(static_cast<InstantNTP*>(NULL),
440 instant_service->ntp_prerenderer()->ntp());
441 EXPECT_TRUE(instant_service->ntp_prerenderer()->ntp()->IsLocal());
442 }
443
444 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, SearchReusesInstantTab) { 355 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, SearchReusesInstantTab) {
445 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 356 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
446 FocusOmniboxAndWaitForInstantNTPSupport(); 357 FocusOmnibox();
447 358
448 content::WindowedNotificationObserver observer( 359 content::WindowedNotificationObserver observer(
449 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 360 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
450 content::NotificationService::AllSources()); 361 content::NotificationService::AllSources());
451 SetOmniboxText("flowers"); 362 SetOmniboxText("flowers");
452 PressEnterAndWaitForNavigation(); 363 PressEnterAndWaitForNavigation();
453 observer.Wait(); 364 observer.Wait();
454 365
455 // Just did a regular search. 366 // Just did a regular search.
456 content::WebContents* active_tab = 367 content::WebContents* active_tab =
457 browser()->tab_strip_model()->GetActiveWebContents(); 368 browser()->tab_strip_model()->GetActiveWebContents();
458 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=flowers")); 369 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=flowers"));
459 ASSERT_TRUE(UpdateSearchState(active_tab)); 370 ASSERT_TRUE(UpdateSearchState(active_tab));
460 ASSERT_EQ(0, submit_count_); 371 ASSERT_EQ(0, submit_count_);
461 372
462 SetOmniboxText("puppies"); 373 SetOmniboxText("puppies");
463 PressEnterAndWaitForNavigation(); 374 PressEnterAndWaitForNavigation();
464 375
465 // Should have reused the tab and sent an onsubmit message. 376 // Should have reused the tab and sent an onsubmit message.
466 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 377 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
467 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies")); 378 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies"));
468 ASSERT_TRUE(UpdateSearchState(active_tab)); 379 ASSERT_TRUE(UpdateSearchState(active_tab));
469 EXPECT_EQ(1, submit_count_); 380 EXPECT_EQ(1, submit_count_);
470 } 381 }
471 382
472 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 383 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
473 SearchDoesntReuseInstantTabWithoutSupport) { 384 SearchDoesntReuseInstantTabWithoutSupport) {
474 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 385 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
475 FocusOmniboxAndWaitForInstantNTPSupport(); 386 FocusOmnibox();
476 387
477 // Don't wait for the navigation to complete. 388 // Don't wait for the navigation to complete.
478 SetOmniboxText("flowers"); 389 SetOmniboxText("flowers");
479 browser()->window()->GetLocationBar()->AcceptInput(); 390 browser()->window()->GetLocationBar()->AcceptInput();
480 391
481 SetOmniboxText("puppies"); 392 SetOmniboxText("puppies");
482 browser()->window()->GetLocationBar()->AcceptInput(); 393 browser()->window()->GetLocationBar()->AcceptInput();
483 394
484 // Should not have reused the tab. 395 // Should not have reused the tab.
485 ASSERT_THAT( 396 ASSERT_THAT(
486 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(), 397 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(),
487 HasSubstr("q=puppies")); 398 HasSubstr("q=puppies"));
488 } 399 }
489 400
490 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 401 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
491 TypedSearchURLDoesntReuseInstantTab) { 402 TypedSearchURLDoesntReuseInstantTab) {
492 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 403 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
493 FocusOmniboxAndWaitForInstantNTPSupport(); 404 FocusOmnibox();
494 405
495 // Create an observer to wait for the instant tab to support Instant. 406 // Create an observer to wait for the instant tab to support Instant.
496 content::WindowedNotificationObserver observer_1( 407 content::WindowedNotificationObserver observer_1(
497 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 408 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
498 content::NotificationService::AllSources()); 409 content::NotificationService::AllSources());
499 SetOmniboxText("flowers"); 410 SetOmniboxText("flowers");
500 PressEnterAndWaitForNavigation(); 411 PressEnterAndWaitForNavigation();
501 observer_1.Wait(); 412 observer_1.Wait();
502 413
503 // Just did a regular search. 414 // Just did a regular search.
(...skipping 11 matching lines...) Expand all
515 PressEnterAndWaitForNavigation(); 426 PressEnterAndWaitForNavigation();
516 observer_2.Wait(); 427 observer_2.Wait();
517 428
518 // Should not have reused the tab. 429 // Should not have reused the tab.
519 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 430 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
520 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies")); 431 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies"));
521 } 432 }
522 433
523 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxMarginSetForSearchURLs) { 434 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxMarginSetForSearchURLs) {
524 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 435 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
525 FocusOmniboxAndWaitForInstantNTPSupport(); 436 FocusOmnibox();
526 437
527 // Create an observer to wait for the instant tab to support Instant. 438 // Create an observer to wait for the instant tab to support Instant.
528 content::WindowedNotificationObserver observer( 439 content::WindowedNotificationObserver observer(
529 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 440 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
530 content::NotificationService::AllSources()); 441 content::NotificationService::AllSources());
531 442
532 SetOmniboxText("flowers"); 443 SetOmniboxText("flowers");
533 browser()->window()->GetLocationBar()->AcceptInput(); 444 browser()->window()->GetLocationBar()->AcceptInput();
534 observer.Wait(); 445 observer.Wait();
535 446
536 const std::string& url = 447 const std::string& url =
537 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(); 448 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec();
538 // Make sure we actually used search_url, not instant_url. 449 // Make sure we actually used search_url, not instant_url.
539 ASSERT_THAT(url, HasSubstr("&is_search")); 450 ASSERT_THAT(url, HasSubstr("&is_search"));
540 EXPECT_THAT(url, HasSubstr("&es_sm=")); 451 EXPECT_THAT(url, HasSubstr("&es_sm="));
541 } 452 }
542 453
543 // Test to verify that switching tabs should not dispatch onmostvisitedchanged 454 // Test to verify that switching tabs should not dispatch onmostvisitedchanged
544 // events. 455 // events.
545 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoMostVisitedChangedOnTabSwitch) { 456 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoMostVisitedChangedOnTabSwitch) {
546 // Initialize Instant. 457 // Initialize Instant.
547 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 458 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
548 FocusOmniboxAndWaitForInstantNTPSupport();
549 459
550 // Open new tab. Preloaded NTP contents should have been used. 460 // Open new tab.
551 ui_test_utils::NavigateToURLWithDisposition( 461 ui_test_utils::NavigateToURLWithDisposition(
552 browser(), 462 browser(),
553 GURL(chrome::kChromeUINewTabURL), 463 GURL(chrome::kChromeUINewTabURL),
554 NEW_FOREGROUND_TAB, 464 NEW_FOREGROUND_TAB,
555 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); 465 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
466 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
556 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 467 EXPECT_EQ(2, browser()->tab_strip_model()->count());
557 468
558 // Make sure new tab received the onmostvisitedchanged event once. 469 // Make sure new tab received the onmostvisitedchanged event once.
559 content::WebContents* active_tab = 470 content::WebContents* active_tab =
560 browser()->tab_strip_model()->GetActiveWebContents(); 471 browser()->tab_strip_model()->GetActiveWebContents();
561 EXPECT_TRUE(UpdateSearchState(active_tab)); 472 EXPECT_TRUE(UpdateSearchState(active_tab));
562 EXPECT_EQ(1, on_most_visited_change_calls_); 473 EXPECT_EQ(1, on_most_visited_change_calls_);
563 474
564 // Activate the previous tab. 475 // Activate the previous tab.
565 browser()->tab_strip_model()->ActivateTabAt(0, false); 476 browser()->tab_strip_model()->ActivateTabAt(0, false);
566 477
567 // Switch back to new tab. 478 // Switch back to new tab.
568 browser()->tab_strip_model()->ActivateTabAt(1, false); 479 browser()->tab_strip_model()->ActivateTabAt(1, false);
569 480
570 // Confirm that new tab got no onmostvisitedchanged event. 481 // Confirm that new tab got no onmostvisitedchanged event.
571 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 482 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
572 EXPECT_TRUE(UpdateSearchState(active_tab)); 483 EXPECT_TRUE(UpdateSearchState(active_tab));
573 EXPECT_EQ(1, on_most_visited_change_calls_); 484 EXPECT_EQ(1, on_most_visited_change_calls_);
574 } 485 }
575 486
576 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { 487 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) {
577 InstallThemeSource(); 488 InstallThemeSource();
578 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); 489 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
579 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 490 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
580 FocusOmniboxAndWaitForInstantNTPSupport();
581 491
582 // The "Instant" New Tab should have access to chrome-search: scheme but not 492 // The "Instant" New Tab should have access to chrome-search: scheme but not
583 // chrome: scheme. 493 // chrome: scheme.
584 ui_test_utils::NavigateToURLWithDisposition( 494 ui_test_utils::NavigateToURLWithDisposition(
585 browser(), 495 browser(),
586 GURL(chrome::kChromeUINewTabURL), 496 GURL(chrome::kChromeUINewTabURL),
587 NEW_FOREGROUND_TAB, 497 NEW_FOREGROUND_TAB,
588 ui_test_utils::BROWSER_TEST_NONE); 498 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
499 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
589 500
590 content::RenderViewHost* rvh = 501 content::RenderViewHost* rvh =
591 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); 502 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
592 503
593 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); 504 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND");
594 const std::string search_url( 505 const std::string search_url(
595 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); 506 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND");
596 bool loaded = false; 507 bool loaded = false;
597 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); 508 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded));
598 EXPECT_FALSE(loaded) << chrome_url; 509 EXPECT_FALSE(loaded) << chrome_url;
599 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); 510 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded));
600 EXPECT_TRUE(loaded) << search_url; 511 EXPECT_TRUE(loaded) << search_url;
601 } 512 }
602 513
603 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, 514 IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
604 NoThemeBackgroundChangeEventOnTabSwitch) { 515 NoThemeBackgroundChangeEventOnTabSwitch) {
605 InstallThemeSource(); 516 InstallThemeSource();
606 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 517 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
607 FocusOmniboxAndWaitForInstantNTPSupport();
608 518
609 // Install a theme. 519 // Install a theme.
610 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); 520 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
611 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 521 EXPECT_EQ(1, browser()->tab_strip_model()->count());
612 522
613 // Open new tab. Preloaded NTP contents should have been used. 523 // Open new tab.
614 ui_test_utils::NavigateToURLWithDisposition( 524 ui_test_utils::NavigateToURLWithDisposition(
615 browser(), 525 browser(),
616 GURL(chrome::kChromeUINewTabURL), 526 GURL(chrome::kChromeUINewTabURL),
617 NEW_FOREGROUND_TAB, 527 NEW_FOREGROUND_TAB,
618 ui_test_utils::BROWSER_TEST_NONE); 528 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
529 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
619 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 530 EXPECT_EQ(2, browser()->tab_strip_model()->count());
620 531
621 content::WebContents* active_tab = 532 content::WebContents* active_tab =
622 browser()->tab_strip_model()->GetActiveWebContents(); 533 browser()->tab_strip_model()->GetActiveWebContents();
623 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 534 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
624 int on_theme_changed_calls = 0; 535 int on_theme_changed_calls = 0;
625 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 536 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
626 &on_theme_changed_calls)); 537 &on_theme_changed_calls));
627 EXPECT_EQ(1, on_theme_changed_calls); 538 EXPECT_EQ(1, on_theme_changed_calls);
628 539
(...skipping 17 matching lines...) Expand all
646 // Flaky on Linux: http://crbug.com/265971 557 // Flaky on Linux: http://crbug.com/265971
647 #if defined(OS_LINUX) 558 #if defined(OS_LINUX)
648 #define MAYBE_SendThemeBackgroundChangedEvent DISABLED_SendThemeBackgroundChange dEvent 559 #define MAYBE_SendThemeBackgroundChangedEvent DISABLED_SendThemeBackgroundChange dEvent
649 #else 560 #else
650 #define MAYBE_SendThemeBackgroundChangedEvent SendThemeBackgroundChangedEvent 561 #define MAYBE_SendThemeBackgroundChangedEvent SendThemeBackgroundChangedEvent
651 #endif 562 #endif
652 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, 563 IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
653 MAYBE_SendThemeBackgroundChangedEvent) { 564 MAYBE_SendThemeBackgroundChangedEvent) {
654 InstallThemeSource(); 565 InstallThemeSource();
655 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 566 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
656 FocusOmniboxAndWaitForInstantNTPSupport();
657 567
658 // Install a theme. 568 // Install a theme.
659 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); 569 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
660 570
661 // Open new tab. Preloaded NTP contents should have been used. 571 // Open new tab.
662 ui_test_utils::NavigateToURLWithDisposition( 572 ui_test_utils::NavigateToURLWithDisposition(
663 browser(), 573 browser(),
664 GURL(chrome::kChromeUINewTabURL), 574 GURL(chrome::kChromeUINewTabURL),
665 NEW_FOREGROUND_TAB, 575 NEW_FOREGROUND_TAB,
666 ui_test_utils::BROWSER_TEST_NONE); 576 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
577 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
667 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 578 EXPECT_EQ(2, browser()->tab_strip_model()->count());
668 579
669 // Make sure new tab received an onthemechanged event. 580 // Make sure new tab received an onthemechanged event.
670 content::WebContents* active_tab = 581 content::WebContents* active_tab =
671 browser()->tab_strip_model()->GetActiveWebContents(); 582 browser()->tab_strip_model()->GetActiveWebContents();
672 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 583 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
673 int on_theme_changed_calls = 0; 584 int on_theme_changed_calls = 0;
674 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 585 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
675 &on_theme_changed_calls)); 586 &on_theme_changed_calls));
676 EXPECT_EQ(1, on_theme_changed_calls); 587 EXPECT_EQ(1, on_theme_changed_calls);
(...skipping 14 matching lines...) Expand all
691 #else 602 #else
692 #define MAYBE_UpdateSearchQueryOnBackNavigation UpdateSearchQueryOnBackNavigatio n 603 #define MAYBE_UpdateSearchQueryOnBackNavigation UpdateSearchQueryOnBackNavigatio n
693 #endif 604 #endif
694 // Test to verify that the omnibox search query is updated on browser 605 // Test to verify that the omnibox search query is updated on browser
695 // back button press event. 606 // back button press event.
696 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 607 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
697 MAYBE_UpdateSearchQueryOnBackNavigation) { 608 MAYBE_UpdateSearchQueryOnBackNavigation) {
698 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 609 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
699 610
700 // Focus omnibox and confirm overlay isn't shown. 611 // Focus omnibox and confirm overlay isn't shown.
701 FocusOmniboxAndWaitForInstantNTPSupport(); 612 FocusOmnibox();
702 613
703 // Create an observer to wait for the instant tab to support Instant. 614 // Create an observer to wait for the instant tab to support Instant.
704 content::WindowedNotificationObserver observer( 615 content::WindowedNotificationObserver observer(
705 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 616 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
706 content::NotificationService::AllSources()); 617 content::NotificationService::AllSources());
707 618
708 SetOmniboxText("flowers"); 619 SetOmniboxText("flowers");
709 // Commit the search by pressing 'Enter'. 620 // Commit the search by pressing 'Enter'.
710 PressEnterAndWaitForNavigation(); 621 PressEnterAndWaitForNavigation();
711 observer.Wait(); 622 observer.Wait();
(...skipping 26 matching lines...) Expand all
738 } 649 }
739 650
740 // Flaky: crbug.com/253092. 651 // Flaky: crbug.com/253092.
741 // Test to verify that the omnibox search query is updated on browser 652 // Test to verify that the omnibox search query is updated on browser
742 // forward button press events. 653 // forward button press events.
743 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 654 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
744 DISABLED_UpdateSearchQueryOnForwardNavigation) { 655 DISABLED_UpdateSearchQueryOnForwardNavigation) {
745 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 656 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
746 657
747 // Focus omnibox and confirm overlay isn't shown. 658 // Focus omnibox and confirm overlay isn't shown.
748 FocusOmniboxAndWaitForInstantNTPSupport(); 659 FocusOmnibox();
749 660
750 // Create an observer to wait for the instant tab to support Instant. 661 // Create an observer to wait for the instant tab to support Instant.
751 content::WindowedNotificationObserver observer( 662 content::WindowedNotificationObserver observer(
752 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 663 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
753 content::NotificationService::AllSources()); 664 content::NotificationService::AllSources());
754 665
755 SetOmniboxText("flowers"); 666 SetOmniboxText("flowers");
756 // Commit the search by pressing 'Enter'. 667 // Commit the search by pressing 'Enter'.
757 PressEnterAndWaitForNavigation(); 668 PressEnterAndWaitForNavigation();
758 observer.Wait(); 669 observer.Wait();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 // Commit the search by pressing 'Enter'. 702 // Commit the search by pressing 'Enter'.
792 FocusOmnibox(); 703 FocusOmnibox();
793 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); 704 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText());
794 PressEnterAndWaitForNavigation(); 705 PressEnterAndWaitForNavigation();
795 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); 706 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText());
796 } 707 }
797 708
798 // Flaky on all bots since re-enabled in r208032, crbug.com/253092 709 // Flaky on all bots since re-enabled in r208032, crbug.com/253092
799 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) { 710 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) {
800 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 711 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
801 FocusOmniboxAndWaitForInstantNTPSupport(); 712 FocusOmnibox();
802 713
803 // Open a new tab page. 714 // Open a new tab page.
804 ui_test_utils::NavigateToURLWithDisposition( 715 ui_test_utils::NavigateToURLWithDisposition(
805 browser(), 716 browser(),
806 GURL(chrome::kChromeUINewTabURL), 717 GURL(chrome::kChromeUINewTabURL),
807 NEW_FOREGROUND_TAB, 718 NEW_FOREGROUND_TAB,
808 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); 719 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
720 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
809 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 721 EXPECT_EQ(2, browser()->tab_strip_model()->count());
810 722
811 content::WindowedNotificationObserver observer( 723 content::WindowedNotificationObserver observer(
812 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 724 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
813 content::NotificationService::AllSources()); 725 content::NotificationService::AllSources());
814 SetOmniboxText("flowers"); 726 SetOmniboxText("flowers");
815 PressEnterAndWaitForNavigation(); 727 PressEnterAndWaitForNavigation();
816 observer.Wait(); 728 observer.Wait();
817 729
818 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); 730 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 763
852 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 764 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
853 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); 765 EXPECT_TRUE(chrome::IsInstantNTP(active_tab));
854 } 766 }
855 767
856 // Flaky: crbug.com/267119 768 // Flaky: crbug.com/267119
857 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 769 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
858 DISABLED_DispatchMVChangeEventWhileNavigatingBackToNTP) { 770 DISABLED_DispatchMVChangeEventWhileNavigatingBackToNTP) {
859 // Setup Instant. 771 // Setup Instant.
860 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 772 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
861 FocusOmniboxAndWaitForInstantNTPSupport(); 773 FocusOmnibox();
862 774
863 // Open new tab. Preloaded NTP contents should have been used. 775 // Open new tab.
864 ui_test_utils::NavigateToURLWithDisposition( 776 ui_test_utils::NavigateToURLWithDisposition(
865 browser(), 777 browser(),
866 GURL(chrome::kChromeUINewTabURL), 778 GURL(chrome::kChromeUINewTabURL),
867 NEW_FOREGROUND_TAB, 779 NEW_FOREGROUND_TAB,
868 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); 780 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
781 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
869 782
870 content::WebContents* active_tab = 783 content::WebContents* active_tab =
871 browser()->tab_strip_model()->GetActiveWebContents(); 784 browser()->tab_strip_model()->GetActiveWebContents();
872 EXPECT_TRUE(UpdateSearchState(active_tab)); 785 EXPECT_TRUE(UpdateSearchState(active_tab));
873 EXPECT_EQ(1, on_most_visited_change_calls_); 786 EXPECT_EQ(1, on_most_visited_change_calls_);
874 787
875 content::WindowedNotificationObserver observer( 788 content::WindowedNotificationObserver observer(
876 content::NOTIFICATION_LOAD_STOP, 789 content::NOTIFICATION_LOAD_STOP,
877 content::NotificationService::AllSources()); 790 content::NotificationService::AllSources());
878 // Set the text and press enter to navigate from NTP. 791 // Set the text and press enter to navigate from NTP.
(...skipping 13 matching lines...) Expand all
892 805
893 // Verify that onmostvisitedchange event is dispatched when we navigate from 806 // Verify that onmostvisitedchange event is dispatched when we navigate from
894 // SRP to NTP. 807 // SRP to NTP.
895 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 808 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
896 EXPECT_TRUE(UpdateSearchState(active_tab)); 809 EXPECT_TRUE(UpdateSearchState(active_tab));
897 EXPECT_EQ(1, on_most_visited_change_calls_); 810 EXPECT_EQ(1, on_most_visited_change_calls_);
898 } 811 }
899 812
900 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) { 813 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) {
901 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 814 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
902 FocusOmniboxAndWaitForInstantNTPSupport(); 815 FocusOmnibox();
903 816
904 content::WindowedNotificationObserver new_tab_observer( 817 content::WindowedNotificationObserver new_tab_observer(
905 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 818 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
906 content::NotificationService::AllSources()); 819 content::NotificationService::AllSources());
907 ui_test_utils::NavigateToURLWithDisposition( 820 ui_test_utils::NavigateToURLWithDisposition(
908 browser(), 821 browser(),
909 GURL(chrome::kChromeUINewTabURL), 822 GURL(chrome::kChromeUINewTabURL),
910 CURRENT_TAB, 823 CURRENT_TAB,
911 ui_test_utils::BROWSER_TEST_NONE); 824 ui_test_utils::BROWSER_TEST_NONE);
912 new_tab_observer.Wait(); 825 new_tab_observer.Wait();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 content::WebContents* active_tab = 865 content::WebContents* active_tab =
953 browser()->tab_strip_model()->GetActiveWebContents(); 866 browser()->tab_strip_model()->GetActiveWebContents();
954 ASSERT_TRUE(UpdateSearchState(active_tab)); 867 ASSERT_TRUE(UpdateSearchState(active_tab));
955 ASSERT_TRUE(SearchProvider::ShouldPrefetch(*( 868 ASSERT_TRUE(SearchProvider::ShouldPrefetch(*(
956 omnibox()->model()->result().default_match()))); 869 omnibox()->model()->result().default_match())));
957 ASSERT_EQ("puppy", prefetch_query_value_); 870 ASSERT_EQ("puppy", prefetch_query_value_);
958 } 871 }
959 872
960 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, ClearPrefetchedResults) { 873 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, ClearPrefetchedResults) {
961 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 874 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
962 FocusOmniboxAndWaitForInstantNTPSupport(); 875 FocusOmnibox();
963 876
964 content::WindowedNotificationObserver new_tab_observer( 877 content::WindowedNotificationObserver new_tab_observer(
965 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 878 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
966 content::NotificationService::AllSources()); 879 content::NotificationService::AllSources());
967 ui_test_utils::NavigateToURLWithDisposition( 880 ui_test_utils::NavigateToURLWithDisposition(
968 browser(), 881 browser(),
969 GURL(chrome::kChromeUINewTabURL), 882 GURL(chrome::kChromeUINewTabURL),
970 CURRENT_TAB, 883 CURRENT_TAB,
971 ui_test_utils::BROWSER_TEST_NONE); 884 ui_test_utils::BROWSER_TEST_NONE);
972 new_tab_observer.Wait(); 885 new_tab_observer.Wait();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 // the search terms is sufficient. 957 // the search terms is sufficient.
1045 EXPECT_NE(ASCIIToUTF16("foo"), omnibox()->GetText()); 958 EXPECT_NE(ASCIIToUTF16("foo"), omnibox()->GetText());
1046 } 959 }
1047 960
1048 // Check that clicking on a result sends the correct referrer. 961 // Check that clicking on a result sends the correct referrer.
1049 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, Referrer) { 962 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, Referrer) {
1050 ASSERT_TRUE(test_server()->Start()); 963 ASSERT_TRUE(test_server()->Start());
1051 GURL result_url = 964 GURL result_url =
1052 test_server()->GetURL("files/referrer_policy/referrer-policy-log.html"); 965 test_server()->GetURL("files/referrer_policy/referrer-policy-log.html");
1053 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 966 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1054 FocusOmniboxAndWaitForInstantNTPSupport(); 967 FocusOmnibox();
1055 968
1056 // Type a query and press enter to get results. 969 // Type a query and press enter to get results.
1057 SetOmniboxText("query"); 970 SetOmniboxText("query");
1058 PressEnterAndWaitForNavigation(); 971 PressEnterAndWaitForNavigation();
1059 972
1060 // Simulate going to a result. 973 // Simulate going to a result.
1061 content::WebContents* contents = 974 content::WebContents* contents =
1062 browser()->tab_strip_model()->GetActiveWebContents(); 975 browser()->tab_strip_model()->GetActiveWebContents();
1063 std::ostringstream stream; 976 std::ostringstream stream;
1064 stream << "var link = document.createElement('a');"; 977 stream << "var link = document.createElement('a');";
1065 stream << "link.href = \"" << result_url.spec() << "\";"; 978 stream << "link.href = \"" << result_url.spec() << "\";";
1066 stream << "document.body.appendChild(link);"; 979 stream << "document.body.appendChild(link);";
1067 stream << "link.click();"; 980 stream << "link.click();";
1068 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); 981 EXPECT_TRUE(content::ExecuteScript(contents, stream.str()));
1069 982
1070 content::WaitForLoadStop(contents); 983 content::WaitForLoadStop(contents);
1071 std::string expected_title = 984 std::string expected_title =
1072 "Referrer is " + instant_url().GetWithEmptyPath().spec(); 985 "Referrer is " + instant_url().GetWithEmptyPath().spec();
1073 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); 986 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle());
1074 } 987 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/browser/ui/search/instant_extended_manual_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698