OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ | 5 #ifndef CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ |
6 #define CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ | 6 #define CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
| 10 #include "base/basictypes.h" |
10 #include "base/scoped_bstr_win.h" | 11 #include "base/scoped_bstr_win.h" |
11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
12 #include "chrome_frame/test/chrome_frame_test_utils.h" | 13 #include "chrome_frame/test/chrome_frame_test_utils.h" |
13 #include "chrome_frame/test/chrome_frame_ui_test_utils.h" | 14 #include "chrome_frame/test/chrome_frame_ui_test_utils.h" |
14 #include "chrome_frame/test/mock_ie_event_sink_test.h" | 15 #include "chrome_frame/test/mock_ie_event_sink_test.h" |
15 #include "chrome_frame/test/simulate_input.h" | 16 #include "chrome_frame/test/simulate_input.h" |
16 #include "gfx/point.h" | 17 #include "gfx/point.h" |
17 #include "gfx/rect.h" | 18 #include "gfx/rect.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 | 20 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 EXPECT_LE(actual_height, height + 100); | 210 EXPECT_LE(actual_height, height + 100); |
210 EXPECT_GT(actual_height, height - 100); | 211 EXPECT_GT(actual_height, height - 100); |
211 } | 212 } |
212 | 213 |
213 ACTION_P(VerifyAddressBarUrlWithGcf, mock) { | 214 ACTION_P(VerifyAddressBarUrlWithGcf, mock) { |
214 std::wstring expected_url = L"gcf:"; | 215 std::wstring expected_url = L"gcf:"; |
215 expected_url += arg1; | 216 expected_url += arg1; |
216 mock->event_sink()->ExpectAddressBarUrl(expected_url); | 217 mock->event_sink()->ExpectAddressBarUrl(expected_url); |
217 } | 218 } |
218 | 219 |
| 220 // Polls to see if the file is saved and closes the browser once it is. |
| 221 // This doesn't do any checking of the contents of the file. |
| 222 ACTION_P3(CloseWhenFileSaved, mock, file, timeout_ms) { |
| 223 base::Time start = base::Time::Now(); |
| 224 while (!file_util::PathExists(file)) { |
| 225 PlatformThread::Sleep(200); |
| 226 if ((base::Time::Now() - start).InMilliseconds() > timeout_ms) { |
| 227 ADD_FAILURE() << "File was not saved within timeout"; |
| 228 break; |
| 229 } |
| 230 } |
| 231 mock->event_sink()->CloseWebBrowser(); |
| 232 } |
| 233 |
219 ACTION_P2(OpenContextMenu, loop, delay) { | 234 ACTION_P2(OpenContextMenu, loop, delay) { |
220 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 235 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( |
221 simulate_input::SendScanCode, VK_F10, simulate_input::SHIFT), delay); | 236 simulate_input::SendScanCode, VK_F10, simulate_input::SHIFT), delay); |
222 } | 237 } |
223 | 238 |
224 ACTION_P3(SelectItem, loop, delay, index) { | 239 ACTION_P3(SelectItem, loop, delay, index) { |
225 chrome_frame_test::DelaySendExtendedKeysEnter(loop, delay, VK_DOWN, index + 1, | 240 chrome_frame_test::DelaySendExtendedKeysEnter(loop, delay, VK_DOWN, index + 1, |
226 simulate_input::NONE); | 241 simulate_input::NONE); |
227 } | 242 } |
228 | 243 |
229 ACTION(FocusAccObject) { | 244 ACTION(FocusWindow) { |
230 scoped_refptr<AccObject> object; | 245 scoped_refptr<AccObject> object; |
231 if (FindAccObjectInWindow(arg0, AccObjectMatcher(), &object)) | 246 if (FindAccObjectInWindow(arg0, AccObjectMatcher(), &object)) |
232 object->Focus(); | 247 object->Focus(); |
233 } | 248 } |
234 | 249 |
235 ACTION_P(DoDefaultAction, matcher) { | 250 ACTION_P(DoDefaultAction, matcher) { |
236 scoped_refptr<AccObject> object; | 251 scoped_refptr<AccObject> object; |
237 if (FindAccObjectInWindow(arg0, matcher, &object)) | 252 if (FindAccObjectInWindow(arg0, matcher, &object)) |
238 object->DoDefaultAction(); | 253 object->DoDefaultAction(); |
239 } | 254 } |
240 | 255 |
241 ACTION_P(FocusAccObject, matcher) { | 256 ACTION_P(FocusAccObject, matcher) { |
242 scoped_refptr<AccObject> object; | 257 scoped_refptr<AccObject> object; |
243 if (FindAccObjectInWindow(arg0, matcher, &object)) | 258 if (FindAccObjectInWindow(arg0, matcher, &object)) |
244 object->Focus(); | 259 object->Focus(); |
245 } | 260 } |
246 | 261 |
247 ACTION_P(SelectAccObject, matcher) { | 262 ACTION_P(SelectAccObject, matcher) { |
248 scoped_refptr<AccObject> object; | 263 scoped_refptr<AccObject> object; |
249 if (FindAccObjectInWindow(arg0, matcher, &object)) | 264 if (FindAccObjectInWindow(arg0, matcher, &object)) |
250 object->Select(); | 265 object->Select(); |
251 } | 266 } |
252 | 267 |
| 268 ACTION_P2(SetAccObjectValue, matcher, value) { |
| 269 scoped_refptr<AccObject> object; |
| 270 if (FindAccObjectInWindow(arg0, matcher, &object)) |
| 271 object->SetValue(value); |
| 272 } |
| 273 |
253 ACTION(OpenContextMenuAsync) { | 274 ACTION(OpenContextMenuAsync) { |
254 // Special case this implementation because the top-left of the window is | 275 // Special case this implementation because the top-left of the window is |
255 // much more likely to be empty than the center. | 276 // much more likely to be empty than the center. |
256 HWND hwnd = arg0; | 277 HWND hwnd = arg0; |
257 scoped_refptr<AccObject> object; | 278 scoped_refptr<AccObject> object; |
258 // TODO(kkania): Switch to using WM_CONTEXTMENU with coordinates -1, -1 | 279 // TODO(kkania): Switch to using WM_CONTEXTMENU with coordinates -1, -1 |
259 // when Chrome supports this. See render_widget_host_view_win.h. | 280 // when Chrome supports this. See render_widget_host_view_win.h. |
260 LPARAM coordinates = (1 << 16) | 1; | 281 LPARAM coordinates = (1 << 16) | 1; |
261 // IE needs both messages in order to work. | 282 // IE needs both messages in order to work. |
262 ::PostMessage(hwnd, WM_RBUTTONDOWN, (WPARAM)0, coordinates); | 283 ::PostMessage(hwnd, WM_RBUTTONDOWN, (WPARAM)0, coordinates); |
(...skipping 26 matching lines...) Expand all Loading... |
289 ::PostMessage(hwnd, WM_RBUTTONUP, (WPARAM)0, coordinates); | 310 ::PostMessage(hwnd, WM_RBUTTONUP, (WPARAM)0, coordinates); |
290 } | 311 } |
291 } | 312 } |
292 } | 313 } |
293 } | 314 } |
294 | 315 |
295 } // namespace chrome_frame_test | 316 } // namespace chrome_frame_test |
296 | 317 |
297 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ | 318 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ |
298 | 319 |
OLD | NEW |