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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 1814002: Remove deprecated things from net test suite: (Closed)
Patch Set: Created 10 years, 7 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
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ptr += 10; 115 ptr += 10;
116 if (idx % 100 == 0) { 116 if (idx % 100 == 0) {
117 ptr--; 117 ptr--;
118 *ptr++ = marker; 118 *ptr++ = marker;
119 if (++marker > 'z') 119 if (++marker > 'z')
120 marker = 'a'; 120 marker = 'a';
121 } 121 }
122 } 122 }
123 uploadBytes[kMsgSize] = '\0'; 123 uploadBytes[kMsgSize] = '\0';
124 124
125 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); 125 scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
126 126
127 for (int i = 0; i < kIterations; ++i) { 127 for (int i = 0; i < kIterations; ++i) {
128 TestDelegate d; 128 TestDelegate d;
129 URLRequest r(server_->TestServerPage("echo"), &d); 129 URLRequest r(server_->TestServerPage("echo"), &d);
130 r.set_context(context); 130 r.set_context(context);
131 r.set_method(method.c_str()); 131 r.set_method(method.c_str());
132 132
133 r.AppendBytesToUpload(uploadBytes, kMsgSize); 133 r.AppendBytesToUpload(uploadBytes, kMsgSize);
134 134
135 r.Start(); 135 r.Start();
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // expect things to just cleanup properly. 477 // expect things to just cleanup properly.
478 478
479 // we won't actually get a received reponse here because we've never run the 479 // we won't actually get a received reponse here because we've never run the
480 // message loop 480 // message loop
481 EXPECT_FALSE(d.received_data_before_response()); 481 EXPECT_FALSE(d.received_data_before_response());
482 EXPECT_EQ(0, d.bytes_received()); 482 EXPECT_EQ(0, d.bytes_received());
483 } 483 }
484 484
485 TEST_F(URLRequestTestHTTP, CancelTest5) { 485 TEST_F(URLRequestTestHTTP, CancelTest5) {
486 ASSERT_TRUE(NULL != server_.get()); 486 ASSERT_TRUE(NULL != server_.get());
487 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); 487 scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
488 488
489 // populate cache 489 // populate cache
490 { 490 {
491 TestDelegate d; 491 TestDelegate d;
492 URLRequest r(server_->TestServerPage("cachetime"), &d); 492 URLRequest r(server_->TestServerPage("cachetime"), &d);
493 r.set_context(context); 493 r.set_context(context);
494 r.Start(); 494 r.Start();
495 MessageLoop::current()->Run(); 495 MessageLoop::current()->Run();
496 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); 496 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
497 } 497 }
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 EXPECT_EQ(1, d.response_started_count()); 1078 EXPECT_EQ(1, d.response_started_count());
1079 EXPECT_EQ(0, d.bytes_received()); 1079 EXPECT_EQ(0, d.bytes_received());
1080 EXPECT_FALSE(d.received_data_before_response()); 1080 EXPECT_FALSE(d.received_data_before_response());
1081 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status()); 1081 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status());
1082 } 1082 }
1083 } 1083 }
1084 1084
1085 TEST_F(URLRequestTestHTTP, VaryHeader) { 1085 TEST_F(URLRequestTestHTTP, VaryHeader) {
1086 ASSERT_TRUE(NULL != server_.get()); 1086 ASSERT_TRUE(NULL != server_.get());
1087 1087
1088 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); 1088 scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
1089 1089
1090 // populate the cache 1090 // populate the cache
1091 { 1091 {
1092 TestDelegate d; 1092 TestDelegate d;
1093 URLRequest req(server_->TestServerPage("echoheader?foo"), &d); 1093 URLRequest req(server_->TestServerPage("echoheader?foo"), &d);
1094 req.set_context(context); 1094 req.set_context(context);
1095 req.SetExtraRequestHeaders("foo: 1"); 1095 req.SetExtraRequestHeaders("foo: 1");
1096 req.Start(); 1096 req.Start();
1097 MessageLoop::current()->Run(); 1097 MessageLoop::current()->Run();
1098 } 1098 }
(...skipping 17 matching lines...) Expand all
1116 req.set_context(context); 1116 req.set_context(context);
1117 req.SetExtraRequestHeaders("foo: 2"); 1117 req.SetExtraRequestHeaders("foo: 2");
1118 req.Start(); 1118 req.Start();
1119 MessageLoop::current()->Run(); 1119 MessageLoop::current()->Run();
1120 1120
1121 EXPECT_FALSE(req.was_cached()); 1121 EXPECT_FALSE(req.was_cached());
1122 } 1122 }
1123 } 1123 }
1124 1124
1125 TEST_F(URLRequestTestHTTP, BasicAuth) { 1125 TEST_F(URLRequestTestHTTP, BasicAuth) {
1126 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); 1126 scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
1127 ASSERT_TRUE(NULL != server_.get()); 1127 ASSERT_TRUE(NULL != server_.get());
1128 1128
1129 // populate the cache 1129 // populate the cache
1130 { 1130 {
1131 TestDelegate d; 1131 TestDelegate d;
1132 d.set_username(L"user"); 1132 d.set_username(L"user");
1133 d.set_password(L"secret"); 1133 d.set_password(L"secret");
1134 1134
1135 URLRequest r(server_->TestServerPage("auth-basic"), &d); 1135 URLRequest r(server_->TestServerPage("auth-basic"), &d);
1136 r.set_context(context); 1136 r.set_context(context);
(...skipping 30 matching lines...) Expand all
1167 // http://crbug.com/6450 1167 // http://crbug.com/6450
1168 TEST_F(URLRequestTestHTTP, BasicAuthWithCookies) { 1168 TEST_F(URLRequestTestHTTP, BasicAuthWithCookies) {
1169 ASSERT_TRUE(NULL != server_.get()); 1169 ASSERT_TRUE(NULL != server_.get());
1170 1170
1171 GURL url_requiring_auth = 1171 GURL url_requiring_auth =
1172 server_->TestServerPage("auth-basic?set-cookie-if-challenged"); 1172 server_->TestServerPage("auth-basic?set-cookie-if-challenged");
1173 1173
1174 // Request a page that will give a 401 containing a Set-Cookie header. 1174 // Request a page that will give a 401 containing a Set-Cookie header.
1175 // Verify that when the transaction is restarted, it includes the new cookie. 1175 // Verify that when the transaction is restarted, it includes the new cookie.
1176 { 1176 {
1177 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); 1177 scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
1178 TestDelegate d; 1178 TestDelegate d;
1179 d.set_username(L"user"); 1179 d.set_username(L"user");
1180 d.set_password(L"secret"); 1180 d.set_password(L"secret");
1181 1181
1182 URLRequest r(url_requiring_auth, &d); 1182 URLRequest r(url_requiring_auth, &d);
1183 r.set_context(context); 1183 r.set_context(context);
1184 r.Start(); 1184 r.Start();
1185 1185
1186 MessageLoop::current()->Run(); 1186 MessageLoop::current()->Run();
1187 1187
1188 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); 1188 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
1189 1189
1190 // Make sure we sent the cookie in the restarted transaction. 1190 // Make sure we sent the cookie in the restarted transaction.
1191 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") 1191 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true")
1192 != std::string::npos); 1192 != std::string::npos);
1193 } 1193 }
1194 1194
1195 // Same test as above, except this time the restart is initiated earlier 1195 // Same test as above, except this time the restart is initiated earlier
1196 // (without user intervention since identity is embedded in the URL). 1196 // (without user intervention since identity is embedded in the URL).
1197 { 1197 {
1198 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); 1198 scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
1199 TestDelegate d; 1199 TestDelegate d;
1200 1200
1201 GURL::Replacements replacements; 1201 GURL::Replacements replacements;
1202 std::string username("user2"); 1202 std::string username("user2");
1203 std::string password("secret"); 1203 std::string password("secret");
1204 replacements.SetUsernameStr(username); 1204 replacements.SetUsernameStr(username);
1205 replacements.SetPasswordStr(password); 1205 replacements.SetPasswordStr(password);
1206 GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements); 1206 GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements);
1207 1207
1208 URLRequest r(url_with_identity, &d); 1208 URLRequest r(url_with_identity, &d);
1209 r.set_context(context); 1209 r.set_context(context);
1210 r.Start(); 1210 r.Start();
1211 1211
1212 MessageLoop::current()->Run(); 1212 MessageLoop::current()->Run();
1213 1213
1214 EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos); 1214 EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos);
1215 1215
1216 // Make sure we sent the cookie in the restarted transaction. 1216 // Make sure we sent the cookie in the restarted transaction.
1217 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") 1217 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true")
1218 != std::string::npos); 1218 != std::string::npos);
1219 } 1219 }
1220 } 1220 }
1221 1221
1222 TEST_F(URLRequestTest, DoNotSendCookies) { 1222 TEST_F(URLRequestTest, DoNotSendCookies) {
1223 scoped_refptr<HTTPTestServer> server = 1223 scoped_refptr<HTTPTestServer> server =
1224 HTTPTestServer::CreateServer(L"", NULL); 1224 HTTPTestServer::CreateServer(L"", NULL);
1225 ASSERT_TRUE(NULL != server.get()); 1225 ASSERT_TRUE(NULL != server.get());
1226 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); 1226 scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
1227 1227
1228 // Set up a cookie. 1228 // Set up a cookie.
1229 { 1229 {
1230 TestDelegate d; 1230 TestDelegate d;
1231 URLRequest req(server->TestServerPage("set-cookie?CookieToNotSend=1"), &d); 1231 URLRequest req(server->TestServerPage("set-cookie?CookieToNotSend=1"), &d);
1232 req.set_context(context); 1232 req.set_context(context);
1233 req.Start(); 1233 req.Start();
1234 MessageLoop::current()->Run(); 1234 MessageLoop::current()->Run();
1235 EXPECT_EQ(0, d.blocked_get_cookies_count()); 1235 EXPECT_EQ(0, d.blocked_get_cookies_count());
1236 EXPECT_EQ(0, d.blocked_set_cookie_count()); 1236 EXPECT_EQ(0, d.blocked_set_cookie_count());
(...skipping 28 matching lines...) Expand all
1265 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookiesBlocked. 1265 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookiesBlocked.
1266 EXPECT_EQ(0, d.blocked_get_cookies_count()); 1266 EXPECT_EQ(0, d.blocked_get_cookies_count());
1267 EXPECT_EQ(0, d.blocked_set_cookie_count()); 1267 EXPECT_EQ(0, d.blocked_set_cookie_count());
1268 } 1268 }
1269 } 1269 }
1270 1270
1271 TEST_F(URLRequestTest, DoNotSaveCookies) { 1271 TEST_F(URLRequestTest, DoNotSaveCookies) {
1272 scoped_refptr<HTTPTestServer> server = 1272 scoped_refptr<HTTPTestServer> server =
1273 HTTPTestServer::CreateServer(L"", NULL); 1273 HTTPTestServer::CreateServer(L"", NULL);
1274 ASSERT_TRUE(NULL != server.get()); 1274 ASSERT_TRUE(NULL != server.get());
1275 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); 1275 scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
1276 1276
1277 // Set up a cookie. 1277 // Set up a cookie.
1278 { 1278 {
1279 TestDelegate d; 1279 TestDelegate d;
1280 URLRequest req(server->TestServerPage("set-cookie?CookieToNotUpdate=2"), 1280 URLRequest req(server->TestServerPage("set-cookie?CookieToNotUpdate=2"),
1281 &d); 1281 &d);
1282 req.set_context(context); 1282 req.set_context(context);
1283 req.Start(); 1283 req.Start();
1284 MessageLoop::current()->Run(); 1284 MessageLoop::current()->Run();
1285 1285
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 1318
1319 EXPECT_EQ(0, d.blocked_get_cookies_count()); 1319 EXPECT_EQ(0, d.blocked_get_cookies_count());
1320 EXPECT_EQ(0, d.blocked_set_cookie_count()); 1320 EXPECT_EQ(0, d.blocked_set_cookie_count());
1321 } 1321 }
1322 } 1322 }
1323 1323
1324 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { 1324 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) {
1325 scoped_refptr<HTTPTestServer> server = 1325 scoped_refptr<HTTPTestServer> server =
1326 HTTPTestServer::CreateServer(L"", NULL); 1326 HTTPTestServer::CreateServer(L"", NULL);
1327 ASSERT_TRUE(NULL != server.get()); 1327 ASSERT_TRUE(NULL != server.get());
1328 scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext(); 1328 scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
1329 1329
1330 // Set up a cookie. 1330 // Set up a cookie.
1331 { 1331 {
1332 TestDelegate d; 1332 TestDelegate d;
1333 URLRequest req(server->TestServerPage("set-cookie?CookieToNotSend=1"), &d); 1333 URLRequest req(server->TestServerPage("set-cookie?CookieToNotSend=1"), &d);
1334 req.set_context(context); 1334 req.set_context(context);
1335 req.Start(); 1335 req.Start();
1336 MessageLoop::current()->Run(); 1336 MessageLoop::current()->Run();
1337 1337
1338 EXPECT_EQ(0, d.blocked_get_cookies_count()); 1338 EXPECT_EQ(0, d.blocked_get_cookies_count());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 1372
1373 EXPECT_EQ(1, d.blocked_get_cookies_count()); 1373 EXPECT_EQ(1, d.blocked_get_cookies_count());
1374 EXPECT_EQ(0, d.blocked_set_cookie_count()); 1374 EXPECT_EQ(0, d.blocked_set_cookie_count());
1375 } 1375 }
1376 } 1376 }
1377 1377
1378 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { 1378 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) {
1379 scoped_refptr<HTTPTestServer> server = 1379 scoped_refptr<HTTPTestServer> server =
1380 HTTPTestServer::CreateServer(L"", NULL); 1380 HTTPTestServer::CreateServer(L"", NULL);
1381 ASSERT_TRUE(NULL != server.get()); 1381 ASSERT_TRUE(NULL != server.get());
1382 scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext(); 1382 scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
1383 1383
1384 // Set up a cookie. 1384 // Set up a cookie.
1385 { 1385 {
1386 TestDelegate d; 1386 TestDelegate d;
1387 URLRequest req(server->TestServerPage("set-cookie?CookieToNotUpdate=2"), 1387 URLRequest req(server->TestServerPage("set-cookie?CookieToNotUpdate=2"),
1388 &d); 1388 &d);
1389 req.set_context(context); 1389 req.set_context(context);
1390 req.Start(); 1390 req.Start();
1391 MessageLoop::current()->Run(); 1391 MessageLoop::current()->Run();
1392 1392
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 1429
1430 EXPECT_EQ(0, d.blocked_get_cookies_count()); 1430 EXPECT_EQ(0, d.blocked_get_cookies_count());
1431 EXPECT_EQ(0, d.blocked_set_cookie_count()); 1431 EXPECT_EQ(0, d.blocked_set_cookie_count());
1432 } 1432 }
1433 } 1433 }
1434 1434
1435 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { 1435 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) {
1436 scoped_refptr<HTTPTestServer> server = 1436 scoped_refptr<HTTPTestServer> server =
1437 HTTPTestServer::CreateServer(L"", NULL); 1437 HTTPTestServer::CreateServer(L"", NULL);
1438 ASSERT_TRUE(NULL != server.get()); 1438 ASSERT_TRUE(NULL != server.get());
1439 scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext(); 1439 scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
1440 1440
1441 // Set up a cookie. 1441 // Set up a cookie.
1442 { 1442 {
1443 TestDelegate d; 1443 TestDelegate d;
1444 URLRequest req(server->TestServerPage("set-cookie?CookieToNotSend=1"), &d); 1444 URLRequest req(server->TestServerPage("set-cookie?CookieToNotSend=1"), &d);
1445 req.set_context(context); 1445 req.set_context(context);
1446 req.Start(); 1446 req.Start();
1447 MessageLoop::current()->Run(); 1447 MessageLoop::current()->Run();
1448 1448
1449 EXPECT_EQ(0, d.blocked_get_cookies_count()); 1449 EXPECT_EQ(0, d.blocked_get_cookies_count());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 1484
1485 EXPECT_EQ(1, d.blocked_get_cookies_count()); 1485 EXPECT_EQ(1, d.blocked_get_cookies_count());
1486 EXPECT_EQ(0, d.blocked_set_cookie_count()); 1486 EXPECT_EQ(0, d.blocked_set_cookie_count());
1487 } 1487 }
1488 } 1488 }
1489 1489
1490 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { 1490 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
1491 scoped_refptr<HTTPTestServer> server = 1491 scoped_refptr<HTTPTestServer> server =
1492 HTTPTestServer::CreateServer(L"", NULL); 1492 HTTPTestServer::CreateServer(L"", NULL);
1493 ASSERT_TRUE(NULL != server.get()); 1493 ASSERT_TRUE(NULL != server.get());
1494 scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext(); 1494 scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
1495 1495
1496 // Set up a cookie. 1496 // Set up a cookie.
1497 { 1497 {
1498 TestDelegate d; 1498 TestDelegate d;
1499 URLRequest req(server->TestServerPage("set-cookie?CookieToNotUpdate=2"), 1499 URLRequest req(server->TestServerPage("set-cookie?CookieToNotUpdate=2"),
1500 &d); 1500 &d);
1501 req.set_context(context); 1501 req.set_context(context);
1502 req.Start(); 1502 req.Start();
1503 MessageLoop::current()->Run(); 1503 MessageLoop::current()->Run();
1504 1504
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 1541
1542 EXPECT_EQ(0, d.blocked_get_cookies_count()); 1542 EXPECT_EQ(0, d.blocked_get_cookies_count());
1543 EXPECT_EQ(0, d.blocked_set_cookie_count()); 1543 EXPECT_EQ(0, d.blocked_set_cookie_count());
1544 } 1544 }
1545 } 1545 }
1546 1546
1547 TEST_F(URLRequestTest, CancelTest_During_CookiePolicy) { 1547 TEST_F(URLRequestTest, CancelTest_During_CookiePolicy) {
1548 scoped_refptr<HTTPTestServer> server = 1548 scoped_refptr<HTTPTestServer> server =
1549 HTTPTestServer::CreateServer(L"", NULL); 1549 HTTPTestServer::CreateServer(L"", NULL);
1550 ASSERT_TRUE(NULL != server.get()); 1550 ASSERT_TRUE(NULL != server.get());
1551 scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext(); 1551 scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
1552 1552
1553 TestCookiePolicy cookie_policy(TestCookiePolicy::ASYNC); 1553 TestCookiePolicy cookie_policy(TestCookiePolicy::ASYNC);
1554 context->set_cookie_policy(&cookie_policy); 1554 context->set_cookie_policy(&cookie_policy);
1555 1555
1556 // Set up a cookie. 1556 // Set up a cookie.
1557 { 1557 {
1558 TestDelegate d; 1558 TestDelegate d;
1559 URLRequest req(server->TestServerPage("set-cookie?A=1&B=2&C=3"), 1559 URLRequest req(server->TestServerPage("set-cookie?A=1&B=2&C=3"),
1560 &d); 1560 &d);
1561 req.set_context(context); 1561 req.set_context(context);
(...skipping 10 matching lines...) Expand all
1572 1572
1573 // Let the cookie policy complete. Make sure it handles the destruction of 1573 // Let the cookie policy complete. Make sure it handles the destruction of
1574 // the URLRequest properly. 1574 // the URLRequest properly.
1575 MessageLoop::current()->RunAllPending(); 1575 MessageLoop::current()->RunAllPending();
1576 } 1576 }
1577 1577
1578 TEST_F(URLRequestTest, CancelTest_During_OnGetCookiesBlocked) { 1578 TEST_F(URLRequestTest, CancelTest_During_OnGetCookiesBlocked) {
1579 scoped_refptr<HTTPTestServer> server = 1579 scoped_refptr<HTTPTestServer> server =
1580 HTTPTestServer::CreateServer(L"", NULL); 1580 HTTPTestServer::CreateServer(L"", NULL);
1581 ASSERT_TRUE(NULL != server.get()); 1581 ASSERT_TRUE(NULL != server.get());
1582 scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext(); 1582 scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
1583 1583
1584 TestCookiePolicy cookie_policy(TestCookiePolicy::NO_GET_COOKIES); 1584 TestCookiePolicy cookie_policy(TestCookiePolicy::NO_GET_COOKIES);
1585 context->set_cookie_policy(&cookie_policy); 1585 context->set_cookie_policy(&cookie_policy);
1586 1586
1587 // Set up a cookie. 1587 // Set up a cookie.
1588 { 1588 {
1589 TestDelegate d; 1589 TestDelegate d;
1590 d.set_cancel_in_get_cookies_blocked(true); 1590 d.set_cancel_in_get_cookies_blocked(true);
1591 URLRequest req(server->TestServerPage("set-cookie?A=1&B=2&C=3"), 1591 URLRequest req(server->TestServerPage("set-cookie?A=1&B=2&C=3"),
1592 &d); 1592 &d);
1593 req.set_context(context); 1593 req.set_context(context);
1594 req.Start(); // Triggers an asynchronous cookie policy check. 1594 req.Start(); // Triggers an asynchronous cookie policy check.
1595 1595
1596 MessageLoop::current()->Run(); 1596 MessageLoop::current()->Run();
1597 1597
1598 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status()); 1598 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status());
1599 1599
1600 EXPECT_EQ(1, d.blocked_get_cookies_count()); 1600 EXPECT_EQ(1, d.blocked_get_cookies_count());
1601 EXPECT_EQ(0, d.blocked_set_cookie_count()); 1601 EXPECT_EQ(0, d.blocked_set_cookie_count());
1602 } 1602 }
1603 1603
1604 context->set_cookie_policy(NULL); 1604 context->set_cookie_policy(NULL);
1605 } 1605 }
1606 1606
1607 TEST_F(URLRequestTest, CancelTest_During_OnSetCookieBlocked) { 1607 TEST_F(URLRequestTest, CancelTest_During_OnSetCookieBlocked) {
1608 scoped_refptr<HTTPTestServer> server = 1608 scoped_refptr<HTTPTestServer> server =
1609 HTTPTestServer::CreateServer(L"", NULL); 1609 HTTPTestServer::CreateServer(L"", NULL);
1610 ASSERT_TRUE(NULL != server.get()); 1610 ASSERT_TRUE(NULL != server.get());
1611 scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext(); 1611 scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
1612 1612
1613 TestCookiePolicy cookie_policy(TestCookiePolicy::NO_SET_COOKIE); 1613 TestCookiePolicy cookie_policy(TestCookiePolicy::NO_SET_COOKIE);
1614 context->set_cookie_policy(&cookie_policy); 1614 context->set_cookie_policy(&cookie_policy);
1615 1615
1616 // Set up a cookie. 1616 // Set up a cookie.
1617 { 1617 {
1618 TestDelegate d; 1618 TestDelegate d;
1619 d.set_cancel_in_set_cookie_blocked(true); 1619 d.set_cancel_in_set_cookie_blocked(true);
1620 URLRequest req(server->TestServerPage("set-cookie?A=1&B=2&C=3"), 1620 URLRequest req(server->TestServerPage("set-cookie?A=1&B=2&C=3"),
1621 &d); 1621 &d);
(...skipping 13 matching lines...) Expand all
1635 EXPECT_EQ(1, d.blocked_set_cookie_count()); 1635 EXPECT_EQ(1, d.blocked_set_cookie_count());
1636 } 1636 }
1637 1637
1638 context->set_cookie_policy(NULL); 1638 context->set_cookie_policy(NULL);
1639 } 1639 }
1640 1640
1641 TEST_F(URLRequestTest, CookiePolicy_ForceSession) { 1641 TEST_F(URLRequestTest, CookiePolicy_ForceSession) {
1642 scoped_refptr<HTTPTestServer> server = 1642 scoped_refptr<HTTPTestServer> server =
1643 HTTPTestServer::CreateServer(L"", NULL); 1643 HTTPTestServer::CreateServer(L"", NULL);
1644 ASSERT_TRUE(NULL != server.get()); 1644 ASSERT_TRUE(NULL != server.get());
1645 scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext(); 1645 scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
1646 1646
1647 TestCookiePolicy cookie_policy(TestCookiePolicy::FORCE_SESSION); 1647 TestCookiePolicy cookie_policy(TestCookiePolicy::FORCE_SESSION);
1648 context->set_cookie_policy(&cookie_policy); 1648 context->set_cookie_policy(&cookie_policy);
1649 1649
1650 // Set up a cookie. 1650 // Set up a cookie.
1651 { 1651 {
1652 TestDelegate d; 1652 TestDelegate d;
1653 URLRequest req(server->TestServerPage( 1653 URLRequest req(server->TestServerPage(
1654 "set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""), &d); 1654 "set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""), &d);
1655 req.set_context(context); 1655 req.set_context(context);
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 EXPECT_FALSE(d->received_data_before_response()); 2471 EXPECT_FALSE(d->received_data_before_response());
2472 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 2472 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
2473 } 2473 }
2474 } 2474 }
2475 2475
2476 // Check that default A-L header is sent. 2476 // Check that default A-L header is sent.
2477 TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) { 2477 TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) {
2478 ASSERT_TRUE(NULL != server_.get()); 2478 ASSERT_TRUE(NULL != server_.get());
2479 TestDelegate d; 2479 TestDelegate d;
2480 TestURLRequest req(server_->TestServerPage("echoheader?Accept-Language"), &d); 2480 TestURLRequest req(server_->TestServerPage("echoheader?Accept-Language"), &d);
2481 req.set_context(new URLRequestTestContext()); 2481 req.set_context(new TestURLRequestContext());
2482 req.Start(); 2482 req.Start();
2483 MessageLoop::current()->Run(); 2483 MessageLoop::current()->Run();
2484 EXPECT_EQ(req.context()->accept_language(), d.data_received()); 2484 EXPECT_EQ(req.context()->accept_language(), d.data_received());
2485 } 2485 }
2486 2486
2487 // Check that if request overrides the A-L header, the default is not appended. 2487 // Check that if request overrides the A-L header, the default is not appended.
2488 // See http://crbug.com/20894 2488 // See http://crbug.com/20894
2489 TEST_F(URLRequestTestHTTP, OverrideAcceptLanguage) { 2489 TEST_F(URLRequestTestHTTP, OverrideAcceptLanguage) {
2490 ASSERT_TRUE(NULL != server_.get()); 2490 ASSERT_TRUE(NULL != server_.get());
2491 TestDelegate d; 2491 TestDelegate d;
2492 TestURLRequest 2492 TestURLRequest
2493 req(server_->TestServerPage("echoheaderoverride?Accept-Language"), &d); 2493 req(server_->TestServerPage("echoheaderoverride?Accept-Language"), &d);
2494 req.set_context(new URLRequestTestContext()); 2494 req.set_context(new TestURLRequestContext());
2495 req.SetExtraRequestHeaders("Accept-Language: ru"); 2495 req.SetExtraRequestHeaders("Accept-Language: ru");
2496 req.Start(); 2496 req.Start();
2497 MessageLoop::current()->Run(); 2497 MessageLoop::current()->Run();
2498 EXPECT_EQ(std::string("ru"), d.data_received()); 2498 EXPECT_EQ(std::string("ru"), d.data_received());
2499 } 2499 }
2500 2500
2501 // Check that default A-C header is sent. 2501 // Check that default A-C header is sent.
2502 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) { 2502 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) {
2503 ASSERT_TRUE(NULL != server_.get()); 2503 ASSERT_TRUE(NULL != server_.get());
2504 TestDelegate d; 2504 TestDelegate d;
2505 TestURLRequest req(server_->TestServerPage("echoheader?Accept-Charset"), &d); 2505 TestURLRequest req(server_->TestServerPage("echoheader?Accept-Charset"), &d);
2506 req.set_context(new URLRequestTestContext()); 2506 req.set_context(new TestURLRequestContext());
2507 req.Start(); 2507 req.Start();
2508 MessageLoop::current()->Run(); 2508 MessageLoop::current()->Run();
2509 EXPECT_EQ(req.context()->accept_charset(), d.data_received()); 2509 EXPECT_EQ(req.context()->accept_charset(), d.data_received());
2510 } 2510 }
2511 2511
2512 // Check that if request overrides the A-C header, the default is not appended. 2512 // Check that if request overrides the A-C header, the default is not appended.
2513 // See http://crbug.com/20894 2513 // See http://crbug.com/20894
2514 TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) { 2514 TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) {
2515 ASSERT_TRUE(NULL != server_.get()); 2515 ASSERT_TRUE(NULL != server_.get());
2516 TestDelegate d; 2516 TestDelegate d;
2517 TestURLRequest 2517 TestURLRequest
2518 req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d); 2518 req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d);
2519 req.set_context(new URLRequestTestContext()); 2519 req.set_context(new TestURLRequestContext());
2520 req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); 2520 req.SetExtraRequestHeaders("Accept-Charset: koi-8r");
2521 req.Start(); 2521 req.Start();
2522 MessageLoop::current()->Run(); 2522 MessageLoop::current()->Run();
2523 EXPECT_EQ(std::string("koi-8r"), d.data_received()); 2523 EXPECT_EQ(std::string("koi-8r"), d.data_received());
2524 } 2524 }
OLDNEW
« chrome/browser/history/redirect_uitest.cc ('K') | « net/url_request/url_request_unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698