OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/dom_operation_notification_details.h" | 13 #include "chrome/browser/dom_operation_notification_details.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/browser/renderer_host/render_view_host.h" | 19 #include "content/browser/renderer_host/render_view_host.h" |
20 #include "content/browser/renderer_host/render_widget_host_view.h" | 20 #include "content/browser/renderer_host/render_widget_host_view.h" |
21 #include "content/browser/tab_contents/tab_contents.h" | 21 #include "content/browser/tab_contents/tab_contents.h" |
22 #include "content/browser/tab_contents/tab_contents_view.h" | 22 #include "content/browser/tab_contents/tab_contents_view.h" |
23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "net/test/test_server.h" | 25 #include "net/test/test_server.h" |
26 #include "ui/base/keycodes/keyboard_codes.h" | 26 #include "ui/base/keycodes/keyboard_codes.h" |
27 | 27 |
| 28 using content::NavigationController; |
| 29 |
28 namespace { | 30 namespace { |
29 | 31 |
30 const char kTestingPage[] = "files/keyevents_test.html"; | 32 const char kTestingPage[] = "files/keyevents_test.html"; |
31 const wchar_t kSuppressEventJS[] = | 33 const wchar_t kSuppressEventJS[] = |
32 L"window.domAutomationController.send(setDefaultAction('%ls', %ls));"; | 34 L"window.domAutomationController.send(setDefaultAction('%ls', %ls));"; |
33 const wchar_t kGetResultJS[] = | 35 const wchar_t kGetResultJS[] = |
34 L"window.domAutomationController.send(keyEventResult[%d]);"; | 36 L"window.domAutomationController.send(keyEventResult[%d]);"; |
35 const wchar_t kGetResultLengthJS[] = | 37 const wchar_t kGetResultLengthJS[] = |
36 L"window.domAutomationController.send(keyEventResult.length);"; | 38 L"window.domAutomationController.send(keyEventResult.length);"; |
37 const wchar_t kGetFocusedElementJS[] = | 39 const wchar_t kGetFocusedElementJS[] = |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 707 |
706 // Make sure the focus is in the testing page. | 708 // Make sure the focus is in the testing page. |
707 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER)); | 709 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER)); |
708 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 710 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
709 | 711 |
710 // Reserved accelerators can't be suppressed. | 712 // Reserved accelerators can't be suppressed. |
711 ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(1, true)); | 713 ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(1, true)); |
712 | 714 |
713 ui_test_utils::WindowedNotificationObserver wait_for_tab_closed( | 715 ui_test_utils::WindowedNotificationObserver wait_for_tab_closed( |
714 content::NOTIFICATION_TAB_CLOSED, | 716 content::NOTIFICATION_TAB_CLOSED, |
715 content::Source<content::NavigationController>( | 717 content::Source<NavigationController>( |
716 &browser()->GetTabContentsAt(1)->GetController())); | 718 &browser()->GetTabContentsAt(1)->GetController())); |
717 | 719 |
718 // Press Ctrl/Cmd+W, which will close the tab. | 720 // Press Ctrl/Cmd+W, which will close the tab. |
719 #if defined(OS_MACOSX) | 721 #if defined(OS_MACOSX) |
720 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 722 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
721 browser(), ui::VKEY_W, false, false, false, true)); | 723 browser(), ui::VKEY_W, false, false, false, true)); |
722 #else | 724 #else |
723 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 725 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
724 browser(), ui::VKEY_W, true, false, false, false)); | 726 browser(), ui::VKEY_W, true, false, false, false)); |
725 #endif | 727 #endif |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); | 859 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); |
858 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 860 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
859 | 861 |
860 // Ctrl+Alt should have no effect. | 862 // Ctrl+Alt should have no effect. |
861 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); | 863 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); |
862 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 864 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
863 } | 865 } |
864 #endif | 866 #endif |
865 | 867 |
866 } // namespace | 868 } // namespace |
OLD | NEW |