| 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 <oleacc.h> | 5 #include <oleacc.h> |
| 6 | 6 |
| 7 #include "chrome_frame/test/net/dialog_watchdog.h" | 7 #include "chrome_frame/test/net/dialog_watchdog.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_comptr_win.h" | 10 #include "base/scoped_comptr_win.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 | 12 |
| 13 #include "chrome_frame/test/chrome_frame_test_utils.h" | 13 #include "chrome_frame/test/simulate_input.h" |
| 14 #include "chrome_frame/function_stub.h" | 14 #include "chrome_frame/function_stub.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 // Uses the IAccessible interface for the window to set the focus. | 17 // Uses the IAccessible interface for the window to set the focus. |
| 18 // This can be useful when you don't have control over the thread that | 18 // This can be useful when you don't have control over the thread that |
| 19 // owns the window. | 19 // owns the window. |
| 20 // NOTE: this depends on oleacc.lib which the net tests already depend on | 20 // NOTE: this depends on oleacc.lib which the net tests already depend on |
| 21 // but other unit tests don't depend on oleacc so we can't just add the method | 21 // but other unit tests don't depend on oleacc so we can't just add the method |
| 22 // directly into chrome_frame_test_utils.cc (without adding a | 22 // directly into chrome_frame_test_utils.cc (without adding a |
| 23 // #pragma comment(lib, "oleacc.lib")). | 23 // #pragma comment(lib, "oleacc.lib")). |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 if (caption.compare("Windows Security") != 0) | 47 if (caption.compare("Windows Security") != 0) |
| 48 return false; | 48 return false; |
| 49 | 49 |
| 50 DialogProps props = {0}; | 50 DialogProps props = {0}; |
| 51 ::EnumChildWindows(hwnd, EnumChildren, reinterpret_cast<LPARAM>(&props)); | 51 ::EnumChildWindows(hwnd, EnumChildren, reinterpret_cast<LPARAM>(&props)); |
| 52 DCHECK(::IsWindow(props.username_)); | 52 DCHECK(::IsWindow(props.username_)); |
| 53 DCHECK(::IsWindow(props.password_)); | 53 DCHECK(::IsWindow(props.password_)); |
| 54 | 54 |
| 55 // We can't use SetWindowText to set the username/password, so simulate | 55 // We can't use SetWindowText to set the username/password, so simulate |
| 56 // keyboard input instead. | 56 // keyboard input instead. |
| 57 chrome_frame_test::ForceSetForegroundWindow(hwnd); | 57 simulate_input::ForceSetForegroundWindow(hwnd); |
| 58 CHECK(SetFocusToAccessibleWindow(props.username_)); | 58 CHECK(SetFocusToAccessibleWindow(props.username_)); |
| 59 chrome_frame_test::SendString(username_.c_str()); | 59 simulate_input::SendString(username_.c_str()); |
| 60 Sleep(100); | 60 Sleep(100); |
| 61 | 61 |
| 62 chrome_frame_test::SendVirtualKey(VK_TAB, false); | 62 simulate_input::SendChar(char(VK_TAB), false, false); |
| 63 Sleep(100); | 63 Sleep(100); |
| 64 chrome_frame_test::SendString(password_.c_str()); | 64 simulate_input::SendString(password_.c_str()); |
| 65 | 65 |
| 66 Sleep(100); | 66 Sleep(100); |
| 67 chrome_frame_test::SendVirtualKey(VK_RETURN, false); | 67 simulate_input::SendChar(char(VK_RETURN), false, false); |
| 68 | 68 |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 // static | 72 // static |
| 73 BOOL SupplyProxyCredentials::EnumChildren(HWND hwnd, LPARAM param) { | 73 BOOL SupplyProxyCredentials::EnumChildren(HWND hwnd, LPARAM param) { |
| 74 if (!::IsWindowVisible(hwnd)) | 74 if (!::IsWindowVisible(hwnd)) |
| 75 return TRUE; // Ignore but continue to enumerate. | 75 return TRUE; // Ignore but continue to enumerate. |
| 76 | 76 |
| 77 DialogProps* props = reinterpret_cast<DialogProps*>(param); | 77 DialogProps* props = reinterpret_cast<DialogProps*>(param); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 void DialogWatchdog::OnDialogFound(HWND hwnd, const std::string& caption) { | 139 void DialogWatchdog::OnDialogFound(HWND hwnd, const std::string& caption) { |
| 140 std::vector<DialogWatchdogObserver*>::iterator it = observers_.begin(); | 140 std::vector<DialogWatchdogObserver*>::iterator it = observers_.begin(); |
| 141 while (it != observers_.end()) { | 141 while (it != observers_.end()) { |
| 142 if ((*it)->OnDialogDetected(hwnd, caption)) | 142 if ((*it)->OnDialogDetected(hwnd, caption)) |
| 143 break; | 143 break; |
| 144 it++; | 144 it++; |
| 145 } | 145 } |
| 146 } | 146 } |
| OLD | NEW |