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

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: Format and lint Created 7 years, 4 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 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 EXPECT_TRUE(active_tab->GetController().CanGoBack()); 1529 EXPECT_TRUE(active_tab->GetController().CanGoBack());
1530 active_tab->GetController().GoBack(); 1530 active_tab->GetController().GoBack();
1531 back_observer.Wait(); 1531 back_observer.Wait();
1532 1532
1533 // Verify that onmostvisitedchange event is dispatched when we navigate from 1533 // Verify that onmostvisitedchange event is dispatched when we navigate from
1534 // SRP to NTP. 1534 // SRP to NTP.
1535 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 1535 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
1536 EXPECT_TRUE(UpdateSearchState(active_tab)); 1536 EXPECT_TRUE(UpdateSearchState(active_tab));
1537 EXPECT_EQ(1, on_most_visited_change_calls_); 1537 EXPECT_EQ(1, on_most_visited_change_calls_);
1538 } 1538 }
1539
1540 // Flaky: crbug.com/267096
1541 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
1542 DISABLED_OnDefaultSearchProviderChanged) {
1543 InstantService* instant_service =
1544 InstantServiceFactory::GetForProfile(browser()->profile());
1545 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
1546
1547 // Setup Instant.
1548 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1549 FocusOmniboxAndWaitForInstantNTPSupport();
1550 EXPECT_EQ(1, instant_service->GetInstantProcessCount());
1551
1552 // Navigating to the NTP should use the Instant render process.
1553 content::WindowedNotificationObserver new_tab_observer(
1554 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1555 content::NotificationService::AllSources());
1556 ui_test_utils::NavigateToURLWithDisposition(
1557 browser(),
1558 GURL(chrome::kChromeUINewTabURL),
1559 CURRENT_TAB,
1560 ui_test_utils::BROWSER_TEST_NONE);
1561 new_tab_observer.Wait();
1562
1563 content::WebContents* ntp_contents =
1564 browser()->tab_strip_model()->GetActiveWebContents();
1565 EXPECT_TRUE(chrome::IsInstantNTP(ntp_contents));
1566 EXPECT_TRUE(instant_service->IsInstantProcess(
1567 ntp_contents->GetRenderProcessHost()->GetID()));
1568 GURL ntp_url = ntp_contents->GetURL();
1569
1570 AddBlankTabAndShow(browser());
1571 content::WebContents* active_tab =
1572 browser()->tab_strip_model()->GetActiveWebContents();
1573 EXPECT_FALSE(chrome::IsInstantNTP(active_tab));
1574 EXPECT_FALSE(instant_service->IsInstantProcess(
1575 active_tab->GetRenderProcessHost()->GetID()));
1576
1577 TemplateURLData data;
1578 data.short_name = ASCIIToUTF16("t");
1579 data.SetURL("http://defaultturl/q={searchTerms}");
1580 data.suggestions_url = "http://defaultturl2/q={searchTerms}";
1581 data.instant_url = "http://does/not/exist";
1582 data.alternate_urls.push_back(data.instant_url + "#q={searchTerms}");
1583 data.search_terms_replacement_key = "strk";
1584
1585 TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
1586 TemplateURLService* service =
1587 TemplateURLServiceFactory::GetForProfile(browser()->profile());
1588 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
1589 service->Add(template_url); // Takes ownership of |template_url|.
1590
1591 // Change the default search provider.
1592 content::WindowedNotificationObserver observer(
1593 content::NOTIFICATION_LOAD_STOP,
1594 content::Source<content::NavigationController>(
1595 &ntp_contents->GetController()));
1596 service->SetDefaultSearchProvider(template_url);
1597 observer.Wait();
1598
1599 // |ntp_contents| should not use the Instant render process.
1600 EXPECT_FALSE(chrome::IsInstantNTP(ntp_contents));
1601 EXPECT_FALSE(instant_service->IsInstantProcess(
1602 ntp_contents->GetRenderProcessHost()->GetID()));
1603 // Make sure the URL remains the same.
1604 EXPECT_EQ(ntp_url, ntp_contents->GetURL());
1605 }
1606
1607 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
1608 ReloadLocalNTPOnSearchProviderChange) {
1609 // Setup Instant.
1610 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1611 FocusOmniboxAndWaitForInstantNTPSupport();
1612
1613 // Navigate to Local NTP.
1614 content::WindowedNotificationObserver new_tab_observer(
1615 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1616 content::NotificationService::AllSources());
1617 ui_test_utils::NavigateToURLWithDisposition(
1618 browser(),
1619 GURL(chrome::kChromeSearchLocalNtpUrl),
1620 CURRENT_TAB,
1621 ui_test_utils::BROWSER_TEST_NONE);
1622 new_tab_observer.Wait();
1623
1624 content::WebContents* ntp_contents =
1625 browser()->tab_strip_model()->GetActiveWebContents();
1626 GURL ntp_url = ntp_contents->GetURL();
1627
1628 TemplateURLData data;
1629 data.short_name = ASCIIToUTF16("t");
1630 data.SetURL("http://defaultturl/q={searchTerms}");
1631 data.suggestions_url = "http://defaultturl2/q={searchTerms}";
1632 data.instant_url = "http://does/not/exist";
1633 data.alternate_urls.push_back(data.instant_url + "#q={searchTerms}");
1634 data.search_terms_replacement_key = "strk";
1635
1636 TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
1637 TemplateURLService* service =
1638 TemplateURLServiceFactory::GetForProfile(browser()->profile());
1639 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
1640 service->Add(template_url); // Takes ownership of |template_url|.
1641
1642 // Change the default search provider. This will reload the local NTP and the
1643 // page URL will remain the same.
1644 content::WindowedNotificationObserver observer(
1645 content::NOTIFICATION_LOAD_STOP,
1646 content::Source<content::NavigationController>(
1647 &ntp_contents->GetController()));
1648 service->SetDefaultSearchProvider(template_url);
1649 observer.Wait();
1650
1651 // Make sure the URL remains the same.
1652 EXPECT_EQ(ntp_url, ntp_contents->GetURL());
1653 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698