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

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

Issue 3012273002: Ignore this CL - here as a baseline only (originally Bjorn's CL)
Patch Set: Created 3 years, 3 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 "webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.h" 11 #include "webrtc/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 "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h" 18 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h"
19 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" 19 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
20 #include "webrtc/rtc_base/checks.h" 20 #include "webrtc/rtc_base/checks.h"
21 #include "webrtc/test/gmock.h"
21 #include "webrtc/test/gtest.h" 22 #include "webrtc/test/gtest.h"
22 #include "webrtc/test/testsupport/fileutils.h" 23 #include "webrtc/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 "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" 29 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h"
29 #endif 30 #endif
30 31
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::VerifyRtpEvent(const ParsedRtcEventLog& parsed_log,
353 size_t index, 354 size_t index,
354 PacketDirection direction, 355 PacketDirection direction,
355 const uint8_t* header, 356 const rtp::Packet& 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(direction == kIncomingPacket, 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(direction, 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);
382 } 381 }
383 382
384 void RtcEventLogTestHelper::VerifyRtcpEvent(const ParsedRtcEventLog& parsed_log, 383 void RtcEventLogTestHelper::VerifyRtcpEvent(const ParsedRtcEventLog& parsed_log,
385 size_t index, 384 size_t index,
386 PacketDirection direction, 385 PacketDirection direction,
387 const uint8_t* packet, 386 const uint8_t* packet,
388 size_t total_size) { 387 size_t total_size) {
389 const rtclog::Event& event = parsed_log.events_[index]; 388 const rtclog::Event& event = parsed_log.events_[index];
390 ASSERT_TRUE(IsValidBasicEvent(event)); 389 ASSERT_TRUE(IsValidBasicEvent(event));
391 ASSERT_EQ(rtclog::Event::RTCP_EVENT, event.type()); 390 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()); 563 ASSERT_TRUE(bwe_event.has_id());
565 EXPECT_EQ(id, bwe_event.id()); 564 EXPECT_EQ(id, bwe_event.id());
566 ASSERT_TRUE(bwe_event.has_result()); 565 ASSERT_TRUE(bwe_event.has_result());
567 EXPECT_EQ(GetProbeResultType(failure_reason), bwe_event.result()); 566 EXPECT_EQ(GetProbeResultType(failure_reason), bwe_event.result());
568 ASSERT_FALSE(bwe_event.has_bitrate_bps()); 567 ASSERT_FALSE(bwe_event.has_bitrate_bps());
569 568
570 // TODO(philipel): Verify the parser when parsing has been implemented. 569 // TODO(philipel): Verify the parser when parsing has been implemented.
571 } 570 }
572 571
573 } // namespace webrtc 572 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698