Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chrome_frame/test/mock_ie_event_sink_actions.h

Issue 8555001: base::Bind: Convert chrome_frame/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bad merge. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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, base::Bind(&IEEventSink::CloseWebBrowser, mock->event_sink()),
53 delay);
52 } 54 }
53 55
54 ACTION_P2(ConnectDocPropNotifySink, mock, sink) { 56 ACTION_P2(ConnectDocPropNotifySink, mock, sink) {
55 base::win::ScopedComPtr<IDispatch> document; 57 base::win::ScopedComPtr<IDispatch> document;
56 mock->event_sink()->web_browser2()->get_Document(document.Receive()); 58 mock->event_sink()->web_browser2()->get_Document(document.Receive());
57 EXPECT_TRUE(document != NULL); // NOLINT 59 EXPECT_TRUE(document != NULL); // NOLINT
58 if (document) { 60 if (document) {
59 sink->Attach(document); 61 sink->Attach(document);
60 } 62 }
61 } 63 }
62 64
63 ACTION_P(DisconnectDocPropNotifySink, sink) { 65 ACTION_P(DisconnectDocPropNotifySink, sink) {
64 sink->Detach(); 66 sink->Detach();
65 } 67 }
66 68
67 ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id, 69 ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id,
68 cmd_exec_opt, in_args, out_args) { 70 cmd_exec_opt, in_args, out_args) {
69 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), 71 loop->PostDelayedTask(
70 &IEEventSink::Exec, cmd_group_guid, cmd_id, cmd_exec_opt, in_args, 72 FROM_HERE,
71 out_args), delay); 73 base::Bind(&IEEventSink::Exec, mock->event_sink(), cmd_group_guid, cmd_id,
74 cmd_exec_opt, in_args, out_args),
75 delay);
72 } 76 }
73 77
74 ACTION_P3(DelayGoBack, mock, loop, delay) { 78 ACTION_P3(DelayGoBack, mock, loop, delay) {
75 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), 79 loop->PostDelayedTask(
76 &IEEventSink::GoBack), delay); 80 FROM_HERE, base::Bind(&IEEventSink::GoBack, mock->event_sink()), delay);
77 } 81 }
78 82
79 ACTION_P3(DelayGoForward, mock, loop, delay) { 83 ACTION_P3(DelayGoForward, mock, loop, delay) {
80 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), 84 loop->PostDelayedTask(
81 &IEEventSink::GoForward), delay); 85 FROM_HERE, base::Bind(&IEEventSink::GoForward, mock->event_sink()),
86 delay);
82 } 87 }
83 88
84 ACTION_P3(DelayRefresh, mock, loop, delay) { 89 ACTION_P3(DelayRefresh, mock, loop, delay) {
85 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), 90 loop->PostDelayedTask(
86 &IEEventSink::Refresh), delay); 91 FROM_HERE, base::Bind(&IEEventSink::Refresh, mock->event_sink()), delay);
87 } 92 }
88 93
89 ACTION_P2(PostMessageToCF, mock, message) { 94 ACTION_P2(PostMessageToCF, mock, message) {
90 mock->event_sink()->PostMessageToCF(message, L"*"); 95 mock->event_sink()->PostMessageToCF(message, L"*");
91 } 96 }
92 97
93 // Accessibility-related actions 98 // Accessibility-related actions
94 99
95 ACTION_P(AccDoDefaultAction, matcher) { 100 ACTION_P(AccDoDefaultAction, matcher) {
96 scoped_refptr<AccObject> object; 101 scoped_refptr<AccObject> object;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 267
263 } // namespace 268 } // namespace
264 269
265 ACTION(DoCloseWindow) { 270 ACTION(DoCloseWindow) {
266 DoCloseWindowNow(arg0); 271 DoCloseWindowNow(arg0);
267 } 272 }
268 273
269 ACTION_P(DelayDoCloseWindow, delay) { 274 ACTION_P(DelayDoCloseWindow, delay) {
270 DCHECK(MessageLoop::current()); 275 DCHECK(MessageLoop::current());
271 MessageLoop::current()->PostDelayedTask( 276 MessageLoop::current()->PostDelayedTask(
272 FROM_HERE, 277 FROM_HERE, base::Bind(DoCloseWindowNow, arg0), delay);
273 NewRunnableFunction(DoCloseWindowNow, arg0),
274 delay);
275 } 278 }
276 279
277 ACTION(KillChromeFrameProcesses) { 280 ACTION(KillChromeFrameProcesses) {
278 KillAllNamedProcessesWithArgument( 281 KillAllNamedProcessesWithArgument(
279 UTF8ToWide(chrome_frame_test::kChromeImageName), 282 UTF8ToWide(chrome_frame_test::kChromeImageName),
280 UTF8ToWide(switches::kChromeFrame)); 283 UTF8ToWide(switches::kChromeFrame));
281 } 284 }
282 285
283 // Verifying actions 286 // Verifying actions
284 ACTION_P(AccExpect, matcher) { 287 ACTION_P(AccExpect, matcher) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 371 }
369 372
370 // Flaky actions 373 // Flaky actions
371 374
372 ACTION_P(SetFocusToRenderer, mock) { 375 ACTION_P(SetFocusToRenderer, mock) {
373 simulate_input::SetKeyboardFocusToWindow( 376 simulate_input::SetKeyboardFocusToWindow(
374 mock->event_sink()->GetRendererWindow()); 377 mock->event_sink()->GetRendererWindow());
375 } 378 }
376 379
377 ACTION_P4(DelaySendChar, loop, delay, c, mod) { 380 ACTION_P4(DelaySendChar, loop, delay, c, mod) {
378 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 381 loop->PostDelayedTask(
379 simulate_input::SendCharA, c, mod), delay); 382 FROM_HERE, base::Bind(simulate_input::SendCharA, c, mod), delay);
380 } 383 }
381 384
382 ACTION_P4(DelaySendScanCode, loop, delay, c, mod) { 385 ACTION_P4(DelaySendScanCode, loop, delay, c, mod) {
383 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 386 loop->PostDelayedTask(
384 simulate_input::SendScanCode, c, mod), delay); 387 FROM_HERE, base::Bind(simulate_input::SendScanCode, c, mod), delay);
385 } 388 }
386 389
387 // This function selects the address bar via the Alt+d shortcut. 390 // This function selects the address bar via the Alt+d shortcut.
388 ACTION_P3(TypeUrlInAddressBar, loop, url, delay) { 391 ACTION_P3(TypeUrlInAddressBar, loop, url, delay) {
389 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 392 loop->PostDelayedTask(
390 simulate_input::SendCharA, 'd', simulate_input::ALT), 393 FROM_HERE,
391 delay); 394 base::Bind(simulate_input::SendCharA, 'd', simulate_input::ALT), delay);
392 395
393 const unsigned int kInterval = 500; 396 const unsigned int kInterval = 500;
394 int next_delay = delay + kInterval; 397 int next_delay = delay + kInterval;
395 398
396 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 399 loop->PostDelayedTask(
397 simulate_input::SendStringW, url), next_delay); 400 FROM_HERE, base::Bind(simulate_input::SendStringW, url), next_delay);
398 401
399 next_delay = next_delay + kInterval; 402 next_delay = next_delay + kInterval;
400 403
401 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 404 loop->PostDelayedTask(
402 simulate_input::SendCharA, VK_RETURN, simulate_input::NONE), 405 FROM_HERE,
406 base::Bind(simulate_input::SendCharA, VK_RETURN, simulate_input::NONE),
403 next_delay); 407 next_delay);
404 } 408 }
405 409
406 } // namespace chrome_frame_test 410 } // namespace chrome_frame_test
407 411
408 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ 412 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698