| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
| 28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 29 #include "content/public/test/mock_render_process_host.h" | 29 #include "content/public/test/mock_render_process_host.h" |
| 30 #include "content/public/test/test_browser_context.h" | 30 #include "content/public/test/test_browser_context.h" |
| 31 #include "content/public/test/test_browser_thread_bundle.h" | 31 #include "content/public/test/test_browser_thread_bundle.h" |
| 32 #include "content/test/test_render_view_host.h" | 32 #include "content/test/test_render_view_host.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "ui/display/screen.h" | 34 #include "ui/display/screen.h" |
| 35 #include "ui/events/base_event_utils.h" | 35 #include "ui/events/base_event_utils.h" |
| 36 #include "ui/events/blink/web_input_event_traits.h" | 36 #include "ui/events/blink/web_input_event_traits.h" |
| 37 #include "ui/events/keycodes/dom/dom_code.h" |
| 37 #include "ui/events/keycodes/keyboard_codes.h" | 38 #include "ui/events/keycodes/keyboard_codes.h" |
| 38 #include "ui/gfx/canvas.h" | 39 #include "ui/gfx/canvas.h" |
| 39 | 40 |
| 40 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 41 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" | 42 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" |
| 42 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 43 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 43 #include "content/test/mock_gpu_channel_establish_factory.h" | 44 #include "content/test/mock_gpu_channel_establish_factory.h" |
| 44 #include "ui/android/screen_android.h" | 45 #include "ui/android/screen_android.h" |
| 45 #endif | 46 #endif |
| 46 | 47 |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 | 980 |
| 980 // Send the simulated response from the renderer back. | 981 // Send the simulated response from the renderer back. |
| 981 SendInputEventACK(WebInputEvent::RawKeyDown, | 982 SendInputEventACK(WebInputEvent::RawKeyDown, |
| 982 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 983 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 983 | 984 |
| 984 EXPECT_TRUE(delegate_->unhandled_keyboard_event_called()); | 985 EXPECT_TRUE(delegate_->unhandled_keyboard_event_called()); |
| 985 EXPECT_EQ(WebInputEvent::RawKeyDown, | 986 EXPECT_EQ(WebInputEvent::RawKeyDown, |
| 986 delegate_->unhandled_keyboard_event_type()); | 987 delegate_->unhandled_keyboard_event_type()); |
| 987 } | 988 } |
| 988 | 989 |
| 990 TEST_F(RenderWidgetHostTest, SuppressEventsUntilKeyDown) { |
| 991 // Clear any messages unrelated to this test. |
| 992 process_->sink().ClearMessages(); |
| 993 EXPECT_EQ(0U, process_->sink().message_count()); |
| 994 |
| 995 // Enable key event suppression. |
| 996 host_->SuppressEventsUntilKeyDown(); |
| 997 |
| 998 // Simulate a KeyUp event. |
| 999 SimulateKeyboardEvent(WebInputEvent::KeyUp); |
| 1000 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1001 |
| 1002 // Simulate a RawKeyDown event. |
| 1003 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 1004 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1005 EXPECT_EQ(InputMsg_HandleInputEvent::ID, |
| 1006 process_->sink().GetMessageAt(0)->type()); |
| 1007 process_->sink().ClearMessages(); |
| 1008 |
| 1009 // Enable key event suppression again. |
| 1010 host_->SuppressEventsUntilKeyDown(); |
| 1011 process_->sink().ClearMessages(); |
| 1012 |
| 1013 // Simulate a PrintScreen KeyUp event. |
| 1014 NativeWebKeyboardEvent print_screen_event(WebInputEvent::KeyUp, 0, |
| 1015 GetNextSimulatedEventTimeSeconds()); |
| 1016 print_screen_event.domCode = static_cast<int>(ui::DomCode::PRINT_SCREEN); |
| 1017 host_->ForwardKeyboardEvent(print_screen_event); |
| 1018 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1019 EXPECT_EQ(InputMsg_HandleInputEvent::ID, |
| 1020 process_->sink().GetMessageAt(0)->type()); |
| 1021 } |
| 1022 |
| 989 TEST_F(RenderWidgetHostTest, RawKeyDownShortcutEvent) { | 1023 TEST_F(RenderWidgetHostTest, RawKeyDownShortcutEvent) { |
| 990 // Simulate the situation that the browser marks the key down as a keyboard | 1024 // Simulate the situation that the browser marks the key down as a keyboard |
| 991 // shortcut, but doesn't consume it in the pre-handle phase. | 1025 // shortcut, but doesn't consume it in the pre-handle phase. |
| 992 delegate_->set_prehandle_keyboard_event_is_shortcut(true); | 1026 delegate_->set_prehandle_keyboard_event_is_shortcut(true); |
| 993 process_->sink().ClearMessages(); | 1027 process_->sink().ClearMessages(); |
| 994 | 1028 |
| 995 // Simulate a keyboard event. | 1029 // Simulate a keyboard event. |
| 996 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 1030 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 997 | 1031 |
| 998 EXPECT_TRUE(delegate_->prehandle_keyboard_event_called()); | 1032 EXPECT_TRUE(delegate_->prehandle_keyboard_event_called()); |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 ui::LatencyInfo()); | 1748 ui::LatencyInfo()); |
| 1715 | 1749 |
| 1716 | 1750 |
| 1717 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1751 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1718 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1752 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
| 1719 | 1753 |
| 1720 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1754 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1721 } | 1755 } |
| 1722 | 1756 |
| 1723 } // namespace content | 1757 } // namespace content |
| OLD | NEW |