Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: net/spdy/spdy_http_utils_unittest.cc

Issue 2832973003: Split net/spdy into core and chromium subdirectories. (Closed)
Patch Set: Fix some more build rules. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_http_utils.cc ('k') | net/spdy/spdy_log_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/spdy/spdy_http_utils.h"
6
7 #include <stdint.h>
8
9 #include <limits>
10
11 #include "net/http/http_request_info.h"
12 #include "net/spdy/spdy_framer.h"
13 #include "net/spdy/spdy_test_utils.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace net {
17
18 namespace {
19
20 bool kDirect = true;
21
22 } // namespace
23
24 TEST(SpdyHttpUtilsTest, ConvertRequestPriorityToSpdy3Priority) {
25 EXPECT_EQ(0, ConvertRequestPriorityToSpdyPriority(HIGHEST));
26 EXPECT_EQ(1, ConvertRequestPriorityToSpdyPriority(MEDIUM));
27 EXPECT_EQ(2, ConvertRequestPriorityToSpdyPriority(LOW));
28 EXPECT_EQ(3, ConvertRequestPriorityToSpdyPriority(LOWEST));
29 EXPECT_EQ(4, ConvertRequestPriorityToSpdyPriority(IDLE));
30 EXPECT_EQ(5, ConvertRequestPriorityToSpdyPriority(THROTTLED));
31 }
32
33 TEST(SpdyHttpUtilsTest, ConvertSpdy3PriorityToRequestPriority) {
34 EXPECT_EQ(HIGHEST, ConvertSpdyPriorityToRequestPriority(0));
35 EXPECT_EQ(MEDIUM, ConvertSpdyPriorityToRequestPriority(1));
36 EXPECT_EQ(LOW, ConvertSpdyPriorityToRequestPriority(2));
37 EXPECT_EQ(LOWEST, ConvertSpdyPriorityToRequestPriority(3));
38 EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(4));
39 EXPECT_EQ(THROTTLED, ConvertSpdyPriorityToRequestPriority(5));
40 // These are invalid values, but we should still handle them
41 // gracefully.
42 for (int i = 6; i < std::numeric_limits<uint8_t>::max(); ++i) {
43 EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(i));
44 }
45 }
46
47 TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestHTTP2) {
48 GURL url("https://www.google.com/index.html");
49 HttpRequestInfo request;
50 request.method = "GET";
51 request.url = url;
52 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, "Chrome/1.1");
53 SpdyHeaderBlock headers;
54 CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, kDirect,
55 &headers);
56 EXPECT_EQ("GET", headers[":method"]);
57 EXPECT_EQ("https", headers[":scheme"]);
58 EXPECT_EQ("www.google.com", headers[":authority"]);
59 EXPECT_EQ("/index.html", headers[":path"]);
60 EXPECT_TRUE(headers.end() == headers.find(":version"));
61 EXPECT_EQ("Chrome/1.1", headers["user-agent"]);
62 }
63
64 TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestProxyHTTP2) {
65 GURL url("https://www.google.com/index.html");
66 HttpRequestInfo request;
67 request.method = "GET";
68 request.url = url;
69 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, "Chrome/1.1");
70 SpdyHeaderBlock headers;
71 CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, !kDirect,
72 &headers);
73 EXPECT_EQ("GET", headers[":method"]);
74 EXPECT_EQ("https", headers[":scheme"]);
75 EXPECT_EQ("www.google.com", headers[":authority"]);
76 EXPECT_EQ("/index.html", headers[":path"]);
77 EXPECT_TRUE(headers.end() == headers.find(":version"));
78 EXPECT_EQ("Chrome/1.1", headers["user-agent"]);
79 }
80
81 TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestConnectHTTP2) {
82 GURL url("https://www.google.com/index.html");
83 HttpRequestInfo request;
84 request.method = "CONNECT";
85 request.url = url;
86 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, "Chrome/1.1");
87 SpdyHeaderBlock headers;
88 CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, kDirect,
89 &headers);
90 EXPECT_EQ("CONNECT", headers[":method"]);
91 EXPECT_TRUE(headers.end() == headers.find(":scheme"));
92 EXPECT_EQ("www.google.com:443", headers[":authority"]);
93 EXPECT_EQ(headers.end(), headers.find(":path"));
94 EXPECT_EQ(headers.end(), headers.find(":scheme"));
95 EXPECT_TRUE(headers.end() == headers.find(":version"));
96 EXPECT_EQ("Chrome/1.1", headers["user-agent"]);
97 }
98
99 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_utils.cc ('k') | net/spdy/spdy_log_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698