summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/simulate_input.h
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-12 18:19:07 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-12 18:19:07 +0000
commit4e676aa41d39aada2731e64f2807611cfad2c785 (patch)
tree409c055c2d5c1849e707e93b97f55e5afcdaf6b1 /chrome_frame/test/simulate_input.h
parentaedd87e5b5e0ee568309eba54b31cb8aa12cd6e6 (diff)
downloadchromium_src-4e676aa41d39aada2731e64f2807611cfad2c785.zip
chromium_src-4e676aa41d39aada2731e64f2807611cfad2c785.tar.gz
chromium_src-4e676aa41d39aada2731e64f2807611cfad2c785.tar.bz2
First batch of context menu tests
Refactored various methods to send keyboard and mouse input. Fixed the context menu focus issue on IE7. Improved existing tests to make them less flaky and added 3 new tests for context menu items. BUG=34673 TEST=new tests added Review URL: http://codereview.chromium.org/604014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/simulate_input.h')
-rw-r--r--chrome_frame/test/simulate_input.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/chrome_frame/test/simulate_input.h b/chrome_frame/test/simulate_input.h
new file mode 100644
index 0000000..562362a
--- /dev/null
+++ b/chrome_frame/test/simulate_input.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_FRAME_TEST_SIMULATE_INPUT_H_
+#define CHROME_FRAME_TEST_SIMULATE_INPUT_H_
+
+#include <windows.h>
+
+#include "base/basictypes.h"
+#include "base/process_util.h"
+
+namespace simulate_input {
+
+// Bring a window into foreground to receive user input.
+// Note that this may not work on
+bool ForceSetForegroundWindow(HWND window);
+
+// Looks for a top level window owned by the given process id and
+// calls ForceSetForegroundWindow on it.
+bool EnsureProcessInForeground(base::ProcessId process_id);
+
+// Helper function to set keyboard focus to a window. This is achieved by
+// sending a mouse move followed by a mouse down/mouse up combination to the
+// window.
+void SetKeyboardFocusToWindow(HWND window);
+
+// Sends a keystroke to the currently active application with optional
+// modifiers set.
+bool SendMnemonic(WORD mnemonic_char, bool shift_pressed, bool control_pressed,
+ bool alt_pressed, bool extended, bool unicode);
+
+// Sends a mouse click to the window passed in.
+enum MouseButton { LEFT, RIGHT, MIDDLE, X };
+void SendMouseClick(HWND window, int x, int y, MouseButton button);
+
+// Translates a single char to a virtual key and calls SendVirtualKey.
+void SendChar(char c, bool control, bool alt);
+void SendChar(wchar_t c, bool control, bool alt);
+
+// Sends extended keystroke to the currently active application with optional
+// modifiers set.
+bool SendExtendedKey(WORD key, bool shift, bool control, bool alt);
+
+// Iterates through all the characters in the string and simulates
+// keyboard input. The input goes to the currently active application.
+template <typename char_type>
+void SendString(const char_type* s) {
+ while (*s) {
+ char_type ch = *s;
+ SendChar(ch, false, false);
+ Sleep(100);
+ s++;
+ }
+}
+
+} // end namespace simulate_input
+
+#endif // CHROME_FRAME_TEST_SIMULATE_INPUT_H_
+