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/ui_test.cc

Issue 10019015: Update uses of TimeDelta in chrome_frame/*. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Another rebase onto master. Created 8 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include <mshtmcid.h> 5 #include <mshtmcid.h>
6 #include <string> 6 #include <string>
7 7
8 #include "base/test/test_file_util.h" 8 #include "base/test/test_file_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/win/scoped_bstr.h" 10 #include "base/win/scoped_bstr.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // page 1 86 // page 1
87 // 4. Sends the Shift + VK_BACK keystroke to IE which should navigate 87 // 4. Sends the Shift + VK_BACK keystroke to IE which should navigate
88 // forward to page2 88 // forward to page2
89 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1))) 89 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1)))
90 .WillOnce(Navigate(&ie_mock_, page2)); 90 .WillOnce(Navigate(&ie_mock_, page2));
91 91
92 short bkspace = VkKeyScanA(VK_BACK); // NOLINT 92 short bkspace = VkKeyScanA(VK_BACK); // NOLINT
93 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2))) 93 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2)))
94 .WillOnce(testing::DoAll( 94 .WillOnce(testing::DoAll(
95 SetFocusToRenderer(&ie_mock_), 95 SetFocusToRenderer(&ie_mock_),
96 DelaySendScanCode(&loop_, 1000, bkspace, simulate_input::NONE))); 96 DelaySendScanCode(&loop_,
97 base::TimeDelta::FromSeconds(1),
98 bkspace,
99 simulate_input::NONE)));
97 100
98 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1))) 101 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1)))
99 .WillOnce(testing::DoAll( 102 .WillOnce(testing::DoAll(
100 SetFocusToRenderer(&ie_mock_), 103 SetFocusToRenderer(&ie_mock_),
101 DelaySendScanCode(&loop_, 1000, bkspace, simulate_input::SHIFT))); 104 DelaySendScanCode(&loop_,
105 base::TimeDelta::FromSeconds(1),
106 bkspace,
107 simulate_input::SHIFT)));
102 108
103 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2))) 109 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2)))
104 .WillOnce(CloseBrowserMock(&ie_mock_)); 110 .WillOnce(CloseBrowserMock(&ie_mock_));
105 111
106 LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout); 112 LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout);
107 } 113 }
108 114
109 // Tests new window behavior with ctrl+N. 115 // Tests new window behavior with ctrl+N.
110 TEST_P(FullTabUITest, CtrlN) { 116 TEST_P(FullTabUITest, CtrlN) {
111 if (IsWorkstationLocked()) { 117 if (IsWorkstationLocked()) {
112 LOG(ERROR) << "This test cannot be run in a locked workstation."; 118 LOG(ERROR) << "This test cannot be run in a locked workstation.";
113 return; 119 return;
114 } 120 }
115 121
116 bool is_cf = GetParam().invokes_cf(); 122 bool is_cf = GetParam().invokes_cf();
117 if (!is_cf) { 123 if (!is_cf) {
118 LOG(ERROR) << "Test not implemented for this configuration."; 124 LOG(ERROR) << "Test not implemented for this configuration.";
119 return; 125 return;
120 } 126 }
121 // Ideally we want to use a ie_mock_ to watch for finer grained 127 // Ideally we want to use a ie_mock_ to watch for finer grained
122 // events for New Window, but for Crl+N we don't get any 128 // events for New Window, but for Crl+N we don't get any
123 // OnNewWindowX notifications. :( 129 // OnNewWindowX notifications. :(
124 MockWindowObserver win_observer_mock; 130 MockWindowObserver win_observer_mock;
125 131
126 const char* kNewWindowTitlePattern = "*Internet Explorer*"; 132 const char* kNewWindowTitlePattern = "*Internet Explorer*";
127 EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(GetSimplePageUrl()))) 133 EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(GetSimplePageUrl())))
128 .WillOnce(testing::DoAll( 134 .WillOnce(testing::DoAll(
129 WatchWindow(&win_observer_mock, kNewWindowTitlePattern, ""), 135 WatchWindow(&win_observer_mock, kNewWindowTitlePattern, ""),
130 SetFocusToRenderer(&ie_mock_), 136 SetFocusToRenderer(&ie_mock_),
131 DelaySendChar(&loop_, 1000, 'n', simulate_input::CONTROL))); 137 DelaySendChar(&loop_,
138 base::TimeDelta::FromSeconds(1),
139 'n',
140 simulate_input::CONTROL)));
132 141
133 // Watch for new window. It appears that the window close message cannot be 142 // Watch for new window. It appears that the window close message cannot be
134 // reliably delivered immediately upon receipt of the window open event. 143 // reliably delivered immediately upon receipt of the window open event.
135 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) 144 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
136 .Times(testing::AtMost(2)) 145 .Times(testing::AtMost(2))
137 .WillOnce(CloseBrowserMock(&ie_mock_)) 146 .WillOnce(CloseBrowserMock(&ie_mock_))
138 .WillOnce(testing::Return()); 147 .WillOnce(testing::Return());
139 148
140 EXPECT_CALL(win_observer_mock, OnWindowClose(_)) 149 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
141 .Times(testing::AtMost(2)); 150 .Times(testing::AtMost(2));
(...skipping 16 matching lines...) Expand all
158 } 167 }
159 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); 168 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
160 MockWindowObserver win_observer_mock; 169 MockWindowObserver win_observer_mock;
161 InSequence expect_in_sequence_for_scope; 170 InSequence expect_in_sequence_for_scope;
162 171
163 const char* kFindDialogCaption = "Find"; 172 const char* kFindDialogCaption = "Find";
164 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl()))) 173 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl())))
165 .WillOnce(testing::DoAll( 174 .WillOnce(testing::DoAll(
166 WatchWindow(&win_observer_mock, kFindDialogCaption, ""), 175 WatchWindow(&win_observer_mock, kFindDialogCaption, ""),
167 SetFocusToRenderer(&ie_mock_), 176 SetFocusToRenderer(&ie_mock_),
168 DelaySendChar(&loop_, 1500, 'f', simulate_input::CONTROL))); 177 DelaySendChar(&loop_,
178 base::TimeDelta::FromMilliseconds(1500),
179 'f',
180 simulate_input::CONTROL)));
169 181
170 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) 182 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
171 .WillOnce(CloseBrowserMock(&ie_mock_)); 183 .WillOnce(CloseBrowserMock(&ie_mock_));
172 184
173 LaunchIENavigateAndLoop(GetSimplePageUrl(), 185 LaunchIENavigateAndLoop(GetSimplePageUrl(),
174 kChromeFrameVeryLongNavigationTimeout); 186 kChromeFrameVeryLongNavigationTimeout);
175 } 187 }
176 188
177 // Test that ctrl+r does cause a refresh. 189 // Test that ctrl+r does cause a refresh.
178 TEST_P(FullTabUITest, CtrlR) { 190 TEST_P(FullTabUITest, CtrlR) {
179 if (IsWorkstationLocked()) { 191 if (IsWorkstationLocked()) {
180 LOG(ERROR) << "This test cannot be run in a locked workstation."; 192 LOG(ERROR) << "This test cannot be run in a locked workstation.";
181 return; 193 return;
182 } 194 }
183 195
184 EXPECT_CALL(server_mock_, Get(_, UrlPathEq(GetSimplePageUrl()), _)) 196 EXPECT_CALL(server_mock_, Get(_, UrlPathEq(GetSimplePageUrl()), _))
185 .Times(testing::AtMost(2)) 197 .Times(testing::AtMost(2))
186 .WillRepeatedly(SendResponse(&server_mock_, GetParam())); 198 .WillRepeatedly(SendResponse(&server_mock_, GetParam()));
187 199
188 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), 200 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
189 StrEq(GetSimplePageUrl()))) 201 StrEq(GetSimplePageUrl())))
190 .Times(testing::AtMost(2)) 202 .Times(testing::AtMost(2))
191 .WillOnce(testing::DoAll( 203 .WillOnce(testing::DoAll(
192 SetFocusToRenderer(&ie_mock_), 204 SetFocusToRenderer(&ie_mock_),
193 DelaySendChar(&loop_, 1000, 'r', simulate_input::CONTROL), 205 DelaySendChar(&loop_,
194 DelayCloseBrowserMock(&loop_, 4000, &ie_mock_))) 206 base::TimeDelta::FromSeconds(1),
207 'r',
208 simulate_input::CONTROL),
209 DelayCloseBrowserMock(
210 &loop_, base::TimeDelta::FromSeconds(4), &ie_mock_)))
195 .WillRepeatedly(testing::Return()); 211 .WillRepeatedly(testing::Return());
196 212
197 LaunchIENavigateAndLoop(GetSimplePageUrl(), 213 LaunchIENavigateAndLoop(GetSimplePageUrl(),
198 kChromeFrameVeryLongNavigationTimeout); 214 kChromeFrameVeryLongNavigationTimeout);
199 } 215 }
200 216
201 // Test window close with ctrl+w. 217 // Test window close with ctrl+w.
202 TEST_P(FullTabUITest, CtrlW) { 218 TEST_P(FullTabUITest, CtrlW) {
203 if (IsWorkstationLocked()) { 219 if (IsWorkstationLocked()) {
204 LOG(ERROR) << "This test cannot be run in a locked workstation."; 220 LOG(ERROR) << "This test cannot be run in a locked workstation.";
205 return; 221 return;
206 } 222 }
207 223
208 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), 224 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
209 StrEq(GetSimplePageUrl()))) 225 StrEq(GetSimplePageUrl())))
210 .WillOnce(testing::DoAll( 226 .WillOnce(testing::DoAll(
211 SetFocusToRenderer(&ie_mock_), 227 SetFocusToRenderer(&ie_mock_),
212 DelaySendChar(&loop_, 1000, 'w', simulate_input::CONTROL))); 228 DelaySendChar(&loop_,
229 base::TimeDelta::FromSeconds(1),
230 'w',
231 simulate_input::CONTROL)));
213 232
214 LaunchIENavigateAndLoop(GetSimplePageUrl(), 233 LaunchIENavigateAndLoop(GetSimplePageUrl(),
215 kChromeFrameVeryLongNavigationTimeout); 234 kChromeFrameVeryLongNavigationTimeout);
216 } 235 }
217 236
218 // Test address bar navigation with Alt+d and URL. 237 // Test address bar navigation with Alt+d and URL.
219 TEST_P(FullTabUITest, AltD) { 238 TEST_P(FullTabUITest, AltD) {
220 if (IsWorkstationLocked()) { 239 if (IsWorkstationLocked()) {
221 LOG(ERROR) << "This test cannot be run in a locked workstation."; 240 LOG(ERROR) << "This test cannot be run in a locked workstation.";
222 return; 241 return;
223 } 242 }
224 243
225 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), 244 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
226 StrEq(GetSimplePageUrl()))) 245 StrEq(GetSimplePageUrl())))
227 .WillOnce(testing::DoAll( 246 .WillOnce(testing::DoAll(
228 SetFocusToRenderer(&ie_mock_), 247 SetFocusToRenderer(&ie_mock_),
229 TypeUrlInAddressBar(&loop_, GetLinkPageUrl(), 1500))); 248 TypeUrlInAddressBar(&loop_,
249 GetLinkPageUrl(),
250 base::TimeDelta::FromMilliseconds(1500))));
230 251
231 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), 252 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
232 StrEq(GetLinkPageUrl()))) 253 StrEq(GetLinkPageUrl())))
233 .WillOnce(CloseBrowserMock(&ie_mock_)); 254 .WillOnce(CloseBrowserMock(&ie_mock_));
234 255
235 LaunchIENavigateAndLoop(GetSimplePageUrl(), 256 LaunchIENavigateAndLoop(GetSimplePageUrl(),
236 kChromeFrameVeryLongNavigationTimeout); 257 kChromeFrameVeryLongNavigationTimeout);
237 } 258 }
238 259
239 // Tests that the renderer has focus after navigation. 260 // Tests that the renderer has focus after navigation.
(...skipping 24 matching lines...) Expand all
264 return; 285 return;
265 } 286 }
266 MockIEEventSink view_source_mock; 287 MockIEEventSink view_source_mock;
267 view_source_mock.ExpectAnyNavigations(); 288 view_source_mock.ExpectAnyNavigations();
268 InSequence expect_in_sequence_for_scope; 289 InSequence expect_in_sequence_for_scope;
269 290
270 // After navigation invoke view soruce action using IWebBrowser2::ExecWB 291 // After navigation invoke view soruce action using IWebBrowser2::ExecWB
271 VARIANT empty = base::win::ScopedVariant::kEmptyVariant; 292 VARIANT empty = base::win::ScopedVariant::kEmptyVariant;
272 EXPECT_CALL(ie_mock_, OnLoad(in_cf, 293 EXPECT_CALL(ie_mock_, OnLoad(in_cf,
273 StrEq(GetSimplePageUrl()))) 294 StrEq(GetSimplePageUrl())))
274 .WillOnce(DelayExecCommand(&ie_mock_, &loop_, 0, &CGID_MSHTML, 295 .WillOnce(DelayExecCommand(
275 static_cast<OLECMDID>(IDM_VIEWSOURCE), 296 &ie_mock_, &loop_, base::TimeDelta(), &CGID_MSHTML,
276 OLECMDEXECOPT_DONTPROMPTUSER, &empty, &empty)); 297 static_cast<OLECMDID>(IDM_VIEWSOURCE),
298 OLECMDEXECOPT_DONTPROMPTUSER, &empty, &empty));
277 299
278 // Expect notification for view-source window, handle new window event 300 // Expect notification for view-source window, handle new window event
279 // and attach a new ie_mock_ to the received web browser 301 // and attach a new ie_mock_ to the received web browser
280 std::wstring view_source_url; 302 std::wstring view_source_url;
281 view_source_url += UTF8ToWide(chrome::kViewSourceScheme); 303 view_source_url += UTF8ToWide(chrome::kViewSourceScheme);
282 view_source_url += L":"; 304 view_source_url += L":";
283 view_source_url += GetSimplePageUrl(); 305 view_source_url += GetSimplePageUrl();
284 std::wstring url_in_new_window = kChromeProtocolPrefix; 306 std::wstring url_in_new_window = kChromeProtocolPrefix;
285 url_in_new_window += view_source_url; 307 url_in_new_window += view_source_url;
286 308
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl()))) 352 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
331 .WillOnce(DoAll( 353 .WillOnce(DoAll(
332 ExpectRendererHasFocus(&ie_mock_), 354 ExpectRendererHasFocus(&ie_mock_),
333 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE), 355 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE),
334 ConnectDocPropNotifySink(&ie_mock_, &prop_listener), 356 ConnectDocPropNotifySink(&ie_mock_, &prop_listener),
335 KillChromeFrameProcesses())); 357 KillChromeFrameProcesses()));
336 358
337 EXPECT_CALL(prop_listener, OnChanged(DISPID_READYSTATE)) 359 EXPECT_CALL(prop_listener, OnChanged(DISPID_READYSTATE))
338 .WillOnce(DoAll( 360 .WillOnce(DoAll(
339 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED), 361 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED),
340 DelayNavigateToCurrentUrl(&ie_mock_, &loop_, 10))); 362 DelayNavigateToCurrentUrl(
363 &ie_mock_, &loop_, base::TimeDelta::FromMilliseconds(10))));
341 364
342 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl()))) 365 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
343 .WillOnce(CloseBrowserMock(&ie_mock_)); 366 .WillOnce(CloseBrowserMock(&ie_mock_));
344 367
345 LaunchIEAndNavigate(GetSimplePageUrl()); 368 LaunchIEAndNavigate(GetSimplePageUrl());
346 } 369 }
347 370
348 // Tests if Chrome gets restarted after a crash by just refreshing the document. 371 // Tests if Chrome gets restarted after a crash by just refreshing the document.
349 // DISABLED as per bug http://crbug.com/99317 (one of the failures is a 372 // DISABLED as per bug http://crbug.com/99317 (one of the failures is a
350 // timeout, which marking as FLAKY or FAILS won't mask). 373 // timeout, which marking as FLAKY or FAILS won't mask).
(...skipping 13 matching lines...) Expand all
364 ExpectRendererHasFocus(&ie_mock_), 387 ExpectRendererHasFocus(&ie_mock_),
365 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE), 388 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE),
366 ConnectDocPropNotifySink(&ie_mock_, &prop_listener), 389 ConnectDocPropNotifySink(&ie_mock_, &prop_listener),
367 KillChromeFrameProcesses())); 390 KillChromeFrameProcesses()));
368 391
369 VARIANT empty = base::win::ScopedVariant::kEmptyVariant; 392 VARIANT empty = base::win::ScopedVariant::kEmptyVariant;
370 EXPECT_CALL(prop_listener, OnChanged(/*DISPID_READYSTATE*/_)) 393 EXPECT_CALL(prop_listener, OnChanged(/*DISPID_READYSTATE*/_))
371 .WillOnce(DoAll( 394 .WillOnce(DoAll(
372 DisconnectDocPropNotifySink(&prop_listener), 395 DisconnectDocPropNotifySink(&prop_listener),
373 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED), 396 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED),
374 DelayExecCommand(&ie_mock_, &loop_, 10, static_cast<GUID*>(NULL), 397 DelayExecCommand(
375 OLECMDID_REFRESH, 0, &empty, &empty))); 398 &ie_mock_, &loop_, base::TimeDelta::FromMilliseconds(10),
399 static_cast<GUID*>(NULL), OLECMDID_REFRESH, 0, &empty, &empty)));
376 400
377 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl()))) 401 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
378 .WillOnce(CloseBrowserMock(&ie_mock_)); 402 .WillOnce(CloseBrowserMock(&ie_mock_));
379 403
380 LaunchIEAndNavigate(GetSimplePageUrl()); 404 LaunchIEAndNavigate(GetSimplePageUrl());
381 } 405 }
382 406
383 // Test that window.print() on a page results in the native Windows print dialog 407 // Test that window.print() on a page results in the native Windows print dialog
384 // appearing rather than Chrome's in-page print preview. 408 // appearing rather than Chrome's in-page print preview.
385 TEST_P(FullTabUITest, WindowPrintOpensNativePrintDialog) { 409 TEST_P(FullTabUITest, WindowPrintOpensNativePrintDialog) {
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 EXPECT_CALL(acc_observer_, OnMenuPopup(_)) 1050 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1027 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward"))); 1051 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
1028 1052
1029 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page3))) 1053 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page3)))
1030 .WillOnce(CloseBrowserMock(&ie_mock_)); 1054 .WillOnce(CloseBrowserMock(&ie_mock_));
1031 1055
1032 LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout); 1056 LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout);
1033 } 1057 }
1034 1058
1035 } // namespace chrome_frame_test 1059 } // namespace chrome_frame_test
OLDNEW
« no previous file with comments | « chrome_frame/test/test_server_test.cc ('k') | webkit/plugins/npapi/webplugin_delegate_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698