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

Side by Side Diff: net/quic/core/quic_framer_test.cc

Issue 2848203002: Add a platform implementation of QuicTest and QuicTestWithParam (Closed)
Patch Set: net/quic/platform/impl/quic_test_impl.cc Created 3 years, 7 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
« no previous file with comments | « net/quic/core/quic_flow_controller_test.cc ('k') | net/quic/core/quic_header_list_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/quic/core/quic_framer.h" 5 #include "net/quic/core/quic_framer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdint> 8 #include <cstdint>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "net/quic/core/crypto/null_decrypter.h" 14 #include "net/quic/core/crypto/null_decrypter.h"
15 #include "net/quic/core/crypto/null_encrypter.h" 15 #include "net/quic/core/crypto/null_encrypter.h"
16 #include "net/quic/core/crypto/quic_decrypter.h" 16 #include "net/quic/core/crypto/quic_decrypter.h"
17 #include "net/quic/core/crypto/quic_encrypter.h" 17 #include "net/quic/core/crypto/quic_encrypter.h"
18 #include "net/quic/core/quic_packets.h" 18 #include "net/quic/core/quic_packets.h"
19 #include "net/quic/core/quic_utils.h" 19 #include "net/quic/core/quic_utils.h"
20 #include "net/quic/platform/api/quic_flags.h" 20 #include "net/quic/platform/api/quic_flags.h"
21 #include "net/quic/platform/api/quic_logging.h" 21 #include "net/quic/platform/api/quic_logging.h"
22 #include "net/quic/platform/api/quic_ptr_util.h" 22 #include "net/quic/platform/api/quic_ptr_util.h"
23 #include "net/quic/platform/api/quic_test.h"
23 #include "net/quic/test_tools/quic_framer_peer.h" 24 #include "net/quic/test_tools/quic_framer_peer.h"
24 #include "net/quic/test_tools/quic_test_utils.h" 25 #include "net/quic/test_tools/quic_test_utils.h"
25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 using std::string; 27 using std::string;
28 using testing::Return; 28 using testing::Return;
29 using testing::Truly; 29 using testing::Truly;
30 using testing::_; 30 using testing::_;
31 31
32 namespace net { 32 namespace net {
33 namespace test { 33 namespace test {
34 namespace { 34 namespace {
35 35
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 std::vector<std::unique_ptr<QuicPaddingFrame>> padding_frames_; 282 std::vector<std::unique_ptr<QuicPaddingFrame>> padding_frames_;
283 std::vector<std::unique_ptr<QuicPingFrame>> ping_frames_; 283 std::vector<std::unique_ptr<QuicPingFrame>> ping_frames_;
284 QuicRstStreamFrame rst_stream_frame_; 284 QuicRstStreamFrame rst_stream_frame_;
285 QuicConnectionCloseFrame connection_close_frame_; 285 QuicConnectionCloseFrame connection_close_frame_;
286 QuicGoAwayFrame goaway_frame_; 286 QuicGoAwayFrame goaway_frame_;
287 QuicWindowUpdateFrame window_update_frame_; 287 QuicWindowUpdateFrame window_update_frame_;
288 QuicBlockedFrame blocked_frame_; 288 QuicBlockedFrame blocked_frame_;
289 std::vector<std::unique_ptr<string>> stream_data_; 289 std::vector<std::unique_ptr<string>> stream_data_;
290 }; 290 };
291 291
292 class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { 292 class QuicFramerTest : public QuicTestWithParam<QuicVersion> {
293 public: 293 public:
294 QuicFramerTest() 294 QuicFramerTest()
295 : encrypter_(new test::TestEncrypter()), 295 : encrypter_(new test::TestEncrypter()),
296 decrypter_(new test::TestDecrypter()), 296 decrypter_(new test::TestDecrypter()),
297 start_(QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(0x10)), 297 start_(QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(0x10)),
298 framer_(AllSupportedVersions(), start_, Perspective::IS_SERVER) { 298 framer_(AllSupportedVersions(), start_, Perspective::IS_SERVER) {
299 version_ = GetParam(); 299 version_ = GetParam();
300 framer_.set_version(version_); 300 framer_.set_version(version_);
301 framer_.SetDecrypter(ENCRYPTION_NONE, decrypter_); 301 framer_.SetDecrypter(ENCRYPTION_NONE, decrypter_);
302 framer_.SetEncrypter(ENCRYPTION_NONE, encrypter_); 302 framer_.SetEncrypter(ENCRYPTION_NONE, encrypter_);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 const QuicFrames& frames) { 431 const QuicFrames& frames) {
432 return BuildUnsizedDataPacket(&framer_, header, frames); 432 return BuildUnsizedDataPacket(&framer_, header, frames);
433 } 433 }
434 434
435 QuicPacket* BuildDataPacket(const QuicPacketHeader& header, 435 QuicPacket* BuildDataPacket(const QuicPacketHeader& header,
436 const QuicFrames& frames, 436 const QuicFrames& frames,
437 size_t packet_size) { 437 size_t packet_size) {
438 return BuildUnsizedDataPacket(&framer_, header, frames, packet_size); 438 return BuildUnsizedDataPacket(&framer_, header, frames, packet_size);
439 } 439 }
440 440
441 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
442 test::TestEncrypter* encrypter_; 441 test::TestEncrypter* encrypter_;
443 test::TestDecrypter* decrypter_; 442 test::TestDecrypter* decrypter_;
444 QuicVersion version_; 443 QuicVersion version_;
445 QuicTime start_; 444 QuicTime start_;
446 QuicFramer framer_; 445 QuicFramer framer_;
447 test::TestQuicVisitor visitor_; 446 test::TestQuicVisitor visitor_;
448 }; 447 };
449 448
450 // Helper function to get index of packets in hex format. 449 // Helper function to get index of packets in hex format.
451 // For each packet in hex format, integers and floating numbers are in big 450 // For each packet in hex format, integers and floating numbers are in big
(...skipping 6817 matching lines...) Expand 10 before | Expand all | Expand 10 after
7269 7268
7270 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; 7269 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39};
7271 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); 7270 size_t index = GetPacketIndex(framer_.version(), framer_.perspective());
7272 7271
7273 QuicFramerFuzzFunc(packets[index], arraysize(packet)); 7272 QuicFramerFuzzFunc(packets[index], arraysize(packet));
7274 } 7273 }
7275 7274
7276 } // namespace 7275 } // namespace
7277 } // namespace test 7276 } // namespace test
7278 } // namespace net 7277 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_flow_controller_test.cc ('k') | net/quic/core/quic_header_list_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698