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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc

Issue 1452733002: rtcp::VoipMetric block moved into own file and got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
(Empty)
1 /*
2 * Copyright (c) 2015 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
11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h"
12
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace webrtc {
16 namespace rtcp {
17 namespace {
18
19 const uint32_t kRemoteSsrc = 0x23456789;
20 const uint8_t kBlock[] = {0x07, 0x00, 0x00, 0x08, 0x23, 0x45, 0x67, 0x89,
21 0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x22, 0x23,
22 0x33, 0x34, 0x44, 0x45, 0x05, 0x06, 0x07, 0x08,
23 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x00, 0x55, 0x56,
24 0x66, 0x67, 0x77, 0x78};
25 const size_t kBlockLength = sizeof(kBlock);
åsapersson 2015/12/14 10:53:45 maybe kBlockSizeBytes to not mix-up with kBlockLen
danilchap 2015/12/14 12:21:31 Done.
26 static_assert(
27 kBlockLength == VoipMetric::kLength,
28 "Size of manually created Voip Metric block should match class constant");
29
30 TEST(RtcpPacketVoipMetricTest, Create) {
31 uint8_t buffer[VoipMetric::kLength];
32 RTCPVoIPMetric metric;
33 metric.lossRate = 1;
34 metric.discardRate = 2;
35 metric.burstDensity = 3;
36 metric.gapDensity = 4;
37 metric.burstDuration = 0x1112;
38 metric.gapDuration = 0x2223;
39 metric.roundTripDelay = 0x3334;
40 metric.endSystemDelay = 0x4445;
41 metric.signalLevel = 5;
42 metric.noiseLevel = 6;
43 metric.RERL = 7;
44 metric.Gmin = 8;
45 metric.Rfactor = 9;
46 metric.extRfactor = 10;
47 metric.MOSLQ = 11;
48 metric.MOSCQ = 12;
49 metric.RXconfig = 13;
50 metric.JBnominal = 0x5556;
51 metric.JBmax = 0x6667;
52 metric.JBabsMax = 0x7778;
53 VoipMetric metric_block;
54 metric_block.To(kRemoteSsrc);
55 metric_block.WithVoipMetric(metric);
56
57 metric_block.Create(buffer);
58 EXPECT_EQ(0, memcmp(buffer, kBlock, kBlockLength));
59 }
60
61 TEST(RtcpPacketVoipMetricTest, Parse) {
62 VoipMetric read_metric;
63 read_metric.Parse(kBlock);
64
65 // Run checks on const object to ensure all accessors have const modifier.
66 const VoipMetric& parsed = read_metric;
67
68 EXPECT_EQ(kRemoteSsrc, parsed.ssrc());
69 EXPECT_EQ(1, parsed.voip_metric().lossRate);
70 EXPECT_EQ(2, parsed.voip_metric().discardRate);
71 EXPECT_EQ(3, parsed.voip_metric().burstDensity);
72 EXPECT_EQ(4, parsed.voip_metric().gapDensity);
73 EXPECT_EQ(0x1112, parsed.voip_metric().burstDuration);
74 EXPECT_EQ(0x2223, parsed.voip_metric().gapDuration);
75 EXPECT_EQ(0x3334, parsed.voip_metric().roundTripDelay);
76 EXPECT_EQ(0x4445, parsed.voip_metric().endSystemDelay);
77 EXPECT_EQ(5, parsed.voip_metric().signalLevel);
78 EXPECT_EQ(6, parsed.voip_metric().noiseLevel);
79 EXPECT_EQ(7, parsed.voip_metric().RERL);
80 EXPECT_EQ(8, parsed.voip_metric().Gmin);
81 EXPECT_EQ(9, parsed.voip_metric().Rfactor);
82 EXPECT_EQ(10, parsed.voip_metric().extRfactor);
83 EXPECT_EQ(11, parsed.voip_metric().MOSLQ);
84 EXPECT_EQ(12, parsed.voip_metric().MOSCQ);
85 EXPECT_EQ(13, parsed.voip_metric().RXconfig);
86 EXPECT_EQ(0x5556, parsed.voip_metric().JBnominal);
87 EXPECT_EQ(0x6667, parsed.voip_metric().JBmax);
88 EXPECT_EQ(0x7778, parsed.voip_metric().JBabsMax);
89 }
90
91 } // namespace
92 } // namespace rtcp
93 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698