OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/keyboard_codes.h" | 5 #include "base/keyboard_codes.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
8 #include "chrome/browser/automation/ui_controls.h" | 8 #include "chrome/browser/automation/ui_controls.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
11 #include "chrome/browser/renderer_host/render_view_host.h" | 11 #include "chrome/browser/renderer_host/render_view_host.h" |
12 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 12 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
13 #include "chrome/browser/tab_contents/interstitial_page.h" | 13 #include "chrome/browser/tab_contents/interstitial_page.h" |
14 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
15 #include "chrome/browser/tab_contents/tab_contents_view.h" | 15 #include "chrome/browser/tab_contents/tab_contents_view.h" |
16 #include "chrome/browser/view_ids.h" | 16 #include "chrome/browser/view_ids.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/test/automation/browser_proxy.h" |
| 19 #include "chrome/test/automation/tab_proxy.h" |
| 20 #include "chrome/test/automation/window_proxy.h" |
18 #include "chrome/test/in_process_browser_test.h" | 21 #include "chrome/test/in_process_browser_test.h" |
| 22 #include "chrome/test/ui/ui_test.h" |
19 #include "chrome/test/ui_test_utils.h" | 23 #include "chrome/test/ui_test_utils.h" |
| 24 #include "views/event.h" |
20 #include "views/focus/focus_manager.h" | 25 #include "views/focus/focus_manager.h" |
21 #include "views/view.h" | 26 #include "views/view.h" |
22 #include "views/window/window.h" | 27 #include "views/window/window.h" |
23 | 28 |
24 #if defined(TOOLKIT_VIEWS) | 29 #if defined(TOOLKIT_VIEWS) |
25 #include "chrome/browser/views/frame/browser_view.h" | 30 #include "chrome/browser/views/frame/browser_view.h" |
26 #include "chrome/browser/views/location_bar_view.h" | 31 #include "chrome/browser/views/location_bar_view.h" |
27 #include "chrome/browser/views/tab_contents/tab_contents_container.h" | 32 #include "chrome/browser/views/tab_contents/tab_contents_container.h" |
28 #endif | 33 #endif |
29 | 34 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 735 |
731 // Open a regular page, crash, reload. | 736 // Open a regular page, crash, reload. |
732 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); | 737 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); |
733 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); | 738 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); |
734 browser()->Reload(); | 739 browser()->Reload(); |
735 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 740 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
736 // Focus should now be on the tab contents. | 741 // Focus should now be on the tab contents. |
737 browser()->ShowDownloadsTab(); | 742 browser()->ShowDownloadsTab(); |
738 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 743 CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); |
739 } | 744 } |
| 745 |
| 746 #if !defined(OS_MACOSX) // see BrowserWindowCocoa::GetCommandId |
| 747 // Tests that tab related keyboard accelerators are reserved by the app. |
| 748 |
| 749 class BrowserInteractiveTest : public UITest { |
| 750 }; |
| 751 |
| 752 TEST_F(BrowserInteractiveTest, ReserveKeyboardAccelerators) { |
| 753 const std::string kBadPage = |
| 754 "<html><script>" |
| 755 "document.onkeydown = function() {" |
| 756 " event.preventDefault();" |
| 757 " return false;" |
| 758 "}" |
| 759 "</script></html>"; |
| 760 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 761 browser->AppendTab(GURL("data:text/html," + kBadPage)); |
| 762 int tab_count = 0; |
| 763 ASSERT_TRUE(browser->GetTabCount(&tab_count)); |
| 764 ASSERT_EQ(tab_count, 2); |
| 765 |
| 766 int active_tab = 0; |
| 767 ASSERT_TRUE(browser->GetActiveTabIndex(&active_tab)); |
| 768 ASSERT_EQ(active_tab, 1); |
| 769 |
| 770 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
| 771 ASSERT_TRUE(window->SimulateOSKeyPress( |
| 772 base::VKEY_TAB, views::Event::EF_CONTROL_DOWN)); |
| 773 ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, action_max_timeout_ms())); |
| 774 |
| 775 ASSERT_TRUE(window->SimulateOSKeyPress( |
| 776 base::VKEY_F4, views::Event::EF_CONTROL_DOWN)); |
| 777 ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms())); |
| 778 } |
| 779 #endif |
OLD | NEW |