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

Side by Side Diff: net/quic/quic_connection_logger_unittest.cc

Issue 944883003: QUIC - Cache the connection type and connection description. Make the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments to Patch Set 5 Created 5 years, 10 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/quic_connection_logger.cc ('k') | net/quic/quic_http_stream_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/quic_connection_logger.h" 5 #include "net/quic/quic_connection_logger.h"
6 6
7 #include "net/quic/quic_protocol.h" 7 #include "net/quic/quic_protocol.h"
8 #include "net/quic/test_tools/quic_test_utils.h" 8 #include "net/quic/test_tools/quic_test_utils.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace net { 11 namespace net {
12 namespace test { 12 namespace test {
13 13
14 class QuicConnectionLoggerPeer { 14 class QuicConnectionLoggerPeer {
15 public: 15 public:
16 static size_t num_truncated_acks_sent(const QuicConnectionLogger& logger) { 16 static size_t num_truncated_acks_sent(const QuicConnectionLogger& logger) {
17 return logger.num_truncated_acks_sent_; 17 return logger.num_truncated_acks_sent_;
18 } 18 }
19 }; 19 };
20 20
21 class QuicConnectionLoggerTest : public ::testing::Test { 21 class QuicConnectionLoggerTest : public ::testing::Test {
22 protected: 22 protected:
23 QuicConnectionLoggerTest() 23 QuicConnectionLoggerTest()
24 : session_(new MockConnection(false)), logger_(&session_, net_log_) {} 24 : session_(new MockConnection(false)),
25 logger_(&session_, "CONNECTION_UNKNOWN", net_log_) {}
25 26
26 BoundNetLog net_log_; 27 BoundNetLog net_log_;
27 MockSession session_; 28 MockSession session_;
28 QuicConnectionLogger logger_; 29 QuicConnectionLogger logger_;
29 }; 30 };
30 31
31 TEST_F(QuicConnectionLoggerTest, TruncatedAcksSentNotChanged) { 32 TEST_F(QuicConnectionLoggerTest, TruncatedAcksSentNotChanged) {
32 QuicAckFrame frame; 33 QuicAckFrame frame;
33 logger_.OnFrameAddedToPacket(QuicFrame(&frame)); 34 logger_.OnFrameAddedToPacket(QuicFrame(&frame));
34 EXPECT_EQ(0u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_)); 35 EXPECT_EQ(0u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_));
35 36
36 for (QuicPacketSequenceNumber i = 0; i < 256; ++i) { 37 for (QuicPacketSequenceNumber i = 0; i < 256; ++i) {
37 frame.missing_packets.insert(i); 38 frame.missing_packets.insert(i);
38 } 39 }
39 logger_.OnFrameAddedToPacket(QuicFrame(&frame)); 40 logger_.OnFrameAddedToPacket(QuicFrame(&frame));
40 EXPECT_EQ(0u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_)); 41 EXPECT_EQ(0u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_));
41 } 42 }
42 43
43 TEST_F(QuicConnectionLoggerTest, TruncatedAcksSent) { 44 TEST_F(QuicConnectionLoggerTest, TruncatedAcksSent) {
44 QuicAckFrame frame; 45 QuicAckFrame frame;
45 for (QuicPacketSequenceNumber i = 0; i < 512; i += 2) { 46 for (QuicPacketSequenceNumber i = 0; i < 512; i += 2) {
46 frame.missing_packets.insert(i); 47 frame.missing_packets.insert(i);
47 } 48 }
48 logger_.OnFrameAddedToPacket(QuicFrame(&frame)); 49 logger_.OnFrameAddedToPacket(QuicFrame(&frame));
49 EXPECT_EQ(1u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_)); 50 EXPECT_EQ(1u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_));
50 } 51 }
51 52
52 } // namespace test 53 } // namespace test
53 } // namespace net 54 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_logger.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698