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

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

Issue 2173002: Add chrome frame tests for common navigation cases to ensure IE is not broken. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: cleanup Created 10 years, 7 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
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());
amit 2010/05/26 22:58:42 I think we need to be precise here about cardinali
kkania 2013/02/28 21:50:54 Done.
159 navigation += EXPECT_CALL(*this, OnNavigateComplete2(_,
160 testing::Field(&VARIANT::bstrVal,
161 testing::StrCaseEq(url))));
162
163 return navigation;
164 }
165
166 ExpectationSet MockWebBrowserEventSink::ExpectNewWindowWithIE(
167 const std::wstring& url, MockWebBrowserEventSink* new_window_mock) {
168 DCHECK(new_window_mock);
169 ExpectationSet new_window;
170 new_window += EXPECT_CALL(*this, OnNewWindow3(_, _, _, _, _));
171 new_window += EXPECT_CALL(*this, OnNewBrowserWindow(_, _))
172 .WillOnce(testing::WithArgs<0>(testing::Invoke(CreateFunctor(
173 new_window_mock, &MockWebBrowserEventSink::Attach))));
174
175 new_window_mock->ExpectNavigationInIE(url);
176 return new_window;
177 }
178
150 } // namespace chrome_frame_test 179 } // namespace chrome_frame_test
151 180
152 ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) { 181 ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) {
153 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock, 182 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock,
154 &MockWebBrowserEventSink::CloseWebBrowser), delay); 183 &MockWebBrowserEventSink::CloseWebBrowser), delay);
155 } 184 }
156 185
157 ACTION_P(SetFocusToChrome, mock) { 186 ACTION_P(SetFocusToChrome, mock) {
158 mock->SetFocusToChrome(); 187 mock->SetFocusToChrome();
159 } 188 }
(...skipping 13 matching lines...) Expand all
173 ACTION_P6(DelaySendMouseClick, mock, loop, delay, x, y, button) { 202 ACTION_P6(DelaySendMouseClick, mock, loop, delay, x, y, button) {
174 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock, 203 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock,
175 &MockWebBrowserEventSink::SendMouseClick, x, y, button), delay); 204 &MockWebBrowserEventSink::SendMouseClick, x, y, button), delay);
176 } 205 }
177 206
178 ACTION_P4(DelaySendChar, loop, delay, c, mod) { 207 ACTION_P4(DelaySendChar, loop, delay, c, mod) {
179 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 208 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
180 simulate_input::SendCharA, c, mod), delay); 209 simulate_input::SendCharA, c, mod), delay);
181 } 210 }
182 211
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) { 212 ACTION_P3(DelaySendString, loop, delay, str) {
202 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( 213 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
203 simulate_input::SendStringW, str), delay); 214 simulate_input::SendStringW, str), delay);
204 } 215 }
205 216
217 ACTION_P5(SendExtendedKeysEnter, loop, delay, c, repeat, mod) {
218 chrome_frame_test::DelaySendExtendedKeysEnter(loop, delay, c, repeat, mod);
219 }
220
206 ACTION(DoCloseWindow) { 221 ACTION(DoCloseWindow) {
207 ::PostMessage(arg0, WM_SYSCOMMAND, SC_CLOSE, 0); 222 ::PostMessage(arg0, WM_SYSCOMMAND, SC_CLOSE, 0);
208 } 223 }
209 224
210 // This function selects the address bar via the Alt+d shortcut. This is done 225 // 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. 226 // 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 227 // 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 228 // 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 229 // 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 230 // to account for the time taken for the accelerator keys to be reflected back
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 .WillOnce(QUIT_LOOP(loop)); 1516 .WillOnce(QUIT_LOOP(loop));
1502 1517
1503 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); 1518 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1);
1504 ASSERT_HRESULT_SUCCEEDED(hr); 1519 ASSERT_HRESULT_SUCCEEDED(hr);
1505 if (hr == S_FALSE) 1520 if (hr == S_FALSE)
1506 return; 1521 return;
1507 1522
1508 ASSERT_TRUE(mock.web_browser2() != NULL); 1523 ASSERT_TRUE(mock.web_browser2() != NULL);
1509 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 1524 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
1510 } 1525 }
OLDNEW
« chrome_frame/test/no_interference_test.cc ('K') | « 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