OLD | NEW |
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 "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
7 #include "chrome/browser/search/instant_service.h" | 7 #include "chrome/browser/search/instant_service.h" |
8 #include "chrome/browser/search/instant_service_factory.h" | 8 #include "chrome/browser/search/instant_service_factory.h" |
9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
10 #include "chrome/browser/task_manager/task_manager.h" | 10 #include "chrome/browser/task_manager/task_manager.h" |
11 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 11 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_commands.h" | 13 #include "chrome/browser/ui/browser_commands.h" |
14 #include "chrome/browser/ui/host_desktop.h" | 14 #include "chrome/browser/ui/host_desktop.h" |
15 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 15 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 16 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h" |
16 #include "chrome/browser/ui/search/instant_test_utils.h" | 17 #include "chrome/browser/ui/search/instant_test_utils.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/common/omnibox_focus_state.h" | 19 #include "chrome/common/omnibox_focus_state.h" |
19 #include "chrome/common/search_types.h" | 20 #include "chrome/common/search_types.h" |
20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chrome/test/base/interactive_test_utils.h" | 23 #include "chrome/test/base/interactive_test_utils.h" |
23 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
24 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
25 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return is_google; | 86 return is_google; |
86 } | 87 } |
87 | 88 |
88 private: | 89 private: |
89 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; | 90 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; |
90 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; | 91 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; |
91 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> | 92 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> |
92 disable_network_change_notifier_; | 93 disable_network_change_notifier_; |
93 }; | 94 }; |
94 | 95 |
| 96 IN_PROC_BROWSER_TEST_F(InstantExtendedManualTest, MANUAL_ShowsGoogleNTP) { |
| 97 set_browser(browser()); |
| 98 InstantService* instant_service = |
| 99 InstantServiceFactory::GetForProfile(browser()->profile()); |
| 100 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 101 instant_service->ntp_prerenderer()->ReloadInstantNTP(); |
| 102 |
| 103 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 104 content::WindowedNotificationObserver observer( |
| 105 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 106 content::NotificationService::AllSources()); |
| 107 ui_test_utils::NavigateToURLWithDisposition( |
| 108 browser(), |
| 109 GURL(chrome::kChromeUINewTabURL), |
| 110 CURRENT_TAB, |
| 111 ui_test_utils::BROWSER_TEST_NONE); |
| 112 observer.Wait(); |
| 113 content::WebContents* active_tab = |
| 114 browser()->tab_strip_model()->GetActiveWebContents(); |
| 115 EXPECT_TRUE(IsGooglePage(active_tab)); |
| 116 } |
| 117 |
95 IN_PROC_BROWSER_TEST_F(InstantExtendedManualTest, MANUAL_SearchesFromFakebox) { | 118 IN_PROC_BROWSER_TEST_F(InstantExtendedManualTest, MANUAL_SearchesFromFakebox) { |
96 set_browser(browser()); | 119 set_browser(browser()); |
| 120 InstantService* instant_service = |
| 121 InstantServiceFactory::GetForProfile(browser()->profile()); |
| 122 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 123 instant_service->ntp_prerenderer()->ReloadInstantNTP(); |
97 | 124 |
98 FocusOmnibox(); | 125 FocusOmniboxAndWaitForInstantNTPSupport(); |
99 // Open a new tab page. | 126 // Open a new tab page. |
100 content::WindowedNotificationObserver observer( | 127 content::WindowedNotificationObserver observer( |
101 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 128 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
102 content::NotificationService::AllSources()); | 129 content::NotificationService::AllSources()); |
103 ui_test_utils::NavigateToURLWithDisposition( | 130 ui_test_utils::NavigateToURLWithDisposition( |
104 browser(), | 131 browser(), |
105 GURL(chrome::kChromeUINewTabURL), | 132 GURL(chrome::kChromeUINewTabURL), |
106 CURRENT_TAB, | 133 CURRENT_TAB, |
107 ui_test_utils::BROWSER_TEST_NONE); | 134 ui_test_utils::BROWSER_TEST_NONE); |
108 observer.Wait(); | 135 observer.Wait(); |
(...skipping 29 matching lines...) Expand all Loading... |
138 EXPECT_EQ("test", GetOmniboxText()); | 165 EXPECT_EQ("test", GetOmniboxText()); |
139 EXPECT_EQ(OMNIBOX_FOCUS_VISIBLE, omnibox()->model()->focus_state()); | 166 EXPECT_EQ(OMNIBOX_FOCUS_VISIBLE, omnibox()->model()->focus_state()); |
140 | 167 |
141 // Pressing enter should search for [test]. | 168 // Pressing enter should search for [test]. |
142 const base::string16& search_title = | 169 const base::string16& search_title = |
143 base::ASCIIToUTF16("test - Google Search"); | 170 base::ASCIIToUTF16("test - Google Search"); |
144 content::TitleWatcher title_watcher(active_tab, search_title); | 171 content::TitleWatcher title_watcher(active_tab, search_title); |
145 PressEnterAndWaitForNavigation(); | 172 PressEnterAndWaitForNavigation(); |
146 EXPECT_EQ(search_title, title_watcher.WaitAndGetTitle()); | 173 EXPECT_EQ(search_title, title_watcher.WaitAndGetTitle()); |
147 } | 174 } |
OLD | NEW |