| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #endif | 10 #endif |
| (...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 | 1752 |
| 1753 // Make sure that URLRequest calls SetPriority on a job before calling | 1753 // Make sure that URLRequest calls SetPriority on a job before calling |
| 1754 // Start on it. | 1754 // Start on it. |
| 1755 TEST_F(URLRequestTest, SetJobPriorityBeforeJobStart) { | 1755 TEST_F(URLRequestTest, SetJobPriorityBeforeJobStart) { |
| 1756 TestDelegate d; | 1756 TestDelegate d; |
| 1757 URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_); | 1757 URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_); |
| 1758 EXPECT_EQ(DEFAULT_PRIORITY, req.priority()); | 1758 EXPECT_EQ(DEFAULT_PRIORITY, req.priority()); |
| 1759 | 1759 |
| 1760 scoped_refptr<URLRequestTestJob> job = | 1760 scoped_refptr<URLRequestTestJob> job = |
| 1761 new URLRequestTestJob(&req, &default_network_delegate_); | 1761 new URLRequestTestJob(&req, &default_network_delegate_); |
| 1762 AddTestInterceptor()->set_main_intercept_job(job); | 1762 AddTestInterceptor()->set_main_intercept_job(job.get()); |
| 1763 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); | 1763 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); |
| 1764 | 1764 |
| 1765 req.SetPriority(LOW); | 1765 req.SetPriority(LOW); |
| 1766 | 1766 |
| 1767 req.Start(); | 1767 req.Start(); |
| 1768 EXPECT_EQ(LOW, job->priority()); | 1768 EXPECT_EQ(LOW, job->priority()); |
| 1769 } | 1769 } |
| 1770 | 1770 |
| 1771 // Make sure that URLRequest passes on its priority updates to its | 1771 // Make sure that URLRequest passes on its priority updates to its |
| 1772 // job. | 1772 // job. |
| 1773 TEST_F(URLRequestTest, SetJobPriority) { | 1773 TEST_F(URLRequestTest, SetJobPriority) { |
| 1774 TestDelegate d; | 1774 TestDelegate d; |
| 1775 URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_); | 1775 URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_); |
| 1776 | 1776 |
| 1777 scoped_refptr<URLRequestTestJob> job = | 1777 scoped_refptr<URLRequestTestJob> job = |
| 1778 new URLRequestTestJob(&req, &default_network_delegate_); | 1778 new URLRequestTestJob(&req, &default_network_delegate_); |
| 1779 AddTestInterceptor()->set_main_intercept_job(job); | 1779 AddTestInterceptor()->set_main_intercept_job(job.get()); |
| 1780 | 1780 |
| 1781 req.SetPriority(LOW); | 1781 req.SetPriority(LOW); |
| 1782 req.Start(); | 1782 req.Start(); |
| 1783 EXPECT_EQ(LOW, job->priority()); | 1783 EXPECT_EQ(LOW, job->priority()); |
| 1784 | 1784 |
| 1785 req.SetPriority(MEDIUM); | 1785 req.SetPriority(MEDIUM); |
| 1786 EXPECT_EQ(MEDIUM, req.priority()); | 1786 EXPECT_EQ(MEDIUM, req.priority()); |
| 1787 EXPECT_EQ(MEDIUM, job->priority()); | 1787 EXPECT_EQ(MEDIUM, job->priority()); |
| 1788 } | 1788 } |
| 1789 | 1789 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1805 }; | 1805 }; |
| 1806 | 1806 |
| 1807 TEST_F(URLRequestTest, DelayedCookieCallback) { | 1807 TEST_F(URLRequestTest, DelayedCookieCallback) { |
| 1808 LocalHttpTestServer test_server; | 1808 LocalHttpTestServer test_server; |
| 1809 ASSERT_TRUE(test_server.Start()); | 1809 ASSERT_TRUE(test_server.Start()); |
| 1810 | 1810 |
| 1811 TestURLRequestContext context; | 1811 TestURLRequestContext context; |
| 1812 scoped_refptr<DelayedCookieMonster> delayed_cm = | 1812 scoped_refptr<DelayedCookieMonster> delayed_cm = |
| 1813 new DelayedCookieMonster(); | 1813 new DelayedCookieMonster(); |
| 1814 scoped_refptr<CookieStore> cookie_store = delayed_cm; | 1814 scoped_refptr<CookieStore> cookie_store = delayed_cm; |
| 1815 context.set_cookie_store(delayed_cm); | 1815 context.set_cookie_store(delayed_cm.get()); |
| 1816 | 1816 |
| 1817 // Set up a cookie. | 1817 // Set up a cookie. |
| 1818 { | 1818 { |
| 1819 TestNetworkDelegate network_delegate; | 1819 TestNetworkDelegate network_delegate; |
| 1820 context.set_network_delegate(&network_delegate); | 1820 context.set_network_delegate(&network_delegate); |
| 1821 TestDelegate d; | 1821 TestDelegate d; |
| 1822 URLRequest req( | 1822 URLRequest req( |
| 1823 test_server.GetURL("set-cookie?CookieToNotSend=1"), &d, &context); | 1823 test_server.GetURL("set-cookie?CookieToNotSend=1"), &d, &context); |
| 1824 req.Start(); | 1824 req.Start(); |
| 1825 base::MessageLoop::current()->Run(); | 1825 base::MessageLoop::current()->Run(); |
| (...skipping 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4568 ASSERT_TRUE(test_server_.Start()); | 4568 ASSERT_TRUE(test_server_.Start()); |
| 4569 | 4569 |
| 4570 TestDelegate d; | 4570 TestDelegate d; |
| 4571 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); | 4571 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); |
| 4572 EXPECT_EQ(DEFAULT_PRIORITY, req.priority()); | 4572 EXPECT_EQ(DEFAULT_PRIORITY, req.priority()); |
| 4573 | 4573 |
| 4574 scoped_refptr<URLRequestRedirectJob> redirect_job = | 4574 scoped_refptr<URLRequestRedirectJob> redirect_job = |
| 4575 new URLRequestRedirectJob( | 4575 new URLRequestRedirectJob( |
| 4576 &req, &default_network_delegate_, test_server_.GetURL("echo"), | 4576 &req, &default_network_delegate_, test_server_.GetURL("echo"), |
| 4577 URLRequestRedirectJob::REDIRECT_302_FOUND); | 4577 URLRequestRedirectJob::REDIRECT_302_FOUND); |
| 4578 AddTestInterceptor()->set_main_intercept_job(redirect_job); | 4578 AddTestInterceptor()->set_main_intercept_job(redirect_job.get()); |
| 4579 | 4579 |
| 4580 req.SetPriority(LOW); | 4580 req.SetPriority(LOW); |
| 4581 req.Start(); | 4581 req.Start(); |
| 4582 EXPECT_TRUE(req.is_pending()); | 4582 EXPECT_TRUE(req.is_pending()); |
| 4583 | 4583 |
| 4584 scoped_refptr<URLRequestTestJob> job = | 4584 scoped_refptr<URLRequestTestJob> job = |
| 4585 new URLRequestTestJob(&req, &default_network_delegate_); | 4585 new URLRequestTestJob(&req, &default_network_delegate_); |
| 4586 AddTestInterceptor()->set_main_intercept_job(job); | 4586 AddTestInterceptor()->set_main_intercept_job(job.get()); |
| 4587 | 4587 |
| 4588 // Should trigger |job| to be started. | 4588 // Should trigger |job| to be started. |
| 4589 base::MessageLoop::current()->Run(); | 4589 base::MessageLoop::current()->Run(); |
| 4590 EXPECT_EQ(LOW, job->priority()); | 4590 EXPECT_EQ(LOW, job->priority()); |
| 4591 } | 4591 } |
| 4592 | 4592 |
| 4593 class HTTPSRequestTest : public testing::Test { | 4593 class HTTPSRequestTest : public testing::Test { |
| 4594 public: | 4594 public: |
| 4595 HTTPSRequestTest() : default_context_(true) { | 4595 HTTPSRequestTest() : default_context_(true) { |
| 4596 default_context_.set_network_delegate(&default_network_delegate_); | 4596 default_context_.set_network_delegate(&default_network_delegate_); |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5175 kOCSPTestCertPolicy)) { | 5175 kOCSPTestCertPolicy)) { |
| 5176 } | 5176 } |
| 5177 | 5177 |
| 5178 virtual void SetUp() OVERRIDE { | 5178 virtual void SetUp() OVERRIDE { |
| 5179 SetupContext(&context_); | 5179 SetupContext(&context_); |
| 5180 context_.Init(); | 5180 context_.Init(); |
| 5181 | 5181 |
| 5182 scoped_refptr<net::X509Certificate> root_cert = | 5182 scoped_refptr<net::X509Certificate> root_cert = |
| 5183 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); | 5183 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); |
| 5184 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert); | 5184 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert); |
| 5185 test_root_.reset(new ScopedTestRoot(root_cert)); | 5185 test_root_.reset(new ScopedTestRoot(root_cert.get())); |
| 5186 | 5186 |
| 5187 #if defined(USE_NSS) || defined(OS_IOS) | 5187 #if defined(USE_NSS) || defined(OS_IOS) |
| 5188 SetURLRequestContextForNSSHttpIO(&context_); | 5188 SetURLRequestContextForNSSHttpIO(&context_); |
| 5189 EnsureNSSHttpIOInit(); | 5189 EnsureNSSHttpIOInit(); |
| 5190 #endif | 5190 #endif |
| 5191 } | 5191 } |
| 5192 | 5192 |
| 5193 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, | 5193 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, |
| 5194 CertStatus* out_cert_status) { | 5194 CertStatus* out_cert_status) { |
| 5195 // We always overwrite out_cert_status. | 5195 // We always overwrite out_cert_status. |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5840 | 5840 |
| 5841 EXPECT_FALSE(r.is_pending()); | 5841 EXPECT_FALSE(r.is_pending()); |
| 5842 EXPECT_EQ(1, d->response_started_count()); | 5842 EXPECT_EQ(1, d->response_started_count()); |
| 5843 EXPECT_FALSE(d->received_data_before_response()); | 5843 EXPECT_FALSE(d->received_data_before_response()); |
| 5844 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 5844 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 5845 } | 5845 } |
| 5846 } | 5846 } |
| 5847 #endif // !defined(DISABLE_FTP_SUPPORT) | 5847 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 5848 | 5848 |
| 5849 } // namespace net | 5849 } // namespace net |
| OLD | NEW |