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

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

Issue 20388003: Reload Instant NTP and Instant-process tabs on search url change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed InstantNTPPrerendererTest Created 7 years, 2 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 <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 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 active_tab->GetController().GoBack(); 1564 active_tab->GetController().GoBack();
1565 back_observer.Wait(); 1565 back_observer.Wait();
1566 1566
1567 // Verify that onmostvisitedchange event is dispatched when we navigate from 1567 // Verify that onmostvisitedchange event is dispatched when we navigate from
1568 // SRP to NTP. 1568 // SRP to NTP.
1569 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 1569 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
1570 EXPECT_TRUE(UpdateSearchState(active_tab)); 1570 EXPECT_TRUE(UpdateSearchState(active_tab));
1571 EXPECT_EQ(1, on_most_visited_change_calls_); 1571 EXPECT_EQ(1, on_most_visited_change_calls_);
1572 } 1572 }
1573 1573
1574 // Flaky: crbug.com/267096
1575 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
1576 DISABLED_OnDefaultSearchProviderChanged) {
1577 InstantService* instant_service =
1578 InstantServiceFactory::GetForProfile(browser()->profile());
1579 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
1580
1581 // Setup Instant.
1582 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1583 FocusOmniboxAndWaitForInstantNTPSupport();
1584 EXPECT_EQ(1, instant_service->GetInstantProcessCount());
1585
1586 // Navigating to the NTP should use the Instant render process.
1587 content::WindowedNotificationObserver new_tab_observer(
1588 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1589 content::NotificationService::AllSources());
1590 ui_test_utils::NavigateToURLWithDisposition(
1591 browser(),
1592 GURL(chrome::kChromeUINewTabURL),
1593 CURRENT_TAB,
1594 ui_test_utils::BROWSER_TEST_NONE);
1595 new_tab_observer.Wait();
1596
1597 content::WebContents* ntp_contents =
1598 browser()->tab_strip_model()->GetActiveWebContents();
1599 EXPECT_TRUE(chrome::IsInstantNTP(ntp_contents));
1600 EXPECT_TRUE(instant_service->IsInstantProcess(
1601 ntp_contents->GetRenderProcessHost()->GetID()));
1602 GURL ntp_url = ntp_contents->GetURL();
1603
1604 AddBlankTabAndShow(browser());
1605 content::WebContents* active_tab =
1606 browser()->tab_strip_model()->GetActiveWebContents();
1607 EXPECT_FALSE(chrome::IsInstantNTP(active_tab));
1608 EXPECT_FALSE(instant_service->IsInstantProcess(
1609 active_tab->GetRenderProcessHost()->GetID()));
1610
1611 TemplateURLData data;
1612 data.short_name = ASCIIToUTF16("t");
1613 data.SetURL("http://defaultturl/q={searchTerms}");
1614 data.suggestions_url = "http://defaultturl2/q={searchTerms}";
1615 data.instant_url = "http://does/not/exist";
1616 data.alternate_urls.push_back(data.instant_url + "#q={searchTerms}");
1617 data.search_terms_replacement_key = "strk";
1618
1619 TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
1620 TemplateURLService* service =
1621 TemplateURLServiceFactory::GetForProfile(browser()->profile());
1622 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
1623 service->Add(template_url); // Takes ownership of |template_url|.
1624
1625 // Change the default search provider.
1626 content::WindowedNotificationObserver observer(
1627 content::NOTIFICATION_LOAD_STOP,
1628 content::Source<content::NavigationController>(
1629 &ntp_contents->GetController()));
1630 service->SetDefaultSearchProvider(template_url);
1631 observer.Wait();
1632
1633 // |ntp_contents| should not use the Instant render process.
1634 EXPECT_FALSE(chrome::IsInstantNTP(ntp_contents));
1635 EXPECT_FALSE(instant_service->IsInstantProcess(
1636 ntp_contents->GetRenderProcessHost()->GetID()));
1637 // Make sure the URL remains the same.
1638 EXPECT_EQ(ntp_url, ntp_contents->GetURL());
1639 }
1640
1641 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
1642 ReloadLocalNTPOnSearchProviderChange) {
1643 // Setup Instant.
1644 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1645 FocusOmniboxAndWaitForInstantNTPSupport();
1646
1647 // Navigate to Local NTP.
1648 content::WindowedNotificationObserver new_tab_observer(
1649 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1650 content::NotificationService::AllSources());
1651 ui_test_utils::NavigateToURLWithDisposition(
1652 browser(),
1653 GURL(chrome::kChromeSearchLocalNtpUrl),
1654 CURRENT_TAB,
1655 ui_test_utils::BROWSER_TEST_NONE);
1656 new_tab_observer.Wait();
1657
1658 content::WebContents* ntp_contents =
1659 browser()->tab_strip_model()->GetActiveWebContents();
1660 GURL ntp_url = ntp_contents->GetURL();
1661
1662 TemplateURLData data;
1663 data.short_name = ASCIIToUTF16("t");
1664 data.SetURL("http://defaultturl/q={searchTerms}");
1665 data.suggestions_url = "http://defaultturl2/q={searchTerms}";
1666 data.instant_url = "http://does/not/exist";
1667 data.alternate_urls.push_back(data.instant_url + "#q={searchTerms}");
1668 data.search_terms_replacement_key = "strk";
1669
1670 TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
1671 TemplateURLService* service =
1672 TemplateURLServiceFactory::GetForProfile(browser()->profile());
1673 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
1674 service->Add(template_url); // Takes ownership of |template_url|.
1675
1676 // Change the default search provider. This will reload the local NTP and the
1677 // page URL will remain the same.
1678 content::WindowedNotificationObserver observer(
1679 content::NOTIFICATION_LOAD_STOP,
1680 content::Source<content::NavigationController>(
1681 &ntp_contents->GetController()));
1682 service->SetDefaultSearchProvider(template_url);
1683 observer.Wait();
1684
1685 // Make sure the URL remains the same.
1686 EXPECT_EQ(ntp_url, ntp_contents->GetURL());
1687 }
1688
1689 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) { 1574 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) {
1690 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1575 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1691 FocusOmniboxAndWaitForInstantNTPSupport(); 1576 FocusOmniboxAndWaitForInstantNTPSupport();
1692 1577
1693 content::WindowedNotificationObserver new_tab_observer( 1578 content::WindowedNotificationObserver new_tab_observer(
1694 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 1579 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1695 content::NotificationService::AllSources()); 1580 content::NotificationService::AllSources());
1696 ui_test_utils::NavigateToURLWithDisposition( 1581 ui_test_utils::NavigateToURLWithDisposition(
1697 browser(), 1582 browser(),
1698 GURL(chrome::kChromeUINewTabURL), 1583 GURL(chrome::kChromeUINewTabURL),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 EXPECT_EQ(ASCIIToUTF16("foo"), omnibox()->GetText()); 1681 EXPECT_EQ(ASCIIToUTF16("foo"), omnibox()->GetText());
1797 1682
1798 // Calling ShowURL() should disable search term replacement and show the URL. 1683 // Calling ShowURL() should disable search term replacement and show the URL.
1799 omnibox()->ShowURL(); 1684 omnibox()->ShowURL();
1800 EXPECT_FALSE(browser()->toolbar_model()->WouldPerformSearchTermReplacement( 1685 EXPECT_FALSE(browser()->toolbar_model()->WouldPerformSearchTermReplacement(
1801 false)); 1686 false));
1802 // Don't bother looking for a specific URL; ensuring we're no longer showing 1687 // Don't bother looking for a specific URL; ensuring we're no longer showing
1803 // the search terms is sufficient. 1688 // the search terms is sufficient.
1804 EXPECT_NE(ASCIIToUTF16("foo"), omnibox()->GetText()); 1689 EXPECT_NE(ASCIIToUTF16("foo"), omnibox()->GetText());
1805 } 1690 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698