Clear webapp storage when site data is cleared
[chromium-blink-merge.git] / net / tools / quic / spdy_balsa_utils_test.cc
blob823a4a6788f52d5de42f5d2fa9b152e8385c3d0e
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 "net/spdy/spdy_test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 using net::test::CompareSpdyHeaderBlocks;
12 namespace net {
13 namespace tools {
14 namespace test {
15 namespace {
17 TEST(SpdyBalsaUtilsTest, RequestHeadersToSpdyHeaders) {
18 BalsaHeaders request_headers;
19 request_headers.SetRequestFirstlineFromStringPieces(
20 "GET", "https://www.google.com/foo", "HTTP/1.1");
21 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::RequestHeadersToSpdyHeaders(
22 request_headers, kSupportedQuicVersions[0]);
24 SpdyHeaderBlock expected_headers;
25 expected_headers[":authority"] = "www.google.com";
26 expected_headers[":path"] = "/foo";
27 expected_headers[":scheme"] = "https";
28 expected_headers[":method"] = "GET";
30 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_headers, spdy_headers));
33 TEST(SpdyBalsaUtilsTest, ResponseHeadersToSpdyHeaders) {
34 BalsaHeaders response_headers;
35 response_headers.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200",
36 "OK");
37 SpdyHeaderBlock spdy_headers = SpdyBalsaUtils::ResponseHeadersToSpdyHeaders(
38 response_headers, kSupportedQuicVersions[0]);
40 SpdyHeaderBlock expected_headers;
41 expected_headers[":status"] = "200";
43 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_headers, spdy_headers));
46 TEST(SpdyBalsaUtilsTest, SpdyHeadersToRequestHeaders) {
47 // Test :authority header.
48 SpdyHeaderBlock spdy_headers;
49 spdy_headers[":authority"] = "www.google.com";
50 spdy_headers[":path"] = "/foo";
51 spdy_headers[":scheme"] = "https";
52 spdy_headers[":method"] = "GET";
54 BalsaHeaders request_headers;
55 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(spdy_headers, &request_headers,
56 kSupportedQuicVersions[0]);
57 EXPECT_EQ("GET", request_headers.request_method());
58 EXPECT_EQ("HTTP/1.1", request_headers.request_version());
59 EXPECT_EQ("/foo", request_headers.request_uri());
60 EXPECT_EQ("www.google.com", request_headers.GetHeader("host"));
62 // Test :host header (and no GET).
63 SpdyHeaderBlock spdy_headers1;
64 spdy_headers1[":host"] = "www.google.com";
65 spdy_headers1[":path"] = "/foo";
66 spdy_headers1[":scheme"] = "http";
68 BalsaHeaders request_headers1;
69 SpdyBalsaUtils::SpdyHeadersToRequestHeaders(spdy_headers1, &request_headers1,
70 kSupportedQuicVersions[0]);
71 EXPECT_EQ("GET", request_headers1.request_method());
72 EXPECT_EQ("HTTP/1.1", request_headers1.request_version());
73 EXPECT_EQ("/foo", request_headers1.request_uri());
74 EXPECT_EQ("www.google.com", request_headers1.GetHeader("host"));
77 TEST(SpdyBalsaUtilsTest, SpdyHeadersToResponseHeaders) {
78 SpdyHeaderBlock spdy_headers;
79 spdy_headers[":status"] = "200";
81 BalsaHeaders response_headers;
82 SpdyBalsaUtils::SpdyHeadersToResponseHeaders(spdy_headers, &response_headers,
83 kSupportedQuicVersions[0]);
84 EXPECT_EQ("200", response_headers.response_code());
87 } // namespace
88 } // namespace test
89 } // namespace tools
90 } // namespace net