| 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 "base/scoped_bstr_win.h" |
| 9 #include "chrome/common/chrome_switches.h" |
| 8 #include "chrome_frame/test/chrome_frame_test_utils.h" | 10 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 9 #include "chrome_frame/test/simulate_input.h" | 11 #include "chrome_frame/test/simulate_input.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 11 | 13 |
| 12 namespace chrome_frame_test { | 14 namespace chrome_frame_test { |
| 13 | 15 |
| 14 MATCHER_P(UrlPathEq, url, "equals the path and query portion of the url") { | 16 MATCHER_P(UrlPathEq, url, "equals the path and query portion of the url") { |
| 15 return arg == chrome_frame_test::GetPathAndQueryFromUrl(url); | 17 return arg == chrome_frame_test::GetPathAndQueryFromUrl(url); |
| 16 } | 18 } |
| 17 | 19 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 34 } | 36 } |
| 35 | 37 |
| 36 ACTION_P(StopWindowWatching, mock) { | 38 ACTION_P(StopWindowWatching, mock) { |
| 37 mock->StopWatching(); | 39 mock->StopWatching(); |
| 38 } | 40 } |
| 39 | 41 |
| 40 ACTION_P(ExpectRendererHasFocus, mock) { | 42 ACTION_P(ExpectRendererHasFocus, mock) { |
| 41 mock->event_sink()->ExpectRendererWindowHasFocus(); | 43 mock->event_sink()->ExpectRendererWindowHasFocus(); |
| 42 } | 44 } |
| 43 | 45 |
| 46 ACTION_P2(ConnectDocPropNotifySink, mock, sink) { |
| 47 ScopedComPtr<IDispatch> document; |
| 48 mock->event_sink()->web_browser2()->get_Document(document.Receive()); |
| 49 EXPECT_TRUE(document != NULL); // NOLINT |
| 50 if (document) { |
| 51 sink->Attach(document); |
| 52 } |
| 53 } |
| 54 |
| 55 ACTION_P(DisconnectDocPropNotifySink, sink) { |
| 56 sink->Detach(); |
| 57 } |
| 58 |
| 59 ACTION_P3(DelayNavigateToCurrentUrl, mock, loop, delay) { |
| 60 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(&NavigateToCurrentUrl, |
| 61 mock), delay); |
| 62 } |
| 63 |
| 64 ACTION_P2(ExpectDocumentReadystate, mock, ready_state) { |
| 65 mock->ExpectDocumentReadystate(ready_state); |
| 66 } |
| 67 |
| 44 ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id, | 68 ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id, |
| 45 cmd_exec_opt, in_args, out_args) { | 69 cmd_exec_opt, in_args, out_args) { |
| 46 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), | 70 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), |
| 47 &IEEventSink::Exec, cmd_group_guid, cmd_id, cmd_exec_opt, in_args, | 71 &IEEventSink::Exec, cmd_group_guid, cmd_id, cmd_exec_opt, in_args, |
| 48 out_args), delay); | 72 out_args), delay); |
| 49 } | 73 } |
| 50 | 74 |
| 51 ACTION_P3(DelayRefresh, mock, loop, delay) { | 75 ACTION_P3(DelayRefresh, mock, loop, delay) { |
| 52 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), | 76 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(), |
| 53 &IEEventSink::Refresh), delay); | 77 &IEEventSink::Refresh), delay); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 123 |
| 100 ACTION_P(VerifyAddressBarUrl, mock) { | 124 ACTION_P(VerifyAddressBarUrl, mock) { |
| 101 mock->event_sink()->ExpectAddressBarUrl(std::wstring(arg1)); | 125 mock->event_sink()->ExpectAddressBarUrl(std::wstring(arg1)); |
| 102 } | 126 } |
| 103 | 127 |
| 104 ACTION_P4(DelaySendScanCode, loop, delay, c, mod) { | 128 ACTION_P4(DelaySendScanCode, loop, delay, c, mod) { |
| 105 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 129 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( |
| 106 simulate_input::SendScanCode, c, mod), delay); | 130 simulate_input::SendScanCode, c, mod), delay); |
| 107 } | 131 } |
| 108 | 132 |
| 133 |
| 134 ACTION(KillChromeFrameProcesses) { |
| 135 KillAllNamedProcessesWithArgument( |
| 136 UTF8ToWide(chrome_frame_test::kChromeImageName), |
| 137 UTF8ToWide(switches::kChromeFrame)); |
| 138 } |
| 139 |
| 109 // This function selects the address bar via the Alt+d shortcut. This is done | 140 // This function selects the address bar via the Alt+d shortcut. This is done |
| 110 // via a delayed task which executes after the delay which is passed in. | 141 // via a delayed task which executes after the delay which is passed in. |
| 111 // The subsequent operations like typing in the actual url and then hitting | 142 // The subsequent operations like typing in the actual url and then hitting |
| 112 // enter to force the browser to navigate to it each execute as delayed tasks | 143 // enter to force the browser to navigate to it each execute as delayed tasks |
| 113 // timed at the delay passed in. The recommended value for delay is 2000 ms | 144 // timed at the delay passed in. The recommended value for delay is 2000 ms |
| 114 // to account for the time taken for the accelerator keys to be reflected back | 145 // to account for the time taken for the accelerator keys to be reflected back |
| 115 // from Chrome. | 146 // from Chrome. |
| 116 ACTION_P3(TypeUrlInAddressBar, loop, url, delay) { | 147 ACTION_P3(TypeUrlInAddressBar, loop, url, delay) { |
| 117 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | 148 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( |
| 118 simulate_input::SendCharA, 'd', simulate_input::ALT), | 149 simulate_input::SendCharA, 'd', simulate_input::ALT), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 131 next_delay); | 162 next_delay); |
| 132 } | 163 } |
| 133 | 164 |
| 134 ACTION_P5(ValidateWindowSize, mock, left, top, width, height) { | 165 ACTION_P5(ValidateWindowSize, mock, left, top, width, height) { |
| 135 int actual_left = 0; | 166 int actual_left = 0; |
| 136 int actual_top = 0; | 167 int actual_top = 0; |
| 137 int actual_width = 0; | 168 int actual_width = 0; |
| 138 int actual_height = 0; | 169 int actual_height = 0; |
| 139 | 170 |
| 140 IWebBrowser2* web_browser2 = mock->event_sink()->web_browser2(); | 171 IWebBrowser2* web_browser2 = mock->event_sink()->web_browser2(); |
| 141 web_browser2->get_Left(reinterpret_cast<long*>(&actual_left)); | 172 web_browser2->get_Left(reinterpret_cast<long*>(&actual_left)); // NOLINT |
| 142 web_browser2->get_Top(reinterpret_cast<long*>(&actual_top)); | 173 web_browser2->get_Top(reinterpret_cast<long*>(&actual_top)); // NOLINT |
| 143 web_browser2->get_Width(reinterpret_cast<long*>(&actual_width)); | 174 web_browser2->get_Width(reinterpret_cast<long*>(&actual_width)); // NOLINT |
| 144 web_browser2->get_Height(reinterpret_cast<long*>(&actual_height)); | 175 web_browser2->get_Height(reinterpret_cast<long*>(&actual_height)); // NOLINT |
| 145 | 176 |
| 146 EXPECT_EQ(actual_left, left); | 177 EXPECT_EQ(actual_left, left); |
| 147 EXPECT_EQ(actual_top, top); | 178 EXPECT_EQ(actual_top, top); |
| 148 | 179 |
| 149 EXPECT_LE(actual_width, width + 20); | 180 EXPECT_LE(actual_width, width + 20); |
| 150 EXPECT_GT(actual_width, width - 20); | 181 EXPECT_GT(actual_width, width - 20); |
| 151 EXPECT_LE(actual_height, height + 100); | 182 EXPECT_LE(actual_height, height + 100); |
| 152 EXPECT_GT(actual_height, height - 100); | 183 EXPECT_GT(actual_height, height - 100); |
| 153 } | 184 } |
| 154 | 185 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 170 | 201 |
| 171 ACTION_P2(DoDefaultUIActionInDocument, mock, matcher) { | 202 ACTION_P2(DoDefaultUIActionInDocument, mock, matcher) { |
| 172 mock->event_sink()->WaitForDOMAccessibilityTree(); | 203 mock->event_sink()->WaitForDOMAccessibilityTree(); |
| 173 DoDefaultUIAction(mock->event_sink()->GetRendererWindow(), matcher); | 204 DoDefaultUIAction(mock->event_sink()->GetRendererWindow(), matcher); |
| 174 } | 205 } |
| 175 | 206 |
| 176 } // namespace chrome_frame_test | 207 } // namespace chrome_frame_test |
| 177 | 208 |
| 178 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ | 209 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ |
| 179 | 210 |
| OLD | NEW |