| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "net/url_request/url_request_unittest.h" | 5 #include "net/url_request/url_request_unittest.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 static void TearDownTestCase() { | 1955 static void TearDownTestCase() { |
| 1956 server_ = NULL; | 1956 server_ = NULL; |
| 1957 } | 1957 } |
| 1958 | 1958 |
| 1959 static scoped_refptr<FTPTestServer> server_; | 1959 static scoped_refptr<FTPTestServer> server_; |
| 1960 }; | 1960 }; |
| 1961 | 1961 |
| 1962 // static | 1962 // static |
| 1963 scoped_refptr<FTPTestServer> URLRequestTestFTP::server_; | 1963 scoped_refptr<FTPTestServer> URLRequestTestFTP::server_; |
| 1964 | 1964 |
| 1965 TEST_F(URLRequestTestFTP, FTPDirectoryListing) { | 1965 // Flaky, see http://crbug.com/25045. |
| 1966 TEST_F(URLRequestTestFTP, FLAKY_FTPDirectoryListing) { |
| 1966 ASSERT_TRUE(NULL != server_.get()); | 1967 ASSERT_TRUE(NULL != server_.get()); |
| 1967 TestDelegate d; | 1968 TestDelegate d; |
| 1968 { | 1969 { |
| 1969 TestURLRequest r(server_->TestServerPage("/"), &d); | 1970 TestURLRequest r(server_->TestServerPage("/"), &d); |
| 1970 r.Start(); | 1971 r.Start(); |
| 1971 EXPECT_TRUE(r.is_pending()); | 1972 EXPECT_TRUE(r.is_pending()); |
| 1972 | 1973 |
| 1973 MessageLoop::current()->Run(); | 1974 MessageLoop::current()->Run(); |
| 1974 | 1975 |
| 1975 EXPECT_FALSE(r.is_pending()); | 1976 EXPECT_FALSE(r.is_pending()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 int64 file_size = 0; | 2044 int64 file_size = 0; |
| 2044 file_util::GetFileSize(app_path, &file_size); | 2045 file_util::GetFileSize(app_path, &file_size); |
| 2045 | 2046 |
| 2046 EXPECT_FALSE(r.is_pending()); | 2047 EXPECT_FALSE(r.is_pending()); |
| 2047 EXPECT_EQ(1, d.response_started_count()); | 2048 EXPECT_EQ(1, d.response_started_count()); |
| 2048 EXPECT_FALSE(d.received_data_before_response()); | 2049 EXPECT_FALSE(d.received_data_before_response()); |
| 2049 EXPECT_EQ(d.bytes_received(), 0); | 2050 EXPECT_EQ(d.bytes_received(), 0); |
| 2050 } | 2051 } |
| 2051 } | 2052 } |
| 2052 | 2053 |
| 2053 TEST_F(URLRequestTestFTP, FTPCheckWrongPasswordRestart) { | 2054 // Flaky, see http://crbug.com/25045. |
| 2055 TEST_F(URLRequestTestFTP, FLAKY_FTPCheckWrongPasswordRestart) { |
| 2054 ASSERT_TRUE(NULL != server_.get()); | 2056 ASSERT_TRUE(NULL != server_.get()); |
| 2055 FilePath app_path; | 2057 FilePath app_path; |
| 2056 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 2058 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
| 2057 app_path = app_path.AppendASCII("LICENSE"); | 2059 app_path = app_path.AppendASCII("LICENSE"); |
| 2058 TestDelegate d; | 2060 TestDelegate d; |
| 2059 // Set correct login credentials. The delegate will be asked for them when | 2061 // Set correct login credentials. The delegate will be asked for them when |
| 2060 // the initial login with wrong credentials will fail. | 2062 // the initial login with wrong credentials will fail. |
| 2061 d.set_username(L"chrome"); | 2063 d.set_username(L"chrome"); |
| 2062 d.set_password(L"chrome"); | 2064 d.set_password(L"chrome"); |
| 2063 { | 2065 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 int64 file_size = 0; | 2097 int64 file_size = 0; |
| 2096 file_util::GetFileSize(app_path, &file_size); | 2098 file_util::GetFileSize(app_path, &file_size); |
| 2097 | 2099 |
| 2098 EXPECT_FALSE(r.is_pending()); | 2100 EXPECT_FALSE(r.is_pending()); |
| 2099 EXPECT_EQ(1, d.response_started_count()); | 2101 EXPECT_EQ(1, d.response_started_count()); |
| 2100 EXPECT_FALSE(d.received_data_before_response()); | 2102 EXPECT_FALSE(d.received_data_before_response()); |
| 2101 EXPECT_EQ(d.bytes_received(), 0); | 2103 EXPECT_EQ(d.bytes_received(), 0); |
| 2102 } | 2104 } |
| 2103 } | 2105 } |
| 2104 | 2106 |
| 2105 TEST_F(URLRequestTestFTP, FTPCheckWrongUserRestart) { | 2107 // Flaky, see http://crbug.com/25045. |
| 2108 TEST_F(URLRequestTestFTP, FLAKY_FTPCheckWrongUserRestart) { |
| 2106 ASSERT_TRUE(NULL != server_.get()); | 2109 ASSERT_TRUE(NULL != server_.get()); |
| 2107 FilePath app_path; | 2110 FilePath app_path; |
| 2108 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 2111 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
| 2109 app_path = app_path.AppendASCII("LICENSE"); | 2112 app_path = app_path.AppendASCII("LICENSE"); |
| 2110 TestDelegate d; | 2113 TestDelegate d; |
| 2111 // Set correct login credentials. The delegate will be asked for them when | 2114 // Set correct login credentials. The delegate will be asked for them when |
| 2112 // the initial login with wrong credentials will fail. | 2115 // the initial login with wrong credentials will fail. |
| 2113 d.set_username(L"chrome"); | 2116 d.set_username(L"chrome"); |
| 2114 d.set_password(L"chrome"); | 2117 d.set_password(L"chrome"); |
| 2115 { | 2118 { |
| 2116 TestURLRequest r(server_->TestServerPage("/LICENSE", | 2119 TestURLRequest r(server_->TestServerPage("/LICENSE", |
| 2117 "wrong_user", "chrome"), &d); | 2120 "wrong_user", "chrome"), &d); |
| 2118 r.Start(); | 2121 r.Start(); |
| 2119 EXPECT_TRUE(r.is_pending()); | 2122 EXPECT_TRUE(r.is_pending()); |
| 2120 | 2123 |
| 2121 MessageLoop::current()->Run(); | 2124 MessageLoop::current()->Run(); |
| 2122 | 2125 |
| 2123 int64 file_size = 0; | 2126 int64 file_size = 0; |
| 2124 file_util::GetFileSize(app_path, &file_size); | 2127 file_util::GetFileSize(app_path, &file_size); |
| 2125 | 2128 |
| 2126 EXPECT_FALSE(r.is_pending()); | 2129 EXPECT_FALSE(r.is_pending()); |
| 2127 EXPECT_EQ(1, d.response_started_count()); | 2130 EXPECT_EQ(1, d.response_started_count()); |
| 2128 EXPECT_FALSE(d.received_data_before_response()); | 2131 EXPECT_FALSE(d.received_data_before_response()); |
| 2129 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); | 2132 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); |
| 2130 } | 2133 } |
| 2131 } | 2134 } |
| 2132 | 2135 |
| 2133 TEST_F(URLRequestTestFTP, DISABLED_FTPCacheURLCredentials) { | 2136 // Flaky, see http://crbug.com/25045. |
| 2137 TEST_F(URLRequestTestFTP, FLAKY_FTPCacheURLCredentials) { |
| 2134 ASSERT_TRUE(NULL != server_.get()); | 2138 ASSERT_TRUE(NULL != server_.get()); |
| 2135 FilePath app_path; | 2139 FilePath app_path; |
| 2136 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 2140 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
| 2137 app_path = app_path.AppendASCII("LICENSE"); | 2141 app_path = app_path.AppendASCII("LICENSE"); |
| 2138 | 2142 |
| 2139 scoped_ptr<TestDelegate> d(new TestDelegate); | 2143 scoped_ptr<TestDelegate> d(new TestDelegate); |
| 2140 { | 2144 { |
| 2141 // Pass correct login identity in the URL. | 2145 // Pass correct login identity in the URL. |
| 2142 TestURLRequest r(server_->TestServerPage("/LICENSE", | 2146 TestURLRequest r(server_->TestServerPage("/LICENSE", |
| 2143 "chrome", "chrome"), | 2147 "chrome", "chrome"), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2168 int64 file_size = 0; | 2172 int64 file_size = 0; |
| 2169 file_util::GetFileSize(app_path, &file_size); | 2173 file_util::GetFileSize(app_path, &file_size); |
| 2170 | 2174 |
| 2171 EXPECT_FALSE(r.is_pending()); | 2175 EXPECT_FALSE(r.is_pending()); |
| 2172 EXPECT_EQ(1, d->response_started_count()); | 2176 EXPECT_EQ(1, d->response_started_count()); |
| 2173 EXPECT_FALSE(d->received_data_before_response()); | 2177 EXPECT_FALSE(d->received_data_before_response()); |
| 2174 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 2178 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 2175 } | 2179 } |
| 2176 } | 2180 } |
| 2177 | 2181 |
| 2178 TEST_F(URLRequestTestFTP, FTPCacheLoginBoxCredentials) { | 2182 // Flaky, see http://crbug.com/25045. |
| 2183 TEST_F(URLRequestTestFTP, FLAKY_FTPCacheLoginBoxCredentials) { |
| 2179 ASSERT_TRUE(NULL != server_.get()); | 2184 ASSERT_TRUE(NULL != server_.get()); |
| 2180 FilePath app_path; | 2185 FilePath app_path; |
| 2181 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 2186 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
| 2182 app_path = app_path.AppendASCII("LICENSE"); | 2187 app_path = app_path.AppendASCII("LICENSE"); |
| 2183 | 2188 |
| 2184 scoped_ptr<TestDelegate> d(new TestDelegate); | 2189 scoped_ptr<TestDelegate> d(new TestDelegate); |
| 2185 // Set correct login credentials. The delegate will be asked for them when | 2190 // Set correct login credentials. The delegate will be asked for them when |
| 2186 // the initial login with wrong credentials will fail. | 2191 // the initial login with wrong credentials will fail. |
| 2187 d->set_username(L"chrome"); | 2192 d->set_username(L"chrome"); |
| 2188 d->set_password(L"chrome"); | 2193 d->set_password(L"chrome"); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2266 TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) { | 2271 TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) { |
| 2267 ASSERT_TRUE(NULL != server_.get()); | 2272 ASSERT_TRUE(NULL != server_.get()); |
| 2268 TestDelegate d; | 2273 TestDelegate d; |
| 2269 TestURLRequest req(server_->TestServerPage("echoheader?Accept-Charset"), &d); | 2274 TestURLRequest req(server_->TestServerPage("echoheader?Accept-Charset"), &d); |
| 2270 req.set_context(new URLRequestTestContext()); | 2275 req.set_context(new URLRequestTestContext()); |
| 2271 req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); | 2276 req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); |
| 2272 req.Start(); | 2277 req.Start(); |
| 2273 MessageLoop::current()->Run(); | 2278 MessageLoop::current()->Run(); |
| 2274 EXPECT_EQ(std::string("koi-8r"), d.data_received()); | 2279 EXPECT_EQ(std::string("koi-8r"), d.data_received()); |
| 2275 } | 2280 } |
| OLD | NEW |