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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/sample_parser_unittest2.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_parser2.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::StrictMock;
22 using webrtc::rtcp::App;
23 using webrtc::rtcp::Bye;
24 using webrtc::rtcp::CommonHeader;
25 using webrtc::rtcp::CompoundPacket;
26 using webrtc::rtcp::Parser2;
27 using webrtc::rtcp::Pli;
28 using webrtc::rtcp::ReceiverReport;
29
30 namespace webrtc {
31
32 class MockParser2 : public Parser2 {
33 public:
34 MOCK_METHOD1(HandleApp, void(const App&));
35 MOCK_METHOD1(HandleBye, void(const Bye&));
36 MOCK_METHOD1(HandlePli, void(const Pli&));
37 MOCK_METHOD1(HandleUnknown, void(const CommonHeader&));
38 MOCK_METHOD0(HandleInvalid, void());
39 };
40
41 TEST(RtcpParser2, ThreePacketsAndUnknown) {
42 CompoundPacket compound;
43 App app;
44 Bye bye;
45 Pli pli;
46 ReceiverReport report;
47 compound.Append(&app);
48 compound.Append(&bye);
49 compound.Append(&pli);
50 compound.Append(&report);
51 auto raw = compound.Build();
52
53 StrictMock<MockParser2> parser;
54 EXPECT_CALL(parser, HandleApp(_)).Times(1);
55 EXPECT_CALL(parser, HandleBye(_)).Times(1);
56 EXPECT_CALL(parser, HandlePli(_)).Times(1);
57 EXPECT_CALL(parser, HandleUnknown(_)).Times(1);
58 parser.Parse(raw.data(), raw.size());
59 }
60
61 TEST(RtcpParser2, InvalidParseCallsHandleInvalid) {
62 CompoundPacket compound;
63 Bye bye;
64 Pli pli;
65 compound.Append(&bye);
66 compound.Append(&pli);
67 auto raw = compound.Build();
68 // Damage Bye packet: increase ssrc cound by 1.
69 raw[0]++;
70
71 StrictMock<MockParser2> parser;
72 EXPECT_CALL(parser, HandleBye(_)).Times(0);
73 EXPECT_CALL(parser, HandlePli(_)).Times(1);
74 EXPECT_CALL(parser, HandleInvalid()).Times(1);
75 parser.Parse(raw.data(), raw.size());
76 }
77
78 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/sample_parser_unittest1.cc ('k') | webrtc/modules/rtp_rtcp/source/sample_parser_unittest4.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698