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.
4
5 #include "base/logging.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "net/quic/congestion_control/tcp_receiver.h"
8 #include "net/quic/test_tools/mock_clock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace net {
12 namespace test {
13
14 class QuicTcpReceiverTest : public ::testing::Test {
15 protected:
SetUp()16 virtual void SetUp() {
17 receiver_.reset(new TcpReceiver());
18 }
19 scoped_ptr<TcpReceiver> receiver_;
20 };
21
TEST_F(QuicTcpReceiverTest,SimpleReceiver)22 TEST_F(QuicTcpReceiverTest, SimpleReceiver) {
23 QuicCongestionFeedbackFrame feedback;
24 QuicTime timestamp(QuicTime::Zero());
25 receiver_->RecordIncomingPacket(1, 1, timestamp, false);
26 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback));
27 EXPECT_EQ(kTCP, feedback.type);
28 EXPECT_EQ(256000u, feedback.tcp.receive_window);
29 EXPECT_EQ(0, feedback.tcp.accumulated_number_of_lost_packets);
30 receiver_->RecordIncomingPacket(1, 2, timestamp, true);
31 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback));
32 EXPECT_EQ(kTCP, feedback.type);
33 EXPECT_EQ(256000u, feedback.tcp.receive_window);
34 EXPECT_EQ(1, feedback.tcp.accumulated_number_of_lost_packets);
35 }
36
37 } // namespace test
38 } // namespace net
39