diff options
-rw-r--r-- | chrome/browser/automation/ui_controls_win.cc | 29 | ||||
-rw-r--r-- | chrome/test/ui_test_utils.cc | 12 |
2 files changed, 41 insertions, 0 deletions
diff --git a/chrome/browser/automation/ui_controls_win.cc b/chrome/browser/automation/ui_controls_win.cc index fdd1732..2b41be1 100644 --- a/chrome/browser/automation/ui_controls_win.cc +++ b/chrome/browser/automation/ui_controls_win.cc @@ -161,79 +161,108 @@ bool SendKeyEvent(app::KeyboardCode key, bool up) { return true; } +void Checkpoint(const char* message, const base::TimeTicks& start_time) { + LOG(INFO) << message << " : " + << (base::TimeTicks::Now() - start_time).InMilliseconds() + << " ms" << std::flush; +} + bool SendKeyPressImpl(app::KeyboardCode key, bool control, bool shift, bool alt, Task* task) { + base::TimeTicks start_time = base::TimeTicks::Now(); + Checkpoint("SendKeyPressImpl starts", start_time); + scoped_refptr<InputDispatcher> dispatcher( task ? new InputDispatcher(task, WM_KEYUP) : NULL); // If a pop-up menu is open, it won't receive events sent using SendInput. // Check for a pop-up menu using its window class (#32768) and if one // exists, send the key event directly there. + Checkpoint("FindWindow", start_time); HWND popup_menu = ::FindWindow(L"#32768", 0); if (popup_menu != NULL && popup_menu == ::GetTopWindow(NULL)) { + Checkpoint("Found popup window", start_time); WPARAM w_param = app::WindowsKeyCodeForKeyboardCode(key); LPARAM l_param = 0; + Checkpoint("Send WM_KEYDOWN", start_time); ::SendMessage(popup_menu, WM_KEYDOWN, w_param, l_param); + Checkpoint("Send WM_KEYUP", start_time); ::SendMessage(popup_menu, WM_KEYUP, w_param, l_param); + Checkpoint("Send Done", start_time); if (dispatcher.get()) dispatcher->AddRef(); return true; } + Checkpoint("Found no popup window", start_time); + INPUT input[8] = { 0 }; // 8, assuming all the modifiers are activated UINT i = 0; if (control) { + Checkpoint("FillKeyboardInput Control", start_time); if (!FillKeyboardInput(app::VKEY_CONTROL, &input[i], false)) return false; i++; } if (shift) { + Checkpoint("FillKeyboardInput Shift", start_time); if (!FillKeyboardInput(app::VKEY_SHIFT, &input[i], false)) return false; i++; } if (alt) { + Checkpoint("FillKeyboardInput Alt", start_time); if (!FillKeyboardInput(app::VKEY_MENU, &input[i], false)) return false; i++; } + Checkpoint("FillKeyboardInput 1", start_time); if (!FillKeyboardInput(key, &input[i], false)) return false; i++; + Checkpoint("FillKeyboardInput 2", start_time); if (!FillKeyboardInput(key, &input[i], true)) return false; i++; if (alt) { + Checkpoint("FillKeyboardInput Alt2", start_time); if (!FillKeyboardInput(app::VKEY_MENU, &input[i], true)) return false; i++; } if (shift) { + Checkpoint("FillKeyboardInput Shift2", start_time); if (!FillKeyboardInput(app::VKEY_SHIFT, &input[i], true)) return false; i++; } if (control) { + Checkpoint("FillKeyboardInput Ctrl2", start_time); if (!FillKeyboardInput(app::VKEY_CONTROL, &input[i], true)) return false; i++; } + Checkpoint("SendInput called", start_time); if (::SendInput(i, input, sizeof(INPUT)) != i) return false; + Checkpoint("SendInput done", start_time); + if (dispatcher.get()) dispatcher->AddRef(); + + Checkpoint("Test done", start_time); return true; } diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index cf71bc3..b7db307 100644 --- a/chrome/test/ui_test_utils.cc +++ b/chrome/test/ui_test_utils.cc @@ -341,6 +341,12 @@ bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host, return true; } +void Checkpoint(const char* message, const base::TimeTicks& start_time) { + LOG(INFO) << message << " : " + << (base::TimeTicks::Now() - start_time).InMilliseconds() + << " ms" << std::flush; +} + } // namespace void RunMessageLoop() { @@ -605,10 +611,14 @@ bool SendKeyPressSync(const Browser* browser, bool shift, bool alt, bool command) { + base::TimeTicks start_time = base::TimeTicks::Now(); + Checkpoint("SendKeyPressSync", start_time); + gfx::NativeWindow window = NULL; if (!GetNativeWindow(browser, &window)) return false; + Checkpoint("SendKeyPressNotifyWhenDone", start_time); if (!ui_controls::SendKeyPressNotifyWhenDone( window, key, control, shift, alt, command, new MessageLoop::QuitTask())) { @@ -618,7 +628,9 @@ bool SendKeyPressSync(const Browser* browser, // Run the message loop. It'll stop running when either the key was received // or the test timed out (in which case testing::Test::HasFatalFailure should // be set). + Checkpoint("Running loop", start_time); RunMessageLoop(); + Checkpoint("Check if HasFatalFailure", start_time); return !testing::Test::HasFatalFailure(); } |