Make certificate viewer a tab-modal dialog.
[chromium-blink-merge.git] / net / spdy / spdy_protocol_test.cc
blobc1725200ad0e1361beef372a31fc5f2f6a623bbd
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.
5 #include "net/spdy/spdy_protocol.h"
7 #include <limits>
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "net/spdy/spdy_bitmasks.h"
12 #include "net/spdy/spdy_framer.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace {
17 enum SpdyProtocolTestTypes {
18 SPDY2 = 2,
19 SPDY3 = 3,
22 } // namespace
24 namespace net {
26 class SpdyProtocolTest
27 : public ::testing::TestWithParam<SpdyProtocolTestTypes> {
28 protected:
29 virtual void SetUp() {
30 spdy_version_ = GetParam();
33 bool IsSpdy2() { return spdy_version_ == SPDY2; }
35 // Version of SPDY protocol to be used.
36 int spdy_version_;
39 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3.
40 INSTANTIATE_TEST_CASE_P(SpdyProtocolTests,
41 SpdyProtocolTest,
42 ::testing::Values(SPDY2, SPDY3));
44 // Test our protocol constants
45 TEST_P(SpdyProtocolTest, ProtocolConstants) {
46 EXPECT_EQ(1, SYN_STREAM);
47 EXPECT_EQ(2, SYN_REPLY);
48 EXPECT_EQ(3, RST_STREAM);
49 EXPECT_EQ(4, SETTINGS);
50 EXPECT_EQ(5, NOOP);
51 EXPECT_EQ(6, PING);
52 EXPECT_EQ(7, GOAWAY);
53 EXPECT_EQ(8, HEADERS);
54 EXPECT_EQ(9, WINDOW_UPDATE);
55 EXPECT_EQ(std::numeric_limits<int32>::max(), kSpdyMaximumWindowSize);
58 class SpdyProtocolDeathTest : public SpdyProtocolTest {};
60 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3.
61 INSTANTIATE_TEST_CASE_P(SpdyProtocolDeathTests,
62 SpdyProtocolDeathTest,
63 ::testing::Values(SPDY2, SPDY3));
65 #if GTEST_HAS_DEATH_TEST && !defined(NDEBUG)
66 TEST_P(SpdyProtocolDeathTest, TestSpdySettingsAndIdOutOfBounds) {
67 scoped_ptr<SettingsFlagsAndId> flags_and_id;
69 EXPECT_DEBUG_DEATH(
71 flags_and_id.reset(new SettingsFlagsAndId(1, ~0));
73 "SPDY setting ID too large.");
74 // Make sure that we get expected values in opt mode.
75 if (flags_and_id.get() != NULL) {
76 EXPECT_EQ(1, flags_and_id->flags());
77 EXPECT_EQ(static_cast<SpdyPingId>(0xffffff), flags_and_id->id());
80 #endif // GTEST_HAS_DEATH_TEST && !defined(NDEBUG)
82 } // namespace net