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

Side by Side Diff: talk/session/media/channel_unittest.cc

Issue 1380103002: Fix flaky test TestSrtpError. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2009 Google Inc. 3 * Copyright 2009 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 0x00, 1695 0x00,
1696 0x00, 1696 0x00,
1697 0x01}; 1697 0x01};
1698 CreateChannels(RTCP | SECURE, RTCP | SECURE); 1698 CreateChannels(RTCP | SECURE, RTCP | SECURE);
1699 EXPECT_FALSE(channel1_->secure()); 1699 EXPECT_FALSE(channel1_->secure());
1700 EXPECT_FALSE(channel2_->secure()); 1700 EXPECT_FALSE(channel2_->secure());
1701 EXPECT_TRUE(SendInitiate()); 1701 EXPECT_TRUE(SendInitiate());
1702 EXPECT_TRUE(SendAccept()); 1702 EXPECT_TRUE(SendAccept());
1703 EXPECT_TRUE(channel1_->secure()); 1703 EXPECT_TRUE(channel1_->secure());
1704 EXPECT_TRUE(channel2_->secure()); 1704 EXPECT_TRUE(channel2_->secure());
1705 1705 channel2_->srtp_filter()->set_signal_silent_time(250);
1706 channel2_->srtp_filter()->SignalSrtpError.connect( 1706 channel2_->srtp_filter()->SignalSrtpError.connect(
1707 &error_handler, &SrtpErrorHandler::OnSrtpError); 1707 &error_handler, &SrtpErrorHandler::OnSrtpError);
1708 1708
1709 // Testing failures in sending packets. 1709 // Testing failures in sending packets.
1710 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); 1710 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
1711 // The first failure will trigger an error. 1711 // The first failure will trigger an error.
1712 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); 1712 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
1713 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); 1713 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1714 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; 1714 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1715 // The next 1 sec failures will not trigger an error. 1715 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1716 // The next 250 ms failures will not trigger an error.
1716 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); 1717 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
1717 // Wait for a while to ensure no message comes in. 1718 // Wait for a while to ensure no message comes in.
1718 rtc::Thread::Current()->ProcessMessages(210); 1719 rtc::Thread::Current()->ProcessMessages(200);
1719 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_); 1720 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
1720 // The error will be triggered again. 1721 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1722 // Wait for a little more - the error will be triggered again.
1723 rtc::Thread::Current()->ProcessMessages(200);
1721 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); 1724 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
1722 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); 1725 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
1723 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); 1726 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1724 1727
1725 // Testing failures in receiving packets. 1728 // Testing failures in receiving packets.
1726 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; 1729 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1730 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1727 1731
1728 cricket::TransportChannel* transport_channel = 1732 cricket::TransportChannel* transport_channel =
1729 channel2_->transport_channel(); 1733 channel2_->transport_channel();
1730 transport_channel->SignalReadPacket( 1734 transport_channel->SignalReadPacket(
1731 transport_channel, reinterpret_cast<const char*>(kBadPacket), 1735 transport_channel, reinterpret_cast<const char*>(kBadPacket),
1732 sizeof(kBadPacket), rtc::PacketTime(), 0); 1736 sizeof(kBadPacket), rtc::PacketTime(), 0);
1733 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); 1737 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
1734 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); 1738 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1735 } 1739 }
1736 1740
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 }; 2794 };
2791 rtc::Buffer payload(data, 3); 2795 rtc::Buffer payload(data, 3);
2792 cricket::SendDataResult result; 2796 cricket::SendDataResult result;
2793 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2797 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2794 EXPECT_EQ(params.ssrc, 2798 EXPECT_EQ(params.ssrc,
2795 media_channel1_->last_sent_data_params().ssrc); 2799 media_channel1_->last_sent_data_params().ssrc);
2796 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2800 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2797 } 2801 }
2798 2802
2799 // TODO(pthatcher): TestSetReceiver? 2803 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698