1b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/*
2b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *
4b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Use of this source code is governed by a BSD-style license
5b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  that can be found in the LICENSE file in the root of the source
6b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  tree. An additional intellectual property rights grant can be found
7b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  in the file PATENTS.  All contributing project authors may
8b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org */
10b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
11471ae72f18e7b23a96b245dbd508386fe139449cpbos@webrtc.org#include "webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h"
12b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
13b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgusing namespace webrtc;
14b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgusing namespace testing;
15b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
16b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass RtpRtcpBeforeStreamingTest : public AfterInitializationFixture {
17b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org protected:
18b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  void SetUp();
19b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  void TearDown();
20b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
21b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  int channel_;
22b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
23b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
24b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgvoid RtpRtcpBeforeStreamingTest::SetUp() {
25b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_THAT(channel_ = voe_base_->CreateChannel(), Not(Lt(0)));
26b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org}
27b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
28b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgvoid RtpRtcpBeforeStreamingTest::TearDown() {
29b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(0, voe_base_->DeleteChannel(channel_));
30b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org}
31b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
32b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgTEST_F(RtpRtcpBeforeStreamingTest,
33b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org       GetRtcpStatusReturnsTrueByDefaultAndObeysSetRtcpStatus) {
34b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  bool on = false;
35b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(0, voe_rtp_rtcp_->GetRTCPStatus(channel_, on));
36b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_TRUE(on);
37b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(0, voe_rtp_rtcp_->SetRTCPStatus(channel_, false));
38b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(0, voe_rtp_rtcp_->GetRTCPStatus(channel_, on));
39b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_FALSE(on);
40b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(0, voe_rtp_rtcp_->SetRTCPStatus(channel_, true));
41b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(0, voe_rtp_rtcp_->GetRTCPStatus(channel_, on));
42b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_TRUE(on);
43b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org}
44b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
45b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgTEST_F(RtpRtcpBeforeStreamingTest, GetLocalSsrcObeysSetLocalSsrc) {
46b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(0, voe_rtp_rtcp_->SetLocalSSRC(channel_, 1234));
47b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  unsigned int result = 0;
48b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(0, voe_rtp_rtcp_->GetLocalSSRC(channel_, result));
49b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  EXPECT_EQ(1234u, result);
50b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org}
51