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

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

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/spdy/spdy_http_utils.h" 5 #include "net/spdy/spdy_http_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 namespace { 12 namespace {
13 13
14 TEST(SpdyHttpUtilsTest, ConvertRequestPriorityToSpdy2Priority) {
15 EXPECT_EQ(0, ConvertRequestPriorityToSpdyPriority(HIGHEST, SPDY2));
16 EXPECT_EQ(1, ConvertRequestPriorityToSpdyPriority(MEDIUM, SPDY2));
17 EXPECT_EQ(2, ConvertRequestPriorityToSpdyPriority(LOW, SPDY2));
18 EXPECT_EQ(2, ConvertRequestPriorityToSpdyPriority(LOWEST, SPDY2));
19 EXPECT_EQ(3, ConvertRequestPriorityToSpdyPriority(IDLE, SPDY2));
20 }
21
22 TEST(SpdyHttpUtilsTest, ConvertRequestPriorityToSpdy3Priority) { 14 TEST(SpdyHttpUtilsTest, ConvertRequestPriorityToSpdy3Priority) {
23 EXPECT_EQ(0, ConvertRequestPriorityToSpdyPriority(HIGHEST, SPDY3)); 15 EXPECT_EQ(0, ConvertRequestPriorityToSpdyPriority(HIGHEST, SPDY3));
24 EXPECT_EQ(1, ConvertRequestPriorityToSpdyPriority(MEDIUM, SPDY3)); 16 EXPECT_EQ(1, ConvertRequestPriorityToSpdyPriority(MEDIUM, SPDY3));
25 EXPECT_EQ(2, ConvertRequestPriorityToSpdyPriority(LOW, SPDY3)); 17 EXPECT_EQ(2, ConvertRequestPriorityToSpdyPriority(LOW, SPDY3));
26 EXPECT_EQ(3, ConvertRequestPriorityToSpdyPriority(LOWEST, SPDY3)); 18 EXPECT_EQ(3, ConvertRequestPriorityToSpdyPriority(LOWEST, SPDY3));
27 EXPECT_EQ(4, ConvertRequestPriorityToSpdyPriority(IDLE, SPDY3)); 19 EXPECT_EQ(4, ConvertRequestPriorityToSpdyPriority(IDLE, SPDY3));
28 } 20 }
29 21
30 TEST(SpdyHttpUtilsTest, ConvertSpdy2PriorityToRequestPriority) {
31 EXPECT_EQ(HIGHEST, ConvertSpdyPriorityToRequestPriority(0, SPDY2));
32 EXPECT_EQ(MEDIUM, ConvertSpdyPriorityToRequestPriority(1, SPDY2));
33 EXPECT_EQ(LOW, ConvertSpdyPriorityToRequestPriority(2, SPDY2));
34 EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(3, SPDY2));
35 // These are invalid values, but we should still handle them
36 // gracefully.
37 for (int i = 4; i < kuint8max; ++i) {
38 EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(i, SPDY2));
39 }
40 }
41
42 TEST(SpdyHttpUtilsTest, ConvertSpdy3PriorityToRequestPriority) { 22 TEST(SpdyHttpUtilsTest, ConvertSpdy3PriorityToRequestPriority) {
43 EXPECT_EQ(HIGHEST, ConvertSpdyPriorityToRequestPriority(0, SPDY3)); 23 EXPECT_EQ(HIGHEST, ConvertSpdyPriorityToRequestPriority(0, SPDY3));
44 EXPECT_EQ(MEDIUM, ConvertSpdyPriorityToRequestPriority(1, SPDY3)); 24 EXPECT_EQ(MEDIUM, ConvertSpdyPriorityToRequestPriority(1, SPDY3));
45 EXPECT_EQ(LOW, ConvertSpdyPriorityToRequestPriority(2, SPDY3)); 25 EXPECT_EQ(LOW, ConvertSpdyPriorityToRequestPriority(2, SPDY3));
46 EXPECT_EQ(LOWEST, ConvertSpdyPriorityToRequestPriority(3, SPDY3)); 26 EXPECT_EQ(LOWEST, ConvertSpdyPriorityToRequestPriority(3, SPDY3));
47 EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(4, SPDY3)); 27 EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(4, SPDY3));
48 // These are invalid values, but we should still handle them 28 // These are invalid values, but we should still handle them
49 // gracefully. 29 // gracefully.
50 for (int i = 5; i < kuint8max; ++i) { 30 for (int i = 5; i < kuint8max; ++i) {
51 EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(i, SPDY3)); 31 EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(i, SPDY3));
52 } 32 }
53 } 33 }
54 34
55 } // namespace 35 } // namespace
56 36
57 } // namespace net 37 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_utils.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698