OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_frame/test/chrome_frame_test_utils.h" | 5 #include "chrome_frame/test/chrome_frame_test_utils.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlwin.h> | 8 #include <atlwin.h> |
9 #include <iepmapi.h> | 9 #include <iepmapi.h> |
10 | 10 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 input[1].ki.dwFlags |= KEYEVENTF_KEYUP; | 205 input[1].ki.dwFlags |= KEYEVENTF_KEYUP; |
206 | 206 |
207 for (const wchar_t* p = string; *p; p++) { | 207 for (const wchar_t* p = string; *p; p++) { |
208 input[0].ki.wScan = input[1].ki.wScan = *p; | 208 input[0].ki.wScan = input[1].ki.wScan = *p; |
209 SendInput(2, input, sizeof(INPUT)); | 209 SendInput(2, input, sizeof(INPUT)); |
210 } | 210 } |
211 | 211 |
212 return true; | 212 return true; |
213 } | 213 } |
214 | 214 |
215 void SendVirtualKey(int16 key) { | 215 void SendVirtualKey(int16 key, bool extended) { |
216 INPUT input = { INPUT_KEYBOARD }; | 216 INPUT input = { INPUT_KEYBOARD }; |
217 input.ki.wVk = key; | 217 input.ki.wVk = key; |
| 218 input.ki.dwFlags = extended ? KEYEVENTF_EXTENDEDKEY : 0; |
218 SendInput(1, &input, sizeof(input)); | 219 SendInput(1, &input, sizeof(input)); |
219 input.ki.dwFlags = KEYEVENTF_KEYUP; | 220 input.ki.dwFlags = (extended ? KEYEVENTF_EXTENDEDKEY : 0) | KEYEVENTF_KEYUP; |
220 SendInput(1, &input, sizeof(input)); | 221 SendInput(1, &input, sizeof(input)); |
221 } | 222 } |
222 | 223 |
223 void SendChar(char c) { | 224 void SendChar(char c) { |
224 SendVirtualKey(VkKeyScanA(c)); | 225 SendVirtualKey(VkKeyScanA(c), false); |
225 } | 226 } |
226 | 227 |
227 void SendString(const char* s) { | 228 void SendString(const char* s) { |
228 while (*s) { | 229 while (*s) { |
229 SendChar(*s); | 230 SendChar(*s); |
230 s++; | 231 s++; |
231 } | 232 } |
232 } | 233 } |
233 | 234 |
234 // Sends a keystroke to the currently active application with optional | 235 // Sends a keystroke to the currently active application with optional |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 435 |
435 MessageLoop::current()->PostDelayedTask( | 436 MessageLoop::current()->PostDelayedTask( |
436 FROM_HERE, | 437 FROM_HERE, |
437 NewRunnableFunction(ShowChromeFrameContextMenuTask), | 438 NewRunnableFunction(ShowChromeFrameContextMenuTask), |
438 kContextMenuDelay); | 439 kContextMenuDelay); |
439 } | 440 } |
440 | 441 |
441 void SelectAboutChromeFrame() { | 442 void SelectAboutChromeFrame() { |
442 // Send a key up message to enable the About chrome frame option to be | 443 // Send a key up message to enable the About chrome frame option to be |
443 // selected followed by a return to select it. | 444 // selected followed by a return to select it. |
444 chrome_frame_test::SendVirtualKey(VK_UP); | 445 SendVirtualKey(VK_UP, true); |
445 chrome_frame_test::SendVirtualKey(VK_RETURN); | 446 SendVirtualKey(VK_RETURN, false); |
446 } | 447 } |
447 | 448 |
448 BOOL CALLBACK FindChromeRendererWindowProc( | 449 BOOL CALLBACK FindChromeRendererWindowProc( |
449 HWND window, LPARAM lParam) { | 450 HWND window, LPARAM lParam) { |
450 HWND* target_window = reinterpret_cast<HWND*>(lParam); | 451 HWND* target_window = reinterpret_cast<HWND*>(lParam); |
451 wchar_t class_name[MAX_PATH] = {0}; | 452 wchar_t class_name[MAX_PATH] = {0}; |
452 | 453 |
453 GetClassName(window, class_name, arraysize(class_name)); | 454 GetClassName(window, class_name, arraysize(class_name)); |
454 if (!_wcsicmp(class_name, L"Chrome_RenderWidgetHostHWND")) { | 455 if (!_wcsicmp(class_name, L"Chrome_RenderWidgetHostHWND")) { |
455 *target_window = window; | 456 *target_window = window; |
(...skipping 13 matching lines...) Expand all Loading... |
469 } | 470 } |
470 | 471 |
471 HWND GetChromeRendererWindow() { | 472 HWND GetChromeRendererWindow() { |
472 HWND chrome_window = NULL; | 473 HWND chrome_window = NULL; |
473 EnumWindows(EnumHostBrowserWindowProc, | 474 EnumWindows(EnumHostBrowserWindowProc, |
474 reinterpret_cast<LPARAM>(&chrome_window)); | 475 reinterpret_cast<LPARAM>(&chrome_window)); |
475 return chrome_window; | 476 return chrome_window; |
476 } | 477 } |
477 | 478 |
478 } // namespace chrome_frame_test | 479 } // namespace chrome_frame_test |
OLD | NEW |