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

Side by Side Diff: media/cast/net/rtcp/rtcp_utility_unittest.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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
OLDNEW
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/test/simple_test_tick_clock.h" 6 #include "base/test/simple_test_tick_clock.h"
7 #include "media/cast/cast_environment.h" 7 #include "media/cast/cast_environment.h"
8 #include "media/cast/net/cast_transport_defines.h" 8 #include "media/cast/net/cast_transport_defines.h"
9 #include "media/cast/net/rtcp/rtcp_utility.h" 9 #include "media/cast/net/rtcp/rtcp_utility.h"
10 #include "media/cast/net/rtcp/test_rtcp_packet_builder.h" 10 #include "media/cast/net/rtcp/test_rtcp_packet_builder.h"
11 #include "media/cast/test/fake_single_thread_task_runner.h" 11 #include "media/cast/test/fake_single_thread_task_runner.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace media { 14 namespace media {
15 namespace cast { 15 namespace cast {
16 16
17 static const uint32 kSenderSsrc = 0x10203; 17 static const uint32_t kSenderSsrc = 0x10203;
18 static const uint32 kSourceSsrc = 0x40506; 18 static const uint32_t kSourceSsrc = 0x40506;
19 static const uint32 kUnknownSsrc = 0xDEAD; 19 static const uint32_t kUnknownSsrc = 0xDEAD;
20 static const base::TimeDelta kTargetDelay = 20 static const base::TimeDelta kTargetDelay =
21 base::TimeDelta::FromMilliseconds(100); 21 base::TimeDelta::FromMilliseconds(100);
22 22
23 class RtcpParserTest : public ::testing::Test { 23 class RtcpParserTest : public ::testing::Test {
24 protected: 24 protected:
25 RtcpParserTest() 25 RtcpParserTest()
26 : testing_clock_(new base::SimpleTestTickClock()), 26 : testing_clock_(new base::SimpleTestTickClock()),
27 task_runner_(new test::FakeSingleThreadTaskRunner( 27 task_runner_(new test::FakeSingleThreadTaskRunner(
28 testing_clock_.get())) { 28 testing_clock_.get())) {
29 } 29 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 p2.AddCast(kSenderSsrc, kSourceSsrc, kTargetDelay); 315 p2.AddCast(kSenderSsrc, kSourceSsrc, kTargetDelay);
316 316
317 // Expected to be pass through since the sender ssrc match our local ssrc. 317 // Expected to be pass through since the sender ssrc match our local ssrc.
318 RtcpParser parser2(kSourceSsrc, kSenderSsrc); 318 RtcpParser parser2(kSourceSsrc, kSenderSsrc);
319 EXPECT_TRUE(parser2.Parse(p2.Reader())); 319 EXPECT_TRUE(parser2.Parse(p2.Reader()));
320 ExpectLastReport(parser2); 320 ExpectLastReport(parser2);
321 ExpectCastFeedback(parser2); 321 ExpectCastFeedback(parser2);
322 } 322 }
323 323
324 TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationBase) { 324 TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationBase) {
325 static const uint32 kTimeBaseMs = 12345678; 325 static const uint32_t kTimeBaseMs = 12345678;
326 static const uint32 kTimeDelayMs = 10; 326 static const uint32_t kTimeDelayMs = 10;
327 static const uint32 kDelayDeltaMs = 123; 327 static const uint32_t kDelayDeltaMs = 123;
328 base::SimpleTestTickClock testing_clock; 328 base::SimpleTestTickClock testing_clock;
329 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs)); 329 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs));
330 330
331 RtcpReceiverLogMessage receiver_log; 331 RtcpReceiverLogMessage receiver_log;
332 RtcpReceiverFrameLogMessage frame_log(kRtpTimestamp); 332 RtcpReceiverFrameLogMessage frame_log(kRtpTimestamp);
333 RtcpReceiverEventLogMessage event_log; 333 RtcpReceiverEventLogMessage event_log;
334 334
335 event_log.type = FRAME_ACK_SENT; 335 event_log.type = FRAME_ACK_SENT;
336 event_log.event_timestamp = testing_clock.NowTicks(); 336 event_log.event_timestamp = testing_clock.NowTicks();
337 event_log.delay_delta = base::TimeDelta::FromMilliseconds(kDelayDeltaMs); 337 event_log.delay_delta = base::TimeDelta::FromMilliseconds(kDelayDeltaMs);
(...skipping 20 matching lines...) Expand all
358 p.AddReceiverEventLog(kDelayDeltaMs, FRAME_ACK_SENT, 0); 358 p.AddReceiverEventLog(kDelayDeltaMs, FRAME_ACK_SENT, 0);
359 p.AddReceiverEventLog(kLostPacketId1, PACKET_RECEIVED, kTimeDelayMs); 359 p.AddReceiverEventLog(kLostPacketId1, PACKET_RECEIVED, kTimeDelayMs);
360 p.AddReceiverEventLog(kLostPacketId2, PACKET_RECEIVED, kTimeDelayMs); 360 p.AddReceiverEventLog(kLostPacketId2, PACKET_RECEIVED, kTimeDelayMs);
361 361
362 RtcpParser parser(kSourceSsrc, kSenderSsrc); 362 RtcpParser parser(kSourceSsrc, kSenderSsrc);
363 EXPECT_TRUE(parser.Parse(p.Reader())); 363 EXPECT_TRUE(parser.Parse(p.Reader()));
364 ExpectReceiverLog(parser, receiver_log); 364 ExpectReceiverLog(parser, receiver_log);
365 } 365 }
366 366
367 TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationMulti) { 367 TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationMulti) {
368 static const uint32 kTimeBaseMs = 12345678; 368 static const uint32_t kTimeBaseMs = 12345678;
369 static const uint32 kTimeDelayMs = 10; 369 static const uint32_t kTimeDelayMs = 10;
370 static const int kDelayDeltaMs = 123; // To be varied for every frame. 370 static const int kDelayDeltaMs = 123; // To be varied for every frame.
371 base::SimpleTestTickClock testing_clock; 371 base::SimpleTestTickClock testing_clock;
372 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs)); 372 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs));
373 373
374 RtcpReceiverLogMessage receiver_log; 374 RtcpReceiverLogMessage receiver_log;
375 375
376 for (int j = 0; j < 100; ++j) { 376 for (int j = 0; j < 100; ++j) {
377 RtcpReceiverFrameLogMessage frame_log(kRtpTimestamp); 377 RtcpReceiverFrameLogMessage frame_log(kRtpTimestamp);
378 RtcpReceiverEventLogMessage event_log; 378 RtcpReceiverEventLogMessage event_log;
379 event_log.type = FRAME_ACK_SENT; 379 event_log.type = FRAME_ACK_SENT;
380 event_log.event_timestamp = testing_clock.NowTicks(); 380 event_log.event_timestamp = testing_clock.NowTicks();
381 event_log.delay_delta = 381 event_log.delay_delta =
382 base::TimeDelta::FromMilliseconds((j - 50) * kDelayDeltaMs); 382 base::TimeDelta::FromMilliseconds((j - 50) * kDelayDeltaMs);
383 frame_log.event_log_messages_.push_back(event_log); 383 frame_log.event_log_messages_.push_back(event_log);
384 receiver_log.push_back(frame_log); 384 receiver_log.push_back(frame_log);
385 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeDelayMs)); 385 testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeDelayMs));
386 } 386 }
387 387
388 TestRtcpPacketBuilder p; 388 TestRtcpPacketBuilder p;
389 p.AddRr(kSenderSsrc, 1); 389 p.AddRr(kSenderSsrc, 1);
390 p.AddRb(kSourceSsrc); 390 p.AddRb(kSourceSsrc);
391 p.AddReceiverLog(kSenderSsrc); 391 p.AddReceiverLog(kSenderSsrc);
392 for (int i = 0; i < 100; ++i) { 392 for (int i = 0; i < 100; ++i) {
393 p.AddReceiverFrameLog(kRtpTimestamp, 1, kTimeBaseMs + i * kTimeDelayMs); 393 p.AddReceiverFrameLog(kRtpTimestamp, 1, kTimeBaseMs + i * kTimeDelayMs);
394 const int delay = (i - 50) * kDelayDeltaMs; 394 const int delay = (i - 50) * kDelayDeltaMs;
395 p.AddReceiverEventLog(static_cast<uint16>(delay), FRAME_ACK_SENT, 0); 395 p.AddReceiverEventLog(static_cast<uint16_t>(delay), FRAME_ACK_SENT, 0);
396 } 396 }
397 397
398 RtcpParser parser(kSourceSsrc, kSenderSsrc); 398 RtcpParser parser(kSourceSsrc, kSenderSsrc);
399 EXPECT_TRUE(parser.Parse(p.Reader())); 399 EXPECT_TRUE(parser.Parse(p.Reader()));
400 ExpectReceiverLog(parser, receiver_log); 400 ExpectReceiverLog(parser, receiver_log);
401 } 401 }
402 402
403 } // namespace cast 403 } // namespace cast
404 } // namespace media 404 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698