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 "net/url_request/url_fetcher_impl.h" | 5 #include "net/url_request/url_fetcher_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "build/build_config.h" | 32 #include "build/build_config.h" |
33 #include "crypto/nss_util.h" | 33 #include "crypto/nss_util.h" |
34 #include "net/base/elements_upload_data_stream.h" | 34 #include "net/base/elements_upload_data_stream.h" |
35 #include "net/base/network_change_notifier.h" | 35 #include "net/base/network_change_notifier.h" |
36 #include "net/base/upload_bytes_element_reader.h" | 36 #include "net/base/upload_bytes_element_reader.h" |
37 #include "net/base/upload_element_reader.h" | 37 #include "net/base/upload_element_reader.h" |
38 #include "net/base/upload_file_element_reader.h" | 38 #include "net/base/upload_file_element_reader.h" |
39 #include "net/dns/mock_host_resolver.h" | 39 #include "net/dns/mock_host_resolver.h" |
40 #include "net/http/http_response_headers.h" | 40 #include "net/http/http_response_headers.h" |
41 #include "net/test/embedded_test_server/embedded_test_server.h" | 41 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 42 #include "net/test/gtest_util.h" |
42 #include "net/url_request/url_fetcher_delegate.h" | 43 #include "net/url_request/url_fetcher_delegate.h" |
43 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
44 #include "net/url_request/url_request_test_util.h" | 45 #include "net/url_request/url_request_test_util.h" |
45 #include "net/url_request/url_request_throttler_manager.h" | 46 #include "net/url_request/url_request_throttler_manager.h" |
| 47 #include "testing/gmock/include/gmock/gmock.h" |
46 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
47 | 49 |
48 #if defined(USE_NSS_CERTS) | 50 #if defined(USE_NSS_CERTS) |
49 #include "net/cert_net/nss_ocsp.h" | 51 #include "net/cert_net/nss_ocsp.h" |
50 #endif | 52 #endif |
51 | 53 |
52 namespace net { | 54 namespace net { |
53 | 55 |
54 using base::Time; | 56 using base::Time; |
55 using base::TimeDelta; | 57 using base::TimeDelta; |
| 58 using net::test::IsError; |
| 59 using net::test::IsOk; |
56 | 60 |
57 // TODO(eroman): Add a regression test for http://crbug.com/40505. | 61 // TODO(eroman): Add a regression test for http://crbug.com/40505. |
58 | 62 |
59 namespace { | 63 namespace { |
60 | 64 |
61 // TODO(akalin): Move all the test data to somewhere under net/. | 65 // TODO(akalin): Move all the test data to somewhere under net/. |
62 const base::FilePath::CharType kDocRoot[] = | 66 const base::FilePath::CharType kDocRoot[] = |
63 FILE_PATH_LITERAL("net/data/url_fetcher_impl_unittest"); | 67 FILE_PATH_LITERAL("net/data/url_fetcher_impl_unittest"); |
64 const char kTestServerFilePrefix[] = "/"; | 68 const char kTestServerFilePrefix[] = "/"; |
65 | 69 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 ASSERT_FALSE(delegate.did_complete()); | 560 ASSERT_FALSE(delegate.did_complete()); |
557 | 561 |
558 // A network change notification aborts the connect job. | 562 // A network change notification aborts the connect job. |
559 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 563 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
560 delegate.WaitForComplete(); | 564 delegate.WaitForComplete(); |
561 EXPECT_FALSE(mock_resolver->has_pending_requests()); | 565 EXPECT_FALSE(mock_resolver->has_pending_requests()); |
562 | 566 |
563 // And the owner of the fetcher gets the ERR_NETWORK_CHANGED error. | 567 // And the owner of the fetcher gets the ERR_NETWORK_CHANGED error. |
564 EXPECT_EQ(hanging_url(), delegate.fetcher()->GetOriginalURL()); | 568 EXPECT_EQ(hanging_url(), delegate.fetcher()->GetOriginalURL()); |
565 ASSERT_FALSE(delegate.fetcher()->GetStatus().is_success()); | 569 ASSERT_FALSE(delegate.fetcher()->GetStatus().is_success()); |
566 EXPECT_EQ(ERR_NETWORK_CHANGED, delegate.fetcher()->GetStatus().error()); | 570 EXPECT_THAT(delegate.fetcher()->GetStatus().error(), |
| 571 IsError(ERR_NETWORK_CHANGED)); |
567 } | 572 } |
568 | 573 |
569 TEST_F(URLFetcherTest, RetryOnNetworkChangedAndFail) { | 574 TEST_F(URLFetcherTest, RetryOnNetworkChangedAndFail) { |
570 EXPECT_EQ(0, GetNumFetcherCores()); | 575 EXPECT_EQ(0, GetNumFetcherCores()); |
571 | 576 |
572 scoped_refptr<FetcherTestURLRequestContextGetter> context_getter( | 577 scoped_refptr<FetcherTestURLRequestContextGetter> context_getter( |
573 CreateSameThreadContextGetter()); | 578 CreateSameThreadContextGetter()); |
574 // Force context creation. | 579 // Force context creation. |
575 context_getter->GetURLRequestContext(); | 580 context_getter->GetURLRequestContext(); |
576 MockHostResolver* mock_resolver = context_getter->context()->mock_resolver(); | 581 MockHostResolver* mock_resolver = context_getter->context()->mock_resolver(); |
(...skipping 26 matching lines...) Expand all Loading... |
603 | 608 |
604 // A 4th failure doesn't trigger another retry, and propagates the error | 609 // A 4th failure doesn't trigger another retry, and propagates the error |
605 // to the owner of the fetcher. | 610 // to the owner of the fetcher. |
606 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 611 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
607 delegate.WaitForComplete(); | 612 delegate.WaitForComplete(); |
608 EXPECT_FALSE(mock_resolver->has_pending_requests()); | 613 EXPECT_FALSE(mock_resolver->has_pending_requests()); |
609 | 614 |
610 // And the owner of the fetcher gets the ERR_NETWORK_CHANGED error. | 615 // And the owner of the fetcher gets the ERR_NETWORK_CHANGED error. |
611 EXPECT_EQ(hanging_url(), delegate.fetcher()->GetOriginalURL()); | 616 EXPECT_EQ(hanging_url(), delegate.fetcher()->GetOriginalURL()); |
612 ASSERT_FALSE(delegate.fetcher()->GetStatus().is_success()); | 617 ASSERT_FALSE(delegate.fetcher()->GetStatus().is_success()); |
613 EXPECT_EQ(ERR_NETWORK_CHANGED, delegate.fetcher()->GetStatus().error()); | 618 EXPECT_THAT(delegate.fetcher()->GetStatus().error(), |
| 619 IsError(ERR_NETWORK_CHANGED)); |
614 } | 620 } |
615 | 621 |
616 TEST_F(URLFetcherTest, RetryOnNetworkChangedAndSucceed) { | 622 TEST_F(URLFetcherTest, RetryOnNetworkChangedAndSucceed) { |
617 EXPECT_EQ(0, GetNumFetcherCores()); | 623 EXPECT_EQ(0, GetNumFetcherCores()); |
618 | 624 |
619 scoped_refptr<FetcherTestURLRequestContextGetter> context_getter( | 625 scoped_refptr<FetcherTestURLRequestContextGetter> context_getter( |
620 CreateSameThreadContextGetter()); | 626 CreateSameThreadContextGetter()); |
621 // Force context creation. | 627 // Force context creation. |
622 context_getter->GetURLRequestContext(); | 628 context_getter->GetURLRequestContext(); |
623 MockHostResolver* mock_resolver = context_getter->context()->mock_resolver(); | 629 MockHostResolver* mock_resolver = context_getter->context()->mock_resolver(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); | 835 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); |
830 | 836 |
831 // Try to append data. | 837 // Try to append data. |
832 delegate.fetcher()->AppendChunkToUpload("kCreateUploadStreamBody", false); | 838 delegate.fetcher()->AppendChunkToUpload("kCreateUploadStreamBody", false); |
833 delegate.fetcher()->AppendChunkToUpload("kCreateUploadStreamBody", true); | 839 delegate.fetcher()->AppendChunkToUpload("kCreateUploadStreamBody", true); |
834 | 840 |
835 delegate.WaitForComplete(); | 841 delegate.WaitForComplete(); |
836 | 842 |
837 // Make sure the request failed, as expected. | 843 // Make sure the request failed, as expected. |
838 EXPECT_FALSE(delegate.fetcher()->GetStatus().is_success()); | 844 EXPECT_FALSE(delegate.fetcher()->GetStatus().is_success()); |
839 EXPECT_EQ(ERR_UNSAFE_PORT, delegate.fetcher()->GetStatus().error()); | 845 EXPECT_THAT(delegate.fetcher()->GetStatus().error(), |
| 846 IsError(ERR_UNSAFE_PORT)); |
840 } | 847 } |
841 | 848 |
842 // Checks that upload progress increases over time, never exceeds what's already | 849 // Checks that upload progress increases over time, never exceeds what's already |
843 // been sent, and adds a chunk whenever all previously appended chunks have | 850 // been sent, and adds a chunk whenever all previously appended chunks have |
844 // been uploaded. | 851 // been uploaded. |
845 class CheckUploadProgressDelegate : public WaitingURLFetcherDelegate { | 852 class CheckUploadProgressDelegate : public WaitingURLFetcherDelegate { |
846 public: | 853 public: |
847 CheckUploadProgressDelegate() | 854 CheckUploadProgressDelegate() |
848 : chunk_(1 << 16, 'a'), num_chunks_appended_(0), last_seen_progress_(0) {} | 855 : chunk_(1 << 16, 'a'), num_chunks_appended_(0), last_seen_progress_(0) {} |
849 ~CheckUploadProgressDelegate() override {} | 856 ~CheckUploadProgressDelegate() override {} |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 WaitingURLFetcherDelegate delegate; | 1073 WaitingURLFetcherDelegate delegate; |
1067 delegate.CreateFetcher( | 1074 delegate.CreateFetcher( |
1068 test_server_->GetURL(std::string("/server-redirect?") + kRedirectTarget), | 1075 test_server_->GetURL(std::string("/server-redirect?") + kRedirectTarget), |
1069 URLFetcher::GET, CreateSameThreadContextGetter()); | 1076 URLFetcher::GET, CreateSameThreadContextGetter()); |
1070 delegate.fetcher()->SetStopOnRedirect(true); | 1077 delegate.fetcher()->SetStopOnRedirect(true); |
1071 delegate.StartFetcherAndWait(); | 1078 delegate.StartFetcherAndWait(); |
1072 | 1079 |
1073 EXPECT_EQ(GURL(kRedirectTarget), delegate.fetcher()->GetURL()); | 1080 EXPECT_EQ(GURL(kRedirectTarget), delegate.fetcher()->GetURL()); |
1074 EXPECT_EQ(URLRequestStatus::CANCELED, | 1081 EXPECT_EQ(URLRequestStatus::CANCELED, |
1075 delegate.fetcher()->GetStatus().status()); | 1082 delegate.fetcher()->GetStatus().status()); |
1076 EXPECT_EQ(ERR_ABORTED, delegate.fetcher()->GetStatus().error()); | 1083 EXPECT_THAT(delegate.fetcher()->GetStatus().error(), IsError(ERR_ABORTED)); |
1077 EXPECT_EQ(301, delegate.fetcher()->GetResponseCode()); | 1084 EXPECT_EQ(301, delegate.fetcher()->GetResponseCode()); |
1078 } | 1085 } |
1079 | 1086 |
1080 TEST_F(URLFetcherTest, ThrottleOnRepeatedFetches) { | 1087 TEST_F(URLFetcherTest, ThrottleOnRepeatedFetches) { |
1081 base::Time start_time = Time::Now(); | 1088 base::Time start_time = Time::Now(); |
1082 GURL url(test_server_->GetURL(kDefaultResponsePath)); | 1089 GURL url(test_server_->GetURL(kDefaultResponsePath)); |
1083 | 1090 |
1084 scoped_refptr<FetcherTestURLRequestContextGetter> context_getter( | 1091 scoped_refptr<FetcherTestURLRequestContextGetter> context_getter( |
1085 CreateSameThreadContextGetter()); | 1092 CreateSameThreadContextGetter()); |
1086 | 1093 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 delegate2.CreateFetcher(hanging_url(), URLFetcher::GET, context_getter); | 1383 delegate2.CreateFetcher(hanging_url(), URLFetcher::GET, context_getter); |
1377 delegate2.fetcher()->Start(); | 1384 delegate2.fetcher()->Start(); |
1378 | 1385 |
1379 // Check that shutting down the getter cancels the request synchronously, | 1386 // Check that shutting down the getter cancels the request synchronously, |
1380 // allowing the context to be destroyed. | 1387 // allowing the context to be destroyed. |
1381 context_getter->Shutdown(); | 1388 context_getter->Shutdown(); |
1382 | 1389 |
1383 // Wait for the first fetcher, make sure it failed. | 1390 // Wait for the first fetcher, make sure it failed. |
1384 delegate1.WaitForComplete(); | 1391 delegate1.WaitForComplete(); |
1385 EXPECT_FALSE(delegate1.fetcher()->GetStatus().is_success()); | 1392 EXPECT_FALSE(delegate1.fetcher()->GetStatus().is_success()); |
1386 EXPECT_EQ(ERR_CONTEXT_SHUT_DOWN, delegate1.fetcher()->GetStatus().error()); | 1393 EXPECT_THAT(delegate1.fetcher()->GetStatus().error(), |
| 1394 IsError(ERR_CONTEXT_SHUT_DOWN)); |
1387 | 1395 |
1388 // Wait for the second fetcher, make sure it failed. | 1396 // Wait for the second fetcher, make sure it failed. |
1389 delegate2.WaitForComplete(); | 1397 delegate2.WaitForComplete(); |
1390 EXPECT_FALSE(delegate2.fetcher()->GetStatus().is_success()); | 1398 EXPECT_FALSE(delegate2.fetcher()->GetStatus().is_success()); |
1391 EXPECT_EQ(ERR_CONTEXT_SHUT_DOWN, delegate2.fetcher()->GetStatus().error()); | 1399 EXPECT_THAT(delegate2.fetcher()->GetStatus().error(), |
| 1400 IsError(ERR_CONTEXT_SHUT_DOWN)); |
1392 | 1401 |
1393 // New fetchers should automatically fail without making new requests. This | 1402 // New fetchers should automatically fail without making new requests. This |
1394 // should follow the same path as the second fetcher, but best to be safe. | 1403 // should follow the same path as the second fetcher, but best to be safe. |
1395 WaitingURLFetcherDelegate delegate3; | 1404 WaitingURLFetcherDelegate delegate3; |
1396 delegate3.CreateFetcher(hanging_url(), URLFetcher::GET, context_getter); | 1405 delegate3.CreateFetcher(hanging_url(), URLFetcher::GET, context_getter); |
1397 delegate3.fetcher()->Start(); | 1406 delegate3.fetcher()->Start(); |
1398 delegate3.WaitForComplete(); | 1407 delegate3.WaitForComplete(); |
1399 EXPECT_FALSE(delegate3.fetcher()->GetStatus().is_success()); | 1408 EXPECT_FALSE(delegate3.fetcher()->GetStatus().is_success()); |
1400 EXPECT_EQ(ERR_CONTEXT_SHUT_DOWN, delegate3.fetcher()->GetStatus().error()); | 1409 EXPECT_THAT(delegate3.fetcher()->GetStatus().error(), |
| 1410 IsError(ERR_CONTEXT_SHUT_DOWN)); |
1401 } | 1411 } |
1402 | 1412 |
1403 TEST_F(URLFetcherTest, ShutdownCrossThread) { | 1413 TEST_F(URLFetcherTest, ShutdownCrossThread) { |
1404 scoped_refptr<FetcherTestURLRequestContextGetter> context_getter( | 1414 scoped_refptr<FetcherTestURLRequestContextGetter> context_getter( |
1405 CreateCrossThreadContextGetter()); | 1415 CreateCrossThreadContextGetter()); |
1406 | 1416 |
1407 WaitingURLFetcherDelegate delegate1; | 1417 WaitingURLFetcherDelegate delegate1; |
1408 delegate1.CreateFetcher(hanging_url(), URLFetcher::GET, context_getter); | 1418 delegate1.CreateFetcher(hanging_url(), URLFetcher::GET, context_getter); |
1409 delegate1.fetcher()->Start(); | 1419 delegate1.fetcher()->Start(); |
1410 // Check that shutting the context getter lets the context be destroyed safely | 1420 // Check that shutting the context getter lets the context be destroyed safely |
1411 // and cancels the request. | 1421 // and cancels the request. |
1412 context_getter->Shutdown(); | 1422 context_getter->Shutdown(); |
1413 delegate1.WaitForComplete(); | 1423 delegate1.WaitForComplete(); |
1414 EXPECT_FALSE(delegate1.fetcher()->GetStatus().is_success()); | 1424 EXPECT_FALSE(delegate1.fetcher()->GetStatus().is_success()); |
1415 EXPECT_EQ(ERR_CONTEXT_SHUT_DOWN, delegate1.fetcher()->GetStatus().error()); | 1425 EXPECT_THAT(delegate1.fetcher()->GetStatus().error(), |
| 1426 IsError(ERR_CONTEXT_SHUT_DOWN)); |
1416 | 1427 |
1417 // New requests should automatically fail without making new requests. | 1428 // New requests should automatically fail without making new requests. |
1418 WaitingURLFetcherDelegate delegate2; | 1429 WaitingURLFetcherDelegate delegate2; |
1419 delegate2.CreateFetcher(hanging_url(), URLFetcher::GET, context_getter); | 1430 delegate2.CreateFetcher(hanging_url(), URLFetcher::GET, context_getter); |
1420 delegate2.StartFetcherAndWait(); | 1431 delegate2.StartFetcherAndWait(); |
1421 EXPECT_FALSE(delegate2.fetcher()->GetStatus().is_success()); | 1432 EXPECT_FALSE(delegate2.fetcher()->GetStatus().is_success()); |
1422 EXPECT_EQ(ERR_CONTEXT_SHUT_DOWN, delegate2.fetcher()->GetStatus().error()); | 1433 EXPECT_THAT(delegate2.fetcher()->GetStatus().error(), |
| 1434 IsError(ERR_CONTEXT_SHUT_DOWN)); |
1423 } | 1435 } |
1424 | 1436 |
1425 // Get a small file. | 1437 // Get a small file. |
1426 TEST_F(URLFetcherTest, FileTestSmallGet) { | 1438 TEST_F(URLFetcherTest, FileTestSmallGet) { |
1427 const char kFileToFetch[] = "simple.html"; | 1439 const char kFileToFetch[] = "simple.html"; |
1428 | 1440 |
1429 base::ScopedTempDir temp_dir; | 1441 base::ScopedTempDir temp_dir; |
1430 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1442 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1431 base::FilePath out_path = temp_dir.path().AppendASCII(kFileToFetch); | 1443 base::FilePath out_path = temp_dir.path().AppendASCII(kFileToFetch); |
1432 SaveFileTest(kFileToFetch, false, out_path, false); | 1444 SaveFileTest(kFileToFetch, false, out_path, false); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 WaitingURLFetcherDelegate delegate; | 1496 WaitingURLFetcherDelegate delegate; |
1485 delegate.CreateFetcher( | 1497 delegate.CreateFetcher( |
1486 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), | 1498 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
1487 URLFetcher::GET, CreateSameThreadContextGetter()); | 1499 URLFetcher::GET, CreateSameThreadContextGetter()); |
1488 delegate.fetcher()->SaveResponseToFileAtPath( | 1500 delegate.fetcher()->SaveResponseToFileAtPath( |
1489 out_path, scoped_refptr<base::SingleThreadTaskRunner>( | 1501 out_path, scoped_refptr<base::SingleThreadTaskRunner>( |
1490 base::ThreadTaskRunnerHandle::Get())); | 1502 base::ThreadTaskRunnerHandle::Get())); |
1491 delegate.StartFetcherAndWait(); | 1503 delegate.StartFetcherAndWait(); |
1492 | 1504 |
1493 EXPECT_FALSE(delegate.fetcher()->GetStatus().is_success()); | 1505 EXPECT_FALSE(delegate.fetcher()->GetStatus().is_success()); |
1494 EXPECT_EQ(ERR_ACCESS_DENIED, delegate.fetcher()->GetStatus().error()); | 1506 EXPECT_THAT(delegate.fetcher()->GetStatus().error(), |
| 1507 IsError(ERR_ACCESS_DENIED)); |
1495 } | 1508 } |
1496 | 1509 |
1497 // Get a small file and save it to a temp file. | 1510 // Get a small file and save it to a temp file. |
1498 TEST_F(URLFetcherTest, TempFileTestSmallGet) { | 1511 TEST_F(URLFetcherTest, TempFileTestSmallGet) { |
1499 SaveFileTest("simple.html", true, base::FilePath(), false); | 1512 SaveFileTest("simple.html", true, base::FilePath(), false); |
1500 } | 1513 } |
1501 | 1514 |
1502 // Get a file large enough to require more than one read into URLFetcher::Core's | 1515 // Get a file large enough to require more than one read into URLFetcher::Core's |
1503 // IOBuffer and save it to a temp file. | 1516 // IOBuffer and save it to a temp file. |
1504 TEST_F(URLFetcherTest, TempFileTestLargeGet) { | 1517 TEST_F(URLFetcherTest, TempFileTestLargeGet) { |
1505 SaveFileTest("animate1.gif", true, base::FilePath(), false); | 1518 SaveFileTest("animate1.gif", true, base::FilePath(), false); |
1506 } | 1519 } |
1507 | 1520 |
1508 // If the caller takes the ownership of the temp file, check that the file | 1521 // If the caller takes the ownership of the temp file, check that the file |
1509 // persists even after URLFetcher is gone. | 1522 // persists even after URLFetcher is gone. |
1510 TEST_F(URLFetcherTest, TempFileTestTakeOwnership) { | 1523 TEST_F(URLFetcherTest, TempFileTestTakeOwnership) { |
1511 SaveFileTest("simple.html", true, base::FilePath(), true); | 1524 SaveFileTest("simple.html", true, base::FilePath(), true); |
1512 } | 1525 } |
1513 | 1526 |
1514 TEST_F(URLFetcherBadHTTPSTest, BadHTTPS) { | 1527 TEST_F(URLFetcherBadHTTPSTest, BadHTTPS) { |
1515 WaitingURLFetcherDelegate delegate; | 1528 WaitingURLFetcherDelegate delegate; |
1516 delegate.CreateFetcher(test_server_->GetURL(kDefaultResponsePath), | 1529 delegate.CreateFetcher(test_server_->GetURL(kDefaultResponsePath), |
1517 URLFetcher::GET, CreateSameThreadContextGetter()); | 1530 URLFetcher::GET, CreateSameThreadContextGetter()); |
1518 delegate.StartFetcherAndWait(); | 1531 delegate.StartFetcherAndWait(); |
1519 | 1532 |
1520 EXPECT_EQ(URLRequestStatus::CANCELED, | 1533 EXPECT_EQ(URLRequestStatus::CANCELED, |
1521 delegate.fetcher()->GetStatus().status()); | 1534 delegate.fetcher()->GetStatus().status()); |
1522 EXPECT_EQ(ERR_ABORTED, delegate.fetcher()->GetStatus().error()); | 1535 EXPECT_THAT(delegate.fetcher()->GetStatus().error(), IsError(ERR_ABORTED)); |
1523 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); | 1536 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); |
1524 EXPECT_FALSE(delegate.fetcher()->GetResponseHeaders()); | 1537 EXPECT_FALSE(delegate.fetcher()->GetResponseHeaders()); |
1525 std::string data; | 1538 std::string data; |
1526 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); | 1539 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); |
1527 EXPECT_TRUE(data.empty()); | 1540 EXPECT_TRUE(data.empty()); |
1528 } | 1541 } |
1529 | 1542 |
1530 } // namespace | 1543 } // namespace |
1531 | 1544 |
1532 } // namespace net | 1545 } // namespace net |
OLD | NEW |