aboutsummaryrefslogtreecommitdiff
path: root/webrtc/test/fake_network_pipe_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webrtc/test/fake_network_pipe_unittest.cc')
-rw-r--r--webrtc/test/fake_network_pipe_unittest.cc54
1 files changed, 32 insertions, 22 deletions
diff --git a/webrtc/test/fake_network_pipe_unittest.cc b/webrtc/test/fake_network_pipe_unittest.cc
index 02438c59f3..ff18993829 100644
--- a/webrtc/test/fake_network_pipe_unittest.cc
+++ b/webrtc/test/fake_network_pipe_unittest.cc
@@ -13,7 +13,7 @@
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/call.h"
-#include "webrtc/system_wrappers/include/tick_util.h"
+#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/test/fake_network_pipe.h"
using ::testing::_;
@@ -39,9 +39,11 @@ class MockReceiver : public PacketReceiver {
};
class FakeNetworkPipeTest : public ::testing::Test {
+ public:
+ FakeNetworkPipeTest() : fake_clock_(12345) {}
+
protected:
virtual void SetUp() {
- TickTime::UseFakeClock(12345);
receiver_.reset(new MockReceiver());
ON_CALL(*receiver_, DeliverPacket(_, _, _, _))
.WillByDefault(Return(PacketReceiver::DELIVERY_OK));
@@ -61,6 +63,7 @@ class FakeNetworkPipeTest : public ::testing::Test {
return 8 * kPacketSize / capacity_kbps;
}
+ SimulatedClock fake_clock_;
rtc::scoped_ptr<MockReceiver> receiver_;
};
@@ -71,7 +74,8 @@ TEST_F(FakeNetworkPipeTest, CapacityTest) {
FakeNetworkPipe::Config config;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
- rtc::scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
+ rtc::scoped_ptr<FakeNetworkPipe> pipe(
+ new FakeNetworkPipe(&fake_clock_, config));
pipe->SetReceiver(receiver_.get());
// Add 10 packets of 1000 bytes, = 80 kb, and verify it takes one second to
@@ -89,17 +93,17 @@ TEST_F(FakeNetworkPipeTest, CapacityTest) {
pipe->Process();
// Advance enough time to release one packet.
- TickTime::AdvanceFakeClock(kPacketTimeMs);
+ fake_clock_.AdvanceTimeMilliseconds(kPacketTimeMs);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(1);
pipe->Process();
// Release all but one packet
- TickTime::AdvanceFakeClock(9 * kPacketTimeMs - 1);
+ fake_clock_.AdvanceTimeMilliseconds(9 * kPacketTimeMs - 1);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(8);
pipe->Process();
// And the last one.
- TickTime::AdvanceFakeClock(1);
+ fake_clock_.AdvanceTimeMilliseconds(1);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(1);
pipe->Process();
}
@@ -110,7 +114,8 @@ TEST_F(FakeNetworkPipeTest, ExtraDelayTest) {
config.queue_length_packets = 20;
config.queue_delay_ms = 100;
config.link_capacity_kbps = 80;
- rtc::scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
+ rtc::scoped_ptr<FakeNetworkPipe> pipe(
+ new FakeNetworkPipe(&fake_clock_, config));
pipe->SetReceiver(receiver_.get());
const int kNumPackets = 2;
@@ -122,17 +127,17 @@ TEST_F(FakeNetworkPipeTest, ExtraDelayTest) {
kPacketSize);
// Increase more than kPacketTimeMs, but not more than the extra delay.
- TickTime::AdvanceFakeClock(kPacketTimeMs);
+ fake_clock_.AdvanceTimeMilliseconds(kPacketTimeMs);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(0);
pipe->Process();
// Advance the network delay to get the first packet.
- TickTime::AdvanceFakeClock(config.queue_delay_ms);
+ fake_clock_.AdvanceTimeMilliseconds(config.queue_delay_ms);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(1);
pipe->Process();
// Advance one more kPacketTimeMs to get the last packet.
- TickTime::AdvanceFakeClock(kPacketTimeMs);
+ fake_clock_.AdvanceTimeMilliseconds(kPacketTimeMs);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(1);
pipe->Process();
}
@@ -143,7 +148,8 @@ TEST_F(FakeNetworkPipeTest, QueueLengthTest) {
FakeNetworkPipe::Config config;
config.queue_length_packets = 2;
config.link_capacity_kbps = 80;
- rtc::scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
+ rtc::scoped_ptr<FakeNetworkPipe> pipe(
+ new FakeNetworkPipe(&fake_clock_, config));
pipe->SetReceiver(receiver_.get());
const int kPacketSize = 1000;
@@ -155,7 +161,7 @@ TEST_F(FakeNetworkPipeTest, QueueLengthTest) {
// Increase time enough to deliver all three packets, verify only two are
// delivered.
- TickTime::AdvanceFakeClock(3 * kPacketTimeMs);
+ fake_clock_.AdvanceTimeMilliseconds(3 * kPacketTimeMs);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(2);
pipe->Process();
}
@@ -166,7 +172,8 @@ TEST_F(FakeNetworkPipeTest, StatisticsTest) {
config.queue_length_packets = 2;
config.queue_delay_ms = 20;
config.link_capacity_kbps = 80;
- rtc::scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
+ rtc::scoped_ptr<FakeNetworkPipe> pipe(
+ new FakeNetworkPipe(&fake_clock_, config));
pipe->SetReceiver(receiver_.get());
const int kPacketSize = 1000;
@@ -175,7 +182,8 @@ TEST_F(FakeNetworkPipeTest, StatisticsTest) {
// Send three packets and verify only 2 are delivered.
SendPackets(pipe.get(), 3, kPacketSize);
- TickTime::AdvanceFakeClock(3 * kPacketTimeMs + config.queue_delay_ms);
+ fake_clock_.AdvanceTimeMilliseconds(3 * kPacketTimeMs +
+ config.queue_delay_ms);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(2);
pipe->Process();
@@ -194,7 +202,8 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
FakeNetworkPipe::Config config;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
- rtc::scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
+ rtc::scoped_ptr<FakeNetworkPipe> pipe(
+ new FakeNetworkPipe(&fake_clock_, config));
pipe->SetReceiver(receiver_.get());
// Add 10 packets of 1000 bytes, = 80 kb, and verify it takes one second to
@@ -212,7 +221,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
// Advance time in steps to release one packet at a time.
for (int i = 0; i < kNumPackets; ++i) {
- TickTime::AdvanceFakeClock(packet_time_ms);
+ fake_clock_.AdvanceTimeMilliseconds(packet_time_ms);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(1);
pipe->Process();
}
@@ -234,14 +243,14 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
// Advance time in steps to release one packet at a time.
for (int i = 0; i < kNumPackets; ++i) {
- TickTime::AdvanceFakeClock(packet_time_ms);
+ fake_clock_.AdvanceTimeMilliseconds(packet_time_ms);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(1);
pipe->Process();
}
// Check that all the packets were sent.
EXPECT_EQ(static_cast<size_t>(2 * kNumPackets), pipe->sent_packets());
- TickTime::AdvanceFakeClock(pipe->TimeUntilNextProcess());
+ fake_clock_.AdvanceTimeMilliseconds(pipe->TimeUntilNextProcess());
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(0);
pipe->Process();
}
@@ -252,7 +261,8 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
FakeNetworkPipe::Config config;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
- rtc::scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
+ rtc::scoped_ptr<FakeNetworkPipe> pipe(
+ new FakeNetworkPipe(&fake_clock_, config));
pipe->SetReceiver(receiver_.get());
// Add 10 packets of 1000 bytes, = 80 kb.
@@ -280,21 +290,21 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
// Advance time in steps to release one packet at a time.
for (int i = 0; i < kNumPackets; ++i) {
- TickTime::AdvanceFakeClock(packet_time_1_ms);
+ fake_clock_.AdvanceTimeMilliseconds(packet_time_1_ms);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(1);
pipe->Process();
}
// Advance time in steps to release one packet at a time.
for (int i = 0; i < kNumPackets; ++i) {
- TickTime::AdvanceFakeClock(packet_time_2_ms);
+ fake_clock_.AdvanceTimeMilliseconds(packet_time_2_ms);
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(1);
pipe->Process();
}
// Check that all the packets were sent.
EXPECT_EQ(static_cast<size_t>(2 * kNumPackets), pipe->sent_packets());
- TickTime::AdvanceFakeClock(pipe->TimeUntilNextProcess());
+ fake_clock_.AdvanceTimeMilliseconds(pipe->TimeUntilNextProcess());
EXPECT_CALL(*receiver_, DeliverPacket(_, _, _, _)).Times(0);
pipe->Process();
}