| 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 { | |
| 18 SPDY2 = net::SPDY2, | |
| 19 SPDY3 = net::SPDY3, | |
| 20 }; | |
| 21 | |
| 22 } // namespace | 17 } // namespace |
| 23 | 18 |
| 24 namespace net { | 19 namespace net { |
| 25 | 20 |
| 26 class SpdyProtocolTest | 21 TEST(SpdyProtocolDeathTest, TestSpdySettingsAndIdOutOfBounds) { |
| 27 : public ::testing::TestWithParam<SpdyProtocolTestTypes> { | |
| 28 protected: | |
| 29 void SetUp() override { | |
| 30 spdy_version_ = static_cast<SpdyMajorVersion>(GetParam()); | |
| 31 } | |
| 32 | |
| 33 // Version of SPDY protocol to be used. | |
| 34 SpdyMajorVersion spdy_version_; | |
| 35 }; | |
| 36 | |
| 37 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. | |
| 38 INSTANTIATE_TEST_CASE_P(SpdyProtocolTests, | |
| 39 SpdyProtocolTest, | |
| 40 ::testing::Values(SPDY2, SPDY3)); | |
| 41 | |
| 42 class SpdyProtocolDeathTest : public SpdyProtocolTest {}; | |
| 43 | |
| 44 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. | |
| 45 INSTANTIATE_TEST_CASE_P(SpdyProtocolDeathTests, | |
| 46 SpdyProtocolDeathTest, | |
| 47 ::testing::Values(SPDY2, SPDY3)); | |
| 48 | |
| 49 TEST_P(SpdyProtocolDeathTest, TestSpdySettingsAndIdOutOfBounds) { | |
| 50 scoped_ptr<SettingsFlagsAndId> flags_and_id; | 22 scoped_ptr<SettingsFlagsAndId> flags_and_id; |
| 51 | 23 |
| 52 EXPECT_DFATAL(flags_and_id.reset(new SettingsFlagsAndId(1, 0xFFFFFFFF)), | 24 EXPECT_DFATAL(flags_and_id.reset(new SettingsFlagsAndId(1, 0xffffffff)), |
| 53 "SPDY setting ID too large."); | 25 "SPDY setting ID too large."); |
| 54 // Make sure that we get expected values in opt mode. | 26 // Make sure that we get expected values in opt mode. |
| 55 if (flags_and_id.get() != NULL) { | 27 if (flags_and_id.get() != nullptr) { |
| 56 EXPECT_EQ(1, flags_and_id->flags()); | 28 EXPECT_EQ(1, flags_and_id->flags()); |
| 57 EXPECT_EQ(static_cast<SpdyPingId>(0xffffff), flags_and_id->id()); | 29 EXPECT_EQ(0xffffffu, flags_and_id->id()); |
| 58 } | 30 } |
| 59 } | 31 } |
| 60 | 32 |
| 61 } // namespace net | 33 } // namespace net |
| OLD | NEW |