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

Side by Side Diff: voice_engine/test/auto_test/standard/rtp_rtcp_test.cc

Issue 3007383002: Replace voe_auto_test (Closed)
Patch Set: reviewer comment Created 3 years, 3 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) 2012 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 #include <memory>
12
13 #include "rtc_base/criticalsection.h"
14 #include "rtc_base/flags.h"
15 #include "system_wrappers/include/event_wrapper.h"
16 #include "test/testsupport/fileutils.h"
17 #include "voice_engine/test/auto_test/fixtures/after_streaming_fixture.h"
18 #include "voice_engine/test/auto_test/voe_standard_test.h"
19
20 DECLARE_bool(include_timing_dependent_tests);
21
22 class TestRtpObserver : public webrtc::VoERTPObserver {
23 public:
24 TestRtpObserver() : changed_ssrc_event_(webrtc::EventWrapper::Create()) {}
25 virtual ~TestRtpObserver() {}
26 virtual void OnIncomingCSRCChanged(int channel,
27 unsigned int CSRC,
28 bool added) {}
29 virtual void OnIncomingSSRCChanged(int channel,
30 unsigned int SSRC);
31 void WaitForChangedSsrc() {
32 // 10 seconds should be enough.
33 EXPECT_EQ(webrtc::kEventSignaled, changed_ssrc_event_->Wait(10*1000));
34 }
35 void SetIncomingSsrc(unsigned int ssrc) {
36 rtc::CritScope lock(&crit_);
37 incoming_ssrc_ = ssrc;
38 }
39 public:
40 rtc::CriticalSection crit_;
41 unsigned int incoming_ssrc_;
42 std::unique_ptr<webrtc::EventWrapper> changed_ssrc_event_;
43 };
44
45 void TestRtpObserver::OnIncomingSSRCChanged(int channel,
46 unsigned int SSRC) {
47 char msg[128];
48 sprintf(msg, "\n=> OnIncomingSSRCChanged(channel=%d, SSRC=%u)\n", channel,
49 SSRC);
50 TEST_LOG("%s", msg);
51
52 {
53 rtc::CritScope lock(&crit_);
54 if (incoming_ssrc_ == SSRC)
55 changed_ssrc_event_->Set();
56 }
57 }
58
59 static const char* const RTCP_CNAME = "Whatever";
60
61 class RtpRtcpTest : public AfterStreamingFixture {
62 protected:
63 void SetUp() {
64 // We need a second channel for this test, so set it up.
65 second_channel_ = voe_base_->CreateChannel();
66 EXPECT_GE(second_channel_, 0);
67
68 transport_ = new LoopBackTransport(voe_network_, second_channel_);
69 EXPECT_EQ(0, voe_network_->RegisterExternalTransport(second_channel_,
70 *transport_));
71
72 EXPECT_EQ(0, voe_base_->StartPlayout(second_channel_));
73 EXPECT_EQ(0, voe_rtp_rtcp_->SetLocalSSRC(second_channel_, 5678));
74 EXPECT_EQ(0, voe_base_->StartSend(second_channel_));
75
76 // We'll set up the RTCP CNAME and SSRC to something arbitrary here.
77 voe_rtp_rtcp_->SetRTCP_CNAME(channel_, RTCP_CNAME);
78 }
79
80 void TearDown() {
81 EXPECT_EQ(0, voe_network_->DeRegisterExternalTransport(second_channel_));
82 voe_base_->DeleteChannel(second_channel_);
83 delete transport_;
84 }
85
86 int second_channel_;
87 LoopBackTransport* transport_;
88 };
89
90 TEST_F(RtpRtcpTest, RemoteRtcpCnameHasPropagatedToRemoteSide) {
91 if (!FLAG_include_timing_dependent_tests) {
92 TEST_LOG("Skipping test - running in slow execution environment...\n");
93 return;
94 }
95
96 // We need to sleep a bit here for the name to propagate. For
97 // instance, 200 milliseconds is not enough, 1 second still flaky,
98 // so we'll go with five seconds here.
99 Sleep(5000);
100
101 char char_buffer[256];
102 voe_rtp_rtcp_->GetRemoteRTCP_CNAME(channel_, char_buffer);
103 EXPECT_STREQ(RTCP_CNAME, char_buffer);
104 }
105
106 TEST_F(RtpRtcpTest, SSRCPropagatesCorrectly) {
107 unsigned int local_ssrc = 1234;
108 EXPECT_EQ(0, voe_base_->StopSend(channel_));
109 EXPECT_EQ(0, voe_rtp_rtcp_->SetLocalSSRC(channel_, local_ssrc));
110 EXPECT_EQ(0, voe_base_->StartSend(channel_));
111
112 Sleep(1000);
113
114 unsigned int ssrc;
115 EXPECT_EQ(0, voe_rtp_rtcp_->GetLocalSSRC(channel_, ssrc));
116 EXPECT_EQ(local_ssrc, ssrc);
117
118 EXPECT_EQ(0, voe_rtp_rtcp_->GetRemoteSSRC(channel_, ssrc));
119 EXPECT_EQ(local_ssrc, ssrc);
120 }
OLDNEW
« no previous file with comments | « voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc ('k') | voice_engine/test/auto_test/voe_standard_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698