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

Side by Side Diff: webrtc/call/rtp_demuxer_unittest.cc

Issue 3003133002: Fix an implicit narrowing conversion found by MSVC (Closed)
Patch Set: no roll Created 3 years, 4 months 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
« no previous file with comments | « webrtc/api/audio_codecs/L16/audio_encoder_L16.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/call/rtp_demuxer.h" 11 #include "webrtc/call/rtp_demuxer.h"
12 12
13 #include <memory> 13 #include <memory>
14 #include <set> 14 #include <set>
15 #include <string> 15 #include <string>
16 16
17 #include "webrtc/call/ssrc_binding_observer.h" 17 #include "webrtc/call/ssrc_binding_observer.h"
18 #include "webrtc/call/test/mock_rtp_packet_sink_interface.h" 18 #include "webrtc/call/test/mock_rtp_packet_sink_interface.h"
19 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h" 20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" 21 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" 22 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
23 #include "webrtc/rtc_base/arraysize.h" 23 #include "webrtc/rtc_base/arraysize.h"
24 #include "webrtc/rtc_base/basictypes.h" 24 #include "webrtc/rtc_base/basictypes.h"
25 #include "webrtc/rtc_base/checks.h" 25 #include "webrtc/rtc_base/checks.h"
26 #include "webrtc/rtc_base/ptr_util.h" 26 #include "webrtc/rtc_base/ptr_util.h"
27 #include "webrtc/rtc_base/safe_conversions.h"
27 #include "webrtc/test/gmock.h" 28 #include "webrtc/test/gmock.h"
28 #include "webrtc/test/gtest.h" 29 #include "webrtc/test/gtest.h"
29 30
30 namespace webrtc { 31 namespace webrtc {
31 32
32 namespace { 33 namespace {
33 34
34 using ::testing::_; 35 using ::testing::_;
35 using ::testing::AtLeast; 36 using ::testing::AtLeast;
36 using ::testing::AtMost; 37 using ::testing::AtMost;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 340 }
340 341
341 TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByRsid) { 342 TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByRsid) {
342 const std::string rsids[] = {"a", "b", "c"}; 343 const std::string rsids[] = {"a", "b", "c"};
343 MockRtpPacketSink sinks[arraysize(rsids)]; 344 MockRtpPacketSink sinks[arraysize(rsids)];
344 for (size_t i = 0; i < arraysize(rsids); i++) { 345 for (size_t i = 0; i < arraysize(rsids); i++) {
345 AddSinkOnlyRsid(rsids[i], &sinks[i]); 346 AddSinkOnlyRsid(rsids[i], &sinks[i]);
346 } 347 }
347 348
348 for (size_t i = 0; i < arraysize(rsids); i++) { 349 for (size_t i = 0; i < arraysize(rsids); i++) {
349 auto packet = CreatePacketWithSsrcRsid(i, rsids[i]); 350 auto packet = CreatePacketWithSsrcRsid(rtc::checked_cast<uint32_t>(i),
351 rsids[i]);
350 EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1); 352 EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1);
351 EXPECT_TRUE(demuxer_.OnRtpPacket(*packet)); 353 EXPECT_TRUE(demuxer_.OnRtpPacket(*packet));
352 } 354 }
353 } 355 }
354 356
355 TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByMid) { 357 TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByMid) {
356 const std::string mids[] = {"a", "v", "s"}; 358 const std::string mids[] = {"a", "v", "s"};
357 MockRtpPacketSink sinks[arraysize(mids)]; 359 MockRtpPacketSink sinks[arraysize(mids)];
358 for (size_t i = 0; i < arraysize(mids); i++) { 360 for (size_t i = 0; i < arraysize(mids); i++) {
359 AddSinkOnlyMid(mids[i], &sinks[i]); 361 AddSinkOnlyMid(mids[i], &sinks[i]);
360 } 362 }
361 363
362 for (size_t i = 0; i < arraysize(mids); i++) { 364 for (size_t i = 0; i < arraysize(mids); i++) {
363 auto packet = CreatePacketWithSsrcMid(i, mids[i]); 365 auto packet = CreatePacketWithSsrcMid(rtc::checked_cast<uint32_t>(i),
366 mids[i]);
364 EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1); 367 EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1);
365 EXPECT_TRUE(demuxer_.OnRtpPacket(*packet)); 368 EXPECT_TRUE(demuxer_.OnRtpPacket(*packet));
366 } 369 }
367 } 370 }
368 371
369 TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByMidAndRsid) { 372 TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByMidAndRsid) {
370 const std::string mid = "v"; 373 const std::string mid = "v";
371 const std::string rsid = "1"; 374 const std::string rsid = "1";
372 constexpr uint32_t ssrc = 10; 375 constexpr uint32_t ssrc = 10;
373 376
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 410 }
408 411
409 TEST_F(RtpDemuxerTest, PacketsDeliveredInRightOrder) { 412 TEST_F(RtpDemuxerTest, PacketsDeliveredInRightOrder) {
410 constexpr uint32_t ssrc = 101; 413 constexpr uint32_t ssrc = 101;
411 MockRtpPacketSink sink; 414 MockRtpPacketSink sink;
412 AddSinkOnlySsrc(ssrc, &sink); 415 AddSinkOnlySsrc(ssrc, &sink);
413 416
414 std::unique_ptr<RtpPacketReceived> packets[5]; 417 std::unique_ptr<RtpPacketReceived> packets[5];
415 for (size_t i = 0; i < arraysize(packets); i++) { 418 for (size_t i = 0; i < arraysize(packets); i++) {
416 packets[i] = CreatePacketWithSsrc(ssrc); 419 packets[i] = CreatePacketWithSsrc(ssrc);
417 packets[i]->SetSequenceNumber(i); 420 packets[i]->SetSequenceNumber(rtc::checked_cast<uint16_t>(i));
418 } 421 }
419 422
420 InSequence sequence; 423 InSequence sequence;
421 for (const auto& packet : packets) { 424 for (const auto& packet : packets) {
422 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); 425 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1);
423 } 426 }
424 427
425 for (const auto& packet : packets) { 428 for (const auto& packet : packets) {
426 EXPECT_TRUE(demuxer_.OnRtpPacket(*packet)); 429 EXPECT_TRUE(demuxer_.OnRtpPacket(*packet));
427 } 430 }
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 TEST_F(RtpDemuxerTest, 1518 TEST_F(RtpDemuxerTest,
1516 DregisterationOfNeverRegisteredSsrcBindingObserverDisallowed) { 1519 DregisterationOfNeverRegisteredSsrcBindingObserverDisallowed) {
1517 MockSsrcBindingObserver observer; 1520 MockSsrcBindingObserver observer;
1518 EXPECT_DEATH(DeregisterSsrcBindingObserver(&observer), ""); 1521 EXPECT_DEATH(DeregisterSsrcBindingObserver(&observer), "");
1519 } 1522 }
1520 1523
1521 #endif 1524 #endif
1522 1525
1523 } // namespace 1526 } // namespace
1524 } // namespace webrtc 1527 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/audio_codecs/L16/audio_encoder_L16.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698