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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "ui/aura/window.h" | 48 #include "ui/aura/window.h" |
49 #include "ui/aura/window_event_dispatcher.h" | 49 #include "ui/aura/window_event_dispatcher.h" |
50 #include "ui/aura/window_observer.h" | 50 #include "ui/aura/window_observer.h" |
51 #include "ui/base/ui_base_types.h" | 51 #include "ui/base/ui_base_types.h" |
52 #include "ui/compositor/compositor.h" | 52 #include "ui/compositor/compositor.h" |
53 #include "ui/compositor/layer_tree_owner.h" | 53 #include "ui/compositor/layer_tree_owner.h" |
54 #include "ui/compositor/test/draw_waiter_for_test.h" | 54 #include "ui/compositor/test/draw_waiter_for_test.h" |
55 #include "ui/events/event.h" | 55 #include "ui/events/event.h" |
56 #include "ui/events/event_utils.h" | 56 #include "ui/events/event_utils.h" |
57 #include "ui/events/gesture_detection/gesture_configuration.h" | 57 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 58 #include "ui/events/keycodes/dom3/dom_code.h" |
| 59 #include "ui/events/keycodes/dom4/keycode_converter.h" |
58 #include "ui/events/test/event_generator.h" | 60 #include "ui/events/test/event_generator.h" |
59 #include "ui/wm/core/default_activation_client.h" | 61 #include "ui/wm/core/default_activation_client.h" |
60 #include "ui/wm/core/default_screen_position_client.h" | 62 #include "ui/wm/core/default_screen_position_client.h" |
61 #include "ui/wm/core/window_util.h" | 63 #include "ui/wm/core/window_util.h" |
62 | 64 |
63 using testing::_; | 65 using testing::_; |
64 | 66 |
65 using blink::WebGestureEvent; | 67 using blink::WebGestureEvent; |
66 using blink::WebInputEvent; | 68 using blink::WebInputEvent; |
67 using blink::WebMouseEvent; | 69 using blink::WebMouseEvent; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 float delta_x_; | 127 float delta_x_; |
126 float delta_y_; | 128 float delta_y_; |
127 | 129 |
128 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); | 130 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); |
129 }; | 131 }; |
130 | 132 |
131 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | 133 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
132 public: | 134 public: |
133 MockRenderWidgetHostDelegate() {} | 135 MockRenderWidgetHostDelegate() {} |
134 ~MockRenderWidgetHostDelegate() override {} | 136 ~MockRenderWidgetHostDelegate() override {} |
| 137 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } |
| 138 protected: |
| 139 // RenderWidgetHostDelegate: |
| 140 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 141 bool* is_keyboard_shortcut) override { |
| 142 last_event_.reset(new NativeWebKeyboardEvent(event)); |
| 143 return true; |
| 144 } |
| 145 private: |
| 146 scoped_ptr<NativeWebKeyboardEvent> last_event_; |
| 147 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); |
135 }; | 148 }; |
136 | 149 |
137 // Simple observer that keeps track of changes to a window for tests. | 150 // Simple observer that keeps track of changes to a window for tests. |
138 class TestWindowObserver : public aura::WindowObserver { | 151 class TestWindowObserver : public aura::WindowObserver { |
139 public: | 152 public: |
140 explicit TestWindowObserver(aura::Window* window_to_observe) | 153 explicit TestWindowObserver(aura::Window* window_to_observe) |
141 : window_(window_to_observe) { | 154 : window_(window_to_observe) { |
142 window_->AddObserver(this); | 155 window_->AddObserver(this); |
143 } | 156 } |
144 ~TestWindowObserver() override { | 157 ~TestWindowObserver() override { |
(...skipping 2817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 | 2975 |
2963 view_->OnTouchEvent(&press); | 2976 view_->OnTouchEvent(&press); |
2964 view_->OnTouchEvent(&invalid_move); | 2977 view_->OnTouchEvent(&invalid_move); |
2965 // Valid press is handled asynchronously. | 2978 // Valid press is handled asynchronously. |
2966 EXPECT_TRUE(press.synchronous_handling_disabled()); | 2979 EXPECT_TRUE(press.synchronous_handling_disabled()); |
2967 // Invalid move is handled synchronously, but is consumed. | 2980 // Invalid move is handled synchronously, but is consumed. |
2968 EXPECT_FALSE(invalid_move.synchronous_handling_disabled()); | 2981 EXPECT_FALSE(invalid_move.synchronous_handling_disabled()); |
2969 EXPECT_TRUE(invalid_move.stopped_propagation()); | 2982 EXPECT_TRUE(invalid_move.stopped_propagation()); |
2970 } | 2983 } |
2971 | 2984 |
| 2985 // Checks key event codes. |
| 2986 TEST_F(RenderWidgetHostViewAuraTest, KeyEvent) { |
| 2987 view_->InitAsChild(NULL); |
| 2988 view_->Show(); |
| 2989 |
| 2990 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::KEY_A, |
| 2991 ui::EF_NONE); |
| 2992 view_->OnKeyEvent(&key_event); |
| 2993 |
| 2994 const NativeWebKeyboardEvent* event = delegate_.last_event(); |
| 2995 EXPECT_NE(nullptr, event); |
| 2996 if (event) { |
| 2997 EXPECT_EQ(key_event.key_code(), event->windowsKeyCode); |
| 2998 EXPECT_EQ(ui::KeycodeConverter::DomCodeToNativeKeycode(key_event.code()), |
| 2999 event->nativeKeyCode); |
| 3000 } |
| 3001 } |
| 3002 |
2972 } // namespace content | 3003 } // namespace content |
OLD | NEW |