forked from sanyaade-mobiledev/chromium.src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspdy_http_utils_unittest.cc
67 lines (56 loc) · 2.59 KB
/
spdy_http_utils_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/spdy/spdy_http_utils.h"
#include "base/basictypes.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace {
TEST(SpdyHttpUtilsTest, ConvertRequestPriorityToSpdy2Priority) {
EXPECT_EQ(0, ConvertRequestPriorityToSpdyPriority(HIGHEST, SPDY2));
EXPECT_EQ(1, ConvertRequestPriorityToSpdyPriority(MEDIUM, SPDY2));
EXPECT_EQ(2, ConvertRequestPriorityToSpdyPriority(LOW, SPDY2));
EXPECT_EQ(2, ConvertRequestPriorityToSpdyPriority(LOWEST, SPDY2));
EXPECT_EQ(3, ConvertRequestPriorityToSpdyPriority(IDLE, SPDY2));
}
TEST(SpdyHttpUtilsTest, ConvertRequestPriorityToSpdy3Priority) {
EXPECT_EQ(0, ConvertRequestPriorityToSpdyPriority(HIGHEST, SPDY3));
EXPECT_EQ(1, ConvertRequestPriorityToSpdyPriority(MEDIUM, SPDY3));
EXPECT_EQ(2, ConvertRequestPriorityToSpdyPriority(LOW, SPDY3));
EXPECT_EQ(3, ConvertRequestPriorityToSpdyPriority(LOWEST, SPDY3));
EXPECT_EQ(4, ConvertRequestPriorityToSpdyPriority(IDLE, SPDY3));
}
TEST(SpdyHttpUtilsTest, ConvertSpdy2PriorityToRequestPriority) {
EXPECT_EQ(HIGHEST, ConvertSpdyPriorityToRequestPriority(0, SPDY2));
EXPECT_EQ(MEDIUM, ConvertSpdyPriorityToRequestPriority(1, SPDY2));
EXPECT_EQ(LOW, ConvertSpdyPriorityToRequestPriority(2, SPDY2));
EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(3, SPDY2));
// These are invalid values, but we should still handle them
// gracefully.
for (int i = 4; i < kuint8max; ++i) {
EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(i, SPDY2));
}
}
TEST(SpdyHttpUtilsTest, ConvertSpdy3PriorityToRequestPriority) {
EXPECT_EQ(HIGHEST, ConvertSpdyPriorityToRequestPriority(0, SPDY3));
EXPECT_EQ(MEDIUM, ConvertSpdyPriorityToRequestPriority(1, SPDY3));
EXPECT_EQ(LOW, ConvertSpdyPriorityToRequestPriority(2, SPDY3));
EXPECT_EQ(LOWEST, ConvertSpdyPriorityToRequestPriority(3, SPDY3));
EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(4, SPDY3));
// These are invalid values, but we should still handle them
// gracefully.
for (int i = 5; i < kuint8max; ++i) {
EXPECT_EQ(IDLE, ConvertSpdyPriorityToRequestPriority(i, SPDY3));
}
}
TEST(SpdyHttpUtilsTest, ShowHttpHeaderValue){
#if defined(SPDY_PROXY_AUTH_ORIGIN)
EXPECT_FALSE(ShouldShowHttpHeaderValue("proxy-authorization"));
EXPECT_TRUE(ShouldShowHttpHeaderValue("accept-encoding"));
#else
EXPECT_TRUE(ShouldShowHttpHeaderValue("proxy-authorization"));
EXPECT_TRUE(ShouldShowHttpHeaderValue("accept-encoding"));
#endif
}
} // namespace
} // namespace net