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

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc

Issue 2803623004: Allow rtp::Packet::*RawExtension to take 0 as an extension id (Closed)
Patch Set: +AllocateRawExtension Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_packet.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc
index bdf3aba7b00013ae8c20d3e0db6a732652f72659..b85d98ae09cfdd6b63b316c8aa0f65baa55c9158 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc
@@ -16,11 +16,12 @@
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
-using testing::ElementsAreArray;
-using testing::make_tuple;
-
namespace webrtc {
namespace {
+using ::testing::ElementsAreArray;
+using ::testing::IsEmpty;
+using ::testing::make_tuple;
+
constexpr int8_t kPayloadType = 100;
constexpr uint32_t kSsrc = 0x12345678;
constexpr uint16_t kSeqNum = 88;
@@ -363,4 +364,21 @@ TEST(RtpPacketTest, ParseWithoutExtensionManager) {
EXPECT_EQ(time_offset, kTimeOffset);
}
+TEST(RtpPacketTest, RawExtensionFunctionsAcceptZeroIdAndReturnFalse) {
+ RtpPacketReceived::ExtensionManager extensions;
+ RtpPacketReceived packet(&extensions);
+ // Use ExtensionManager to set kInvalidId to 0 to demonstrate natural way for
+ // using zero value as a parameter to Packet::*RawExtension functions.
+ const int kInvalidId = extensions.GetId(TransmissionOffset::kId);
+ ASSERT_EQ(kInvalidId, 0);
+
+ ASSERT_TRUE(packet.Parse(kPacket, sizeof(kPacket)));
+
+ EXPECT_FALSE(packet.HasRawExtension(kInvalidId));
+ EXPECT_THAT(packet.GetRawExtension(kInvalidId), IsEmpty());
+ const uint8_t kExtension[] = {'e', 'x', 't'};
+ EXPECT_FALSE(packet.SetRawExtension(kInvalidId, kExtension));
+ EXPECT_THAT(packet.AllocateRawExtension(kInvalidId, 3), IsEmpty());
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_packet.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698