Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <iostream> | 6 #include <iostream> |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1794 { "HTTP/1.1 200 OK\n" | 1794 { "HTTP/1.1 200 OK\n" |
| 1795 "etag: W / \"foo\"\n", | 1795 "etag: W / \"foo\"\n", |
| 1796 false | 1796 false |
| 1797 } | 1797 } |
| 1798 }; | 1798 }; |
| 1799 | 1799 |
| 1800 INSTANTIATE_TEST_CASE_P(HttpResponseHeaders, | 1800 INSTANTIATE_TEST_CASE_P(HttpResponseHeaders, |
| 1801 HasStrongValidatorsTest, | 1801 HasStrongValidatorsTest, |
| 1802 testing::ValuesIn(strong_validators_tests)); | 1802 testing::ValuesIn(strong_validators_tests)); |
| 1803 | 1803 |
| 1804 TEST(HttpResponseHeadersTest, HasValidatorsNone) { | |
|
bengr
2015/12/03 17:42:21
Add tests that expect false when the HTTP version
jamartin (wrong)
2015/12/08 16:58:18
Those test are already in http_util_unittest.cc, w
| |
| 1805 std::string headers("HTTP/1.1 200 OK"); | |
| 1806 HeadersToRaw(&headers); | |
| 1807 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers)); | |
| 1808 EXPECT_FALSE(parsed->HasValidators()); | |
| 1809 } | |
| 1810 | |
| 1811 TEST(HttpResponseHeadersTest, HasValidatorsEtag) { | |
| 1812 std::string headers( | |
| 1813 "HTTP/1.1 200 OK\n" | |
| 1814 "etag: \"anything\""); | |
| 1815 HeadersToRaw(&headers); | |
| 1816 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers)); | |
| 1817 EXPECT_TRUE(parsed->HasValidators()); | |
| 1818 } | |
| 1819 | |
| 1820 TEST(HttpResponseHeadersTest, HasValidatorsLastModified) { | |
| 1821 std::string headers( | |
| 1822 "HTTP/1.1 200 OK\n" | |
| 1823 "Last-Modified: Wed, 28 Nov 2007 00:40:10 GMT"); | |
|
bengr
2015/12/03 17:42:21
Add a test that expects false when last-modified h
jamartin (wrong)
2015/12/08 16:58:18
Please see my reply above.
| |
| 1824 HeadersToRaw(&headers); | |
| 1825 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers)); | |
| 1826 EXPECT_TRUE(parsed->HasValidators()); | |
| 1827 } | |
| 1828 | |
| 1829 TEST(HttpResponseHeadersTest, HasValidatorsWeakEtag) { | |
| 1830 std::string headers( | |
| 1831 "HTTP/1.1 200 OK\n" | |
| 1832 "etag: W/\"anything\""); | |
| 1833 HeadersToRaw(&headers); | |
| 1834 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers)); | |
| 1835 EXPECT_TRUE(parsed->HasValidators()); | |
| 1836 } | |
| 1837 | |
| 1804 TEST(HttpResponseHeadersTest, GetStatusText) { | 1838 TEST(HttpResponseHeadersTest, GetStatusText) { |
| 1805 std::string headers("HTTP/1.1 404 Not Found"); | 1839 std::string headers("HTTP/1.1 404 Not Found"); |
| 1806 HeadersToRaw(&headers); | 1840 HeadersToRaw(&headers); |
| 1807 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers)); | 1841 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers)); |
| 1808 EXPECT_EQ(std::string("Not Found"), parsed->GetStatusText()); | 1842 EXPECT_EQ(std::string("Not Found"), parsed->GetStatusText()); |
| 1809 } | 1843 } |
| 1810 | 1844 |
| 1811 TEST(HttpResponseHeadersTest, GetStatusTextMissing) { | 1845 TEST(HttpResponseHeadersTest, GetStatusTextMissing) { |
| 1812 std::string headers("HTTP/1.1 404"); | 1846 std::string headers("HTTP/1.1 404"); |
| 1813 HeadersToRaw(&headers); | 1847 HeadersToRaw(&headers); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2312 TEST_F(HttpResponseHeadersCacheControlTest, | 2346 TEST_F(HttpResponseHeadersCacheControlTest, |
| 2313 FirstStaleWhileRevalidateValueUsed) { | 2347 FirstStaleWhileRevalidateValueUsed) { |
| 2314 InitializeHeadersWithCacheControl( | 2348 InitializeHeadersWithCacheControl( |
| 2315 "stale-while-revalidate=1,stale-while-revalidate=7200"); | 2349 "stale-while-revalidate=1,stale-while-revalidate=7200"); |
| 2316 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue()); | 2350 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue()); |
| 2317 } | 2351 } |
| 2318 | 2352 |
| 2319 } // namespace | 2353 } // namespace |
| 2320 | 2354 |
| 2321 } // namespace net | 2355 } // namespace net |
| OLD | NEW |