blob: 2ec54171c8897368e4fd18760368867ecaccb3d1 [file] [log] [blame]
elad.alon5bbf43f2017-03-09 06:40:08 -08001/*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/congestion_controller/congestion_controller_unittests_helper.h"
elad.alon5bbf43f2017-03-09 06:40:08 -080012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "rtc_base/checks.h"
14#include "test/gtest.h"
elad.alon5bbf43f2017-03-09 06:40:08 -080015
16namespace webrtc {
17void ComparePacketFeedbackVectors(const std::vector<PacketFeedback>& truth,
18 const std::vector<PacketFeedback>& input) {
19 ASSERT_EQ(truth.size(), input.size());
20 size_t len = truth.size();
21 // truth contains the input data for the test, and input is what will be
22 // sent to the bandwidth estimator. truth.arrival_tims_ms is used to
23 // populate the transport feedback messages. As these times may be changed
24 // (because of resolution limits in the packets, and because of the time
25 // base adjustment performed by the TransportFeedbackAdapter at the first
26 // packet, the truth[x].arrival_time and input[x].arrival_time may not be
27 // equal. However, the difference must be the same for all x.
28 int64_t arrival_time_delta =
29 truth[0].arrival_time_ms - input[0].arrival_time_ms;
30 for (size_t i = 0; i < len; ++i) {
31 RTC_CHECK(truth[i].arrival_time_ms != PacketFeedback::kNotReceived);
32 if (input[i].arrival_time_ms != PacketFeedback::kNotReceived) {
33 EXPECT_EQ(truth[i].arrival_time_ms,
34 input[i].arrival_time_ms + arrival_time_delta);
35 }
36 EXPECT_EQ(truth[i].send_time_ms, input[i].send_time_ms);
37 EXPECT_EQ(truth[i].sequence_number, input[i].sequence_number);
38 EXPECT_EQ(truth[i].payload_size, input[i].payload_size);
39 EXPECT_EQ(truth[i].pacing_info, input[i].pacing_info);
40 }
41}
42} // namespace webrtc