OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/tools/quic/spdy_balsa_utils.h" | 5 #include "net/tools/quic/spdy_balsa_utils.h" |
6 | 6 |
| 7 #include "net/spdy/spdy_test_utils.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
| 10 using net::test::CompareSpdyHeaderBlocks; |
| 11 |
9 namespace net { | 12 namespace net { |
10 namespace tools { | 13 namespace tools { |
11 namespace test { | 14 namespace test { |
12 namespace { | 15 namespace { |
13 | 16 |
14 TEST(SpdyBalsaUtilsTest, RequestHeadersToSpdyHeaders) { | 17 TEST(SpdyBalsaUtilsTest, RequestHeadersToSpdyHeaders) { |
15 BalsaHeaders request_headers; | 18 BalsaHeaders request_headers; |
16 request_headers.SetRequestFirstlineFromStringPieces( | 19 request_headers.SetRequestFirstlineFromStringPieces( |
17 "GET", "https://www.google.com/foo", "HTTP/1.1"); | 20 "GET", "https://www.google.com/foo", "HTTP/1.1"); |
18 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::RequestHeadersToSpdyHeaders( | 21 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::RequestHeadersToSpdyHeaders( |
19 request_headers, kSupportedQuicVersions[0]); | 22 request_headers, kSupportedQuicVersions[0]); |
20 | 23 |
21 SpdyHeaderBlock expected_headers; | 24 SpdyHeaderBlock expected_headers; |
22 expected_headers[":authority"] = "www.google.com"; | 25 expected_headers[":authority"] = "www.google.com"; |
23 expected_headers[":method"] = "GET"; | 26 expected_headers[":method"] = "GET"; |
24 expected_headers[":path"] = "/foo"; | 27 expected_headers[":path"] = "/foo"; |
25 expected_headers[":scheme"] = "https"; | 28 expected_headers[":scheme"] = "https"; |
26 | 29 |
27 EXPECT_EQ(expected_headers, spdy_headers); | 30 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_headers, spdy_headers)); |
28 } | 31 } |
29 | 32 |
30 TEST(SpdyBalsaUtilsTest, ResponseHeadersToSpdyHeaders) { | 33 TEST(SpdyBalsaUtilsTest, ResponseHeadersToSpdyHeaders) { |
31 BalsaHeaders response_headers; | 34 BalsaHeaders response_headers; |
32 response_headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", | 35 response_headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", |
33 "OK"); | 36 "OK"); |
34 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::ResponseHeadersToSpdyHeaders( | 37 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::ResponseHeadersToSpdyHeaders( |
35 response_headers, kSupportedQuicVersions[0]); | 38 response_headers, kSupportedQuicVersions[0]); |
36 | 39 |
37 SpdyHeaderBlock expected_headers; | 40 SpdyHeaderBlock expected_headers; |
38 expected_headers[":status"] = "200"; | 41 expected_headers[":status"] = "200"; |
39 | 42 |
40 EXPECT_EQ(expected_headers, spdy_headers); | 43 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_headers, spdy_headers)); |
41 } | 44 } |
42 | 45 |
43 TEST(SpdyBalsaUtilsTest, SpdyHeadersToRequestHeaders) { | 46 TEST(SpdyBalsaUtilsTest, SpdyHeadersToRequestHeaders) { |
44 // Test :authority header. | 47 // Test :authority header. |
45 SpdyHeaderBlock spdy_headers; | 48 SpdyHeaderBlock spdy_headers; |
46 spdy_headers[":authority"] = "www.google.com"; | 49 spdy_headers[":authority"] = "www.google.com"; |
47 spdy_headers[":method"] = "GET"; | 50 spdy_headers[":method"] = "GET"; |
48 spdy_headers[":path"] = "/foo"; | 51 spdy_headers[":path"] = "/foo"; |
49 spdy_headers[":scheme"] = "https"; | 52 spdy_headers[":scheme"] = "https"; |
50 | 53 |
(...skipping 27 matching lines...) Expand all Loading... |
78 BalsaHeaders response_headers; | 81 BalsaHeaders response_headers; |
79 SpdyBalsaUtils::SpdyHeadersToResponseHeaders(spdy_headers, &response_headers, | 82 SpdyBalsaUtils::SpdyHeadersToResponseHeaders(spdy_headers, &response_headers, |
80 kSupportedQuicVersions[0]); | 83 kSupportedQuicVersions[0]); |
81 EXPECT_EQ("200", response_headers.response_code()); | 84 EXPECT_EQ("200", response_headers.response_code()); |
82 } | 85 } |
83 | 86 |
84 } // namespace | 87 } // namespace |
85 } // namespace test | 88 } // namespace test |
86 } // namespace tools | 89 } // namespace tools |
87 } // namespace net | 90 } // namespace net |
OLD | NEW |