Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: media/cast/rtcp/rtcp_receiver_unittest.cc

Issue 69603002: Incorporating logging into Cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding scoped_ptr include Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/cast/rtcp/rtcp_receiver.cc ('k') | media/cast/rtcp/rtcp_sender.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/test/simple_test_tick_clock.h"
7 #include "media/cast/cast_environment.h"
6 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h" 8 #include "media/cast/rtcp/mock_rtcp_receiver_feedback.h"
7 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h" 9 #include "media/cast/rtcp/mock_rtcp_sender_feedback.h"
8 #include "media/cast/rtcp/rtcp_receiver.h" 10 #include "media/cast/rtcp/rtcp_receiver.h"
9 #include "media/cast/rtcp/rtcp_utility.h" 11 #include "media/cast/rtcp/rtcp_utility.h"
10 #include "media/cast/rtcp/test_rtcp_packet_builder.h" 12 #include "media/cast/rtcp/test_rtcp_packet_builder.h"
13 #include "media/cast/test/fake_task_runner.h"
11 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
12 15
13 namespace media { 16 namespace media {
14 namespace cast { 17 namespace cast {
15 18
16 using testing::_; 19 using testing::_;
17 20
18 static const uint32 kSenderSsrc = 0x10203; 21 static const uint32 kSenderSsrc = 0x10203;
19 static const uint32 kSourceSsrc = 0x40506; 22 static const uint32 kSourceSsrc = 0x40506;
20 static const uint32 kUnknownSsrc = 0xDEAD; 23 static const uint32 kUnknownSsrc = 0xDEAD;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 bool called() const { return called_; } 57 bool called() const { return called_; }
55 58
56 private: 59 private:
57 bool called_; 60 bool called_;
58 }; 61 };
59 } // namespace 62 } // namespace
60 63
61 class RtcpReceiverTest : public ::testing::Test { 64 class RtcpReceiverTest : public ::testing::Test {
62 protected: 65 protected:
63 RtcpReceiverTest() 66 RtcpReceiverTest()
64 : rtcp_receiver_(new RtcpReceiver(&mock_sender_feedback_, 67 : task_runner_(new test::FakeTaskRunner(&testing_clock_)),
68 cast_environment_(new CastEnvironment(&testing_clock_, task_runner_,
69 task_runner_, task_runner_, task_runner_, task_runner_,
70 GetDefaultCastLoggingConfig())),
71 rtcp_receiver_(new RtcpReceiver(cast_environment_,
72 &mock_sender_feedback_,
65 &mock_receiver_feedback_, 73 &mock_receiver_feedback_,
66 &mock_rtt_feedback_, 74 &mock_rtt_feedback_,
67 kSourceSsrc)) { 75 kSourceSsrc)) {
68 } 76 }
69 77
70 virtual ~RtcpReceiverTest() {} 78 virtual ~RtcpReceiverTest() {}
71 79
72 virtual void SetUp() OVERRIDE { 80 virtual void SetUp() OVERRIDE {
73 EXPECT_CALL(mock_receiver_feedback_, OnReceivedSenderReport(_)).Times(0); 81 EXPECT_CALL(mock_receiver_feedback_, OnReceivedSenderReport(_)).Times(0);
74 EXPECT_CALL(mock_receiver_feedback_, 82 EXPECT_CALL(mock_receiver_feedback_,
(...skipping 22 matching lines...) Expand all
97 expected_receiver_reference_report_.ntp_seconds = kNtpHigh; 105 expected_receiver_reference_report_.ntp_seconds = kNtpHigh;
98 expected_receiver_reference_report_.ntp_fraction = kNtpLow; 106 expected_receiver_reference_report_.ntp_fraction = kNtpLow;
99 } 107 }
100 108
101 // Injects an RTCP packet into the receiver. 109 // Injects an RTCP packet into the receiver.
102 void InjectRtcpPacket(const uint8* packet, uint16 length) { 110 void InjectRtcpPacket(const uint8* packet, uint16 length) {
103 RtcpParser rtcp_parser(packet, length); 111 RtcpParser rtcp_parser(packet, length);
104 rtcp_receiver_->IncomingRtcpPacket(&rtcp_parser); 112 rtcp_receiver_->IncomingRtcpPacket(&rtcp_parser);
105 } 113 }
106 114
115 base::SimpleTestTickClock testing_clock_;
116 scoped_refptr<test::FakeTaskRunner> task_runner_;
117 scoped_refptr<CastEnvironment> cast_environment_;
107 MockRtcpReceiverFeedback mock_receiver_feedback_; 118 MockRtcpReceiverFeedback mock_receiver_feedback_;
108 MockRtcpRttFeedback mock_rtt_feedback_; 119 MockRtcpRttFeedback mock_rtt_feedback_;
109 MockRtcpSenderFeedback mock_sender_feedback_; 120 MockRtcpSenderFeedback mock_sender_feedback_;
110 scoped_ptr<RtcpReceiver> rtcp_receiver_; 121 scoped_ptr<RtcpReceiver> rtcp_receiver_;
111 RtcpSenderInfo expected_sender_info_; 122 RtcpSenderInfo expected_sender_info_;
112 RtcpReportBlock expected_report_block_; 123 RtcpReportBlock expected_report_block_;
113 RtcpReceiverReferenceTimeReport expected_receiver_reference_report_; 124 RtcpReceiverReferenceTimeReport expected_receiver_reference_report_;
114 }; 125 };
115 126
116 TEST_F(RtcpReceiverTest, BrokenPacketIsIgnored) { 127 TEST_F(RtcpReceiverTest, BrokenPacketIsIgnored) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 p2.AddRr(kSenderSsrc, 1); 327 p2.AddRr(kSenderSsrc, 1);
317 p2.AddRb(kSourceSsrc); 328 p2.AddRb(kSourceSsrc);
318 p2.AddCast(kSenderSsrc, kSourceSsrc); 329 p2.AddCast(kSenderSsrc, kSourceSsrc);
319 330
320 // Expected to be pass through since the sender ssrc match our local ssrc. 331 // Expected to be pass through since the sender ssrc match our local ssrc.
321 InjectRtcpPacket(p2.Packet(), p2.Length()); 332 InjectRtcpPacket(p2.Packet(), p2.Length());
322 } 333 }
323 334
324 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastVerification) { 335 TEST_F(RtcpReceiverTest, InjectReceiverReportPacketWithCastVerification) {
325 SenderFeedbackCastVerification sender_feedback_cast_verification; 336 SenderFeedbackCastVerification sender_feedback_cast_verification;
326 RtcpReceiver rtcp_receiver(&sender_feedback_cast_verification, 337 RtcpReceiver rtcp_receiver(cast_environment_,
338 &sender_feedback_cast_verification,
327 &mock_receiver_feedback_, 339 &mock_receiver_feedback_,
328 &mock_rtt_feedback_, 340 &mock_rtt_feedback_,
329 kSourceSsrc); 341 kSourceSsrc);
330 342
331 EXPECT_CALL(mock_rtt_feedback_, 343 EXPECT_CALL(mock_rtt_feedback_,
332 OnReceivedDelaySinceLastReport(kSourceSsrc, 344 OnReceivedDelaySinceLastReport(kSourceSsrc,
333 kLastSr, 345 kLastSr,
334 kDelayLastSr)).Times(1); 346 kDelayLastSr)).Times(1);
335 347
336 // Enable receiving the cast feedback. 348 // Enable receiving the cast feedback.
337 rtcp_receiver.SetRemoteSSRC(kSenderSsrc); 349 rtcp_receiver.SetRemoteSSRC(kSenderSsrc);
338 350
339 TestRtcpPacketBuilder p; 351 TestRtcpPacketBuilder p;
340 p.AddRr(kSenderSsrc, 1); 352 p.AddRr(kSenderSsrc, 1);
341 p.AddRb(kSourceSsrc); 353 p.AddRb(kSourceSsrc);
342 p.AddCast(kSenderSsrc, kSourceSsrc); 354 p.AddCast(kSenderSsrc, kSourceSsrc);
343 355
344 // Expected to be pass through since the sender ssrc match our local ssrc. 356 // Expected to be pass through since the sender ssrc match our local ssrc.
345 RtcpParser rtcp_parser(p.Packet(), p.Length()); 357 RtcpParser rtcp_parser(p.Packet(), p.Length());
346 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser); 358 rtcp_receiver.IncomingRtcpPacket(&rtcp_parser);
347 359
348 EXPECT_TRUE(sender_feedback_cast_verification.called()); 360 EXPECT_TRUE(sender_feedback_cast_verification.called());
349 } 361 }
350 362
351 } // namespace cast 363 } // namespace cast
352 } // namespace media 364 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/rtcp/rtcp_receiver.cc ('k') | media/cast/rtcp/rtcp_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698