Fix the flaky RTP DataChannel test.
BUG=2891
R=wu@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/18519004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6418 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/app/webrtc/peerconnection_unittest.cc b/talk/app/webrtc/peerconnection_unittest.cc
index a98c256..0c39297 100644
--- a/talk/app/webrtc/peerconnection_unittest.cc
+++ b/talk/app/webrtc/peerconnection_unittest.cc
@@ -1009,6 +1009,16 @@
kMaxWaitForFramesMs);
}
+ void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) {
+ // Messages may get lost on the unreliable DataChannel, so we send multiple
+ // times to avoid test flakiness.
+ static const size_t kSendAttempts = 5;
+
+ for (size_t i = 0; i < kSendAttempts; ++i) {
+ dc->Send(DataBuffer(data));
+ }
+ }
+
SignalingClass* initializing_client() { return initiating_client_.get(); }
SignalingClass* receiving_client() { return receiving_client_.get(); }
@@ -1251,12 +1261,7 @@
}
// This test sets up a call between two parties with audio, video and data.
-// TODO(jiayl): fix the flakiness on Windows and reenable. Issue 2891.
-#if defined(WIN32)
-TEST_F(JsepPeerConnectionP2PTestClient, DISABLED_LocalP2PTestDataChannel) {
-#else
TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) {
-#endif
FakeConstraints setup_constraints;
setup_constraints.SetAllowRtpDataChannels();
ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints));
@@ -1270,10 +1275,12 @@
kMaxWaitMs);
std::string data = "hello world";
- initializing_client()->data_channel()->Send(DataBuffer(data));
+
+ SendRtpData(initializing_client()->data_channel(), data);
EXPECT_EQ_WAIT(data, receiving_client()->data_observer()->last_message(),
kMaxWaitMs);
- receiving_client()->data_channel()->Send(DataBuffer(data));
+
+ SendRtpData(receiving_client()->data_channel(), data);
EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(),
kMaxWaitMs);
@@ -1307,8 +1314,10 @@
// Unregister the existing observer.
receiving_client()->data_channel()->UnregisterObserver();
+
std::string data = "hello world";
- initializing_client()->data_channel()->Send(DataBuffer(data));
+ SendRtpData(initializing_client()->data_channel(), data);
+
// Wait a while to allow the sent data to arrive before an observer is
// registered..
talk_base::Thread::Current()->ProcessMessages(100);