OLD | NEW |
---|---|
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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/big_endian.h" | 7 #include "base/big_endian.h" |
8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
9 #include "media/cast/logging/logging_impl.h" | 9 #include "media/cast/logging/logging_impl.h" |
10 #include "media/cast/logging/simple_event_subscriber.h" | 10 #include "media/cast/logging/simple_event_subscriber.h" |
11 #include "media/cast/net/pacing/paced_sender.h" | 11 #include "media/cast/net/pacing/paced_sender.h" |
12 #include "media/cast/test/fake_single_thread_task_runner.h" | 12 #include "media/cast/test/fake_single_thread_task_runner.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 | 14 |
15 using testing::_; | 15 using testing::_; |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 namespace cast { | 18 namespace cast { |
19 namespace { | 19 namespace { |
20 | 20 |
21 static const uint8 kValue = 123; | 21 static const uint8 kValue = 123; |
22 static const size_t kSize1 = 100; | 22 static const size_t kSize1 = 101; |
23 static const size_t kSize2 = 101; | 23 static const size_t kSize2 = 102; |
24 static const size_t kSize3 = 102; | 24 static const size_t kSize3 = 103; |
25 static const size_t kSize4 = 103; | 25 static const size_t kSize4 = 104; |
26 static const size_t kNackSize = 104; | 26 static const size_t kNackSize = 105; |
27 static const int64 kStartMillisecond = INT64_C(12345678900000); | 27 static const int64 kStartMillisecond = INT64_C(12345678900000); |
28 static const uint32 kVideoSsrc = 0x1234; | 28 static const uint32 kVideoSsrc = 0x1234; |
29 static const uint32 kAudioSsrc = 0x5678; | 29 static const uint32 kAudioSsrc = 0x5678; |
30 | 30 |
31 class TestPacketSender : public PacketSender { | 31 class TestPacketSender : public PacketSender { |
32 public: | 32 public: |
33 TestPacketSender() {} | 33 TestPacketSender() {} |
34 | 34 |
35 virtual bool SendPacket(PacketRef packet, const base::Closure& cb) OVERRIDE { | 35 virtual bool SendPacket(PacketRef packet, const base::Closure& cb) OVERRIDE { |
36 EXPECT_FALSE(expected_packet_size_.empty()); | 36 EXPECT_FALSE(expected_packet_size_.empty()); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 testing_clock_.Advance(timeout_10ms); | 342 testing_clock_.Advance(timeout_10ms); |
343 task_runner_->RunTasks(); | 343 task_runner_->RunTasks(); |
344 | 344 |
345 testing_clock_.Advance(timeout_10ms); | 345 testing_clock_.Advance(timeout_10ms); |
346 task_runner_->RunTasks(); | 346 task_runner_->RunTasks(); |
347 | 347 |
348 // No more packets. | 348 // No more packets. |
349 EXPECT_TRUE(RunUntilEmpty(5)); | 349 EXPECT_TRUE(RunUntilEmpty(5)); |
350 } | 350 } |
351 | 351 |
352 TEST_F(PacedSenderTest, SendPriority) { | |
353 mock_transport_.AddExpectedSize(kSize2, 10); // Normal video packets. | |
354 mock_transport_.AddExpectedSize(kSize3, 1); // RTCP packet. | |
355 mock_transport_.AddExpectedSize(kSize1, 1); // Audio packet. | |
356 mock_transport_.AddExpectedSize(kSize4, 10); // Resend video packets. | |
357 mock_transport_.AddExpectedSize(kSize2, 10); // Normal video packets. | |
358 | |
359 paced_sender_->RegisterPrioritySsrc(kAudioSsrc); | |
360 | |
361 SendPacketVector resend_packets = | |
miu
2014/07/16 22:55:56
Can you add comments for the rest of this test cod
Alpha Left Google
2014/07/17 00:12:57
Done.
| |
362 CreateSendPacketVector(kSize4, 10, false); | |
363 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(10)); | |
364 EXPECT_TRUE(paced_sender_->SendPackets( | |
365 CreateSendPacketVector(kSize2, 20, false))); | |
366 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(10)); | |
367 EXPECT_TRUE(paced_sender_->SendPackets( | |
368 CreateSendPacketVector(kSize1, 1, true))); | |
369 EXPECT_TRUE(paced_sender_->SendRtcpPacket( | |
370 kVideoSsrc, | |
371 new base::RefCountedData<Packet>(Packet(kSize3, kValue)))); | |
372 EXPECT_TRUE(paced_sender_->ResendPackets( | |
373 resend_packets, base::TimeDelta())); | |
374 task_runner_->RunTasks(); | |
375 EXPECT_TRUE(RunUntilEmpty(4)); | |
376 } | |
377 | |
352 } // namespace cast | 378 } // namespace cast |
353 } // namespace media | 379 } // namespace media |
OLD | NEW |