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

Unified Diff: webrtc/p2p/base/dtlstransportchannel_unittest.cc

Issue 1363573002: Wire up transport sequence number / send time callbacks to webrtc via libjingle. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add missing updated_options 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/dtlstransportchannel_unittest.cc
diff --git a/webrtc/p2p/base/dtlstransportchannel_unittest.cc b/webrtc/p2p/base/dtlstransportchannel_unittest.cc
index 460e294a0048c99badecd63cc1543ea6d538ff0e..07e3b87847203150eac14e38b368ab0677e270d7 100644
--- a/webrtc/p2p/base/dtlstransportchannel_unittest.cc
+++ b/webrtc/p2p/base/dtlstransportchannel_unittest.cc
@@ -33,6 +33,7 @@ static const char kIceUfrag1[] = "TESTICEUFRAG0001";
static const char kIcePwd1[] = "TESTICEPWD00000000000001";
static const size_t kPacketNumOffset = 8;
static const size_t kPacketHeaderLen = 12;
+static const int kFakePacketId = 0x1234;
static bool IsRtpLeadByte(uint8_t b) {
return ((b & 0xC0) == 0x80);
@@ -86,6 +87,8 @@ class DtlsTestClient : public sigslot::has_slots<> {
&DtlsTestClient::OnTransportChannelWritableState);
channel->SignalReadPacket.connect(this,
&DtlsTestClient::OnTransportChannelReadPacket);
+ channel->SignalSentPacket.connect(
+ this, &DtlsTestClient::OnTransportChannelSentPacket);
channels_.push_back(channel);
// Hook the raw packets so that we can verify they are encrypted.
@@ -259,6 +262,7 @@ class DtlsTestClient : public sigslot::has_slots<> {
// Only set the bypass flag if we've activated DTLS.
int flags = (certificate_ && srtp) ? cricket::PF_SRTP_BYPASS : 0;
rtc::PacketOptions packet_options;
+ packet_options.packet_id = kFakePacketId;
int rv = channels_[channel]->SendPacket(
packet.get(), size, packet_options, flags);
ASSERT_GT(rv, 0);
@@ -338,6 +342,13 @@ class DtlsTestClient : public sigslot::has_slots<> {
ASSERT_EQ(expected_flags, flags);
}
+ void OnTransportChannelSentPacket(cricket::TransportChannel* channel,
+ const rtc::SentPacket& sent_packet) {
+ sent_packet_ = sent_packet;
+ }
+
+ rtc::SentPacket sent_packet() const { return sent_packet_; }
+
// Hook into the raw packet stream to make sure DTLS packets are encrypted.
void OnFakeTransportChannelReadPacket(cricket::TransportChannel* channel,
const char* data, size_t size,
@@ -378,6 +389,7 @@ class DtlsTestClient : public sigslot::has_slots<> {
bool negotiated_dtls_;
bool received_dtls_client_hello_;
bool received_dtls_server_hello_;
+ rtc::SentPacket sent_packet_;
};
@@ -558,6 +570,15 @@ TEST_F(DtlsTransportChannelTest, TestTransfer) {
TestTransfer(0, 1000, 100, false);
}
+// Connect without DTLS, and transfer some data.
+TEST_F(DtlsTransportChannelTest, TestOnSentPacket) {
+ ASSERT_TRUE(Connect());
+ EXPECT_EQ(client1_.sent_packet().send_time_ms, -1);
+ TestTransfer(0, 1000, 100, false);
+ EXPECT_EQ(kFakePacketId, client1_.sent_packet().packet_id);
+ EXPECT_GE(client1_.sent_packet().send_time_ms, 0);
+}
+
// Create two channels without DTLS, and transfer some data.
TEST_F(DtlsTransportChannelTest, TestTransferTwoChannels) {
SetChannelCount(2);

Powered by Google App Engine
This is Rietveld 408576698