| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/test/render_view_test.h" | 5 #include "chrome/test/render_view_test.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/native_web_keyboard_event.h" | 9 #include "chrome/common/native_web_keyboard_event.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 if (length != 1) | 151 if (length != 1) |
| 152 return -1; | 152 return -1; |
| 153 | 153 |
| 154 // Create IPC messages from Windows messages and send them to our | 154 // Create IPC messages from Windows messages and send them to our |
| 155 // back-end. | 155 // back-end. |
| 156 // A keyboard event of Windows consists of three Windows messages: | 156 // A keyboard event of Windows consists of three Windows messages: |
| 157 // WM_KEYDOWN, WM_CHAR, and WM_KEYUP. | 157 // WM_KEYDOWN, WM_CHAR, and WM_KEYUP. |
| 158 // WM_KEYDOWN and WM_KEYUP sends virtual-key codes. On the other hand, | 158 // WM_KEYDOWN and WM_KEYUP sends virtual-key codes. On the other hand, |
| 159 // WM_CHAR sends a composed Unicode character. | 159 // WM_CHAR sends a composed Unicode character. |
| 160 NativeWebKeyboardEvent keydown_event(NULL, WM_KEYDOWN, key_code, 0); | 160 NativeWebKeyboardEvent keydown_event(NULL, WM_KEYDOWN, key_code, 0); |
| 161 scoped_ptr<IPC::Message> keydown_message(new ViewMsg_HandleInputEvent(0)); | 161 SendNativeKeyEvent(keydown_event); |
| 162 keydown_message->WriteData(reinterpret_cast<const char*>(&keydown_event), | |
| 163 sizeof(WebKit::WebKeyboardEvent)); | |
| 164 view_->OnHandleInputEvent(*keydown_message); | |
| 165 | 162 |
| 166 NativeWebKeyboardEvent char_event(NULL, WM_CHAR, (*output)[0], 0); | 163 NativeWebKeyboardEvent char_event(NULL, WM_CHAR, (*output)[0], 0); |
| 167 scoped_ptr<IPC::Message> char_message(new ViewMsg_HandleInputEvent(0)); | 164 SendNativeKeyEvent(char_event); |
| 168 char_message->WriteData(reinterpret_cast<const char*>(&char_event), | |
| 169 sizeof(WebKit::WebKeyboardEvent)); | |
| 170 view_->OnHandleInputEvent(*char_message); | |
| 171 | 165 |
| 172 NativeWebKeyboardEvent keyup_event(NULL, WM_KEYUP, key_code, 0); | 166 NativeWebKeyboardEvent keyup_event(NULL, WM_KEYUP, key_code, 0); |
| 173 scoped_ptr<IPC::Message> keyup_message(new ViewMsg_HandleInputEvent(0)); | 167 SendNativeKeyEvent(keyup_event); |
| 174 keyup_message->WriteData(reinterpret_cast<const char*>(&keyup_event), | |
| 175 sizeof(WebKit::WebKeyboardEvent)); | |
| 176 view_->OnHandleInputEvent(*keyup_message); | |
| 177 | 168 |
| 178 return length; | 169 return length; |
| 179 #else | 170 #else |
| 180 NOTIMPLEMENTED(); | 171 NOTIMPLEMENTED(); |
| 181 return L'\0'; | 172 return L'\0'; |
| 182 #endif | 173 #endif |
| 183 } | 174 } |
| 175 |
| 176 void RenderViewTest::SendNativeKeyEvent( |
| 177 const NativeWebKeyboardEvent& key_event) { |
| 178 scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0)); |
| 179 input_message->WriteData(reinterpret_cast<const char*>(&key_event), |
| 180 sizeof(WebKit::WebKeyboardEvent)); |
| 181 view_->OnHandleInputEvent(*input_message); |
| 182 } |
| OLD | NEW |