test/fake_network_pipe_unittest.cc
TEST_F(FakeNetworkPipeTest, StatisticsTest) {
  FakeNetworkPipe::Config config;
  config.queue_length_packets = 2;
  config.queue_delay_ms = 20;
  config.link_capacity_kbps = 80;
  rtc::scoped_ptr<FakeNetworkPipe> pipe(
      new FakeNetworkPipe(&fake_clock_, config));
  pipe->SetReceiver(receiver_.get());

  const int kPacketSize = 1000;
  const int kPacketTimeMs = PacketTimeMs(config.link_capacity_kbps,
                                         kPacketSize);

  // Send three packets and verify only 2 are delivered.
  SendPackets(pipe.get(), 3, kPacketSize);
  fake_clock_.AdvanceTimeMilliseconds(3 * kPacketTimeMs +
                                      config.queue_delay_ms);

  EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(2);
  pipe->Process();

  // Packet 1: kPacketTimeMs + config.queue_delay_ms,
  // packet 2: 2 * kPacketTimeMs + config.queue_delay_ms => 170 ms average.
  EXPECT_EQ(pipe->AverageDelay(), 170);
  EXPECT_EQ(pipe->sent_packets(), 2u);
  EXPECT_EQ(pipe->dropped_packets(), 1u);
  EXPECT_EQ(pipe->PercentageLoss(), 1/3.f);
}
// Test we get statistics as expected.
Test we get statistics as expected.
Test we get statistics as expected .
TEST_F(FakeNetworkPipeTest, StatisticsTest) {
  FakeNetworkPipe::Config config;
  config.queue_length_packets = 2;
  config.queue_delay_ms = 20;
  config.link_capacity_kbps = 80;
  rtc::scoped_ptr<FakeNetworkPipe> pipe(
      new FakeNetworkPipe(&fake_clock_, config));
  pipe->SetReceiver(receiver_.get());
  const int kPacketSize = 1000;
  const int kPacketTimeMs = PacketTimeMs(config.link_capacity_kbps,
                                         kPacketSize);
  SendPackets(pipe.get(), 3, kPacketSize);
  fake_clock_.AdvanceTimeMilliseconds(3 * kPacketTimeMs +
                                      config.queue_delay_ms);
  EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(2);
  pipe->Process();
  EXPECT_EQ(pipe->AverageDelay(), 170);
  EXPECT_EQ(pipe->sent_packets(), 2u);
  EXPECT_EQ(pipe->dropped_packets(), 1u);
  EXPECT_EQ(pipe->PercentageLoss(), 1/3.f);
}
TEST_F ( FakeNetworkPipeTest , StatisticsTest ) { FakeNetworkPipe :: Config config ; config . queue_length_packets = 2 ; config . queue_delay_ms = 20 ; config . link_capacity_kbps = 80 ; rtc :: scoped_ptr < FakeNetworkPipe > pipe ( new FakeNetworkPipe ( & fake_clock_ , config ) ) ; pipe -> SetReceiver ( receiver_ . get ( ) ) ; const int kPacketSize = 1000 ; const int kPacketTimeMs = PacketTimeMs ( config . link_capacity_kbps , kPacketSize ) ; SendPackets ( pipe . get ( ) , 3 , kPacketSize ) ; fake_clock_ . AdvanceTimeMilliseconds ( 3 * kPacketTimeMs + config . queue_delay_ms ) ; EXPECT_CALL ( * receiver_ , DeliverPacket ( _ , _ , _ , _ ) ) . Times ( 2 ) ; pipe -> Process ( ) ; EXPECT_EQ ( pipe -> AverageDelay ( ) , 170 ) ; EXPECT_EQ ( pipe -> sent_packets ( ) , 2u ) ; EXPECT_EQ ( pipe -> dropped_packets ( ) , 1u ) ; EXPECT_EQ ( pipe -> PercentageLoss ( ) , 1 / 3.f ) ; }
Test we get statistics as expected.
Test we get statistics as expected .
// Send three packets and verify only 2 are delivered. // Packet 1: kPacketTimeMs + config.queue_delay_ms, // packet 2: 2 * kPacketTimeMs + config.queue_delay_ms => 170 ms average.