| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/browser_navigator_browsertest.h" | 5 #include "chrome/browser/ui/browser_navigator_browsertest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 9 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
| 13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
| 14 #include "chrome/browser/ui/browser_navigator.h" | 14 #include "chrome/browser/ui/browser_navigator.h" |
| 15 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/chrome_pages.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
| 18 #include "chrome/browser/ui/omnibox/location_bar.h" | |
| 19 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | |
| 20 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | |
| 21 #include "chrome/browser/ui/omnibox/omnibox_view.h" | |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 24 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 27 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 28 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
| 30 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 31 #include "content/public/browser/web_contents_view.h" | 27 #include "content/public/browser/web_contents_view.h" |
| (...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 content::NOTIFICATION_LOAD_STOP, | 1150 content::NOTIFICATION_LOAD_STOP, |
| 1155 content::NotificationService::AllSources()); | 1151 content::NotificationService::AllSources()); |
| 1156 chrome::ShowSettings(browser()); | 1152 chrome::ShowSettings(browser()); |
| 1157 observer.Wait(); | 1153 observer.Wait(); |
| 1158 } | 1154 } |
| 1159 EXPECT_EQ(2, browser()->tab_count()); | 1155 EXPECT_EQ(2, browser()->tab_count()); |
| 1160 EXPECT_EQ(GetSettingsURL(), | 1156 EXPECT_EQ(GetSettingsURL(), |
| 1161 ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL())); | 1157 ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL())); |
| 1162 } | 1158 } |
| 1163 | 1159 |
| 1164 // Tests that when a new tab is opened from the omnibox, the focus is moved from | |
| 1165 // the omnibox for the current tab. | |
| 1166 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | |
| 1167 NavigateFromOmniboxIntoNewTab) { | |
| 1168 GURL url("http://www.google.com/"); | |
| 1169 GURL url2("http://maps.google.com/"); | |
| 1170 | |
| 1171 // Navigate to url. | |
| 1172 chrome::NavigateParams p(MakeNavigateParams()); | |
| 1173 p.disposition = CURRENT_TAB; | |
| 1174 p.url = url; | |
| 1175 chrome::Navigate(&p); | |
| 1176 | |
| 1177 // Focus the omnibox. | |
| 1178 chrome::FocusLocationBar(browser()); | |
| 1179 | |
| 1180 OmniboxEditController* controller = | |
| 1181 browser()->window()->GetLocationBar()->GetLocationEntry()->model()-> | |
| 1182 controller(); | |
| 1183 | |
| 1184 // Simulate an alt-enter. | |
| 1185 controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB, | |
| 1186 content::PAGE_TRANSITION_TYPED, GURL()); | |
| 1187 | |
| 1188 // Make sure the second tab is selected. | |
| 1189 EXPECT_EQ(1, browser()->active_index()); | |
| 1190 | |
| 1191 // The tab contents should have the focus in the second tab. | |
| 1192 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | |
| 1193 | |
| 1194 // Go back to the first tab. The focus should not be in the omnibox. | |
| 1195 chrome::SelectPreviousTab(browser()); | |
| 1196 EXPECT_EQ(0, browser()->active_index()); | |
| 1197 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), | |
| 1198 VIEW_ID_LOCATION_BAR)); | |
| 1199 } | |
| 1200 | |
| 1201 // TODO(csilv): Update this for uber page. http://crbug.com/111579. | 1160 // TODO(csilv): Update this for uber page. http://crbug.com/111579. |
| 1202 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1161 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1203 DISABLED_NavigateFromDefaultToHistoryInSameTab) { | 1162 DISABLED_NavigateFromDefaultToHistoryInSameTab) { |
| 1204 { | 1163 { |
| 1205 content::WindowedNotificationObserver observer( | 1164 content::WindowedNotificationObserver observer( |
| 1206 content::NOTIFICATION_LOAD_STOP, | 1165 content::NOTIFICATION_LOAD_STOP, |
| 1207 content::NotificationService::AllSources()); | 1166 content::NotificationService::AllSources()); |
| 1208 chrome::ShowHistory(browser()); | 1167 chrome::ShowHistory(browser()); |
| 1209 observer.Wait(); | 1168 observer.Wait(); |
| 1210 } | 1169 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 // Now navigate using the incognito profile and check that a new window | 1212 // Now navigate using the incognito profile and check that a new window |
| 1254 // is created. | 1213 // is created. |
| 1255 chrome::NavigateParams params_incognito( | 1214 chrome::NavigateParams params_incognito( |
| 1256 browser()->profile()->GetOffTheRecordProfile(), | 1215 browser()->profile()->GetOffTheRecordProfile(), |
| 1257 GetGoogleURL(), content::PAGE_TRANSITION_LINK); | 1216 GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
| 1258 ui_test_utils::NavigateToURL(¶ms_incognito); | 1217 ui_test_utils::NavigateToURL(¶ms_incognito); |
| 1259 EXPECT_EQ(2u, BrowserList::size()); | 1218 EXPECT_EQ(2u, BrowserList::size()); |
| 1260 } | 1219 } |
| 1261 | 1220 |
| 1262 } // namespace | 1221 } // namespace |
| OLD | NEW |