| Index: webrtc/modules/rtp_rtcp/source/sample_parser_unittest1.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/sample_parser_unittest1.cc b/webrtc/modules/rtp_rtcp/source/sample_parser_unittest1.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..76c85c7111a710fe51a9ebbee80155edf77086d8
|
| --- /dev/null
|
| +++ b/webrtc/modules/rtp_rtcp/source/sample_parser_unittest1.cc
|
| @@ -0,0 +1,79 @@
|
| +/*
|
| + * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license
|
| + * that can be found in the LICENSE file in the root of the source
|
| + * tree. An additional intellectual property rights grant can be found
|
| + * in the file PATENTS. All contributing project authors may
|
| + * be found in the AUTHORS file in the root of the source tree.
|
| + *
|
| + */
|
| +
|
| +#include "webrtc/modules/rtp_rtcp/source/sample_rtcp_parser1.h"
|
| +
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
|
| +#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
| +
|
| +using ::testing::_;
|
| +using ::testing::Return;
|
| +using ::testing::StrictMock;
|
| +using ::webrtc::rtcp::App;
|
| +using ::webrtc::rtcp::Bye;
|
| +using ::webrtc::rtcp::CommonHeader;
|
| +using ::webrtc::rtcp::CompoundPacket;
|
| +using ::webrtc::rtcp::Parser1;
|
| +using ::webrtc::rtcp::Pli;
|
| +using ::webrtc::rtcp::ReceiverReport;
|
| +
|
| +namespace webrtc {
|
| +
|
| +class MockParserHandler : public Parser1::Handler {
|
| + public:
|
| + MOCK_METHOD1(HandleApp, bool(const App&));
|
| + MOCK_METHOD1(HandleBye, bool(const Bye&));
|
| + MOCK_METHOD1(HandlePli, bool(const Pli&));
|
| + MOCK_METHOD1(HandleUnknown, void(const CommonHeader&));
|
| + MOCK_METHOD0(HandleInvalid, void());
|
| +};
|
| +
|
| +TEST(RtcpParser1, ThreePacketsAndUnknown) {
|
| + CompoundPacket compound;
|
| + App app;
|
| + Bye bye;
|
| + Pli pli;
|
| + ReceiverReport report;
|
| + compound.Append(&app);
|
| + compound.Append(&bye);
|
| + compound.Append(&pli);
|
| + compound.Append(&report);
|
| + auto raw = compound.Build();
|
| +
|
| + StrictMock<MockParserHandler> handler;
|
| + EXPECT_CALL(handler, HandleApp(_)).Times(1).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(handler, HandleBye(_)).Times(1).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(handler, HandlePli(_)).Times(1).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(handler, HandleUnknown(_)).Times(1);
|
| + Parser1::Parse(raw.data(), raw.size(), &handler);
|
| +}
|
| +
|
| +TEST(RtcpParser1, InvalidParseCallsHandleUnknown) {
|
| + CompoundPacket compound;
|
| + Bye bye;
|
| + Pli pli;
|
| + compound.Append(&bye);
|
| + compound.Append(&pli);
|
| + auto raw = compound.Build();
|
| + // Damage Bye packet: increase ssrc count by 1.
|
| + raw[0]++;
|
| +
|
| + StrictMock<MockParserHandler> handler;
|
| + EXPECT_CALL(handler, HandleBye(_)).Times(0);
|
| + EXPECT_CALL(handler, HandlePli(_)).Times(1).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(handler, HandleUnknown(_)).Times(1);
|
| + Parser1::Parse(raw.data(), raw.size(), &handler);
|
| +}
|
| +
|
| +} // namespace webrtc
|
|
|