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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/sample_parser_unittest1.cc

Issue 1555683002: [Draft] RTCP Parser sketched. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix RtcpParser* tests Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 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
12 #include "webrtc/modules/rtp_rtcp/source/sample_rtcp_parser1.h"
13
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
19
20 using ::testing::_;
21 using ::testing::Return;
22 using ::testing::StrictMock;
23 using ::webrtc::rtcp::App;
24 using ::webrtc::rtcp::Bye;
25 using ::webrtc::rtcp::CommonHeader;
26 using ::webrtc::rtcp::CompoundPacket;
27 using ::webrtc::rtcp::Parser1;
28 using ::webrtc::rtcp::Pli;
29 using ::webrtc::rtcp::ReceiverReport;
30
31 namespace webrtc {
32
33 class MockParserHandler : public Parser1::Handler {
34 public:
35 MOCK_METHOD1(HandleApp, bool(const App&));
36 MOCK_METHOD1(HandleBye, bool(const Bye&));
37 MOCK_METHOD1(HandlePli, bool(const Pli&));
38 MOCK_METHOD1(HandleUnknown, void(const CommonHeader&));
39 MOCK_METHOD0(HandleInvalid, void());
40 };
41
42 TEST(RtcpParser1, ThreePacketsAndUnknown) {
43 CompoundPacket compound;
44 App app;
45 Bye bye;
46 Pli pli;
47 ReceiverReport report;
48 compound.Append(&app);
49 compound.Append(&bye);
50 compound.Append(&pli);
51 compound.Append(&report);
52 auto raw = compound.Build();
53
54 StrictMock<MockParserHandler> handler;
55 EXPECT_CALL(handler, HandleApp(_)).Times(1).WillRepeatedly(Return(true));
56 EXPECT_CALL(handler, HandleBye(_)).Times(1).WillRepeatedly(Return(true));
57 EXPECT_CALL(handler, HandlePli(_)).Times(1).WillRepeatedly(Return(true));
58 EXPECT_CALL(handler, HandleUnknown(_)).Times(1);
59 Parser1::Parse(raw.data(), raw.size(), &handler);
60 }
61
62 TEST(RtcpParser1, InvalidParseCallsHandleUnknown) {
63 CompoundPacket compound;
64 Bye bye;
65 Pli pli;
66 compound.Append(&bye);
67 compound.Append(&pli);
68 auto raw = compound.Build();
69 // Damage Bye packet: increase ssrc count by 1.
70 raw[0]++;
71
72 StrictMock<MockParserHandler> handler;
73 EXPECT_CALL(handler, HandleBye(_)).Times(0);
74 EXPECT_CALL(handler, HandlePli(_)).Times(1).WillRepeatedly(Return(true));
75 EXPECT_CALL(handler, HandleUnknown(_)).Times(1);
76 Parser1::Parse(raw.data(), raw.size(), &handler);
77 }
78
79 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698