| OLD | NEW |
| 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 "chrome_frame/test/test_with_web_server.h" | 5 #include "chrome_frame/test/test_with_web_server.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 } // namespace | 72 } // namespace |
| 73 | 73 |
| 74 FilePath ChromeFrameTestWithWebServer::test_file_path_; | 74 FilePath ChromeFrameTestWithWebServer::test_file_path_; |
| 75 FilePath ChromeFrameTestWithWebServer::results_dir_; | 75 FilePath ChromeFrameTestWithWebServer::results_dir_; |
| 76 FilePath ChromeFrameTestWithWebServer::CFInstall_path_; | 76 FilePath ChromeFrameTestWithWebServer::CFInstall_path_; |
| 77 FilePath ChromeFrameTestWithWebServer::CFInstance_path_; | 77 FilePath ChromeFrameTestWithWebServer::CFInstance_path_; |
| 78 ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_; | 78 ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_; |
| 79 FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_; | 79 FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_; |
| 80 chrome_frame_test::TimedMsgLoop* ChromeFrameTestWithWebServer::loop_; | 80 chrome_frame_test::TimedMsgLoop* ChromeFrameTestWithWebServer::loop_; |
| 81 std::string ChromeFrameTestWithWebServer::local_address_; |
| 81 testing::StrictMock<MockWebServerListener>* | 82 testing::StrictMock<MockWebServerListener>* |
| 82 ChromeFrameTestWithWebServer::listener_mock_; | 83 ChromeFrameTestWithWebServer::listener_mock_; |
| 83 testing::StrictMock<MockWebServer>* ChromeFrameTestWithWebServer::server_mock_; | 84 testing::StrictMock<MockWebServer>* ChromeFrameTestWithWebServer::server_mock_; |
| 84 | 85 |
| 85 ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() { | 86 ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() { |
| 86 } | 87 } |
| 87 | 88 |
| 88 // static | 89 // static |
| 89 void ChromeFrameTestWithWebServer::SetUpTestCase() { | 90 void ChromeFrameTestWithWebServer::SetUpTestCase() { |
| 90 FilePath chrome_frame_source_path; | 91 FilePath chrome_frame_source_path; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 | 109 |
| 109 ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_)); | 110 ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_)); |
| 110 | 111 |
| 111 CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js"); | 112 CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js"); |
| 112 CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js"); | 113 CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js"); |
| 113 | 114 |
| 114 ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_)); | 115 ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_)); |
| 115 | 116 |
| 116 loop_ = new chrome_frame_test::TimedMsgLoop(); | 117 loop_ = new chrome_frame_test::TimedMsgLoop(); |
| 117 loop_->set_snapshot_on_timeout(true); | 118 loop_->set_snapshot_on_timeout(true); |
| 119 local_address_ = chrome_frame_test::GetLocalIPv4Address(); |
| 118 listener_mock_ = new testing::StrictMock<MockWebServerListener>(); | 120 listener_mock_ = new testing::StrictMock<MockWebServerListener>(); |
| 119 server_mock_ = new testing::StrictMock<MockWebServer>( | 121 server_mock_ = new testing::StrictMock<MockWebServer>( |
| 120 1337, ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()), | 122 1337, ASCIIToWide(local_address_), |
| 121 chrome_frame_test::GetTestDataFolder()); | 123 chrome_frame_test::GetTestDataFolder()); |
| 122 server_mock_->set_listener(listener_mock_); | 124 server_mock_->set_listener(listener_mock_); |
| 123 } | 125 } |
| 124 | 126 |
| 125 // static | 127 // static |
| 126 void ChromeFrameTestWithWebServer::TearDownTestCase() { | 128 void ChromeFrameTestWithWebServer::TearDownTestCase() { |
| 127 delete server_mock_; | 129 delete server_mock_; |
| 128 server_mock_ = NULL; | 130 server_mock_ = NULL; |
| 129 delete listener_mock_; | 131 delete listener_mock_; |
| 130 listener_mock_ = NULL; | 132 listener_mock_ = NULL; |
| 133 local_address_.clear(); |
| 131 delete loop_; | 134 delete loop_; |
| 132 loop_ = NULL; | 135 loop_ = NULL; |
| 133 file_util::Delete(CFInstall_path_, false); | 136 file_util::Delete(CFInstall_path_, false); |
| 134 file_util::Delete(CFInstance_path_, false); | 137 file_util::Delete(CFInstance_path_, false); |
| 135 if (temp_dir_.IsValid()) | 138 if (temp_dir_.IsValid()) |
| 136 EXPECT_TRUE(temp_dir_.Delete()); | 139 EXPECT_TRUE(temp_dir_.Delete()); |
| 137 } | 140 } |
| 138 | 141 |
| 139 // static | 142 // static |
| 140 const FilePath& ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() { | 143 const FilePath& ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() { |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 // the request to get reissued. It should not. | 755 // the request to get reissued. It should not. |
| 753 // https://code.google.com/p/chromium/issues/detail?id=143699 | 756 // https://code.google.com/p/chromium/issues/detail?id=143699 |
| 754 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_TestPostReissue) { | 757 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_TestPostReissue) { |
| 755 // The order of pages in this array is assumed to be mshtml, cf, script. | 758 // The order of pages in this array is assumed to be mshtml, cf, script. |
| 756 const wchar_t* kPages[] = { | 759 const wchar_t* kPages[] = { |
| 757 L"full_tab_post_mshtml.html", | 760 L"full_tab_post_mshtml.html", |
| 758 L"full_tab_post_target_cf.html", | 761 L"full_tab_post_target_cf.html", |
| 759 L"chrome_frame_tester_helpers.js", | 762 L"chrome_frame_tester_helpers.js", |
| 760 }; | 763 }; |
| 761 | 764 |
| 762 SimpleWebServerTest server(46664); | 765 SimpleWebServerTest server(local_address_, 46664); |
| 763 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, | 766 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, |
| 764 arraysize(kPages), GetCFTestFilePath()); | 767 arraysize(kPages), GetCFTestFilePath()); |
| 765 | 768 |
| 766 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); | 769 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); |
| 767 | 770 |
| 768 loop().RunFor(kChromeFrameLongNavigationTimeout); | 771 loop().RunFor(kChromeFrameLongNavigationTimeout); |
| 769 | 772 |
| 770 const test_server::Request* request = NULL; | 773 const test_server::Request* request = NULL; |
| 771 server.FindRequest("/quit?OK", &request); | 774 server.FindRequest("/quit?OK", &request); |
| 772 ASSERT_TRUE(request != NULL); | 775 ASSERT_TRUE(request != NULL); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 783 // Test whether following a link from an mshtml page to a CF page will cause | 786 // Test whether following a link from an mshtml page to a CF page will cause |
| 784 // multiple network requests. It should not. | 787 // multiple network requests. It should not. |
| 785 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestMultipleGet) { | 788 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestMultipleGet) { |
| 786 // The order of pages in this array is assumed to be mshtml, cf, script. | 789 // The order of pages in this array is assumed to be mshtml, cf, script. |
| 787 const wchar_t* kPages[] = { | 790 const wchar_t* kPages[] = { |
| 788 L"full_tab_get_mshtml.html", | 791 L"full_tab_get_mshtml.html", |
| 789 L"full_tab_get_target_cf.html", | 792 L"full_tab_get_target_cf.html", |
| 790 L"chrome_frame_tester_helpers.js", | 793 L"chrome_frame_tester_helpers.js", |
| 791 }; | 794 }; |
| 792 | 795 |
| 793 SimpleWebServerTest server(46664); | 796 SimpleWebServerTest server(local_address_, 46664); |
| 794 | 797 |
| 795 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, | 798 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, |
| 796 arraysize(kPages), GetCFTestFilePath()); | 799 arraysize(kPages), GetCFTestFilePath()); |
| 797 | 800 |
| 798 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); | 801 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); |
| 799 | 802 |
| 800 loop().RunFor(kChromeFrameVeryLongNavigationTimeout); | 803 loop().RunFor(kChromeFrameVeryLongNavigationTimeout); |
| 801 | 804 |
| 802 const test_server::Request* request = NULL; | 805 const test_server::Request* request = NULL; |
| 803 server.FindRequest("/quit?OK", &request); | 806 server.FindRequest("/quit?OK", &request); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 // a page that needs to be rendered in GCF. | 904 // a page that needs to be rendered in GCF. |
| 902 // | 905 // |
| 903 // This test currently fails because GCF does not add the chromeframe header | 906 // This test currently fails because GCF does not add the chromeframe header |
| 904 // to requests that mshtml initiates via IInternetSession::CreateBinding. | 907 // to requests that mshtml initiates via IInternetSession::CreateBinding. |
| 905 TEST_F(ChromeFrameTestWithWebServer, FAILS_FullTabModeIE_RefreshMshtmlTest) { | 908 TEST_F(ChromeFrameTestWithWebServer, FAILS_FullTabModeIE_RefreshMshtmlTest) { |
| 906 const wchar_t* kPages[] = { | 909 const wchar_t* kPages[] = { |
| 907 L"mshtml_refresh_test.html", | 910 L"mshtml_refresh_test.html", |
| 908 L"mshtml_refresh_test_popup.html", | 911 L"mshtml_refresh_test_popup.html", |
| 909 }; | 912 }; |
| 910 | 913 |
| 911 SimpleWebServerTest server(46664); | 914 SimpleWebServerTest server(local_address_, 46664); |
| 912 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, | 915 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, |
| 913 arraysize(kPages), GetCFTestFilePath()); | 916 arraysize(kPages), GetCFTestFilePath()); |
| 914 | 917 |
| 915 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); | 918 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); |
| 916 | 919 |
| 917 loop().RunFor(kChromeFrameLongNavigationTimeout); | 920 loop().RunFor(kChromeFrameLongNavigationTimeout); |
| 918 | 921 |
| 919 test_server::SimpleWebServer* ws = server.web_server(); | 922 test_server::SimpleWebServer* ws = server.web_server(); |
| 920 const test_server::ConnectionList& connections = ws->connections(); | 923 const test_server::ConnectionList& connections = ws->connections(); |
| 921 test_server::ConnectionList::const_iterator it = connections.begin(); | 924 test_server::ConnectionList::const_iterator it = connections.begin(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 }; | 1044 }; |
| 1042 | 1045 |
| 1043 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) | 1046 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) |
| 1044 .Times(testing::AtMost(1)) | 1047 .Times(testing::AtMost(1)) |
| 1045 .WillOnce(chrome_frame_test::DoCloseWindow()); | 1048 .WillOnce(chrome_frame_test::DoCloseWindow()); |
| 1046 | 1049 |
| 1047 EXPECT_CALL(win_observer_mock, OnWindowClose(_)) | 1050 EXPECT_CALL(win_observer_mock, OnWindowClose(_)) |
| 1048 .Times(testing::AtMost(1)) | 1051 .Times(testing::AtMost(1)) |
| 1049 .WillOnce(QUIT_LOOP(loop())); | 1052 .WillOnce(QUIT_LOOP(loop())); |
| 1050 | 1053 |
| 1051 SimpleWebServerTest server(46664); | 1054 SimpleWebServerTest server(local_address_, 46664); |
| 1052 CustomResponse* response = new CustomResponse("/form.html"); | 1055 CustomResponse* response = new CustomResponse("/form.html"); |
| 1053 server.web_server()->AddResponse(response); | 1056 server.web_server()->AddResponse(response); |
| 1054 | 1057 |
| 1055 std::wstring url(server.FormatHttpPath(L"form.html")); | 1058 std::wstring url(server.FormatHttpPath(L"form.html")); |
| 1056 | 1059 |
| 1057 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); | 1060 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); |
| 1058 loop().RunFor(kChromeFrameLongNavigationTimeout); | 1061 loop().RunFor(kChromeFrameLongNavigationTimeout); |
| 1059 | 1062 |
| 1060 EXPECT_EQ(1, response->get_request_count()); | 1063 EXPECT_EQ(1, response->get_request_count()); |
| 1061 EXPECT_EQ(1, response->post_request_count()); | 1064 EXPECT_EQ(1, response->post_request_count()); |
| 1062 } | 1065 } |
| OLD | NEW |