| 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 #include <mshtmcid.h> | 5 #include <mshtmcid.h> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/scoped_variant_win.h" | 8 #include "base/scoped_variant_win.h" |
| 9 #include "base/test/test_file_util.h" |
| 9 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| 10 #include "chrome_frame/test/chrome_frame_test_utils.h" | 11 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 11 #include "chrome_frame/test/chrome_frame_ui_test_utils.h" | 12 #include "chrome_frame/test/chrome_frame_ui_test_utils.h" |
| 12 #include "chrome_frame/test/mock_ie_event_sink_actions.h" | 13 #include "chrome_frame/test/mock_ie_event_sink_actions.h" |
| 13 #include "chrome_frame/test/mock_ie_event_sink_test.h" | 14 #include "chrome_frame/test/mock_ie_event_sink_test.h" |
| 14 | 15 |
| 15 #include "testing/gmock_mutant.h" | 16 #include "testing/gmock_mutant.h" |
| 16 | 17 |
| 17 using testing::_; | 18 using testing::_; |
| 18 using testing::InSequence; | 19 using testing::InSequence; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 EXPECT_CALL(win_observer_mock, | 437 EXPECT_CALL(win_observer_mock, |
| 437 OnWindowDetected(_, testing::StartsWith(kPageInfoCaption))) | 438 OnWindowDetected(_, testing::StartsWith(kPageInfoCaption))) |
| 438 .WillOnce(testing::DoAll( | 439 .WillOnce(testing::DoAll( |
| 439 DelayDoCloseWindow(5000), // wait to catch possible crash | 440 DelayDoCloseWindow(5000), // wait to catch possible crash |
| 440 DelayCloseBrowserMock(&loop_, 5500, &ie_mock_))); | 441 DelayCloseBrowserMock(&loop_, 5500, &ie_mock_))); |
| 441 | 442 |
| 442 LaunchIENavigateAndLoop(GetSimplePageUrl(), | 443 LaunchIENavigateAndLoop(GetSimplePageUrl(), |
| 443 kChromeFrameLongNavigationTimeoutInSeconds * 2); | 444 kChromeFrameLongNavigationTimeoutInSeconds * 2); |
| 444 } | 445 } |
| 445 | 446 |
| 446 TEST_F(ContextMenuTest, FLAKY_CFSaveAs) { | 447 TEST_F(ContextMenuTest, CFSaveAs) { |
| 447 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); | 448 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); |
| 448 MockWindowObserver win_observer_mock; | 449 MockWindowObserver win_observer_mock; |
| 449 InSequence expect_in_sequence_for_scope; | 450 InSequence expect_in_sequence_for_scope; |
| 450 | 451 |
| 451 // Open 'Save As' dialog. | 452 // Open 'Save As' dialog. |
| 452 const wchar_t* kSaveDlgClass = L"#32770"; | 453 const wchar_t* kSaveDlgClass = L"#32770"; |
| 453 EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) | 454 EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) |
| 454 .WillOnce(testing::DoAll( | 455 .WillOnce(testing::DoAll( |
| 455 WatchWindow(&win_observer_mock, kSaveDlgClass), | 456 WatchWindow(&win_observer_mock, kSaveDlgClass), |
| 456 OpenContextMenuAsync())); | 457 OpenContextMenuAsync())); |
| 457 EXPECT_CALL(acc_observer_, OnMenuPopup(_)) | 458 EXPECT_CALL(acc_observer_, OnMenuPopup(_)) |
| 458 .WillOnce(DoDefaultAction(AccObjectMatcher(L"Save as..."))); | 459 .WillOnce(DoDefaultAction(AccObjectMatcher(L"Save as..."))); |
| 459 | 460 |
| 461 // Get safe download name using temporary file. |
| 460 FilePath temp_file_path; | 462 FilePath temp_file_path; |
| 461 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | 463 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); |
| 462 temp_file_path = temp_file_path.ReplaceExtension(L".htm"); | 464 temp_file_path = temp_file_path.ReplaceExtension(L".htm"); |
| 465 ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false)); |
| 463 | 466 |
| 464 const wchar_t* kSaveFileName = temp_file_path.value().c_str(); | 467 EXPECT_CALL(win_observer_mock, OnWindowDetected(_, StrEq("Save As"))) |
| 465 DeleteFile(kSaveFileName); | |
| 466 | |
| 467 const char* kSaveDlgCaption = "Save As"; | |
| 468 EXPECT_CALL(win_observer_mock, OnWindowDetected(_, StrEq(kSaveDlgCaption))) | |
| 469 .WillOnce(testing::DoAll( | 468 .WillOnce(testing::DoAll( |
| 470 DelaySendString(&loop_, 100, kSaveFileName), | 469 SetAccObjectValue(AccObjectMatcher(L"File name:", L"", L"simple*"), |
| 471 DelaySendChar(&loop_, 200, VK_RETURN, simulate_input::NONE), | 470 temp_file_path.value()), |
| 472 DelayCloseBrowserMock(&loop_, 4000, &ie_mock_))); | 471 DoDefaultAction(AccObjectMatcher(L"Save", L"push button")), |
| 472 CloseWhenFileSaved(&ie_mock_, temp_file_path, 5000))); |
| 473 | 473 |
| 474 LaunchIENavigateAndLoop(GetSimplePageUrl(), | 474 LaunchIENavigateAndLoop(GetSimplePageUrl(), |
| 475 kChromeFrameLongNavigationTimeoutInSeconds * 2); | 475 kChromeFrameLongNavigationTimeoutInSeconds * 2); |
| 476 ASSERT_NE(INVALID_FILE_ATTRIBUTES, GetFileAttributes(kSaveFileName)); | 476 ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false)); |
| 477 ASSERT_TRUE(DeleteFile(kSaveFileName)); | |
| 478 } | 477 } |
| 479 | 478 |
| 480 // This tests that the about:version page can be opened via the CF context menu. | 479 // This tests that the about:version page can be opened via the CF context menu. |
| 481 TEST_F(ContextMenuTest, CFAboutVersionLoads) { | 480 TEST_F(ContextMenuTest, CFAboutVersionLoads) { |
| 482 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); | 481 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); |
| 483 const wchar_t* kAboutVersionUrl = L"gcf:about:version"; | 482 const wchar_t* kAboutVersionUrl = L"gcf:about:version"; |
| 484 const wchar_t* kAboutVersionWithoutProtoUrl = L"about:version"; | 483 const wchar_t* kAboutVersionWithoutProtoUrl = L"about:version"; |
| 485 MockIEEventSink new_window_mock; | 484 MockIEEventSink new_window_mock; |
| 486 new_window_mock.ExpectAnyNavigations(); | 485 new_window_mock.ExpectAnyNavigations(); |
| 487 InSequence expect_in_sequence_for_scope; | 486 InSequence expect_in_sequence_for_scope; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 EXPECT_CALL(acc_observer_, OnMenuPopup(_)) | 579 EXPECT_CALL(acc_observer_, OnMenuPopup(_)) |
| 581 .WillOnce(DoDefaultAction(AccObjectMatcher(L"Forward"))); | 580 .WillOnce(DoDefaultAction(AccObjectMatcher(L"Forward"))); |
| 582 | 581 |
| 583 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2))) | 582 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2))) |
| 584 .WillOnce(CloseBrowserMock(&ie_mock_)); | 583 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 585 | 584 |
| 586 LaunchIEAndNavigate(page1); | 585 LaunchIEAndNavigate(page1); |
| 587 } | 586 } |
| 588 | 587 |
| 589 } // namespace chrome_frame_test | 588 } // namespace chrome_frame_test |
| OLD | NEW |