Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / tools / quic / spdy_balsa_utils_test.cc
blob3d11c94cc19fc4bb471bc0d6dde0860f9e2228fc
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
3 // found in the LICENSE file.
5 #include "net/tools/quic/spdy_balsa_utils.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace net {
10 namespace tools {
11 namespace test {
12 namespace {
14 TEST(SpdyBalsaUtilsTest, RequestHeadersToSpdyHeaders) {
15 BalsaHeaders request_headers;
16 request_headers.SetRequestFirstlineFromStringPieces(
17 "GET", "https://www.google.com/foo", "HTTP/1.1");
18 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::RequestHeadersToSpdyHeaders(
19 request_headers, kSupportedQuicVersions[0]);
21 SpdyHeaderBlock expected_headers;
22 expected_headers[":authority"] = "www.google.com";
23 expected_headers[":method"] = "GET";
24 expected_headers[":path"] = "/foo";
25 expected_headers[":scheme"] = "https";
27 EXPECT_EQ(expected_headers, spdy_headers);
30 TEST(SpdyBalsaUtilsTest, ResponseHeadersToSpdyHeaders) {
31 BalsaHeaders response_headers;
32 response_headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200",
33 "OK");
34 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::ResponseHeadersToSpdyHeaders(
35 response_headers, kSupportedQuicVersions[0]);
37 SpdyHeaderBlock expected_headers;
38 expected_headers[":status"] = "200";
40 EXPECT_EQ(expected_headers, spdy_headers);
43 TEST(SpdyBalsaUtilsTest, SpdyHeadersToRequestHeaders) {
44 // Test :authority header.
45 SpdyHeaderBlock spdy_headers;
46 spdy_headers[":authority"] = "www.google.com";
47 spdy_headers[":method"] = "GET";
48 spdy_headers[":path"] = "/foo";
49 spdy_headers[":scheme"] = "https";
51 BalsaHeaders request_headers;
52 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(spdy_headers, &request_headers,
53 kSupportedQuicVersions[0]);
54 EXPECT_EQ("GET", request_headers.request_method());
55 EXPECT_EQ("HTTP/1.1", request_headers.request_version());
56 EXPECT_EQ("/foo", request_headers.request_uri());
57 EXPECT_EQ("www.google.com", request_headers.GetHeader("host"));
59 // Test :host header (and no GET).
60 SpdyHeaderBlock spdy_headers1;
61 spdy_headers1[":host"] = "www.google.com";
62 spdy_headers1[":path"] = "/foo";
63 spdy_headers1[":scheme"] = "http";
65 BalsaHeaders request_headers1;
66 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(spdy_headers1, &request_headers1,
67 kSupportedQuicVersions[0]);
68 EXPECT_EQ("GET", request_headers1.request_method());
69 EXPECT_EQ("HTTP/1.1", request_headers1.request_version());
70 EXPECT_EQ("/foo", request_headers1.request_uri());
71 EXPECT_EQ("www.google.com", request_headers1.GetHeader("host"));
74 TEST(SpdyBalsaUtilsTest, SpdyHeadersToResponseHeaders) {
75 SpdyHeaderBlock spdy_headers;
76 spdy_headers[":status"] = "200";
78 BalsaHeaders response_headers;
79 SpdyBalsaUtils::SpdyHeadersToResponseHeaders(spdy_headers, &response_headers,
80 kSupportedQuicVersions[0]);
81 EXPECT_EQ("200", response_headers.response_code());
84 } // namespace
85 } // namespace test
86 } // namespace tools
87 } // namespace net