10e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// libjingle
20e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Copyright 2011 Google Inc.
30e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//
40e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Redistribution and use in source and binary forms, with or without
50e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// modification, are permitted provided that the following conditions are met:
60e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//
70e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//  1. Redistributions of source code must retain the above copyright notice,
80e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//     this list of conditions and the following disclaimer.
90e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//  2. Redistributions in binary form must reproduce the above copyright notice,
100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//     this list of conditions and the following disclaimer in the documentation
110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//     and/or other materials provided with the distribution.
120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//  3. The name of the author may not be used to endorse or promote products
130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//     derived from this software without specific prior written permission.
140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//
150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/session/media/rtcpmuxfilter.h"
270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/media/base/testutils.h"
29cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "webrtc/base/gunit.h"
300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, DemuxRtcpSender) {
320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const char data[] = { 0, 73, 0, 0 };
340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const int len = 4;
350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Init state - refuse to demux
370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.DemuxRtcp(data, len));
380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // After sent offer, demux should be enabled
390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetOffer(true, cricket::CS_LOCAL);
400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.DemuxRtcp(data, len));
410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Remote accepted, demux should be enabled
420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetAnswer(true, cricket::CS_REMOTE);
430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.DemuxRtcp(data, len));
440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, DemuxRtcpReceiver) {
470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const char data[] = { 0, 73, 0, 0 };
490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const int len = 4;
500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Init state - refuse to demux
520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.DemuxRtcp(data, len));
530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // After received offer, demux should not be enabled
540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetOffer(true, cricket::CS_REMOTE);
550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.DemuxRtcp(data, len));
560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // We accept, demux is now enabled
570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetAnswer(true, cricket::CS_LOCAL);
580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.DemuxRtcp(data, len));
590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, DemuxRtcpSenderProvisionalAnswer) {
620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const char data[] = { 0, 73, 0, 0 };
640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const int len = 4;
650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetOffer(true, cricket::CS_REMOTE);
670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Received provisional answer without mux enabled.
680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetProvisionalAnswer(false, cricket::CS_LOCAL);
690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.DemuxRtcp(data, len));
700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Received provisional answer with mux enabled.
710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetProvisionalAnswer(true, cricket::CS_LOCAL);
720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.DemuxRtcp(data, len));
730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Remote accepted, demux should be enabled.
740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetAnswer(true, cricket::CS_LOCAL);
750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.DemuxRtcp(data, len));
760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, DemuxRtcpReceiverProvisionalAnswer) {
790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const char data[] = { 0, 73, 0, 0 };
810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const int len = 4;
820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetOffer(true, cricket::CS_LOCAL);
840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Received provisional answer without mux enabled.
850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetProvisionalAnswer(false, cricket::CS_REMOTE);
860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // After sent offer, demux should be enabled until we have received a
870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // final answer.
880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.DemuxRtcp(data, len));
890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Received provisional answer with mux enabled.
900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetProvisionalAnswer(true, cricket::CS_REMOTE);
910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.DemuxRtcp(data, len));
920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Remote accepted, demux should be enabled.
930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetAnswer(true, cricket::CS_REMOTE);
940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.DemuxRtcp(data, len));
950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, IsActiveSender) {
980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Init state - not active
1000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
1010e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // After sent offer, demux should not be active.
1020e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetOffer(true, cricket::CS_LOCAL);
1030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
1040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Remote accepted, filter is now active.
1050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetAnswer(true, cricket::CS_REMOTE);
1060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
1080e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Test that we can receive provisional answer and final answer.
1100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, ReceivePrAnswer) {
1110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
1120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetOffer(true, cricket::CS_LOCAL);
1130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Received provisional answer with mux enabled.
1140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetProvisionalAnswer(true, cricket::CS_REMOTE));
1150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // We are now active since both sender and receiver support mux.
1160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Received provisional answer with mux disabled.
1180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetProvisionalAnswer(false, cricket::CS_REMOTE));
1190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // We are now inactive since the receiver doesn't support mux.
1200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
1210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Received final answer with mux enabled.
1220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(true, cricket::CS_REMOTE));
1230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
1250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, IsActiveReceiver) {
1270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
1280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Init state - not active.
1290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
1300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // After received offer, demux should not be active
1310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetOffer(true, cricket::CS_REMOTE);
1320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
1330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // We accept, filter is now active
1340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetAnswer(true, cricket::CS_LOCAL);
1350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
1370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Test that we can send provisional answer and final answer.
1390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, SendPrAnswer) {
1400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
1410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  filter.SetOffer(true, cricket::CS_REMOTE);
1420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Send provisional answer with mux enabled.
1430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetProvisionalAnswer(true, cricket::CS_LOCAL));
1440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Received provisional answer with mux disabled.
1460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetProvisionalAnswer(false, cricket::CS_LOCAL));
1470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
1480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Send final answer with mux enabled.
1490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(true, cricket::CS_LOCAL));
1500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
1520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Test that we can enable the filter in an update.
1540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// We can not disable the filter later since that would mean we need to
1550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// recreate a rtcp transport channel.
1560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, EnableFilterDuringUpdate) {
1570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
1580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
1590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetOffer(false, cricket::CS_REMOTE));
1600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(false, cricket::CS_LOCAL));
1610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
1620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetOffer(true, cricket::CS_REMOTE));
1640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(true, cricket::CS_LOCAL));
1650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.SetOffer(false, cricket::CS_REMOTE));
1680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.SetAnswer(false, cricket::CS_LOCAL));
1690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
1710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Test that SetOffer can be called twice.
1730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, SetOfferTwice) {
1740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
1750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetOffer(true, cricket::CS_REMOTE));
1770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetOffer(true, cricket::CS_REMOTE));
1780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(true, cricket::CS_LOCAL));
1790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter2;
1820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter2.SetOffer(false, cricket::CS_LOCAL));
1830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter2.SetOffer(false, cricket::CS_LOCAL));
1840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter2.SetAnswer(false, cricket::CS_REMOTE));
1850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter2.IsActive());
1860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
1870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Test that the filter can be enabled twice.
1890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, EnableFilterTwiceDuringUpdate) {
1900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
1910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetOffer(true, cricket::CS_REMOTE));
1930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(true, cricket::CS_LOCAL));
1940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetOffer(true, cricket::CS_REMOTE));
1970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(true, cricket::CS_LOCAL));
1980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.IsActive());
1990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
2000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2010e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Test that the filter can be kept disabled during updates.
2020e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgTEST(RtcpMuxFilterTest, KeepFilterDisabledDuringUpdate) {
2030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  cricket::RtcpMuxFilter filter;
2040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetOffer(false, cricket::CS_REMOTE));
2060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(false, cricket::CS_LOCAL));
2070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
2080e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetOffer(false, cricket::CS_REMOTE));
2100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_TRUE(filter.SetAnswer(false, cricket::CS_LOCAL));
2110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  EXPECT_FALSE(filter.IsActive());
2120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}
213