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

Side by Side Diff: logging/rtc_event_log/rtc_event_log_unittest_helper.cc

Issue 2997973002: Split LogRtpHeader and LogRtcpPacket into separate versions for incoming and outgoing packets.
Patch Set: Split VerifyRtpEvent into one incoming and one outgoing version. Created 3 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 "logging/rtc_event_log/rtc_event_log_unittest_helper.h" 11 #include "logging/rtc_event_log/rtc_event_log_unittest_helper.h"
12 12
13 #include <string.h> 13 #include <string.h>
14 14
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adapt or.h" 18 #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adapt or.h"
19 #include "modules/remote_bitrate_estimator/include/bwe_defines.h" 19 #include "modules/remote_bitrate_estimator/include/bwe_defines.h"
20 #include "rtc_base/checks.h" 20 #include "rtc_base/checks.h"
21 #include "test/gmock.h"
21 #include "test/gtest.h" 22 #include "test/gtest.h"
22 #include "test/testsupport/fileutils.h" 23 #include "test/testsupport/fileutils.h"
23 24
24 // Files generated at build-time by the protobuf compiler. 25 // Files generated at build-time by the protobuf compiler.
25 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 26 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
26 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" 27 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h"
27 #else 28 #else
28 #include "logging/rtc_event_log/rtc_event_log.pb.h" 29 #include "logging/rtc_event_log/rtc_event_log.pb.h"
29 #endif 30 #endif
30 31
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 int id = sender_config.header_extensions(i).id(); 343 int id = sender_config.header_extensions(i).id();
343 EXPECT_EQ(config.rtp_extensions[i].id, id); 344 EXPECT_EQ(config.rtp_extensions[i].id, id);
344 EXPECT_EQ(config.rtp_extensions[i].uri, name); 345 EXPECT_EQ(config.rtp_extensions[i].uri, name);
345 } 346 }
346 347
347 // Check consistency of the parser. 348 // Check consistency of the parser.
348 rtclog::StreamConfig parsed_config = parsed_log.GetAudioSendConfig(index); 349 rtclog::StreamConfig parsed_config = parsed_log.GetAudioSendConfig(index);
349 VerifyStreamConfigsAreEqual(config, parsed_config); 350 VerifyStreamConfigsAreEqual(config, parsed_config);
350 } 351 }
351 352
352 void RtcEventLogTestHelper::VerifyRtpEvent(const ParsedRtcEventLog& parsed_log, 353 void RtcEventLogTestHelper::VerifyIncomingRtpEvent(
353 size_t index, 354 const ParsedRtcEventLog& parsed_log,
354 PacketDirection direction, 355 size_t index,
355 const uint8_t* header, 356 const RtpPacketReceived& expected_packet) {
356 size_t header_size,
357 size_t total_size) {
358 const rtclog::Event& event = parsed_log.events_[index]; 357 const rtclog::Event& event = parsed_log.events_[index];
359 ASSERT_TRUE(IsValidBasicEvent(event)); 358 ASSERT_TRUE(IsValidBasicEvent(event));
360 ASSERT_EQ(rtclog::Event::RTP_EVENT, event.type()); 359 ASSERT_EQ(rtclog::Event::RTP_EVENT, event.type());
361 const rtclog::RtpPacket& rtp_packet = event.rtp_packet(); 360 const rtclog::RtpPacket& rtp_packet = event.rtp_packet();
362 ASSERT_TRUE(rtp_packet.has_incoming()); 361 ASSERT_TRUE(rtp_packet.has_incoming());
363 EXPECT_EQ(direction == kIncomingPacket, rtp_packet.incoming()); 362 EXPECT_EQ(true, rtp_packet.incoming());
364 ASSERT_TRUE(rtp_packet.has_packet_length()); 363 ASSERT_TRUE(rtp_packet.has_packet_length());
365 EXPECT_EQ(total_size, rtp_packet.packet_length()); 364 EXPECT_EQ(expected_packet.size(), rtp_packet.packet_length());
365 size_t header_size = expected_packet.headers_size();
366 ASSERT_TRUE(rtp_packet.has_header()); 366 ASSERT_TRUE(rtp_packet.has_header());
367 ASSERT_EQ(header_size, rtp_packet.header().size()); 367 EXPECT_THAT(testing::make_tuple(expected_packet.data(), header_size),
368 for (size_t i = 0; i < header_size; i++) { 368 testing::ElementsAreArray(rtp_packet.header().data(),
369 EXPECT_EQ(header[i], static_cast<uint8_t>(rtp_packet.header()[i])); 369 rtp_packet.header().size()));
370 }
371 370
372 // Check consistency of the parser. 371 // Check consistency of the parser.
373 PacketDirection parsed_direction; 372 PacketDirection parsed_direction;
374 uint8_t parsed_header[1500]; 373 uint8_t parsed_header[1500];
375 size_t parsed_header_size, parsed_total_size; 374 size_t parsed_header_size, parsed_total_size;
376 parsed_log.GetRtpHeader(index, &parsed_direction, parsed_header, 375 parsed_log.GetRtpHeader(index, &parsed_direction, parsed_header,
377 &parsed_header_size, &parsed_total_size); 376 &parsed_header_size, &parsed_total_size);
378 EXPECT_EQ(direction, parsed_direction); 377 EXPECT_EQ(kIncomingPacket, parsed_direction);
379 ASSERT_EQ(header_size, parsed_header_size); 378 EXPECT_THAT(testing::make_tuple(expected_packet.data(), header_size),
380 EXPECT_EQ(0, std::memcmp(header, parsed_header, header_size)); 379 testing::ElementsAreArray(parsed_header, parsed_header_size));
381 EXPECT_EQ(total_size, parsed_total_size); 380 EXPECT_EQ(expected_packet.size(), parsed_total_size);
381 }
382
383 void RtcEventLogTestHelper::VerifyOutgoingRtpEvent(
384 const ParsedRtcEventLog& parsed_log,
385 size_t index,
386 const RtpPacketToSend& expected_packet) {
387 const rtclog::Event& event = parsed_log.events_[index];
388 ASSERT_TRUE(IsValidBasicEvent(event));
389 ASSERT_EQ(rtclog::Event::RTP_EVENT, event.type());
390 const rtclog::RtpPacket& rtp_packet = event.rtp_packet();
391 ASSERT_TRUE(rtp_packet.has_incoming());
392 EXPECT_EQ(false, rtp_packet.incoming());
393 ASSERT_TRUE(rtp_packet.has_packet_length());
394 EXPECT_EQ(expected_packet.size(), rtp_packet.packet_length());
395 size_t header_size = expected_packet.headers_size();
396 ASSERT_TRUE(rtp_packet.has_header());
397 EXPECT_THAT(testing::make_tuple(expected_packet.data(), header_size),
398 testing::ElementsAreArray(rtp_packet.header().data(),
399 rtp_packet.header().size()));
400
401 // Check consistency of the parser.
402 PacketDirection parsed_direction;
403 uint8_t parsed_header[1500];
404 size_t parsed_header_size, parsed_total_size;
405 parsed_log.GetRtpHeader(index, &parsed_direction, parsed_header,
406 &parsed_header_size, &parsed_total_size);
407 EXPECT_EQ(kOutgoingPacket, parsed_direction);
408 EXPECT_THAT(testing::make_tuple(expected_packet.data(), header_size),
409 testing::ElementsAreArray(parsed_header, parsed_header_size));
410 EXPECT_EQ(expected_packet.size(), parsed_total_size);
382 } 411 }
383 412
384 void RtcEventLogTestHelper::VerifyRtcpEvent(const ParsedRtcEventLog& parsed_log, 413 void RtcEventLogTestHelper::VerifyRtcpEvent(const ParsedRtcEventLog& parsed_log,
385 size_t index, 414 size_t index,
386 PacketDirection direction, 415 PacketDirection direction,
387 const uint8_t* packet, 416 const uint8_t* packet,
388 size_t total_size) { 417 size_t total_size) {
389 const rtclog::Event& event = parsed_log.events_[index]; 418 const rtclog::Event& event = parsed_log.events_[index];
390 ASSERT_TRUE(IsValidBasicEvent(event)); 419 ASSERT_TRUE(IsValidBasicEvent(event));
391 ASSERT_EQ(rtclog::Event::RTCP_EVENT, event.type()); 420 ASSERT_EQ(rtclog::Event::RTCP_EVENT, event.type());
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 ASSERT_TRUE(bwe_event.has_id()); 593 ASSERT_TRUE(bwe_event.has_id());
565 EXPECT_EQ(id, bwe_event.id()); 594 EXPECT_EQ(id, bwe_event.id());
566 ASSERT_TRUE(bwe_event.has_result()); 595 ASSERT_TRUE(bwe_event.has_result());
567 EXPECT_EQ(GetProbeResultType(failure_reason), bwe_event.result()); 596 EXPECT_EQ(GetProbeResultType(failure_reason), bwe_event.result());
568 ASSERT_FALSE(bwe_event.has_bitrate_bps()); 597 ASSERT_FALSE(bwe_event.has_bitrate_bps());
569 598
570 // TODO(philipel): Verify the parser when parsing has been implemented. 599 // TODO(philipel): Verify the parser when parsing has been implemented.
571 } 600 }
572 601
573 } // namespace webrtc 602 } // namespace webrtc
OLDNEW
« no previous file with comments | « logging/rtc_event_log/rtc_event_log_unittest_helper.h ('k') | modules/rtp_rtcp/source/rtcp_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698