| 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" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/installer/util/product.h" | 15 #include "chrome/installer/util/product.h" |
| 16 #include "chrome/installer/util/install_util.h" | 16 #include "chrome/installer/util/install_util.h" |
| 17 #include "chrome/installer/util/helper.h" | 17 #include "chrome/installer/util/helper.h" |
| 18 #include "chrome_frame/html_utils.h" | 18 #include "chrome_frame/html_utils.h" |
| 19 #include "chrome_frame/utils.h" | 19 #include "chrome_frame/utils.h" |
| 20 #include "chrome_frame/test/chrome_frame_test_utils.h" | 20 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 21 #include "chrome_frame/test/mock_ie_event_sink_actions.h" | 21 #include "chrome_frame/test/mock_ie_event_sink_actions.h" |
| 22 #include "chrome_frame/test/mock_ie_event_sink_test.h" | 22 #include "chrome_frame/test/mock_ie_event_sink_test.h" |
| 23 #include "chrome_frame/test/test_scrubber.h" | 23 #include "chrome_frame/test/test_scrubber.h" |
| 24 #include "net/base/mime_util.h" | 24 #include "net/base/mime_util.h" |
| 25 #include "net/base/stream_listen_socket.h" |
| 25 #include "net/http/http_util.h" | 26 #include "net/http/http_util.h" |
| 26 | 27 |
| 27 using chrome_frame_test::kChromeFrameLongNavigationTimeout; | 28 using chrome_frame_test::kChromeFrameLongNavigationTimeout; |
| 28 using chrome_frame_test::kChromeFrameVeryLongNavigationTimeout; | 29 using chrome_frame_test::kChromeFrameVeryLongNavigationTimeout; |
| 29 | 30 |
| 30 using testing::_; | 31 using testing::_; |
| 31 using testing::StrCaseEq; | 32 using testing::StrCaseEq; |
| 32 | 33 |
| 33 const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; | 34 const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; |
| 34 | 35 |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 if (i != std::string::npos) | 873 if (i != std::string::npos) |
| 873 content_.replace(i, arraysize(kUserAgentTemplate) - 1, ua_); | 874 content_.replace(i, arraysize(kUserAgentTemplate) - 1, ua_); |
| 874 i = content_.find(kRequestIdTemplate); | 875 i = content_.find(kRequestIdTemplate); |
| 875 if (i != std::string::npos) { | 876 if (i != std::string::npos) { |
| 876 content_.replace(i, arraysize(kRequestIdTemplate) - 1, | 877 content_.replace(i, arraysize(kRequestIdTemplate) - 1, |
| 877 base::StringPrintf("%i", request_id_)); | 878 base::StringPrintf("%i", request_id_)); |
| 878 } | 879 } |
| 879 return content_.length(); | 880 return content_.length(); |
| 880 } | 881 } |
| 881 | 882 |
| 882 virtual void WriteContents(net::ListenSocket* socket) const { | 883 virtual void WriteContents(net::StreamListenSocket* socket) const { |
| 883 DCHECK(content_.length()); | 884 DCHECK(content_.length()); |
| 884 socket->Send(content_.c_str(), content_.length(), false); | 885 socket->Send(content_.c_str(), content_.length(), false); |
| 885 request_id_++; | 886 request_id_++; |
| 886 } | 887 } |
| 887 | 888 |
| 888 protected: | 889 protected: |
| 889 mutable std::string ua_; | 890 mutable std::string ua_; |
| 890 mutable std::string content_; | 891 mutable std::string content_; |
| 891 mutable int request_id_; | 892 mutable int request_id_; |
| 892 }; | 893 }; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 } | 999 } |
| 999 | 1000 |
| 1000 virtual bool Matches(const test_server::Request& r) const { | 1001 virtual bool Matches(const test_server::Request& r) const { |
| 1001 bool match = __super::Matches(r); | 1002 bool match = __super::Matches(r); |
| 1002 if (match) { | 1003 if (match) { |
| 1003 is_post_ = LowerCaseEqualsASCII(r.method().c_str(), "post"); | 1004 is_post_ = LowerCaseEqualsASCII(r.method().c_str(), "post"); |
| 1004 } | 1005 } |
| 1005 return match; | 1006 return match; |
| 1006 } | 1007 } |
| 1007 | 1008 |
| 1008 virtual void WriteContents(net::ListenSocket* socket) const { | 1009 virtual void WriteContents(net::StreamListenSocket* socket) const { |
| 1009 if (is_post_) { | 1010 if (is_post_) { |
| 1010 socket->Send(kText, sizeof(kText) - 1, false); | 1011 socket->Send(kText, sizeof(kText) - 1, false); |
| 1011 } else { | 1012 } else { |
| 1012 socket->Send(kHtml, sizeof(kHtml) - 1, false); | 1013 socket->Send(kHtml, sizeof(kHtml) - 1, false); |
| 1013 } | 1014 } |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1016 virtual void IncrementAccessCounter() { | 1017 virtual void IncrementAccessCounter() { |
| 1017 __super::IncrementAccessCounter(); | 1018 __super::IncrementAccessCounter(); |
| 1018 if (is_post_) { | 1019 if (is_post_) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1049 server.web_server()->AddResponse(response); | 1050 server.web_server()->AddResponse(response); |
| 1050 | 1051 |
| 1051 std::wstring url(server.FormatHttpPath(L"form.html")); | 1052 std::wstring url(server.FormatHttpPath(L"form.html")); |
| 1052 | 1053 |
| 1053 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); | 1054 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); |
| 1054 loop().RunFor(kChromeFrameLongNavigationTimeout); | 1055 loop().RunFor(kChromeFrameLongNavigationTimeout); |
| 1055 | 1056 |
| 1056 EXPECT_EQ(1, response->get_request_count()); | 1057 EXPECT_EQ(1, response->get_request_count()); |
| 1057 EXPECT_EQ(1, response->post_request_count()); | 1058 EXPECT_EQ(1, response->post_request_count()); |
| 1058 } | 1059 } |
| OLD | NEW |