| 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 "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/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.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/interactive_test_utils.h" | 17 #include "chrome/test/base/interactive_test_utils.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/browser/dom_operation_notification_details.h" | 20 #include "content/public/browser/dom_operation_notification_details.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/render_widget_host_view.h" | 24 #include "content/public/browser/render_widget_host_view.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/browser/web_contents_view.h" | 26 #include "content/public/browser/web_contents_view.h" |
| 27 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
| 28 #include "net/test/test_server.h" | 28 #include "net/test/test_server.h" |
| 29 #include "ui/base/keycodes/keyboard_codes.h" | 29 #include "ui/base/keycodes/keyboard_codes.h" |
| 30 #include "ui/views/controls/textfield/textfield.h" |
| 30 | 31 |
| 31 using content::DomOperationNotificationDetails; | 32 using content::DomOperationNotificationDetails; |
| 32 using content::NavigationController; | 33 using content::NavigationController; |
| 33 using content::RenderViewHost; | 34 using content::RenderViewHost; |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 const char kTestingPage[] = "files/keyevents_test.html"; | 38 const char kTestingPage[] = "files/keyevents_test.html"; |
| 38 const char kSuppressEventJS[] = | 39 const char kSuppressEventJS[] = |
| 39 "window.domAutomationController.send(setDefaultAction('%ls', %ls));"; | 40 "window.domAutomationController.send(setDefaultAction('%ls', %ls));"; |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 // Make sure no element is focused. | 632 // Make sure no element is focused. |
| 632 EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L"")); | 633 EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L"")); |
| 633 | 634 |
| 634 #if !defined(OS_MACOSX) | 635 #if !defined(OS_MACOSX) |
| 635 // Alt+D should move the focus to the location entry. | 636 // Alt+D should move the focus to the location entry. |
| 636 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAccessD)); | 637 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAccessD)); |
| 637 | 638 |
| 638 // TODO(isherman): This is an experimental change to help diagnose | 639 // TODO(isherman): This is an experimental change to help diagnose |
| 639 // http://crbug.com/55713 | 640 // http://crbug.com/55713 |
| 640 content::RunAllPendingInMessageLoop(); | 641 content::RunAllPendingInMessageLoop(); |
| 641 #if defined(USE_AURA) | |
| 642 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 642 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 643 #else | |
| 644 EXPECT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); | |
| 645 #endif | |
| 646 // No element should be focused, as Alt+D was handled by the browser. | 643 // No element should be focused, as Alt+D was handled by the browser. |
| 647 EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L"")); | 644 EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L"")); |
| 648 | 645 |
| 649 // Move the focus back to the web page. | 646 // Move the focus back to the web page. |
| 650 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER)); | 647 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER)); |
| 651 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 648 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
| 652 | 649 |
| 653 // Make sure no element is focused. | 650 // Make sure no element is focused. |
| 654 EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L"")); | 651 EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L"")); |
| 655 #endif | 652 #endif |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); | 883 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); |
| 887 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 884 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
| 888 | 885 |
| 889 // Ctrl+Alt should have no effect. | 886 // Ctrl+Alt should have no effect. |
| 890 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); | 887 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); |
| 891 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 888 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
| 892 } | 889 } |
| 893 #endif | 890 #endif |
| 894 | 891 |
| 895 } // namespace | 892 } // namespace |
| OLD | NEW |