| 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 #include <sddl.h> | 10 #include <sddl.h> |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 input_info.mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE; | 465 input_info.mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE; |
| 466 ::SendInput(1, &input_info, sizeof(INPUT)); | 466 ::SendInput(1, &input_info, sizeof(INPUT)); |
| 467 | 467 |
| 468 Sleep(10); | 468 Sleep(10); |
| 469 | 469 |
| 470 input_info.mi.dwFlags = MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE; | 470 input_info.mi.dwFlags = MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE; |
| 471 ::SendInput(1, &input_info, sizeof(INPUT)); | 471 ::SendInput(1, &input_info, sizeof(INPUT)); |
| 472 } | 472 } |
| 473 | 473 |
| 474 void SendInputToWindow(HWND window, const std::string& input_string) { | 474 void SendInputToWindow(HWND window, const std::string& input_string) { |
| 475 SetKeyboardFocusToWindow(window, 100, 100); | 475 const unsigned long kIntervalBetweenInput = 100; |
| 476 | 476 |
| 477 for (size_t index = 0; index < input_string.length(); index++) { | 477 for (size_t index = 0; index < input_string.length(); index++) { |
| 478 bool is_upper_case = isupper(input_string[index]); | 478 bool is_upper_case = isupper(input_string[index]); |
| 479 if (is_upper_case) { | 479 if (is_upper_case) { |
| 480 INPUT input = { INPUT_KEYBOARD }; | 480 INPUT input = { INPUT_KEYBOARD }; |
| 481 input.ki.wVk = VK_SHIFT; | 481 input.ki.wVk = VK_SHIFT; |
| 482 input.ki.dwFlags = 0; | 482 input.ki.dwFlags = 0; |
| 483 SendInput(1, &input, sizeof(input)); | 483 SendInput(1, &input, sizeof(input)); |
| 484 Sleep(200); | 484 Sleep(kIntervalBetweenInput); |
| 485 } | 485 } |
| 486 | 486 |
| 487 // The WM_KEYDOWN and WM_KEYUP messages for characters always contain | 487 // The WM_KEYDOWN and WM_KEYUP messages for characters always contain |
| 488 // the uppercase character codes. | 488 // the uppercase character codes. |
| 489 SendVirtualKey(toupper(input_string[index]), false); | 489 SendVirtualKey(toupper(input_string[index]), false); |
| 490 Sleep(kIntervalBetweenInput); |
| 490 | 491 |
| 491 if (is_upper_case) { | 492 if (is_upper_case) { |
| 492 INPUT input = { INPUT_KEYBOARD }; | 493 INPUT input = { INPUT_KEYBOARD }; |
| 493 input.ki.wVk = VK_SHIFT; | 494 input.ki.wVk = VK_SHIFT; |
| 494 input.ki.dwFlags = KEYEVENTF_KEYUP; | 495 input.ki.dwFlags = KEYEVENTF_KEYUP; |
| 495 SendInput(1, &input, sizeof(input)); | 496 SendInput(1, &input, sizeof(input)); |
| 497 Sleep(kIntervalBetweenInput); |
| 496 } | 498 } |
| 497 } | 499 } |
| 498 } | 500 } |
| 499 | 501 |
| 500 void SelectAboutChromeFrame() { | 502 void SelectAboutChromeFrame() { |
| 501 // Send a key up message to enable the About chrome frame option to be | 503 // Send a key up message to enable the About chrome frame option to be |
| 502 // selected followed by a return to select it. | 504 // selected followed by a return to select it. |
| 503 SendVirtualKey(VK_UP, true); | 505 SendVirtualKey(VK_UP, true); |
| 504 SendVirtualKey(VK_RETURN, false); | 506 SendVirtualKey(VK_RETURN, false); |
| 505 } | 507 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 return true; | 617 return true; |
| 616 } | 618 } |
| 617 | 619 |
| 618 if (token) | 620 if (token) |
| 619 ::CloseHandle(token); | 621 ::CloseHandle(token); |
| 620 | 622 |
| 621 return false; | 623 return false; |
| 622 } | 624 } |
| 623 | 625 |
| 624 } // namespace chrome_frame_test | 626 } // namespace chrome_frame_test |
| OLD | NEW |