Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / net / quic / quic_connection_logger_unittest.cc
blobd5e4e74f2efa5ea6683b49d35561dd0fc50f4167
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
3 // found in the LICENSE file.
5 #include "net/quic/quic_connection_logger.h"
7 #include "net/quic/quic_protocol.h"
8 #include "net/quic/test_tools/quic_test_utils.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace net {
12 namespace test {
14 class QuicConnectionLoggerPeer {
15 public:
16 static size_t num_truncated_acks_sent(const QuicConnectionLogger& logger) {
17 return logger.num_truncated_acks_sent_;
20 static void set_num_packets_received(QuicConnectionLogger& logger,
21 int value) {
22 logger.num_packets_received_ = value;
25 static void set_largest_received_packet_number(QuicConnectionLogger& logger,
26 int value) {
27 logger.largest_received_packet_number_ = value;
31 class QuicConnectionLoggerTest : public ::testing::Test {
32 protected:
33 QuicConnectionLoggerTest()
34 : session_(new MockConnection(Perspective::IS_CLIENT)),
35 logger_(&session_, "CONNECTION_UNKNOWN", net_log_) {}
37 BoundNetLog net_log_;
38 MockQuicSpdySession session_;
39 QuicConnectionLogger logger_;
42 TEST_F(QuicConnectionLoggerTest, TruncatedAcksSentNotChanged) {
43 QuicAckFrame frame;
44 logger_.OnFrameAddedToPacket(QuicFrame(&frame));
45 EXPECT_EQ(0u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_));
47 for (QuicPacketNumber i = 0; i < 256; ++i) {
48 frame.missing_packets.insert(i);
50 logger_.OnFrameAddedToPacket(QuicFrame(&frame));
51 EXPECT_EQ(0u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_));
54 TEST_F(QuicConnectionLoggerTest, TruncatedAcksSent) {
55 QuicAckFrame frame;
56 for (QuicPacketNumber i = 0; i < 512; i += 2) {
57 frame.missing_packets.insert(i);
59 logger_.OnFrameAddedToPacket(QuicFrame(&frame));
60 EXPECT_EQ(1u, QuicConnectionLoggerPeer::num_truncated_acks_sent(logger_));
63 TEST_F(QuicConnectionLoggerTest, ReceivedPacketLossRate) {
64 QuicConnectionLoggerPeer::set_num_packets_received(logger_, 1);
65 QuicConnectionLoggerPeer::set_largest_received_packet_number(logger_, 2);
66 EXPECT_EQ(0.5f, logger_.ReceivedPacketLossRate());
69 } // namespace test
70 } // namespace net