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" | |
17 #include "chrome/browser/ui/search/instant_test_utils.h" | 16 #include "chrome/browser/ui/search/instant_test_utils.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/common/omnibox_focus_state.h" | 18 #include "chrome/common/omnibox_focus_state.h" |
20 #include "chrome/common/search_types.h" | 19 #include "chrome/common/search_types.h" |
21 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
22 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
23 #include "chrome/test/base/interactive_test_utils.h" | 22 #include "chrome/test/base/interactive_test_utils.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
25 #include "content/public/browser/navigation_controller.h" | 24 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return is_google; | 85 return is_google; |
87 } | 86 } |
88 | 87 |
89 private: | 88 private: |
90 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; | 89 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; |
91 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; | 90 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; |
92 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> | 91 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> |
93 disable_network_change_notifier_; | 92 disable_network_change_notifier_; |
94 }; | 93 }; |
95 | 94 |
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 | |
118 IN_PROC_BROWSER_TEST_F(InstantExtendedManualTest, MANUAL_SearchesFromFakebox) { | 95 IN_PROC_BROWSER_TEST_F(InstantExtendedManualTest, MANUAL_SearchesFromFakebox) { |
119 set_browser(browser()); | 96 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(); | |
124 | 97 |
125 FocusOmniboxAndWaitForInstantNTPSupport(); | 98 FocusOmnibox(); |
126 // Open a new tab page. | 99 // Open a new tab page. |
127 content::WindowedNotificationObserver observer( | 100 content::WindowedNotificationObserver observer( |
128 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 101 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
129 content::NotificationService::AllSources()); | 102 content::NotificationService::AllSources()); |
130 ui_test_utils::NavigateToURLWithDisposition( | 103 ui_test_utils::NavigateToURLWithDisposition( |
131 browser(), | 104 browser(), |
132 GURL(chrome::kChromeUINewTabURL), | 105 GURL(chrome::kChromeUINewTabURL), |
133 CURRENT_TAB, | 106 CURRENT_TAB, |
134 ui_test_utils::BROWSER_TEST_NONE); | 107 ui_test_utils::BROWSER_TEST_NONE); |
135 observer.Wait(); | 108 observer.Wait(); |
(...skipping 29 matching lines...) Expand all Loading... |
165 EXPECT_EQ("test", GetOmniboxText()); | 138 EXPECT_EQ("test", GetOmniboxText()); |
166 EXPECT_EQ(OMNIBOX_FOCUS_VISIBLE, omnibox()->model()->focus_state()); | 139 EXPECT_EQ(OMNIBOX_FOCUS_VISIBLE, omnibox()->model()->focus_state()); |
167 | 140 |
168 // Pressing enter should search for [test]. | 141 // Pressing enter should search for [test]. |
169 const base::string16& search_title = | 142 const base::string16& search_title = |
170 base::ASCIIToUTF16("test - Google Search"); | 143 base::ASCIIToUTF16("test - Google Search"); |
171 content::TitleWatcher title_watcher(active_tab, search_title); | 144 content::TitleWatcher title_watcher(active_tab, search_title); |
172 PressEnterAndWaitForNavigation(); | 145 PressEnterAndWaitForNavigation(); |
173 EXPECT_EQ(search_title, title_watcher.WaitAndGetTitle()); | 146 EXPECT_EQ(search_title, title_watcher.WaitAndGetTitle()); |
174 } | 147 } |
OLD | NEW |