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

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

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 3 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 388 }
389 389
390 // Test to verify that switching tabs should not dispatch onmostvisitedchanged 390 // Test to verify that switching tabs should not dispatch onmostvisitedchanged
391 // events. 391 // events.
392 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoMostVisitedChangedOnTabSwitch) { 392 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoMostVisitedChangedOnTabSwitch) {
393 // Initialize Instant. 393 // Initialize Instant.
394 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 394 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
395 395
396 // Open new tab. 396 // Open new tab.
397 ui_test_utils::NavigateToURLWithDisposition( 397 ui_test_utils::NavigateToURLWithDisposition(
398 browser(), 398 browser(), GURL(chrome::kChromeUINewTabURL),
399 GURL(chrome::kChromeUINewTabURL), 399 WindowOpenDisposition::NEW_FOREGROUND_TAB,
400 NEW_FOREGROUND_TAB,
401 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | 400 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
402 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 401 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
403 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 402 EXPECT_EQ(2, browser()->tab_strip_model()->count());
404 403
405 // Make sure new tab received the onmostvisitedchanged event once. 404 // Make sure new tab received the onmostvisitedchanged event once.
406 content::WebContents* active_tab = 405 content::WebContents* active_tab =
407 browser()->tab_strip_model()->GetActiveWebContents(); 406 browser()->tab_strip_model()->GetActiveWebContents();
408 EXPECT_TRUE(UpdateSearchState(active_tab)); 407 EXPECT_TRUE(UpdateSearchState(active_tab));
409 EXPECT_EQ(1, on_most_visited_change_calls_); 408 EXPECT_EQ(1, on_most_visited_change_calls_);
410 409
411 // Activate the previous tab. 410 // Activate the previous tab.
412 browser()->tab_strip_model()->ActivateTabAt(0, false); 411 browser()->tab_strip_model()->ActivateTabAt(0, false);
413 412
414 // Switch back to new tab. 413 // Switch back to new tab.
415 browser()->tab_strip_model()->ActivateTabAt(1, false); 414 browser()->tab_strip_model()->ActivateTabAt(1, false);
416 415
417 // Confirm that new tab got no onmostvisitedchanged event. 416 // Confirm that new tab got no onmostvisitedchanged event.
418 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 417 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
419 EXPECT_TRUE(UpdateSearchState(active_tab)); 418 EXPECT_TRUE(UpdateSearchState(active_tab));
420 EXPECT_EQ(1, on_most_visited_change_calls_); 419 EXPECT_EQ(1, on_most_visited_change_calls_);
421 } 420 }
422 421
423 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { 422 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) {
424 InstallThemeSource(); 423 InstallThemeSource();
425 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); 424 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
426 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 425 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
427 426
428 // The "Instant" New Tab should have access to chrome-search: scheme but not 427 // The "Instant" New Tab should have access to chrome-search: scheme but not
429 // chrome: scheme. 428 // chrome: scheme.
430 ui_test_utils::NavigateToURLWithDisposition( 429 ui_test_utils::NavigateToURLWithDisposition(
431 browser(), 430 browser(), GURL(chrome::kChromeUINewTabURL),
432 GURL(chrome::kChromeUINewTabURL), 431 WindowOpenDisposition::NEW_FOREGROUND_TAB,
433 NEW_FOREGROUND_TAB,
434 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | 432 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
435 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 433 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
436 434
437 content::RenderViewHost* rvh = 435 content::RenderViewHost* rvh =
438 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); 436 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
439 437
440 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); 438 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND");
441 const std::string search_url( 439 const std::string search_url(
442 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); 440 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND");
443 bool loaded = false; 441 bool loaded = false;
444 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); 442 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded));
445 EXPECT_FALSE(loaded) << chrome_url; 443 EXPECT_FALSE(loaded) << chrome_url;
446 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); 444 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded));
447 EXPECT_TRUE(loaded) << search_url; 445 EXPECT_TRUE(loaded) << search_url;
448 } 446 }
449 447
450 // Flaky on all bots. http://crbug.com/335297. 448 // Flaky on all bots. http://crbug.com/335297.
451 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, 449 IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
452 DISABLED_NoThemeBackgroundChangeEventOnTabSwitch) { 450 DISABLED_NoThemeBackgroundChangeEventOnTabSwitch) {
453 InstallThemeSource(); 451 InstallThemeSource();
454 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 452 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
455 453
456 // Install a theme. 454 // Install a theme.
457 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); 455 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
458 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 456 EXPECT_EQ(1, browser()->tab_strip_model()->count());
459 457
460 // Open new tab. 458 // Open new tab.
461 ui_test_utils::NavigateToURLWithDisposition( 459 ui_test_utils::NavigateToURLWithDisposition(
462 browser(), 460 browser(), GURL(chrome::kChromeUINewTabURL),
463 GURL(chrome::kChromeUINewTabURL), 461 WindowOpenDisposition::NEW_FOREGROUND_TAB,
464 NEW_FOREGROUND_TAB,
465 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | 462 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
466 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 463 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
467 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 464 EXPECT_EQ(2, browser()->tab_strip_model()->count());
468 465
469 content::WebContents* active_tab = 466 content::WebContents* active_tab =
470 browser()->tab_strip_model()->GetActiveWebContents(); 467 browser()->tab_strip_model()->GetActiveWebContents();
471 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 468 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
472 int on_theme_changed_calls = 0; 469 int on_theme_changed_calls = 0;
473 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 470 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
474 &on_theme_changed_calls)); 471 &on_theme_changed_calls));
475 EXPECT_EQ(1, on_theme_changed_calls); 472 EXPECT_EQ(1, on_theme_changed_calls);
476 473
(...skipping 17 matching lines...) Expand all
494 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, 491 IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
495 DISABLED_SendThemeBackgroundChangedEvent) { 492 DISABLED_SendThemeBackgroundChangedEvent) {
496 InstallThemeSource(); 493 InstallThemeSource();
497 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 494 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
498 495
499 // Install a theme. 496 // Install a theme.
500 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); 497 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
501 498
502 // Open new tab. 499 // Open new tab.
503 ui_test_utils::NavigateToURLWithDisposition( 500 ui_test_utils::NavigateToURLWithDisposition(
504 browser(), 501 browser(), GURL(chrome::kChromeUINewTabURL),
505 GURL(chrome::kChromeUINewTabURL), 502 WindowOpenDisposition::NEW_FOREGROUND_TAB,
506 NEW_FOREGROUND_TAB,
507 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | 503 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
508 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 504 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
509 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 505 EXPECT_EQ(2, browser()->tab_strip_model()->count());
510 506
511 // Make sure new tab received an onthemechanged event. 507 // Make sure new tab received an onthemechanged event.
512 content::WebContents* active_tab = 508 content::WebContents* active_tab =
513 browser()->tab_strip_model()->GetActiveWebContents(); 509 browser()->tab_strip_model()->GetActiveWebContents();
514 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 510 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
515 int on_theme_changed_calls = 0; 511 int on_theme_changed_calls = 0;
516 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 512 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
517 &on_theme_changed_calls)); 513 &on_theme_changed_calls));
518 EXPECT_EQ(1, on_theme_changed_calls); 514 EXPECT_EQ(1, on_theme_changed_calls);
519 515
520 // Install a new theme. 516 // Install a new theme.
521 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme2", "snowflake theme")); 517 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme2", "snowflake theme"));
522 518
523 // Confirm that new tab is notified about the theme changed event. 519 // Confirm that new tab is notified about the theme changed event.
524 on_theme_changed_calls = 0; 520 on_theme_changed_calls = 0;
525 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 521 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
526 &on_theme_changed_calls)); 522 &on_theme_changed_calls));
527 EXPECT_EQ(2, on_theme_changed_calls); 523 EXPECT_EQ(2, on_theme_changed_calls);
528 } 524 }
529 525
530 // Flaky on all bots since re-enabled in r208032, crbug.com/253092 526 // Flaky on all bots since re-enabled in r208032, crbug.com/253092
531 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) { 527 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) {
532 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 528 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
533 FocusOmnibox(); 529 FocusOmnibox();
534 530
535 // Open a new tab page. 531 // Open a new tab page.
536 ui_test_utils::NavigateToURLWithDisposition( 532 ui_test_utils::NavigateToURLWithDisposition(
537 browser(), 533 browser(), GURL(chrome::kChromeUINewTabURL),
538 GURL(chrome::kChromeUINewTabURL), 534 WindowOpenDisposition::NEW_FOREGROUND_TAB,
539 NEW_FOREGROUND_TAB,
540 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | 535 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
541 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 536 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
542 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 537 EXPECT_EQ(2, browser()->tab_strip_model()->count());
543 538
544 SetOmniboxText("flowers"); 539 SetOmniboxText("flowers");
545 PressEnterAndWaitForNavigation(); 540 PressEnterAndWaitForNavigation();
546 541
547 // Navigate back to NTP. 542 // Navigate back to NTP.
548 content::WebContents* active_tab = 543 content::WebContents* active_tab =
549 browser()->tab_strip_model()->GetActiveWebContents(); 544 browser()->tab_strip_model()->GetActiveWebContents();
550 EXPECT_TRUE(active_tab->GetController().CanGoBack()); 545 EXPECT_TRUE(active_tab->GetController().CanGoBack());
551 content::WindowedNotificationObserver load_stop_observer( 546 content::WindowedNotificationObserver load_stop_observer(
552 content::NOTIFICATION_LOAD_STOP, 547 content::NOTIFICATION_LOAD_STOP,
553 content::Source<content::NavigationController>( 548 content::Source<content::NavigationController>(
554 &active_tab->GetController())); 549 &active_tab->GetController()));
555 active_tab->GetController().GoBack(); 550 active_tab->GetController().GoBack();
556 load_stop_observer.Wait(); 551 load_stop_observer.Wait();
557 552
558 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 553 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
559 EXPECT_TRUE(search::IsInstantNTP(active_tab)); 554 EXPECT_TRUE(search::IsInstantNTP(active_tab));
560 } 555 }
561 556
562 // Flaky: crbug.com/267119 557 // Flaky: crbug.com/267119
563 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 558 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
564 DISABLED_DispatchMVChangeEventWhileNavigatingBackToNTP) { 559 DISABLED_DispatchMVChangeEventWhileNavigatingBackToNTP) {
565 // Setup Instant. 560 // Setup Instant.
566 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 561 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
567 FocusOmnibox(); 562 FocusOmnibox();
568 563
569 // Open new tab. 564 // Open new tab.
570 ui_test_utils::NavigateToURLWithDisposition( 565 ui_test_utils::NavigateToURLWithDisposition(
571 browser(), 566 browser(), GURL(chrome::kChromeUINewTabURL),
572 GURL(chrome::kChromeUINewTabURL), 567 WindowOpenDisposition::NEW_FOREGROUND_TAB,
573 NEW_FOREGROUND_TAB,
574 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | 568 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
575 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 569 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
576 570
577 content::WebContents* active_tab = 571 content::WebContents* active_tab =
578 browser()->tab_strip_model()->GetActiveWebContents(); 572 browser()->tab_strip_model()->GetActiveWebContents();
579 EXPECT_TRUE(UpdateSearchState(active_tab)); 573 EXPECT_TRUE(UpdateSearchState(active_tab));
580 EXPECT_EQ(1, on_most_visited_change_calls_); 574 EXPECT_EQ(1, on_most_visited_change_calls_);
581 575
582 content::WindowedNotificationObserver observer( 576 content::WindowedNotificationObserver observer(
583 content::NOTIFICATION_LOAD_STOP, 577 content::NOTIFICATION_LOAD_STOP,
584 content::NotificationService::AllSources()); 578 content::NotificationService::AllSources());
585 // Set the text and press enter to navigate from NTP. 579 // Set the text and press enter to navigate from NTP.
(...skipping 26 matching lines...) Expand all
612 prefs::kSearchSuggestEnabled)) { 606 prefs::kSearchSuggestEnabled)) {
613 return; 607 return;
614 } 608 }
615 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 609 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
616 FocusOmnibox(); 610 FocusOmnibox();
617 611
618 content::WindowedNotificationObserver new_tab_observer( 612 content::WindowedNotificationObserver new_tab_observer(
619 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 613 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
620 content::NotificationService::AllSources()); 614 content::NotificationService::AllSources());
621 ui_test_utils::NavigateToURLWithDisposition( 615 ui_test_utils::NavigateToURLWithDisposition(
622 browser(), 616 browser(), GURL(chrome::kChromeUINewTabURL),
623 GURL(chrome::kChromeUINewTabURL), 617 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
624 CURRENT_TAB,
625 ui_test_utils::BROWSER_TEST_NONE);
626 new_tab_observer.Wait(); 618 new_tab_observer.Wait();
627 619
628 OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 0; 620 OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 0;
629 621
630 // Set the fake response for search query. 622 // Set the fake response for search query.
631 fake_factory()->SetFakeResponse(instant_url().Resolve("#q=flowers"), 623 fake_factory()->SetFakeResponse(instant_url().Resolve("#q=flowers"),
632 "", 624 "",
633 net::HTTP_OK, 625 net::HTTP_OK,
634 net::URLRequestStatus::SUCCESS); 626 net::URLRequestStatus::SUCCESS);
635 627
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 prefs::kSearchSuggestEnabled)) { 670 prefs::kSearchSuggestEnabled)) {
679 return; 671 return;
680 } 672 }
681 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 673 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
682 FocusOmnibox(); 674 FocusOmnibox();
683 675
684 content::WindowedNotificationObserver new_tab_observer( 676 content::WindowedNotificationObserver new_tab_observer(
685 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 677 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
686 content::NotificationService::AllSources()); 678 content::NotificationService::AllSources());
687 ui_test_utils::NavigateToURLWithDisposition( 679 ui_test_utils::NavigateToURLWithDisposition(
688 browser(), 680 browser(), GURL(chrome::kChromeUINewTabURL),
689 GURL(chrome::kChromeUINewTabURL), 681 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
690 CURRENT_TAB,
691 ui_test_utils::BROWSER_TEST_NONE);
692 new_tab_observer.Wait(); 682 new_tab_observer.Wait();
693 683
694 OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 0; 684 OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 0;
695 685
696 // Set the fake response for search query. 686 // Set the fake response for search query.
697 fake_factory()->SetFakeResponse(instant_url().Resolve("#q=flowers"), 687 fake_factory()->SetFakeResponse(instant_url().Resolve("#q=flowers"),
698 "", 688 "",
699 net::HTTP_OK, 689 net::HTTP_OK,
700 net::URLRequestStatus::SUCCESS); 690 net::URLRequestStatus::SUCCESS);
701 691
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 stream << "link.href = \"" << result_url.spec() << "\";"; 742 stream << "link.href = \"" << result_url.spec() << "\";";
753 stream << "document.body.appendChild(link);"; 743 stream << "document.body.appendChild(link);";
754 stream << "link.click();"; 744 stream << "link.click();";
755 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); 745 EXPECT_TRUE(content::ExecuteScript(contents, stream.str()));
756 746
757 content::WaitForLoadStop(contents); 747 content::WaitForLoadStop(contents);
758 std::string expected_title = 748 std::string expected_title =
759 "Referrer is " + instant_url().GetWithEmptyPath().spec(); 749 "Referrer is " + instant_url().GetWithEmptyPath().spec();
760 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); 750 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle());
761 } 751 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698