| 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/common/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 namespace { | 28 namespace { |
| 29 | 29 |
| 30 const char kTestingPage[] = "files/keyevents_test.html"; | 30 const char kTestingPage[] = "files/keyevents_test.html"; |
| 31 const wchar_t kSuppressEventJS[] = | 31 const wchar_t kSuppressEventJS[] = |
| 32 L"window.domAutomationController.send(setDefaultAction('%ls', %ls));"; | 32 L"window.domAutomationController.send(setDefaultAction('%ls', %ls));"; |
| 33 const wchar_t kGetResultJS[] = | 33 const wchar_t kGetResultJS[] = |
| 34 L"window.domAutomationController.send(keyEventResult[%d]);"; | 34 L"window.domAutomationController.send(keyEventResult[%d]);"; |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 { "D 91 0 false false false true" } | 674 { "D 91 0 false false false true" } |
| 675 #else | 675 #else |
| 676 ui::VKEY_T, true, false, false, false, | 676 ui::VKEY_T, true, false, false, false, |
| 677 true, false, false, false, 1, | 677 true, false, false, false, 1, |
| 678 { "D 17 0 true false false false" } | 678 { "D 17 0 true false false false" } |
| 679 #endif | 679 #endif |
| 680 }; | 680 }; |
| 681 | 681 |
| 682 ui_test_utils::WindowedNotificationObserver wait_for_new_tab( | 682 ui_test_utils::WindowedNotificationObserver wait_for_new_tab( |
| 683 content::NOTIFICATION_TAB_PARENTED, | 683 content::NOTIFICATION_TAB_PARENTED, |
| 684 NotificationService::AllSources()); | 684 content::NotificationService::AllSources()); |
| 685 | 685 |
| 686 // Press Ctrl/Cmd+T, which will open a new tab. It cannot be suppressed. | 686 // Press Ctrl/Cmd+T, which will open a new tab. It cannot be suppressed. |
| 687 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(0, kTestCtrlOrCmdT)); | 687 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(0, kTestCtrlOrCmdT)); |
| 688 wait_for_new_tab.Wait(); | 688 wait_for_new_tab.Wait(); |
| 689 | 689 |
| 690 int result_length; | 690 int result_length; |
| 691 ASSERT_NO_FATAL_FAILURE(GetResultLength(0, &result_length)); | 691 ASSERT_NO_FATAL_FAILURE(GetResultLength(0, &result_length)); |
| 692 EXPECT_EQ(1, result_length); | 692 EXPECT_EQ(1, result_length); |
| 693 | 693 |
| 694 EXPECT_EQ(2, browser()->tab_count()); | 694 EXPECT_EQ(2, browser()->tab_count()); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); | 852 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); |
| 853 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 853 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 854 | 854 |
| 855 // Ctrl+Alt should have no effect. | 855 // Ctrl+Alt should have no effect. |
| 856 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); | 856 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); |
| 857 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 857 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 858 } | 858 } |
| 859 #endif | 859 #endif |
| 860 | 860 |
| 861 } // namespace | 861 } // namespace |
| OLD | NEW |