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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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
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 <algorithm> 5 #include <algorithm>
6 #include <iostream> 6 #include <iostream>
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 size_t len, 287 size_t len,
288 bool fin) override { 288 bool fin) override {
289 EXPECT_EQ(header_stream_id_, stream_id); 289 EXPECT_EQ(header_stream_id_, stream_id);
290 if (len == 0) 290 if (len == 0)
291 ++zero_length_data_frame_count_; 291 ++zero_length_data_frame_count_;
292 292
293 data_bytes_ += len; 293 data_bytes_ += len;
294 std::cerr << "OnStreamFrameData(" << stream_id << ", \""; 294 std::cerr << "OnStreamFrameData(" << stream_id << ", \"";
295 if (len > 0) { 295 if (len > 0) {
296 for (size_t i = 0 ; i < len; ++i) { 296 for (size_t i = 0 ; i < len; ++i) {
297 std::cerr << std::hex << (0xFF & (unsigned int)data[i]) << std::dec; 297 std::cerr << std::hex << (0xFF & static_cast<unsigned int>(data[i]))
298 << std::dec;
298 } 299 }
299 } 300 }
300 std::cerr << "\", " << len << ")\n"; 301 std::cerr << "\", " << len << ")\n";
301 } 302 }
302 303
303 bool OnControlFrameHeaderData(SpdyStreamId stream_id, 304 bool OnControlFrameHeaderData(SpdyStreamId stream_id,
304 const char* header_data, 305 const char* header_data,
305 size_t len) override { 306 size_t len) override {
306 ++control_frame_header_data_count_; 307 ++control_frame_header_data_count_;
307 CHECK_EQ(header_stream_id_, stream_id); 308 CHECK_EQ(header_stream_id_, stream_id);
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 << "'."; 661 << "'.";
661 return false; 662 return false;
662 } 663 }
663 } 664 }
664 return true; 665 return true;
665 } 666 }
666 667
667 bool IsSpdy2() { return spdy_version_ == SPDY2; } 668 bool IsSpdy2() { return spdy_version_ == SPDY2; }
668 bool IsSpdy3() { return spdy_version_ == SPDY3; } 669 bool IsSpdy3() { return spdy_version_ == SPDY3; }
669 bool IsSpdy4() { return spdy_version_ == SPDY4; } 670 bool IsSpdy4() { return spdy_version_ == SPDY4; }
670 bool IsSpdy5() { return spdy_version_ == SPDY5; }
671 671
672 // Version of SPDY protocol to be used. 672 // Version of SPDY protocol to be used.
673 SpdyMajorVersion spdy_version_; 673 SpdyMajorVersion spdy_version_;
674 unsigned char spdy_version_ch_; 674 unsigned char spdy_version_ch_;
675 }; 675 };
676 676
677 // All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, SPDY/4. 677 // All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, SPDY/4.
678 INSTANTIATE_TEST_CASE_P(SpdyFramerTests, 678 INSTANTIATE_TEST_CASE_P(SpdyFramerTests,
679 SpdyFramerTest, 679 SpdyFramerTest,
680 ::testing::Values(SPDY2, SPDY3, SPDY4)); 680 ::testing::Values(SPDY2, SPDY3, SPDY4));
(...skipping 3986 matching lines...) Expand 10 before | Expand all | Expand 10 after
4667 0xff, 0xff, 4667 0xff, 0xff,
4668 }; 4668 };
4669 4669
4670 TestSpdyVisitor visitor(spdy_version_); 4670 TestSpdyVisitor visitor(spdy_version_);
4671 visitor.SimulateInFramer(kInput, arraysize(kInput)); 4671 visitor.SimulateInFramer(kInput, arraysize(kInput));
4672 EXPECT_EQ(1, visitor.error_count_); 4672 EXPECT_EQ(1, visitor.error_count_);
4673 } 4673 }
4674 4674
4675 TEST_P(SpdyFramerTest, SizesTest) { 4675 TEST_P(SpdyFramerTest, SizesTest) {
4676 SpdyFramer framer(spdy_version_); 4676 SpdyFramer framer(spdy_version_);
4677 if (IsSpdy4() || IsSpdy5()) { 4677 if (IsSpdy4()) {
4678 EXPECT_EQ(9u, framer.GetDataFrameMinimumSize()); 4678 EXPECT_EQ(9u, framer.GetDataFrameMinimumSize());
4679 EXPECT_EQ(9u, framer.GetControlFrameHeaderSize()); 4679 EXPECT_EQ(9u, framer.GetControlFrameHeaderSize());
4680 EXPECT_EQ(14u, framer.GetSynStreamMinimumSize()); 4680 EXPECT_EQ(14u, framer.GetSynStreamMinimumSize());
4681 EXPECT_EQ(9u, framer.GetSynReplyMinimumSize()); 4681 EXPECT_EQ(9u, framer.GetSynReplyMinimumSize());
4682 EXPECT_EQ(13u, framer.GetRstStreamMinimumSize()); 4682 EXPECT_EQ(13u, framer.GetRstStreamMinimumSize());
4683 EXPECT_EQ(9u, framer.GetSettingsMinimumSize()); 4683 EXPECT_EQ(9u, framer.GetSettingsMinimumSize());
4684 EXPECT_EQ(17u, framer.GetPingSize()); 4684 EXPECT_EQ(17u, framer.GetPingSize());
4685 EXPECT_EQ(17u, framer.GetGoAwayMinimumSize()); 4685 EXPECT_EQ(17u, framer.GetGoAwayMinimumSize());
4686 EXPECT_EQ(9u, framer.GetHeadersMinimumSize()); 4686 EXPECT_EQ(9u, framer.GetHeadersMinimumSize());
4687 EXPECT_EQ(13u, framer.GetWindowUpdateSize()); 4687 EXPECT_EQ(13u, framer.GetWindowUpdateSize());
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
5935 TestSpdyVisitor visitor(spdy_version_); 5935 TestSpdyVisitor visitor(spdy_version_);
5936 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); 5936 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData));
5937 5937
5938 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); 5938 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state());
5939 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, 5939 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME,
5940 visitor.framer_.error_code()) 5940 visitor.framer_.error_code())
5941 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); 5941 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code());
5942 } 5942 }
5943 5943
5944 } // namespace net 5944 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_headers_block_parser.h » ('j') | shell/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698