OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 constexpr uint8_t kPacketWithUnalignedPayload[] = { | 46 constexpr uint8_t kPacketWithUnalignedPayload[] = { |
47 kVersionBits | kPaddingBit | kSubtype, App::kPacketType, 0x00, 0x03, | 47 kVersionBits | kPaddingBit | kSubtype, App::kPacketType, 0x00, 0x03, |
48 0x12, 0x34, 0x56, 0x78, | 48 0x12, 0x34, 0x56, 0x78, |
49 'n', 'a', 'm', 'e', | 49 'n', 'a', 'm', 'e', |
50 'd', 'a', 't', kPaddingSize}; | 50 'd', 'a', 't', kPaddingSize}; |
51 // clang-format on | 51 // clang-format on |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 TEST(RtcpPacketAppTest, CreateWithoutData) { | 54 TEST(RtcpPacketAppTest, CreateWithoutData) { |
55 App app; | 55 App app; |
56 app.SetSsrc(kSenderSsrc); | 56 app.From(kSenderSsrc); |
57 app.SetSubType(kSubtype); | 57 app.WithSubType(kSubtype); |
58 app.SetName(kName); | 58 app.WithName(kName); |
59 | 59 |
60 rtc::Buffer raw = app.Build(); | 60 rtc::Buffer raw = app.Build(); |
61 | 61 |
62 EXPECT_THAT(make_tuple(raw.data(), raw.size()), | 62 EXPECT_THAT(make_tuple(raw.data(), raw.size()), |
63 ElementsAreArray(kPacketWithoutData)); | 63 ElementsAreArray(kPacketWithoutData)); |
64 } | 64 } |
65 | 65 |
66 TEST(RtcpPacketAppTest, ParseWithoutData) { | 66 TEST(RtcpPacketAppTest, ParseWithoutData) { |
67 App parsed; | 67 App parsed; |
68 EXPECT_TRUE(test::ParseSinglePacket(kPacketWithoutData, &parsed)); | 68 EXPECT_TRUE(test::ParseSinglePacket(kPacketWithoutData, &parsed)); |
69 | 69 |
70 EXPECT_EQ(kSenderSsrc, parsed.ssrc()); | 70 EXPECT_EQ(kSenderSsrc, parsed.ssrc()); |
71 EXPECT_EQ(kSubtype, parsed.sub_type()); | 71 EXPECT_EQ(kSubtype, parsed.sub_type()); |
72 EXPECT_EQ(kName, parsed.name()); | 72 EXPECT_EQ(kName, parsed.name()); |
73 EXPECT_EQ(0u, parsed.data_size()); | 73 EXPECT_EQ(0u, parsed.data_size()); |
74 } | 74 } |
75 | 75 |
76 TEST(RtcpPacketAppTest, CreateWithData) { | 76 TEST(RtcpPacketAppTest, CreateWithData) { |
77 App app; | 77 App app; |
78 app.SetSsrc(kSenderSsrc); | 78 app.From(kSenderSsrc); |
79 app.SetSubType(kSubtype); | 79 app.WithSubType(kSubtype); |
80 app.SetName(kName); | 80 app.WithName(kName); |
81 app.SetData(kData, sizeof(kData)); | 81 app.WithData(kData, sizeof(kData)); |
82 | 82 |
83 rtc::Buffer raw = app.Build(); | 83 rtc::Buffer raw = app.Build(); |
84 | 84 |
85 EXPECT_THAT(make_tuple(raw.data(), raw.size()), | 85 EXPECT_THAT(make_tuple(raw.data(), raw.size()), |
86 ElementsAreArray(kPacketWithData)); | 86 ElementsAreArray(kPacketWithData)); |
87 } | 87 } |
88 | 88 |
89 TEST(RtcpPacketAppTest, ParseWithData) { | 89 TEST(RtcpPacketAppTest, ParseWithData) { |
90 App parsed; | 90 App parsed; |
91 EXPECT_TRUE(test::ParseSinglePacket(kPacketWithData, &parsed)); | 91 EXPECT_TRUE(test::ParseSinglePacket(kPacketWithData, &parsed)); |
92 | 92 |
93 EXPECT_EQ(kSenderSsrc, parsed.ssrc()); | 93 EXPECT_EQ(kSenderSsrc, parsed.ssrc()); |
94 EXPECT_EQ(kSubtype, parsed.sub_type()); | 94 EXPECT_EQ(kSubtype, parsed.sub_type()); |
95 EXPECT_EQ(kName, parsed.name()); | 95 EXPECT_EQ(kName, parsed.name()); |
96 EXPECT_THAT(make_tuple(parsed.data(), parsed.data_size()), | 96 EXPECT_THAT(make_tuple(parsed.data(), parsed.data_size()), |
97 ElementsAreArray(kData)); | 97 ElementsAreArray(kData)); |
98 } | 98 } |
99 | 99 |
100 TEST(RtcpPacketAppTest, ParseFailsOnTooSmallPacket) { | 100 TEST(RtcpPacketAppTest, ParseFailsOnTooSmallPacket) { |
101 App parsed; | 101 App parsed; |
102 EXPECT_FALSE(test::ParseSinglePacket(kTooSmallPacket, &parsed)); | 102 EXPECT_FALSE(test::ParseSinglePacket(kTooSmallPacket, &parsed)); |
103 } | 103 } |
104 | 104 |
105 TEST(RtcpPacketAppTest, ParseFailsOnUnalignedPayload) { | 105 TEST(RtcpPacketAppTest, ParseFailsOnUnalignedPayload) { |
106 App parsed; | 106 App parsed; |
107 EXPECT_FALSE(test::ParseSinglePacket(kPacketWithUnalignedPayload, &parsed)); | 107 EXPECT_FALSE(test::ParseSinglePacket(kPacketWithUnalignedPayload, &parsed)); |
108 } | 108 } |
109 | 109 |
110 } // namespace webrtc | 110 } // namespace webrtc |
OLD | NEW |