OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/base/test/ui_controls_internal_win.h" | 5 #include "ui/base/test/ui_controls_internal_win.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 bool FillKeyboardInput(ui::KeyboardCode key, INPUT* input, bool key_up) { | 141 bool FillKeyboardInput(ui::KeyboardCode key, INPUT* input, bool key_up) { |
142 memset(input, 0, sizeof(INPUT)); | 142 memset(input, 0, sizeof(INPUT)); |
143 input->type = INPUT_KEYBOARD; | 143 input->type = INPUT_KEYBOARD; |
144 input->ki.wVk = ui::WindowsKeyCodeForKeyboardCode(key); | 144 input->ki.wVk = ui::WindowsKeyCodeForKeyboardCode(key); |
145 input->ki.dwFlags = key_up ? KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP : | 145 input->ki.dwFlags = key_up ? KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP : |
146 KEYEVENTF_EXTENDEDKEY; | 146 KEYEVENTF_EXTENDEDKEY; |
147 | 147 |
148 return true; | 148 return true; |
149 } | 149 } |
150 | 150 |
151 // Send a key event (up/down) | |
152 bool SendKeyEvent(ui::KeyboardCode key, bool up) { | |
153 INPUT input = { 0 }; | |
154 | |
155 if (!FillKeyboardInput(key, &input, up)) | |
156 return false; | |
157 | |
158 if (!::SendInput(1, &input, sizeof(INPUT))) | |
159 return false; | |
160 | |
161 return true; | |
162 } | |
163 | |
164 } // namespace | 151 } // namespace |
165 | 152 |
166 namespace ui_controls { | 153 namespace ui_controls { |
167 namespace internal { | 154 namespace internal { |
168 | 155 |
169 bool SendKeyPressImpl(HWND window, | 156 bool SendKeyPressImpl(HWND window, |
170 ui::KeyboardCode key, | 157 ui::KeyboardCode key, |
171 bool control, | 158 bool control, |
172 bool shift, | 159 bool shift, |
173 bool alt, | 160 bool alt, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return false; | 322 return false; |
336 | 323 |
337 if (dispatcher.get()) | 324 if (dispatcher.get()) |
338 dispatcher->AddRef(); | 325 dispatcher->AddRef(); |
339 | 326 |
340 return true; | 327 return true; |
341 } | 328 } |
342 | 329 |
343 } // namespace internal | 330 } // namespace internal |
344 } // namespace ui_controls | 331 } // namespace ui_controls |
OLD | NEW |