OLD | NEW |
---|---|
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_protocol.h" | 5 #include "net/spdy/spdy_protocol.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/spdy/spdy_bitmasks.h" | 10 #include "net/spdy/spdy_bitmasks.h" |
11 #include "net/spdy/spdy_framer.h" | 11 #include "net/spdy/spdy_framer.h" |
12 #include "net/test/gtest_util.h" | 12 #include "net/test/gtest_util.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 enum SpdyProtocolTestTypes { | 17 enum SpdyProtocolTestTypes { |
18 SPDY2 = net::SPDY2, | |
19 SPDY3 = net::SPDY3, | 18 SPDY3 = net::SPDY3, |
20 }; | 19 }; |
21 | 20 |
22 } // namespace | 21 } // namespace |
23 | 22 |
24 namespace net { | 23 namespace net { |
25 | 24 |
26 class SpdyProtocolTest | 25 class SpdyProtocolTest |
27 : public ::testing::TestWithParam<SpdyProtocolTestTypes> { | 26 : public ::testing::TestWithParam<SpdyProtocolTestTypes> { |
28 protected: | 27 protected: |
29 void SetUp() override { | 28 void SetUp() override { |
30 spdy_version_ = static_cast<SpdyMajorVersion>(GetParam()); | 29 spdy_version_ = static_cast<SpdyMajorVersion>(GetParam()); |
31 } | 30 } |
32 | 31 |
33 // Version of SPDY protocol to be used. | 32 // Version of SPDY protocol to be used. |
34 SpdyMajorVersion spdy_version_; | 33 SpdyMajorVersion spdy_version_; |
35 }; | 34 }; |
36 | 35 |
37 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. | |
38 INSTANTIATE_TEST_CASE_P(SpdyProtocolTests, | 36 INSTANTIATE_TEST_CASE_P(SpdyProtocolTests, |
Ryan Hamilton
2016/01/07 22:09:15
If we're just doing 1 version, do we still want to
Bence
2016/01/08 18:58:25
Oops, sorry I didn't catch this.
Turns out |spdy_
Ryan Hamilton
2016/01/08 20:53:06
opt mode == !debug mode. Which is to say, when DCH
| |
39 SpdyProtocolTest, | 37 SpdyProtocolTest, |
40 ::testing::Values(SPDY2, SPDY3)); | 38 ::testing::Values(SPDY3)); |
41 | 39 |
42 class SpdyProtocolDeathTest : public SpdyProtocolTest {}; | 40 class SpdyProtocolDeathTest : public SpdyProtocolTest {}; |
43 | 41 |
44 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. | |
45 INSTANTIATE_TEST_CASE_P(SpdyProtocolDeathTests, | 42 INSTANTIATE_TEST_CASE_P(SpdyProtocolDeathTests, |
46 SpdyProtocolDeathTest, | 43 SpdyProtocolDeathTest, |
47 ::testing::Values(SPDY2, SPDY3)); | 44 ::testing::Values(SPDY3)); |
48 | 45 |
49 TEST_P(SpdyProtocolDeathTest, TestSpdySettingsAndIdOutOfBounds) { | 46 TEST_P(SpdyProtocolDeathTest, TestSpdySettingsAndIdOutOfBounds) { |
50 scoped_ptr<SettingsFlagsAndId> flags_and_id; | 47 scoped_ptr<SettingsFlagsAndId> flags_and_id; |
51 | 48 |
52 EXPECT_DFATAL(flags_and_id.reset(new SettingsFlagsAndId(1, 0xFFFFFFFF)), | 49 EXPECT_DFATAL(flags_and_id.reset(new SettingsFlagsAndId(1, 0xFFFFFFFF)), |
53 "SPDY setting ID too large."); | 50 "SPDY setting ID too large."); |
54 // Make sure that we get expected values in opt mode. | 51 // Make sure that we get expected values in opt mode. |
55 if (flags_and_id.get() != NULL) { | 52 if (flags_and_id.get() != NULL) { |
56 EXPECT_EQ(1, flags_and_id->flags()); | 53 EXPECT_EQ(1, flags_and_id->flags()); |
57 EXPECT_EQ(static_cast<SpdyPingId>(0xffffff), flags_and_id->id()); | 54 EXPECT_EQ(static_cast<SpdyPingId>(0xffffff), flags_and_id->id()); |
58 } | 55 } |
59 } | 56 } |
60 | 57 |
61 } // namespace net | 58 } // namespace net |
OLD | NEW |