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

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

Issue 126143005: Remove Chrome Frame code and resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to r244038 Created 6 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <mshtmcid.h>
6 #include <string>
7
8 #include "base/file_util.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_file_util.h"
11 #include "base/win/scoped_bstr.h"
12 #include "base/win/scoped_variant.h"
13 #include "base/win/windows_version.h"
14 #include "chrome/common/url_constants.h"
15 #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/mock_ie_event_sink_actions.h"
18 #include "chrome_frame/test/mock_ie_event_sink_test.h"
19 #include "chrome_frame/test/simulate_input.h"
20
21 #include "testing/gmock_mutant.h"
22
23 using testing::_;
24 using testing::InSequence;
25 using testing::StrCaseEq;
26 using testing::StrEq;
27
28 namespace chrome_frame_test {
29
30 // This parameterized test fixture uses the MockIEEventSink and is used by
31 // UI-related tests.
32 class FullTabUITest : public MockIEEventSinkTest,
33 public testing::TestWithParam<CFInvocation> {
34 public:
35 FullTabUITest() {}
36
37 virtual void SetUp() {
38 ResetKeyState();
39
40 // These are UI-related tests, so we do not care about the exact requests
41 // and navigations that occur.
42 server_mock_.ExpectAndServeAnyRequests(GetParam());
43 ie_mock_.ExpectAnyNavigations();
44 }
45
46 virtual void TearDown() {
47 ResetKeyState();
48 }
49
50 void ResetKeyState() {
51 // Call this to reset the state of any current keyboard modifiers, as it has
52 // been observed that these tests can leave the desktop in an invalid state
53 // (e.g. thinking that the Ctrl key is held down). Send F23 as that is
54 // particularly unlikely to be used by any real application.
55 simulate_input::SendMnemonic(
56 VK_F23,
57 simulate_input::CONTROL | simulate_input::SHIFT | simulate_input::ALT,
58 false,
59 false,
60 simulate_input::KEY_UP);
61 }
62 };
63
64 // Instantiate each test case for the IE case and for CF meta tag case.
65 // It does not seem too useful to also run the CF http header case since these
66 // are UI, not navigation tests.
67 INSTANTIATE_TEST_CASE_P(IE, FullTabUITest,
68 testing::Values(CFInvocation::None()));
69 INSTANTIATE_TEST_CASE_P(CF, FullTabUITest,
70 testing::Values(CFInvocation::MetaTag()));
71
72 // Tests keyboard input.
73 TEST_P(FullTabUITest, KeyboardInput) {
74 if (!GetParam().invokes_cf()) {
75 LOG(ERROR) << "Test not implemented for this configuration.";
76 return;
77 }
78 std::wstring key_event_url = GetTestUrl(L"keyevent.html");
79
80 static const char input[] = "chrome";
81 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(key_event_url)))
82 .WillOnce(PostKeyMessagesToRenderer(&ie_mock_, input));
83
84 EXPECT_CALL(ie_mock_, OnMessage(StrCaseEq(base::UTF8ToWide(input)), _, _))
85 .WillOnce(CloseBrowserMock(&ie_mock_));
86
87 LaunchIEAndNavigate(key_event_url);
88 }
89
90 // Tests keyboard shortcuts for back and forward.
91 // http://code.google.com/p/chromium/issues/detail?id=114058
92 TEST_P(FullTabUITest, DISABLED_KeyboardBackForward) {
93 if (IsWorkstationLocked()) {
94 LOG(ERROR) << "This test cannot be run in a locked workstation.";
95 return;
96 }
97
98 std::wstring page1 = GetSimplePageUrl();
99 std::wstring page2 = GetLinkPageUrl();
100 bool in_cf = GetParam().invokes_cf();
101 InSequence expect_in_sequence_for_scope;
102
103 // This test performs the following steps.
104 // 1. Launches IE and navigates to page1
105 // 2. It then navigates to page2
106 // 3. Sends the VK_BACK keystroke to IE, which should navigate back to
107 // page 1
108 // 4. Sends the Shift + VK_BACK keystroke to IE which should navigate
109 // forward to page2
110 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1)))
111 .WillOnce(Navigate(&ie_mock_, page2));
112
113 short bkspace = VkKeyScanA(VK_BACK); // NOLINT
114 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2)))
115 .WillOnce(testing::DoAll(
116 SetFocusToRenderer(&ie_mock_),
117 DelaySendScanCode(&loop_,
118 base::TimeDelta::FromSeconds(1),
119 bkspace,
120 simulate_input::NONE)));
121
122 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1)))
123 .WillOnce(testing::DoAll(
124 SetFocusToRenderer(&ie_mock_),
125 DelaySendScanCode(&loop_,
126 base::TimeDelta::FromSeconds(1),
127 bkspace,
128 simulate_input::SHIFT)));
129
130 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2)))
131 .WillOnce(CloseBrowserMock(&ie_mock_));
132
133 LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout);
134 }
135
136 // Tests new window behavior with ctrl+N.
137 TEST_P(FullTabUITest, CtrlN) {
138 if (IsWorkstationLocked()) {
139 LOG(ERROR) << "This test cannot be run in a locked workstation.";
140 return;
141 }
142
143 bool is_cf = GetParam().invokes_cf();
144 if (!is_cf) {
145 LOG(ERROR) << "Test not implemented for this configuration.";
146 return;
147 }
148 // Ideally we want to use a ie_mock_ to watch for finer grained
149 // events for New Window, but for Crl+N we don't get any
150 // OnNewWindowX notifications. :(
151 MockWindowObserver win_observer_mock;
152
153 const char* kNewWindowTitlePattern = "*Internet Explorer*";
154 EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(GetSimplePageUrl())))
155 .WillOnce(testing::DoAll(
156 WatchWindow(&win_observer_mock, kNewWindowTitlePattern, ""),
157 SetFocusToRenderer(&ie_mock_),
158 DelaySendChar(&loop_,
159 base::TimeDelta::FromSeconds(1),
160 'n',
161 simulate_input::CONTROL)));
162
163 // Watch for new window. It appears that the window close message cannot be
164 // reliably delivered immediately upon receipt of the window open event.
165 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
166 .Times(testing::AtMost(2))
167 .WillOnce(CloseBrowserMock(&ie_mock_))
168 .WillOnce(testing::Return());
169
170 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
171 .Times(testing::AtMost(2));
172
173 LaunchIENavigateAndLoop(GetSimplePageUrl(),
174 kChromeFrameVeryLongNavigationTimeout);
175 }
176
177 // Test that Ctrl+F opens the Find dialog.
178 TEST_P(FullTabUITest, CtrlF) {
179 if (IsWorkstationLocked()) {
180 LOG(ERROR) << "This test cannot be run in a locked workstation.";
181 return;
182 }
183
184 bool is_cf = GetParam().invokes_cf();
185 if (!is_cf) {
186 LOG(ERROR) << "Test not implemented for this configuration.";
187 return;
188 }
189 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
190 MockWindowObserver win_observer_mock;
191 InSequence expect_in_sequence_for_scope;
192
193 const char* kFindDialogCaption = "Find";
194 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl())))
195 .WillOnce(testing::DoAll(
196 WatchWindow(&win_observer_mock, kFindDialogCaption, ""),
197 SetFocusToRenderer(&ie_mock_),
198 DelaySendChar(&loop_,
199 base::TimeDelta::FromMilliseconds(1500),
200 'f',
201 simulate_input::CONTROL)));
202
203 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
204 .WillOnce(CloseBrowserMock(&ie_mock_));
205
206 LaunchIENavigateAndLoop(GetSimplePageUrl(),
207 kChromeFrameVeryLongNavigationTimeout);
208 }
209
210 // Test that ctrl+r does cause a refresh.
211 TEST_P(FullTabUITest, CtrlR) {
212 if (IsWorkstationLocked()) {
213 LOG(ERROR) << "This test cannot be run in a locked workstation.";
214 return;
215 }
216
217 EXPECT_CALL(server_mock_, Get(_, UrlPathEq(GetSimplePageUrl()), _))
218 .Times(testing::AtMost(2))
219 .WillRepeatedly(SendResponse(&server_mock_, GetParam()));
220
221 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
222 StrEq(GetSimplePageUrl())))
223 .Times(testing::AtMost(2))
224 .WillOnce(testing::DoAll(
225 SetFocusToRenderer(&ie_mock_),
226 DelaySendChar(&loop_,
227 base::TimeDelta::FromSeconds(1),
228 'r',
229 simulate_input::CONTROL),
230 DelayCloseBrowserMock(
231 &loop_, base::TimeDelta::FromSeconds(4), &ie_mock_)))
232 .WillRepeatedly(testing::Return());
233
234 LaunchIENavigateAndLoop(GetSimplePageUrl(),
235 kChromeFrameVeryLongNavigationTimeout);
236 }
237
238 // Test window close with ctrl+w.
239 TEST_P(FullTabUITest, CtrlW) {
240 if (IsWorkstationLocked()) {
241 LOG(ERROR) << "This test cannot be run in a locked workstation.";
242 return;
243 }
244
245 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
246 StrEq(GetSimplePageUrl())))
247 .WillOnce(testing::DoAll(
248 SetFocusToRenderer(&ie_mock_),
249 DelaySendChar(&loop_,
250 base::TimeDelta::FromSeconds(1),
251 'w',
252 simulate_input::CONTROL)));
253
254 LaunchIENavigateAndLoop(GetSimplePageUrl(),
255 kChromeFrameVeryLongNavigationTimeout);
256 }
257
258 // Test address bar navigation with Alt+d and URL.
259 // Flaky due to TypeUrlInAddressBar; see http://crbug.com/124244.
260 TEST_P(FullTabUITest, DISABLED_AltD) {
261 if (IsWorkstationLocked()) {
262 LOG(ERROR) << "This test cannot be run in a locked workstation.";
263 return;
264 }
265
266 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
267 StrEq(GetSimplePageUrl())))
268 .WillOnce(testing::DoAll(
269 SetFocusToRenderer(&ie_mock_),
270 TypeUrlInAddressBar(&loop_,
271 GetLinkPageUrl(),
272 base::TimeDelta::FromMilliseconds(1500))));
273
274 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
275 StrEq(GetLinkPageUrl())))
276 .WillOnce(CloseBrowserMock(&ie_mock_));
277
278 LaunchIENavigateAndLoop(GetSimplePageUrl(),
279 kChromeFrameVeryLongNavigationTimeout);
280 }
281
282 // Tests that the renderer has focus after navigation.
283 // Flaky, see http://crbug.com/90791 .
284 TEST_P(FullTabUITest, DISABLED_RendererHasFocus) {
285 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
286 StrEq(GetSimplePageUrl())))
287 .WillOnce(testing::DoAll(
288 ExpectRendererHasFocus(&ie_mock_),
289 CloseBrowserMock(&ie_mock_)));
290
291 LaunchIEAndNavigate(GetSimplePageUrl());
292 }
293
294 // Tests that view source works.
295 TEST_P(FullTabUITest, ViewSource) {
296 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
297 // for more information on why this test is disabled for Vista with IE7.
298 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
299 GetInstalledIEVersion() == IE_7) {
300 LOG(INFO) << "Not running test on Vista with IE7";
301 return;
302 }
303
304 bool in_cf = GetParam().invokes_cf();
305 if (!in_cf) {
306 LOG(ERROR) << "Test not implemented for this configuration.";
307 return;
308 }
309 MockIEEventSink view_source_mock;
310 view_source_mock.ExpectAnyNavigations();
311 InSequence expect_in_sequence_for_scope;
312
313 // After navigation invoke view soruce action using IWebBrowser2::ExecWB
314 VARIANT empty = base::win::ScopedVariant::kEmptyVariant;
315 EXPECT_CALL(ie_mock_, OnLoad(in_cf,
316 StrEq(GetSimplePageUrl())))
317 .WillOnce(DelayExecCommand(
318 &ie_mock_, &loop_, base::TimeDelta(), &CGID_MSHTML,
319 static_cast<OLECMDID>(IDM_VIEWSOURCE),
320 OLECMDEXECOPT_DONTPROMPTUSER, &empty, &empty));
321
322 // Expect notification for view-source window, handle new window event
323 // and attach a new ie_mock_ to the received web browser
324 std::wstring view_source_url;
325 view_source_url += base::UTF8ToWide(content::kViewSourceScheme);
326 view_source_url += L":";
327 view_source_url += GetSimplePageUrl();
328 std::wstring url_in_new_window = kChromeProtocolPrefix;
329 url_in_new_window += view_source_url;
330
331 ie_mock_.ExpectNewWindow(&view_source_mock);
332 // For some reason this happens occasionally at least on XP IE7.
333 EXPECT_CALL(view_source_mock, OnLoad(IN_IE, StrEq(url_in_new_window)))
334 .Times(testing::AtMost(1));
335 EXPECT_CALL(view_source_mock, OnLoad(in_cf, StrEq(view_source_url)))
336 .WillOnce(testing::DoAll(
337 VerifyAddressBarUrlWithGcf(&view_source_mock),
338 CloseBrowserMock(&view_source_mock)));
339
340 EXPECT_CALL(view_source_mock, OnQuit())
341 .Times(testing::AtMost(1))
342 .WillOnce(CloseBrowserMock(&ie_mock_));
343
344 LaunchIEAndNavigate(GetSimplePageUrl());
345 }
346
347 void NavigateToCurrentUrl(MockIEEventSink* mock) {
348 IWebBrowser2* browser = mock->event_sink()->web_browser2();
349 DCHECK(browser);
350 base::win::ScopedBstr bstr;
351 HRESULT hr = browser->get_LocationURL(bstr.Receive());
352 EXPECT_HRESULT_SUCCEEDED(hr);
353 if (SUCCEEDED(hr)) {
354 DCHECK(bstr.Length());
355 VARIANT empty = base::win::ScopedVariant::kEmptyVariant;
356 hr = browser->Navigate(bstr, &empty, &empty, &empty, &empty);
357 EXPECT_HRESULT_SUCCEEDED(hr);
358 }
359 }
360
361 // Tests that Chrome gets re-instantiated after crash if we reload via
362 // the address bar or via a new navigation.
363 // Flaky on ie7, http://crbug.com/277406.
364 TEST_P(FullTabUITest, DISABLED_TabCrashReload) {
365 using testing::DoAll;
366
367 if (!GetParam().invokes_cf()) {
368 LOG(ERROR) << "Test needs CF.";
369 return;
370 }
371
372 MockPropertyNotifySinkListener prop_listener;
373 InSequence expect_in_sequence_for_scope;
374
375 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
376 .WillOnce(DoAll(
377 ExpectRendererHasFocus(&ie_mock_),
378 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE),
379 ConnectDocPropNotifySink(&ie_mock_, &prop_listener),
380 KillChromeFrameProcesses()));
381
382 EXPECT_CALL(prop_listener, OnChanged(DISPID_READYSTATE))
383 .WillOnce(DoAll(
384 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED),
385 DelayNavigateToCurrentUrl(
386 &ie_mock_, &loop_, base::TimeDelta::FromMilliseconds(10))));
387
388 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
389 .WillOnce(CloseBrowserMock(&ie_mock_));
390
391 LaunchIEAndNavigate(GetSimplePageUrl());
392 }
393
394 // Tests if Chrome gets restarted after a crash by just refreshing the document.
395 // DISABLED as per bug http://crbug.com/99317 (one of the failures is a
396 // timeout, which marking as FLAKY or FAILS won't mask).
397 TEST_P(FullTabUITest, DISABLED_TabCrashRefresh) {
398 using testing::DoAll;
399
400 if (!GetParam().invokes_cf()) {
401 LOG(ERROR) << "Test needs CF.";
402 return;
403 }
404
405 MockPropertyNotifySinkListener prop_listener;
406 InSequence expect_in_sequence_for_scope;
407
408 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
409 .WillOnce(DoAll(
410 ExpectRendererHasFocus(&ie_mock_),
411 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE),
412 ConnectDocPropNotifySink(&ie_mock_, &prop_listener),
413 KillChromeFrameProcesses()));
414
415 VARIANT empty = base::win::ScopedVariant::kEmptyVariant;
416 EXPECT_CALL(prop_listener, OnChanged(/*DISPID_READYSTATE*/_))
417 .WillOnce(DoAll(
418 DisconnectDocPropNotifySink(&prop_listener),
419 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED),
420 DelayExecCommand(
421 &ie_mock_, &loop_, base::TimeDelta::FromMilliseconds(10),
422 static_cast<GUID*>(NULL), OLECMDID_REFRESH, 0, &empty, &empty)));
423
424 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
425 .WillOnce(CloseBrowserMock(&ie_mock_));
426
427 LaunchIEAndNavigate(GetSimplePageUrl());
428 }
429
430 // Test that window.print() on a page results in the native Windows print dialog
431 // appearing rather than Chrome's in-page print preview.
432 TEST_P(FullTabUITest, WindowPrintOpensNativePrintDialog) {
433 std::wstring window_print_url(GetTestUrl(L"window_print.html"));
434 std::wstring window_print_title(L"window.print");
435
436 const bool is_cf = GetParam().invokes_cf();
437 MockWindowObserver win_observer_mock;
438
439 // When the page is loaded, start watching for the Print dialog to appear.
440 EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(window_print_url)))
441 .WillOnce(WatchWindow(&win_observer_mock, "Print", ""));
442
443 // When the print dialog opens, close it.
444 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
445 .WillOnce(DoCloseWindow());
446
447 // When the print dialog closes, close the browser.
448 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
449 .WillOnce(CloseBrowserMock(&ie_mock_));
450
451 // Launch IE and navigate to the window_print.html page, which will
452 // window.print() immediately after loading.
453 LaunchIEAndNavigate(window_print_url);
454 }
455
456 // Test fixture for tests related to the context menu UI. Since the context
457 // menus for CF and IE are different, these tests are not parameterized.
458 class ContextMenuTest : public MockIEEventSinkTest, public testing::Test {
459 public:
460 ContextMenuTest(): kTextFieldInitValue(L"SomeInitializedTextValue") {}
461
462 virtual void SetUp() {
463 context_menu_page_url = GetTestUrl(L"context_menu.html");
464 context_menu_page_title = L"context menu";
465 // Clear clipboard to make sure there is no effect from previous tests.
466 SetClipboardText(L"");
467 // These are UI-related tests, so we do not care about the exact
468 // navigations that occur.
469 ie_mock_.ExpectAnyNavigations();
470 EXPECT_CALL(ie_mock_, OnLoad(_, _)).Times(testing::AnyNumber());
471 EXPECT_CALL(acc_observer_, OnAccDocLoad(_)).Times(testing::AnyNumber());
472 }
473
474 virtual void TearDown() {
475 // Destroy the clipboard here because it is not destroyed automatically.
476 DestroyClipboard();
477 }
478
479 // Common helper function for "Save xxx As" tests.
480 void DoSaveAsTest(const wchar_t* role, const wchar_t* menu_item_name,
481 const wchar_t* file_ext) {
482 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
483 MockWindowObserver win_observer_mock;
484 InSequence expect_in_sequence_for_scope;
485
486 // Open 'Save As' dialog.
487 base::string16 initial_url(GetTestUrl(L"save_as_context_menu.html"));
488 const char* kSaveDlgCaption = "Save As";
489 EXPECT_CALL(acc_observer_,
490 OnAccDocLoad(TabContentsTitleEq(initial_url,
491 L"Save As download test")))
492 .WillOnce(testing::DoAll(
493 WatchWindow(&win_observer_mock, kSaveDlgCaption, ""),
494 AccRightClick(AccObjectMatcher(L"", role))));
495 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
496 .WillOnce(AccLeftClick(AccObjectMatcher(menu_item_name)));
497
498 // Get safe download name using temporary file.
499 base::FilePath temp_file_path;
500 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path));
501 ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false));
502 temp_file_path = temp_file_path.ReplaceExtension(file_ext);
503
504 AccObjectMatcher file_name_box(L"File name:", L"editable text");
505 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
506 .WillOnce(testing::DoAll(
507 AccSendCharMessage(file_name_box, L'a'),
508 AccSetValue(file_name_box, temp_file_path.value()),
509 AccDoDefaultAction(AccObjectMatcher(L"Save", L"push button"))));
510
511 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
512 .WillOnce(CloseWhenFileSaved(&ie_mock_, temp_file_path, 8000));
513
514 LaunchIENavigateAndLoop(initial_url,
515 kChromeFrameVeryLongNavigationTimeout);
516 ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false));
517 }
518
519 protected:
520 // Html page that holds a text field for context menu testing.
521 std::wstring context_menu_page_url;
522 // Title of said html page.
523 std::wstring context_menu_page_title;
524 // This is the text value used to test cut/copy/paste etc.
525 const std::wstring kTextFieldInitValue;
526
527 testing::NiceMock<MockAccEventObserver> acc_observer_;
528 };
529
530 // Test reloading from the context menu.
531 TEST_F(ContextMenuTest, CFReload) {
532 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
533 InSequence expect_in_sequence_for_scope;
534
535 base::string16 initial_url(GetSimplePageUrl());
536 EXPECT_CALL(acc_observer_,
537 OnAccDocLoad(TabContentsTitleEq(initial_url,
538 GetSimplePageTitle())))
539 .WillOnce(OpenContextMenuAsync());
540 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
541 .WillOnce(AccLeftClick(AccObjectMatcher(L"Reload")));
542
543 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(initial_url)))
544 .WillOnce(CloseBrowserMock(&ie_mock_));
545
546 LaunchIEAndNavigate(initial_url);
547 }
548
549 // Test view source from the context menu.
550 TEST_F(ContextMenuTest, CFViewSource) {
551 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
552 // for more information on why this test is disabled for Vista with IE7.
553 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
554 GetInstalledIEVersion() == IE_7) {
555 LOG(INFO) << "Not running test on Vista with IE7";
556 return;
557 }
558 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
559 MockIEEventSink view_source_mock;
560 view_source_mock.ExpectAnyNavigations();
561 InSequence expect_in_sequence_for_scope;
562 base::string16 initial_url(GetSimplePageUrl());
563
564 // View the page source.
565 EXPECT_CALL(acc_observer_,
566 OnAccDocLoad(TabContentsTitleEq(initial_url,
567 GetSimplePageTitle())))
568 .WillOnce(OpenContextMenuAsync());
569 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
570 .WillOnce(AccLeftClick(AccObjectMatcher(L"View page source")));
571
572 // Expect notification for view-source window, handle new window event
573 // and attach a new ie_mock_ to the received web browser
574 std::wstring view_source_url;
575 view_source_url += base::UTF8ToWide(content::kViewSourceScheme);
576 view_source_url += L":";
577 view_source_url += initial_url;
578 std::wstring url_in_new_window = kChromeProtocolPrefix;
579 url_in_new_window += view_source_url;
580
581 ie_mock_.ExpectNewWindow(&view_source_mock);
582 // For some reason this happens occasionally at least on XP IE7 and Win7 IE8.
583 EXPECT_CALL(view_source_mock, OnLoad(IN_IE, StrEq(url_in_new_window)))
584 .Times(testing::AtMost(1));
585 EXPECT_CALL(view_source_mock, OnLoad(IN_CF, StrEq(view_source_url)))
586 .WillOnce(testing::DoAll(
587 VerifyAddressBarUrlWithGcf(&view_source_mock),
588 CloseBrowserMock(&view_source_mock)));
589 EXPECT_CALL(view_source_mock, OnQuit())
590 .Times(testing::AtMost(1))
591 .WillOnce(CloseBrowserMock(&ie_mock_));
592
593 LaunchIEAndNavigate(initial_url);
594 }
595
596 TEST_F(ContextMenuTest, DISABLED_CFPageInfo) {
597 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
598 MockWindowObserver win_observer_mock;
599 InSequence expect_in_sequence_for_scope;
600 base::string16 initial_url(GetSimplePageUrl());
601
602 // View page information.
603 EXPECT_CALL(acc_observer_,
604 OnAccDocLoad(TabContentsTitleEq(initial_url,
605 GetSimplePageTitle())))
606 .WillOnce(testing::DoAll(
607 WatchWindow(&win_observer_mock, "", "Chrome_WidgetWin_*"),
608 OpenContextMenuAsync()));
609 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
610 .WillOnce(AccLeftClick(AccObjectMatcher(L"View page info")));
611
612 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)).Times(1);
613 // Expect page info dialog to pop up. Dismiss the dialog with 'Esc' key
614 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
615 .WillOnce(DoCloseWindow());
616
617 EXPECT_CALL(win_observer_mock, OnWindowClose(_)).Times(1);
618 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
619 .WillOnce(CloseBrowserMock(&ie_mock_));
620
621 LaunchIEAndNavigate(initial_url);
622 }
623
624 TEST_F(ContextMenuTest, CFInspector) {
625 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
626 MockWindowObserver win_observer_mock;
627 InSequence expect_in_sequence_for_scope;
628
629 // Open developer tools.
630 // Devtools begins life with "Untitled" caption and it changes
631 // later to the 'Developer Tools - <url> form.
632 const char* kPageInfoCaptionPattern = "Untitled*";
633 base::string16 initial_url(GetSimplePageUrl());
634 EXPECT_CALL(acc_observer_,
635 OnAccDocLoad(TabContentsTitleEq(initial_url,
636 GetSimplePageTitle())))
637 .WillOnce(testing::DoAll(
638 WatchWindow(&win_observer_mock, kPageInfoCaptionPattern, ""),
639 OpenContextMenuAsync()));
640 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
641 .WillOnce(AccLeftClick(AccObjectMatcher(L"Inspect element")));
642
643 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
644 .WillOnce(DelayDoCloseWindow(5000)); // wait to catch possible crash
645 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
646 .WillOnce(CloseBrowserMock(&ie_mock_));
647
648 LaunchIENavigateAndLoop(initial_url,
649 kChromeFrameVeryLongNavigationTimeout);
650 }
651
652 // http://code.google.com/p/chromium/issues/detail?id=83114
653 TEST_F(ContextMenuTest, DISABLED_CFSavePageAs) {
654 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
655 // for more information on why this test is disabled for Vista with IE7.
656 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
657 GetInstalledIEVersion() == IE_7) {
658 LOG(INFO) << "Not running test on Vista with IE7";
659 return;
660 }
661 ASSERT_NO_FATAL_FAILURE(DoSaveAsTest(L"", L"Save as...", L".html"));
662 }
663
664 // http://code.google.com/p/chromium/issues/detail?id=83114
665 TEST_F(ContextMenuTest, DISABLED_CFSaveLinkAs) {
666 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
667 // for more information on why this test is disabled for Vista with IE7.
668 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
669 GetInstalledIEVersion() == IE_7) {
670 LOG(INFO) << "Not running test on Vista with IE7";
671 return;
672 }
673 ASSERT_NO_FATAL_FAILURE(DoSaveAsTest(L"link", L"Save link as...", L".zip"));
674 }
675
676 // This tests that the about:version page can be opened via the CF context menu.
677 TEST_F(ContextMenuTest, CFAboutVersionLoads) {
678 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
679 // for more information on why this test is disabled for Vista with IE7.
680 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
681 GetInstalledIEVersion() == IE_7) {
682 LOG(INFO) << "Not running test on Vista with IE7";
683 return;
684 }
685 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
686 const wchar_t* kAboutVersionUrl = L"gcf:about:version";
687 const wchar_t* kAboutVersionWithoutProtoUrl = L"about:version";
688 MockIEEventSink new_window_mock;
689 new_window_mock.ExpectAnyNavigations();
690 InSequence expect_in_sequence_for_scope;
691 base::string16 initial_url(GetSimplePageUrl());
692
693 EXPECT_CALL(acc_observer_,
694 OnAccDocLoad(TabContentsTitleEq(initial_url,
695 GetSimplePageTitle())))
696 .WillOnce(OpenContextMenuAsync());
697 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
698 .WillOnce(AccLeftClick(AccObjectMatcher(L"About*")));
699
700 ie_mock_.ExpectNewWindow(&new_window_mock);
701 // For some reason this happens occasionally at least on Win7 IE8.
702 EXPECT_CALL(new_window_mock, OnLoad(IN_IE, StrEq(kAboutVersionUrl)))
703 .Times(testing::AtMost(1));
704 EXPECT_CALL(new_window_mock,
705 OnLoad(IN_CF, StrEq(kAboutVersionWithoutProtoUrl)))
706 .WillOnce(testing::DoAll(
707 VerifyAddressBarUrlWithGcf(&new_window_mock),
708 CloseBrowserMock(&new_window_mock)));
709
710 EXPECT_CALL(new_window_mock, OnQuit())
711 .Times(testing::AtMost(1))
712 .WillOnce(CloseBrowserMock(&ie_mock_));
713
714 LaunchIEAndNavigate(initial_url);
715 }
716
717 TEST_F(ContextMenuTest, IEOpen) {
718 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None());
719 InSequence expect_in_sequence_for_scope;
720 base::string16 initial_url(GetLinkPageUrl());
721
722 // Open the link through the context menu.
723 EXPECT_CALL(acc_observer_,
724 OnAccDocLoad(TabContentsTitleEq(initial_url, GetLinkPageTitle())))
725 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")));
726 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
727 .WillOnce(AccLeftClick(AccObjectMatcher(L"Open")));
728
729 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
730 .WillOnce(testing::DoAll(
731 VerifyAddressBarUrl(&ie_mock_),
732 CloseBrowserMock(&ie_mock_)));
733
734 LaunchIEAndNavigate(initial_url);
735 }
736
737 TEST_F(ContextMenuTest, IEOpenInNewWindow) {
738 // See crbug.com/64794.
739 if (GetInstalledIEVersion() == IE_7) {
740 LOG(INFO) << "Not running test with IE7";
741 return;
742 }
743 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None());
744 MockIEEventSink new_window_mock;
745 new_window_mock.ExpectAnyNavigations();
746 InSequence expect_in_sequence_for_scope;
747 base::string16 initial_url(GetLinkPageUrl());
748
749 // Open the link in a new window.
750 EXPECT_CALL(acc_observer_,
751 OnAccDocLoad(TabContentsTitleEq(initial_url, GetLinkPageTitle())))
752 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")));
753 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
754 .WillOnce(AccLeftClick(AccObjectMatcher(L"Open in New Window")));
755
756 ie_mock_.ExpectNewWindow(&new_window_mock);
757 EXPECT_CALL(new_window_mock, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
758 // TODO(kkania): Verifying the address bar is flaky with this, at least
759 // on XP ie6. Fix.
760 .WillOnce(CloseBrowserMock(&new_window_mock));
761
762 EXPECT_CALL(new_window_mock, OnQuit())
763 .Times(testing::AtMost(1))
764 .WillOnce(CloseBrowserMock(&ie_mock_));
765
766 LaunchIEAndNavigate(initial_url);
767 }
768
769 // Test Back/Forward from context menu.
770 TEST_F(ContextMenuTest, IEBackForward) {
771 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None());
772 std::wstring page1 = GetLinkPageUrl();
773 std::wstring title1 = GetLinkPageTitle();
774 std::wstring page2 = GetSimplePageUrl();
775 std::wstring title2 = GetSimplePageTitle();
776 InSequence expect_in_sequence_for_scope;
777
778 // Navigate to second page.
779 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page1, title1)))
780 .WillOnce(Navigate(&ie_mock_, page2));
781
782 // Go back.
783 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page2, title2)))
784 .WillOnce(testing::DoAll(
785 VerifyPageLoad(&ie_mock_, IN_IE, page2),
786 OpenContextMenuAsync()));
787 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
788 .WillOnce(AccLeftClick(AccObjectMatcher(L"Back")));
789
790 // Go forward.
791 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page1, title1)))
792 .WillOnce(testing::DoAll(
793 VerifyPageLoad(&ie_mock_, IN_IE, page1),
794 OpenContextMenuAsync()));
795 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
796 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
797
798 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2)))
799 .WillOnce(CloseBrowserMock(&ie_mock_));
800
801 LaunchIEAndNavigate(page1);
802 }
803
804 // Test CF link context menu - Open link in new window.
805 // Failing intermittently on IE6/7. See crbug.com/64794.
806 TEST_F(ContextMenuTest, DISABLED_CFOpenLinkInNewWindow) {
807 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
808 MockIEEventSink new_window_mock;
809 new_window_mock.ExpectAnyNavigations();
810 base::string16 initial_url(GetLinkPageUrl());
811
812 // Invoke 'Open link in new window' context menu item.
813 EXPECT_CALL(acc_observer_,
814 OnAccDocLoad(TabContentsTitleEq(initial_url, GetLinkPageTitle())))
815 .Times(testing::AtMost(2))
816 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")))
817 .WillOnce(testing::Return());
818 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
819 .WillOnce(AccLeftClick(AccObjectMatcher(L"Open link in new window*")));
820
821 ie_mock_.ExpectNewWindow(&new_window_mock);
822 EXPECT_CALL(new_window_mock, OnLoad(IN_CF, StrEq(GetSimplePageUrl())))
823 .WillOnce(CloseBrowserMock(&new_window_mock));
824 EXPECT_CALL(new_window_mock, OnQuit())
825 .WillOnce(CloseBrowserMock(&ie_mock_));
826
827 LaunchIEAndNavigate(initial_url);
828 }
829
830 // Test CF link context menu - Copy link address.
831 TEST_F(ContextMenuTest, CFCopyLinkAddress) {
832 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
833 base::string16 initial_url(GetLinkPageUrl());
834
835 // Invoke 'Copy link address' context menu item.
836 EXPECT_CALL(acc_observer_,
837 OnAccDocLoad(TabContentsTitleEq(initial_url, GetLinkPageTitle())))
838 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")));
839 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
840 .WillOnce(testing::DoAll(
841 AccLeftClick(AccObjectMatcher(L"Copy link address*")),
842 CloseBrowserMock(&ie_mock_)));
843
844 LaunchIEAndNavigate(initial_url);
845
846 EXPECT_STREQ(GetSimplePageUrl().c_str(), GetClipboardText().c_str());
847 }
848
849 // Test CF text field context menu - cut.
850 // Times out sporadically http://crbug.com/119660.
851 TEST_F(ContextMenuTest, DISABLED_CFTxtFieldCut) {
852 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
853 AccObjectMatcher txtfield_matcher(L"", L"editable text");
854
855 // Invoke "Cut" context menu item of text field.
856 EXPECT_CALL(acc_observer_,
857 OnAccDocLoad(TabContentsTitleEq(context_menu_page_url,
858 context_menu_page_title)))
859 .WillOnce(testing::DoAll(
860 AccRightClick(txtfield_matcher),
861 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
862 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
863 .WillOnce(AccLeftClick(AccObjectMatcher(L"Cut*")));
864
865 // Verify that text field is empty after cut operation.
866 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"")))
867 .WillOnce(CloseBrowserMock(&ie_mock_));
868
869 LaunchIEAndNavigate(context_menu_page_url);
870 // Verify that the text value has been cut to clipboard.
871 EXPECT_STREQ(kTextFieldInitValue.c_str(), GetClipboardText().c_str());
872 }
873
874 // Test CF text field context menu - copy.
875 // Times out sporadically http://crbug.com/119660.
876 TEST_F(ContextMenuTest, DISABLED_CFTxtFieldCopy) {
877 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
878 AccObjectMatcher txtfield_matcher(L"", L"editable text");
879
880 // Invoke "Copy" context menu item of text field.
881 EXPECT_CALL(acc_observer_,
882 OnAccDocLoad(TabContentsTitleEq(context_menu_page_url,
883 context_menu_page_title)))
884 .WillOnce(testing::DoAll(
885 AccRightClick(txtfield_matcher),
886 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
887 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
888 .WillOnce(testing::DoAll(
889 AccLeftClick(AccObjectMatcher(L"Copy*")),
890 CloseBrowserMock(&ie_mock_)));
891
892 // Verify that there is no change on text field value after copy operation.
893 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, _))
894 .Times(testing::AtMost(0));
895
896 LaunchIEAndNavigate(context_menu_page_url);
897 // Verify that the text value has been copied to clipboard.
898 EXPECT_STREQ(kTextFieldInitValue.c_str(), GetClipboardText().c_str());
899 }
900
901 // Test CF text field context menu - paste.
902 // Times out sporadically http://crbug.com/119660.
903 TEST_F(ContextMenuTest, DISABLED_CFTxtFieldPaste) {
904 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
905 AccObjectMatcher txtfield_matcher(L"", L"editable text");
906
907 // Invoke "Paste" context menu item of text field.
908 EXPECT_CALL(acc_observer_,
909 OnAccDocLoad(TabContentsTitleEq(context_menu_page_url,
910 context_menu_page_title)))
911 .WillOnce(testing::DoAll(
912 AccRightClick(txtfield_matcher),
913 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
914 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
915 .WillOnce(AccLeftClick(AccObjectMatcher(L"Paste*")));
916 // Verify that value has been pasted to text field.
917 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
918 .WillOnce(CloseBrowserMock(&ie_mock_));
919
920 // Set some text value to clipboard, this is to emulate the 'copy' action.
921 SetClipboardText(kTextFieldInitValue);
922
923 LaunchIEAndNavigate(context_menu_page_url);
924 }
925
926 // Test CF text field context menu - delete.
927 // Times out sporadically http://crbug.com/119660.
928 TEST_F(ContextMenuTest, DISABLED_CFTxtFieldDelete) {
929 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
930 AccObjectMatcher txtfield_matcher(L"", L"editable text");
931
932 // Invoke 'Delete' context menu item of text field.
933 EXPECT_CALL(acc_observer_,
934 OnAccDocLoad(TabContentsTitleEq(context_menu_page_url,
935 context_menu_page_title)))
936 .WillOnce(testing::DoAll(
937 AccRightClick(txtfield_matcher),
938 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
939 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
940 .WillOnce(AccLeftClick(AccObjectMatcher(L"Delete*")));
941 // Verify that value has been deleted from text field.
942 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"")))
943 .WillOnce(CloseBrowserMock(&ie_mock_));
944
945 LaunchIEAndNavigate(context_menu_page_url);
946 }
947
948 // Test CF text field context menu - select all.
949 // Flaky: http://crbug.com/144664
950 TEST_F(ContextMenuTest, DISABLED_CFTxtFieldSelectAll) {
951 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
952
953 // Invoke 'Select all' context menu item of text field.
954 EXPECT_CALL(acc_observer_,
955 OnAccDocLoad(TabContentsTitleEq(context_menu_page_url,
956 context_menu_page_title)))
957 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"editable text")));
958 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
959 .WillOnce(testing::DoAll(
960 AccLeftClick(AccObjectMatcher(L"Select all*")),
961 PostMessageToCF(&ie_mock_, L"selectall")));
962 // Client side script verifies that the text field value has been selected,
963 // then send 'OK' message.
964 EXPECT_CALL(ie_mock_, OnMessage(testing::StrCaseEq(L"OK"), _, _))
965 .WillOnce(CloseBrowserMock(&ie_mock_));
966
967 LaunchIEAndNavigate(context_menu_page_url + L"?action=selectall");
968 }
969
970 // Test CF text field context menu - undo.
971 // Times out sporadically http://crbug.com/119660.
972 TEST_F(ContextMenuTest, DISABLED_CFTxtFieldUndo) {
973 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
974 AccObjectMatcher txtfield_matcher(L"", L"editable text");
975
976 // Change the value of text field to 'A'.
977 EXPECT_CALL(acc_observer_,
978 OnAccDocLoad(TabContentsTitleEq(context_menu_page_url,
979 context_menu_page_title)))
980 .WillOnce(testing::DoAll(
981 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
982 AccSendCharMessage(txtfield_matcher, L'A')));
983 // Bring up the context menu once the value has changed.
984 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
985 .WillOnce(AccRightClick(txtfield_matcher));
986 // Then select "Undo".
987 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
988 .WillOnce(testing::DoAll(
989 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
990 AccLeftClick(AccObjectMatcher(L"Undo*"))));
991
992 // Verify that value has been reset to initial value after undo operation.
993 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
994 .WillOnce(CloseBrowserMock(&ie_mock_));
995
996 LaunchIEAndNavigate(context_menu_page_url);
997 }
998
999 // Test CF text field context menu - redo.
1000 // Times out sporadically http://crbug.com/119660.
1001 TEST_F(ContextMenuTest, DISABLED_CFTxtFieldRedo) {
1002 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
1003 AccObjectMatcher txtfield_matcher(L"", L"editable text");
1004 InSequence expect_in_sequence_for_scope;
1005
1006 // Change text field from its initial value to 'A'.
1007 EXPECT_CALL(acc_observer_,
1008 OnAccDocLoad(TabContentsTitleEq(context_menu_page_url,
1009 context_menu_page_title)))
1010 .WillOnce(testing::DoAll(
1011 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
1012 AccSendCharMessage(txtfield_matcher, L'A')));
1013 // Bring up the context menu.
1014 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
1015 .WillOnce(AccRightClick(txtfield_matcher));
1016 // Select "Undo"
1017 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1018 .WillOnce(testing::DoAll(
1019 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
1020 AccLeftClick(AccObjectMatcher(L"Undo*"))));
1021
1022 // After undo operation is done, bring up the context menu again.
1023 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
1024 .WillOnce(AccRightClick(txtfield_matcher));
1025 // Select "Redo"
1026 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1027 .WillOnce(testing::DoAll(
1028 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
1029 AccLeftClick(AccObjectMatcher(L"Redo*"))));
1030
1031 // Verify that text field value is reset to its changed value 'A' and exit.
1032 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
1033 .WillOnce(CloseBrowserMock(&ie_mock_));
1034
1035 LaunchIEAndNavigate(context_menu_page_url);
1036 }
1037
1038 // Disabled because it seems to hang, causing the test process to timeout and
1039 // be killed; see http://crbug.com/121097.
1040 TEST_F(ContextMenuTest, DISABLED_CFBackForward) {
1041 std::wstring page1 = GetLinkPageUrl();
1042 std::wstring title1 = GetLinkPageTitle();
1043 std::wstring page2 = GetSimplePageUrl();
1044 std::wstring title2 = GetSimplePageTitle();
1045 std::wstring page3 = GetTestUrl(L"anchor.html");
1046 std::wstring title3 = GetAnchorPageTitle();
1047
1048 server_mock_.ExpectAndServeRequestWithCardinality(
1049 CFInvocation::MetaTag(), page1, testing::Exactly(2));
1050
1051 server_mock_.ExpectAndServeRequestWithCardinality(
1052 CFInvocation::None(), page2, testing::Exactly(3));
1053
1054 server_mock_.ExpectAndServeRequestWithCardinality(
1055 CFInvocation::MetaTag(), page3, testing::Exactly(2));
1056
1057 InSequence expect_in_sequence_for_scope;
1058
1059 // Navigate to second page.
1060 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page1, title1)))
1061 .WillOnce(testing::DoAll(
1062 VerifyPageLoad(&ie_mock_, IN_CF, page1),
1063 Navigate(&ie_mock_, page2)));
1064
1065 // Navigate to third page.
1066 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page2, title2)))
1067 .WillOnce(testing::DoAll(
1068 VerifyPageLoad(&ie_mock_, IN_IE, page2),
1069 Navigate(&ie_mock_, page3)));
1070
1071 // Go back.
1072 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page3, title3)))
1073 .WillOnce(testing::DoAll(
1074 VerifyPageLoad(&ie_mock_, IN_CF, page3),
1075 OpenContextMenuAsync()));
1076
1077 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1078 .WillOnce(AccLeftClick(AccObjectMatcher(L"Back")));
1079
1080 // Go back
1081 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page2, title2)))
1082 .WillOnce(testing::DoAll(
1083 VerifyPageLoad(&ie_mock_, IN_IE, page2),
1084 OpenContextMenuAsync()));
1085
1086 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1087 .WillOnce(AccLeftClick(AccObjectMatcher(L"Back")));
1088
1089 // Go forward.
1090 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page1, title1)))
1091 .WillOnce(testing::DoAll(
1092 VerifyPageLoad(&ie_mock_, IN_CF, page1),
1093 OpenContextMenuAsync()));
1094
1095 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1096 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
1097
1098 // Go forward.
1099 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(page2, title2)))
1100 .WillOnce(testing::DoAll(
1101 VerifyPageLoad(&ie_mock_, IN_IE, page2),
1102 OpenContextMenuAsync()));
1103
1104 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1105 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
1106
1107 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page3)))
1108 .WillOnce(CloseBrowserMock(&ie_mock_));
1109
1110 LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout);
1111 }
1112
1113 } // namespace chrome_frame_test
OLDNEW
« no previous file with comments | « chrome_frame/test/test_with_web_server.cc ('k') | chrome_frame/test/urlmon_moniker_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698