OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 int modifiers, | 72 int modifiers, |
73 WebKit::WebMouseEvent::Button button, | 73 WebKit::WebMouseEvent::Button button, |
74 const gfx::Point& point); | 74 const gfx::Point& point); |
75 | 75 |
76 // Simulates asynchronously a mouse enter/move/leave event. | 76 // Simulates asynchronously a mouse enter/move/leave event. |
77 void SimulateMouseEvent(WebContents* web_contents, | 77 void SimulateMouseEvent(WebContents* web_contents, |
78 WebKit::WebInputEvent::Type type, | 78 WebKit::WebInputEvent::Type type, |
79 const gfx::Point& point); | 79 const gfx::Point& point); |
80 | 80 |
81 // Sends a key press asynchronously. | 81 // Sends a key press asynchronously. |
| 82 // The native code of the key event will be set to InvalidNativeKeycode(). |
| 83 // |key_code| alone is good enough for scenarios that only need the char |
| 84 // value represented by a key event and not the physical key on the keyboard |
| 85 // or the keyboard layout. |
| 86 // For scenarios such as chromoting that need the native code, |
| 87 // SimulateKeyPressWithCode should be used. |
82 void SimulateKeyPress(WebContents* web_contents, | 88 void SimulateKeyPress(WebContents* web_contents, |
83 ui::KeyboardCode key, | 89 ui::KeyboardCode key_code, |
84 bool control, | 90 bool control, |
85 bool shift, | 91 bool shift, |
86 bool alt, | 92 bool alt, |
87 bool command); | 93 bool command); |
88 | 94 |
| 95 // Sends a key press asynchronously. |
| 96 // |code| specifies the UIEvents (aka: DOM4Events) value of the key: |
| 97 // https://dvcs.w3.org/hg/d4e/raw-file/tip/source_respec.htm |
| 98 // The native code of the key event will be set based on |code|. |
| 99 // See ui/base/keycodes/vi usb_keycode_map.h for mappings between |code| |
| 100 // and the native code. |
| 101 // Examples of the various codes: |
| 102 // key_code: VKEY_A |
| 103 // code: "KeyA" |
| 104 // native key code: 0x001e (for Windows). |
| 105 // native key code: 0x0026 (for Linux). |
| 106 void SimulateKeyPressWithCode(WebContents* web_contents, |
| 107 ui::KeyboardCode key_code, |
| 108 const char* code, |
| 109 bool control, |
| 110 bool shift, |
| 111 bool alt, |
| 112 bool command); |
| 113 |
89 // Allow ExecuteScript* methods to target either a WebContents or a | 114 // Allow ExecuteScript* methods to target either a WebContents or a |
90 // RenderViewHost. Targetting a WebContents means executing script in the | 115 // RenderViewHost. Targetting a WebContents means executing script in the |
91 // RenderViewHost returned by WebContents::GetRenderViewHost(), which is the | 116 // RenderViewHost returned by WebContents::GetRenderViewHost(), which is the |
92 // "current" RenderViewHost. Pass a specific RenderViewHost to target, for | 117 // "current" RenderViewHost. Pass a specific RenderViewHost to target, for |
93 // example, a "swapped-out" RenderViewHost. | 118 // example, a "swapped-out" RenderViewHost. |
94 namespace internal { | 119 namespace internal { |
95 class ToRenderViewHost { | 120 class ToRenderViewHost { |
96 public: | 121 public: |
97 ToRenderViewHost(WebContents* web_contents); | 122 ToRenderViewHost(WebContents* web_contents); |
98 ToRenderViewHost(RenderViewHost* render_view_host); | 123 ToRenderViewHost(RenderViewHost* render_view_host); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 std::queue<std::string> message_queue_; | 252 std::queue<std::string> message_queue_; |
228 bool waiting_for_message_; | 253 bool waiting_for_message_; |
229 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 254 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
230 | 255 |
231 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | 256 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
232 }; | 257 }; |
233 | 258 |
234 } // namespace content | 259 } // namespace content |
235 | 260 |
236 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 261 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |