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

Side by Side Diff: chrome_frame/test/test_mock_with_web_server.cc

Issue 2375003: Add chrome_frame_tests to check that some navigation cases are not broken in ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months 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
« no previous file with comments | « chrome_frame/test/test_mock_with_web_server.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 #include "chrome_frame/test/test_mock_with_web_server.h" 4 #include "chrome_frame/test/test_mock_with_web_server.h"
5 5
6 #include <mshtmcid.h> 6 #include <mshtmcid.h>
7 7
8 #include "base/scoped_bstr_win.h" 8 #include "base/scoped_bstr_win.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome_frame/utils.h" 10 #include "chrome_frame/utils.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ExpectationSet new_window; 140 ExpectationSet new_window;
141 new_window += EXPECT_CALL(*this, OnNewWindow3(_, _, _, _, _)); 141 new_window += EXPECT_CALL(*this, OnNewWindow3(_, _, _, _, _));
142 new_window += EXPECT_CALL(*this, OnNewBrowserWindow(_, _)) 142 new_window += EXPECT_CALL(*this, OnNewBrowserWindow(_, _))
143 .WillOnce(testing::WithArgs<0>(testing::Invoke(CreateFunctor( 143 .WillOnce(testing::WithArgs<0>(testing::Invoke(CreateFunctor(
144 new_window_mock, &MockWebBrowserEventSink::Attach)))); 144 new_window_mock, &MockWebBrowserEventSink::Attach))));
145 145
146 new_window_mock->ExpectNavigationAndSwitch(std::wstring()); 146 new_window_mock->ExpectNavigationAndSwitch(std::wstring());
147 return new_window; 147 return new_window;
148 } 148 }
149 149
150 ExpectationSet MockWebBrowserEventSink::ExpectNavigationInIE(
151 const std::wstring& url) {
152 testing::InSequence sequence;
153 ExpectationSet navigation;
154 navigation += EXPECT_CALL(*this, OnBeforeNavigate2(_,
155 testing::Field(&VARIANT::bstrVal,
156 testing::StrCaseEq(url)), _, _, _, _, _));
157 navigation += EXPECT_CALL(*this, OnFileDownload(VARIANT_TRUE, _))
158 .Times(testing::AnyNumber());
159 navigation += EXPECT_CALL(*this, OnNavigateComplete2(_,
160 testing::Field(&VARIANT::bstrVal,
161 testing::StrCaseEq(url))));
162 return navigation;
163 }
164
165 ExpectationSet MockWebBrowserEventSink::ExpectNewWindowWithIE(
166 const std::wstring& url, MockWebBrowserEventSink* new_window_mock) {
167 DCHECK(new_window_mock);
168 ExpectationSet new_window;
169 new_window += EXPECT_CALL(*this, OnNewWindow3(_, _, _, _, _));
170 new_window += EXPECT_CALL(*this, OnNewBrowserWindow(_, _))
171 .WillOnce(testing::WithArgs<0>(testing::Invoke(CreateFunctor(
172 new_window_mock, &MockWebBrowserEventSink::Attach))));
173
174 new_window_mock->ExpectNavigationInIE(url);
175 return new_window;
176 }
177
150 } // namespace chrome_frame_test 178 } // namespace chrome_frame_test
151 179
152 ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) { 180 ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) {
153 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock, 181 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock,
154 &MockWebBrowserEventSink::CloseWebBrowser), delay); 182 &MockWebBrowserEventSink::CloseWebBrowser), delay);
155 } 183 }
156 184
157 ACTION_P(SetFocusToChrome, mock) { 185 ACTION_P(SetFocusToChrome, mock) {
158 mock->SetFocusToChrome(); 186 mock->SetFocusToChrome();
159 } 187 }
(...skipping 13 matching lines...) Expand all
173 ACTION_P6(DelaySendMouseClick, mock, loop, delay, x, y, button) { 201 ACTION_P6(DelaySendMouseClick, mock, loop, delay, x, y, button) {
174 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock, 202 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock,
175 &MockWebBrowserEventSink::SendMouseClick, x, y, button), delay); 203 &MockWebBrowserEventSink::SendMouseClick, x, y, button), delay);
176 } 204 }
177 205
178 ACTION_P4(DelaySendChar, loop, delay, c, mod) { 206 ACTION_P4(DelaySendChar, loop, delay, c, mod) {
179 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 207 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
180 simulate_input::SendCharA, c, mod), delay); 208 simulate_input::SendCharA, c, mod), delay);
181 } 209 }
182 210
183 ACTION_P4(DelaySendScanCode, loop, delay, c, mod) {
184 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
185 simulate_input::SendScanCode, c, mod), delay);
186 }
187
188 ACTION_P5(SendExtendedKeysEnter, loop, delay, c, repeat, mod) {
189 const unsigned int kInterval = 25;
190 unsigned int next_delay = delay;
191 for (int i = 0; i < repeat; i++) {
192 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
193 simulate_input::SendExtendedKey, c, mod), next_delay);
194 next_delay += kInterval;
195 }
196
197 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
198 simulate_input::SendCharA, VK_RETURN, simulate_input::NONE), next_delay);
199 }
200
201 ACTION_P3(DelaySendString, loop, delay, str) { 211 ACTION_P3(DelaySendString, loop, delay, str) {
202 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 212 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
203 simulate_input::SendStringW, str), delay); 213 simulate_input::SendStringW, str), delay);
204 } 214 }
205 215
216 ACTION_P5(SendExtendedKeysEnter, loop, delay, c, repeat, mod) {
217 chrome_frame_test::DelaySendExtendedKeysEnter(loop, delay, c, repeat, mod);
218 }
219
206 ACTION(DoCloseWindow) { 220 ACTION(DoCloseWindow) {
207 ::PostMessage(arg0, WM_SYSCOMMAND, SC_CLOSE, 0); 221 ::PostMessage(arg0, WM_SYSCOMMAND, SC_CLOSE, 0);
208 } 222 }
209 223
210 // This function selects the address bar via the Alt+d shortcut. This is done 224 // This function selects the address bar via the Alt+d shortcut. This is done
211 // via a delayed task which executes after the delay which is passed in. 225 // via a delayed task which executes after the delay which is passed in.
212 // The subsequent operations like typing in the actual url and then hitting 226 // The subsequent operations like typing in the actual url and then hitting
213 // enter to force the browser to navigate to it each execute as delayed tasks 227 // enter to force the browser to navigate to it each execute as delayed tasks
214 // timed at the delay passed in. The recommended value for delay is 2000 ms 228 // timed at the delay passed in. The recommended value for delay is 2000 ms
215 // to account for the time taken for the accelerator keys to be reflected back 229 // to account for the time taken for the accelerator keys to be reflected back
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 .WillOnce(QUIT_LOOP(loop)); 1514 .WillOnce(QUIT_LOOP(loop));
1501 1515
1502 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); 1516 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1);
1503 ASSERT_HRESULT_SUCCEEDED(hr); 1517 ASSERT_HRESULT_SUCCEEDED(hr);
1504 if (hr == S_FALSE) 1518 if (hr == S_FALSE)
1505 return; 1519 return;
1506 1520
1507 ASSERT_TRUE(mock.web_browser2() != NULL); 1521 ASSERT_TRUE(mock.web_browser2() != NULL);
1508 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 1522 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
1509 } 1523 }
OLDNEW
« no previous file with comments | « chrome_frame/test/test_mock_with_web_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698