| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" |
| 12 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 13 #include "base/time.h" | 14 #include "base/time.h" |
| 14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome_frame/test/chrome_frame_test_utils.h" | 16 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 16 #include "chrome_frame/test/chrome_frame_ui_test_utils.h" | 17 #include "chrome_frame/test/chrome_frame_ui_test_utils.h" |
| 17 #include "chrome_frame/test/ie_event_sink.h" | 18 #include "chrome_frame/test/ie_event_sink.h" |
| 18 #include "chrome_frame/test/mock_ie_event_sink_test.h" | 19 #include "chrome_frame/test/mock_ie_event_sink_test.h" |
| 19 #include "chrome_frame/test/simulate_input.h" | 20 #include "chrome_frame/test/simulate_input.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "ui/gfx/point.h" | 22 #include "ui/gfx/point.h" |
| 22 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
| 23 | 24 |
| 24 namespace chrome_frame_test { | 25 namespace chrome_frame_test { |
| 25 | 26 |
| 26 MATCHER_P(UrlPathEq, url, "equals the path and query portion of the url") { | 27 MATCHER_P(UrlPathEq, url, "equals the path and query portion of the url") { |
| 27 return arg == chrome_frame_test::GetPathAndQueryFromUrl(url); | 28 return arg == chrome_frame_test::GetPathAndQueryFromUrl(url); |
| 28 } | 29 } |
| 29 | 30 |
| 30 MATCHER_P(AccSatisfies, matcher, "satisfies the given AccObjectMatcher") { | 31 MATCHER_P(AccSatisfies, matcher, "satisfies the given AccObjectMatcher") { |
| 31 return matcher.DoesMatch(arg); | 32 return matcher.DoesMatch(arg); |
| 32 } | 33 } |
| 33 | 34 |
| 34 // IWebBrowser2 actions | 35 // IWebBrowser2 actions |
| 35 | 36 |
| 36 ACTION_P2(Navigate, mock, navigate_url) { | 37 ACTION_P2(Navigate, mock, navigate_url) { |
| 37 mock->event_sink()->Navigate(navigate_url); | 38 mock->event_sink()->Navigate(navigate_url); |
| 38 } | 39 } |
| 39 | 40 |
| 40 ACTION_P3(DelayNavigateToCurrentUrl, mock, loop, delay) { | 41 ACTION_P3(DelayNavigateToCurrentUrl, mock, loop, delay) { |
| 41 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(&NavigateToCurrentUrl, | 42 loop->PostDelayedTask(FROM_HERE, |
| 42 mock), delay); | 43 base::Bind(&NavigateToCurrentUrl, mock), delay); |
| 43 } | 44 } |
| 44 | 45 |
| 45 ACTION_P(CloseBrowserMock, mock) { | 46 ACTION_P(CloseBrowserMock, mock) { |
| 46 mock->event_sink()->CloseWebBrowser(); | 47 mock->event_sink()->CloseWebBrowser(); |
| 47 } | 48 } |
| 48 | 49 |
| 49 ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) { | 50 ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) { |
| 50 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), | 51 loop->PostDelayedTask( |
| 51 &IEEventSink::CloseWebBrowser), delay); | 52 FROM_HERE, |
| 53 base::IgnoreReturn<HRESULT>( |
| 54 base::Bind(&IEEventSink::CloseWebBrowser, mock->event_sink())), |
| 55 delay); |
| 52 } | 56 } |
| 53 | 57 |
| 54 ACTION_P2(ConnectDocPropNotifySink, mock, sink) { | 58 ACTION_P2(ConnectDocPropNotifySink, mock, sink) { |
| 55 base::win::ScopedComPtr<IDispatch> document; | 59 base::win::ScopedComPtr<IDispatch> document; |
| 56 mock->event_sink()->web_browser2()->get_Document(document.Receive()); | 60 mock->event_sink()->web_browser2()->get_Document(document.Receive()); |
| 57 EXPECT_TRUE(document != NULL); // NOLINT | 61 EXPECT_TRUE(document != NULL); // NOLINT |
| 58 if (document) { | 62 if (document) { |
| 59 sink->Attach(document); | 63 sink->Attach(document); |
| 60 } | 64 } |
| 61 } | 65 } |
| 62 | 66 |
| 63 ACTION_P(DisconnectDocPropNotifySink, sink) { | 67 ACTION_P(DisconnectDocPropNotifySink, sink) { |
| 64 sink->Detach(); | 68 sink->Detach(); |
| 65 } | 69 } |
| 66 | 70 |
| 67 ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id, | 71 ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id, |
| 68 cmd_exec_opt, in_args, out_args) { | 72 cmd_exec_opt, in_args, out_args) { |
| 69 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), | 73 loop->PostDelayedTask( |
| 70 &IEEventSink::Exec, cmd_group_guid, cmd_id, cmd_exec_opt, in_args, | 74 FROM_HERE, |
| 71 out_args), delay); | 75 base::Bind(&IEEventSink::Exec, mock->event_sink(), cmd_group_guid, cmd_id, |
| 76 cmd_exec_opt, in_args, out_args), |
| 77 delay); |
| 72 } | 78 } |
| 73 | 79 |
| 74 ACTION_P3(DelayGoBack, mock, loop, delay) { | 80 ACTION_P3(DelayGoBack, mock, loop, delay) { |
| 75 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), | 81 loop->PostDelayedTask( |
| 76 &IEEventSink::GoBack), delay); | 82 FROM_HERE, base::Bind(&IEEventSink::GoBack, mock->event_sink()), delay); |
| 77 } | 83 } |
| 78 | 84 |
| 79 ACTION_P3(DelayGoForward, mock, loop, delay) { | 85 ACTION_P3(DelayGoForward, mock, loop, delay) { |
| 80 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), | 86 loop->PostDelayedTask( |
| 81 &IEEventSink::GoForward), delay); | 87 FROM_HERE, base::Bind(&IEEventSink::GoForward, mock->event_sink()), |
| 88 delay); |
| 82 } | 89 } |
| 83 | 90 |
| 84 ACTION_P3(DelayRefresh, mock, loop, delay) { | 91 ACTION_P3(DelayRefresh, mock, loop, delay) { |
| 85 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), | 92 loop->PostDelayedTask( |
| 86 &IEEventSink::Refresh), delay); | 93 FROM_HERE, base::Bind(&IEEventSink::Refresh, mock->event_sink()), delay); |
| 87 } | 94 } |
| 88 | 95 |
| 89 ACTION_P2(PostMessageToCF, mock, message) { | 96 ACTION_P2(PostMessageToCF, mock, message) { |
| 90 mock->event_sink()->PostMessageToCF(message, L"*"); | 97 mock->event_sink()->PostMessageToCF(message, L"*"); |
| 91 } | 98 } |
| 92 | 99 |
| 93 // Accessibility-related actions | 100 // Accessibility-related actions |
| 94 | 101 |
| 95 ACTION_P(AccDoDefaultAction, matcher) { | 102 ACTION_P(AccDoDefaultAction, matcher) { |
| 96 scoped_refptr<AccObject> object; | 103 scoped_refptr<AccObject> object; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 269 |
| 263 } // namespace | 270 } // namespace |
| 264 | 271 |
| 265 ACTION(DoCloseWindow) { | 272 ACTION(DoCloseWindow) { |
| 266 DoCloseWindowNow(arg0); | 273 DoCloseWindowNow(arg0); |
| 267 } | 274 } |
| 268 | 275 |
| 269 ACTION_P(DelayDoCloseWindow, delay) { | 276 ACTION_P(DelayDoCloseWindow, delay) { |
| 270 DCHECK(MessageLoop::current()); | 277 DCHECK(MessageLoop::current()); |
| 271 MessageLoop::current()->PostDelayedTask( | 278 MessageLoop::current()->PostDelayedTask( |
| 272 FROM_HERE, | 279 FROM_HERE, base::Bind(DoCloseWindowNow, arg0), delay); |
| 273 NewRunnableFunction(DoCloseWindowNow, arg0), | |
| 274 delay); | |
| 275 } | 280 } |
| 276 | 281 |
| 277 ACTION(KillChromeFrameProcesses) { | 282 ACTION(KillChromeFrameProcesses) { |
| 278 KillAllNamedProcessesWithArgument( | 283 KillAllNamedProcessesWithArgument( |
| 279 UTF8ToWide(chrome_frame_test::kChromeImageName), | 284 UTF8ToWide(chrome_frame_test::kChromeImageName), |
| 280 UTF8ToWide(switches::kChromeFrame)); | 285 UTF8ToWide(switches::kChromeFrame)); |
| 281 } | 286 } |
| 282 | 287 |
| 283 // Verifying actions | 288 // Verifying actions |
| 284 ACTION_P(AccExpect, matcher) { | 289 ACTION_P(AccExpect, matcher) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 373 } |
| 369 | 374 |
| 370 // Flaky actions | 375 // Flaky actions |
| 371 | 376 |
| 372 ACTION_P(SetFocusToRenderer, mock) { | 377 ACTION_P(SetFocusToRenderer, mock) { |
| 373 simulate_input::SetKeyboardFocusToWindow( | 378 simulate_input::SetKeyboardFocusToWindow( |
| 374 mock->event_sink()->GetRendererWindow()); | 379 mock->event_sink()->GetRendererWindow()); |
| 375 } | 380 } |
| 376 | 381 |
| 377 ACTION_P4(DelaySendChar, loop, delay, c, mod) { | 382 ACTION_P4(DelaySendChar, loop, delay, c, mod) { |
| 378 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 383 loop->PostDelayedTask( |
| 379 simulate_input::SendCharA, c, mod), delay); | 384 FROM_HERE, base::Bind(simulate_input::SendCharA, c, mod), delay); |
| 380 } | 385 } |
| 381 | 386 |
| 382 ACTION_P4(DelaySendScanCode, loop, delay, c, mod) { | 387 ACTION_P4(DelaySendScanCode, loop, delay, c, mod) { |
| 383 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 388 loop->PostDelayedTask( |
| 384 simulate_input::SendScanCode, c, mod), delay); | 389 FROM_HERE, base::Bind(simulate_input::SendScanCode, c, mod), delay); |
| 385 } | 390 } |
| 386 | 391 |
| 387 // This function selects the address bar via the Alt+d shortcut. | 392 // This function selects the address bar via the Alt+d shortcut. |
| 388 ACTION_P3(TypeUrlInAddressBar, loop, url, delay) { | 393 ACTION_P3(TypeUrlInAddressBar, loop, url, delay) { |
| 389 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 394 loop->PostDelayedTask( |
| 390 simulate_input::SendCharA, 'd', simulate_input::ALT), | 395 FROM_HERE, |
| 391 delay); | 396 base::Bind(simulate_input::SendCharA, 'd', simulate_input::ALT), delay); |
| 392 | 397 |
| 393 const unsigned int kInterval = 500; | 398 const unsigned int kInterval = 500; |
| 394 int next_delay = delay + kInterval; | 399 int next_delay = delay + kInterval; |
| 395 | 400 |
| 396 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 401 loop->PostDelayedTask( |
| 397 simulate_input::SendStringW, url), next_delay); | 402 FROM_HERE, base::Bind(simulate_input::SendStringW, url), next_delay); |
| 398 | 403 |
| 399 next_delay = next_delay + kInterval; | 404 next_delay = next_delay + kInterval; |
| 400 | 405 |
| 401 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 406 loop->PostDelayedTask( |
| 402 simulate_input::SendCharA, VK_RETURN, simulate_input::NONE), | 407 FROM_HERE, |
| 408 base::Bind(simulate_input::SendCharA, VK_RETURN, simulate_input::NONE), |
| 403 next_delay); | 409 next_delay); |
| 404 } | 410 } |
| 405 | 411 |
| 406 } // namespace chrome_frame_test | 412 } // namespace chrome_frame_test |
| 407 | 413 |
| 408 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ | 414 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ |
| OLD | NEW |