Fix potential flakiness in voe_auto_test.
BUG= R=tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/41929004 Cr-Commit-Position: refs/heads/master@{#8362} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8362 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
2adf4c4edd
commit
8db5854eb0
@ -14,9 +14,11 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
#include "webrtc/common_types.h"
|
#include "webrtc/common_types.h"
|
||||||
|
#include "webrtc/system_wrappers/interface/atomic32.h"
|
||||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||||
|
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||||
#include "webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h"
|
#include "webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h"
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ class LoopBackTransport : public webrtc::Transport {
|
|||||||
: crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
: crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
packet_event_(webrtc::EventWrapper::Create()),
|
packet_event_(webrtc::EventWrapper::Create()),
|
||||||
thread_(webrtc::ThreadWrapper::CreateThread(NetworkProcess, this)),
|
thread_(webrtc::ThreadWrapper::CreateThread(NetworkProcess, this)),
|
||||||
voe_network_(voe_network) {
|
voe_network_(voe_network), transmitted_packets_(0) {
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
thread_->Start(id);
|
thread_->Start(id);
|
||||||
}
|
}
|
||||||
@ -47,6 +49,16 @@ class LoopBackTransport : public webrtc::Transport {
|
|||||||
return static_cast<int>(len);
|
return static_cast<int>(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaitForTransmittedPackets(int32_t packet_count) {
|
||||||
|
enum {
|
||||||
|
kSleepIntervalMs = 10
|
||||||
|
};
|
||||||
|
int32_t limit = transmitted_packets_.Value() + packet_count;
|
||||||
|
while (transmitted_packets_.Value() < limit) {
|
||||||
|
webrtc::SleepMs(kSleepIntervalMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Packet {
|
struct Packet {
|
||||||
enum Type { Rtp, Rtcp, } type;
|
enum Type { Rtp, Rtcp, } type;
|
||||||
@ -106,6 +118,7 @@ class LoopBackTransport : public webrtc::Transport {
|
|||||||
voe_network_->ReceivedRTCPPacket(p.channel, p.data, p.len);
|
voe_network_->ReceivedRTCPPacket(p.channel, p.data, p.len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
++transmitted_packets_;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -115,6 +128,7 @@ class LoopBackTransport : public webrtc::Transport {
|
|||||||
webrtc::scoped_ptr<webrtc::ThreadWrapper> thread_;
|
webrtc::scoped_ptr<webrtc::ThreadWrapper> thread_;
|
||||||
std::deque<Packet> packet_queue_ GUARDED_BY(crit_.get());
|
std::deque<Packet> packet_queue_ GUARDED_BY(crit_.get());
|
||||||
webrtc::VoENetwork* const voe_network_;
|
webrtc::VoENetwork* const voe_network_;
|
||||||
|
webrtc::Atomic32 transmitted_packets_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This fixture initializes the voice engine in addition to the work
|
// This fixture initializes the voice engine in addition to the work
|
||||||
|
@ -56,6 +56,10 @@ void BeforeStreamingFixture::ResumePlaying() {
|
|||||||
EXPECT_EQ(0, voe_base_->StartSend(channel_));
|
EXPECT_EQ(0, voe_base_->StartSend(channel_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BeforeStreamingFixture::WaitForTransmittedPackets(int32_t packet_count) {
|
||||||
|
transport_->WaitForTransmittedPackets(packet_count);
|
||||||
|
}
|
||||||
|
|
||||||
void BeforeStreamingFixture::SetUpLocalPlayback() {
|
void BeforeStreamingFixture::SetUpLocalPlayback() {
|
||||||
transport_ = new LoopBackTransport(voe_network_);
|
transport_ = new LoopBackTransport(voe_network_);
|
||||||
EXPECT_EQ(0, voe_network_->RegisterExternalTransport(channel_, *transport_));
|
EXPECT_EQ(0, voe_network_->RegisterExternalTransport(channel_, *transport_));
|
||||||
|
@ -41,6 +41,9 @@ class BeforeStreamingFixture : public AfterInitializationFixture {
|
|||||||
// Resumes all sending and playout.
|
// Resumes all sending and playout.
|
||||||
void ResumePlaying();
|
void ResumePlaying();
|
||||||
|
|
||||||
|
// Waits until packet_count packetes have been processed by recipient.
|
||||||
|
void WaitForTransmittedPackets(int32_t packet_count);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetUpLocalPlayback();
|
void SetUpLocalPlayback();
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class ExtensionVerifyTransport : public webrtc::Transport {
|
|||||||
while (received_packets_.Value() < kPacketsExpected) {
|
while (received_packets_.Value() < kPacketsExpected) {
|
||||||
webrtc::SleepMs(kSleepIntervalMs);
|
webrtc::SleepMs(kSleepIntervalMs);
|
||||||
}
|
}
|
||||||
// Check whether any where 'bad' (didn't contain an extension when they
|
// Check whether any were 'bad' (didn't contain an extension when they
|
||||||
// where supposed to).
|
// where supposed to).
|
||||||
return bad_packets_.Value() == 0;
|
return bad_packets_.Value() == 0;
|
||||||
}
|
}
|
||||||
@ -183,7 +183,12 @@ class ReceiveRtpRtcpHeaderExtensionsTest : public BeforeStreamingFixture {
|
|||||||
voe_rtp_rtcp_->SetReceiveAbsoluteSenderTimeStatus(channel_, true, 11));
|
voe_rtp_rtcp_->SetReceiveAbsoluteSenderTimeStatus(channel_, true, 11));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wait() {
|
||||||
|
WaitForTransmittedPackets(kPacketsExpected);
|
||||||
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
kPacketsExpected = 5,
|
||||||
kVideoChannelId1 = 667,
|
kVideoChannelId1 = 667,
|
||||||
kVideoChannelId2 = 668
|
kVideoChannelId2 = 668
|
||||||
};
|
};
|
||||||
@ -191,8 +196,9 @@ class ReceiveRtpRtcpHeaderExtensionsTest : public BeforeStreamingFixture {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTDisabled) {
|
TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTDisabled) {
|
||||||
|
EXPECT_CALL(mock_network_, ReceivedBWEPacket(_, _, _, _)).Times(0);
|
||||||
ResumePlaying();
|
ResumePlaying();
|
||||||
Sleep(500);
|
Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTFailSetTarget) {
|
TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTFailSetTarget) {
|
||||||
@ -200,6 +206,7 @@ TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTFailSetTarget) {
|
|||||||
EXPECT_EQ(-1, voe_rtp_rtcp_->SetVideoEngineBWETarget(-1, &mock_network_,
|
EXPECT_EQ(-1, voe_rtp_rtcp_->SetVideoEngineBWETarget(-1, &mock_network_,
|
||||||
kVideoChannelId1));
|
kVideoChannelId1));
|
||||||
ResumePlaying();
|
ResumePlaying();
|
||||||
|
Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabled) {
|
TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabled) {
|
||||||
@ -211,7 +218,7 @@ TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabled) {
|
|||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
||||||
kVideoChannelId1));
|
kVideoChannelId1));
|
||||||
ResumePlaying();
|
ResumePlaying();
|
||||||
Sleep(500);
|
Wait();
|
||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +233,7 @@ TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabledBadExtensionId) {
|
|||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
||||||
kVideoChannelId1));
|
kVideoChannelId1));
|
||||||
ResumePlaying();
|
ResumePlaying();
|
||||||
Sleep(500);
|
Wait();
|
||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +248,7 @@ TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabledNotSending) {
|
|||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
||||||
kVideoChannelId1));
|
kVideoChannelId1));
|
||||||
ResumePlaying();
|
ResumePlaying();
|
||||||
Sleep(500);
|
Wait();
|
||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +263,7 @@ TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabledNotReceiving) {
|
|||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
||||||
kVideoChannelId1));
|
kVideoChannelId1));
|
||||||
ResumePlaying();
|
ResumePlaying();
|
||||||
Sleep(500);
|
Wait();
|
||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,10 +282,10 @@ TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTSwitchViENetwork) {
|
|||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_2,
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_2,
|
||||||
kVideoChannelId1));
|
kVideoChannelId1));
|
||||||
ResumePlaying();
|
ResumePlaying();
|
||||||
Sleep(500);
|
Wait();
|
||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
||||||
kVideoChannelId1));
|
kVideoChannelId1));
|
||||||
Sleep(500);
|
Wait();
|
||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,9 +302,9 @@ TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTSwitchVideoChannel) {
|
|||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
||||||
kVideoChannelId1));
|
kVideoChannelId1));
|
||||||
ResumePlaying();
|
ResumePlaying();
|
||||||
Sleep(500);
|
Wait();
|
||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_,
|
||||||
kVideoChannelId2));
|
kVideoChannelId2));
|
||||||
Sleep(500);
|
Wait();
|
||||||
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user