| Index: webrtc/p2p/base/asyncstuntcpsocket_unittest.cc
|
| diff --git a/webrtc/p2p/base/asyncstuntcpsocket_unittest.cc b/webrtc/p2p/base/asyncstuntcpsocket_unittest.cc
|
| index 6c026f67668cc79d3f798af5490b26a0696b0400..61e14117c99a487fa900e511f9f114a1ce4c8e79 100644
|
| --- a/webrtc/p2p/base/asyncstuntcpsocket_unittest.cc
|
| +++ b/webrtc/p2p/base/asyncstuntcpsocket_unittest.cc
|
| @@ -86,6 +86,8 @@ class AsyncStunTCPSocketTest : public testing::Test,
|
| kClientAddr.family(), SOCK_STREAM);
|
| send_socket_.reset(AsyncStunTCPSocket::Create(
|
| client, kClientAddr, recv_socket_->GetLocalAddress()));
|
| + send_socket_->SignalSentPacket.connect(
|
| + this, &AsyncStunTCPSocketTest::OnSentPacket);
|
| ASSERT_TRUE(send_socket_.get() != NULL);
|
| vss_->ProcessMessagesUntilIdle();
|
| }
|
| @@ -96,6 +98,11 @@ class AsyncStunTCPSocketTest : public testing::Test,
|
| recv_packets_.push_back(std::string(data, len));
|
| }
|
|
|
| + void OnSentPacket(rtc::AsyncPacketSocket* socket,
|
| + const rtc::SentPacket& packet) {
|
| + ++sent_packets_;
|
| + }
|
| +
|
| void OnNewConnection(rtc::AsyncPacketSocket* server,
|
| rtc::AsyncPacketSocket* new_socket) {
|
| listen_socket_.reset(new_socket);
|
| @@ -127,6 +134,7 @@ class AsyncStunTCPSocketTest : public testing::Test,
|
| std::unique_ptr<AsyncStunTCPSocket> recv_socket_;
|
| std::unique_ptr<rtc::AsyncPacketSocket> listen_socket_;
|
| std::list<std::string> recv_packets_;
|
| + int sent_packets_ = 0;
|
| };
|
|
|
| // Testing a stun packet sent/recv properly.
|
| @@ -259,4 +267,25 @@ TEST_F(AsyncStunTCPSocketTest, DISABLED_TestWithSmallSendBuffer) {
|
| sizeof(kTurnChannelDataMessageWithOddLength)));
|
| }
|
|
|
| +// Test that SignalSentPacket is fired when a packet is sent.
|
| +TEST_F(AsyncStunTCPSocketTest, SignalSentPacketFiredWhenPacketSent) {
|
| + ASSERT_TRUE(
|
| + Send(kStunMessageWithZeroLength, sizeof(kStunMessageWithZeroLength)));
|
| + EXPECT_EQ(1, sent_packets_);
|
| + // Send another packet for good measure.
|
| + ASSERT_TRUE(
|
| + Send(kStunMessageWithZeroLength, sizeof(kStunMessageWithZeroLength)));
|
| + EXPECT_EQ(2, sent_packets_);
|
| +}
|
| +
|
| +// Test that SignalSentPacket isn't fired when a packet isn't sent (for
|
| +// example, because it's invalid).
|
| +TEST_F(AsyncStunTCPSocketTest, SignalSentPacketNotFiredWhenPacketNotSent) {
|
| + // Attempt to send a packet that's too small; since it isn't sent,
|
| + // SignalSentPacket shouldn't fire.
|
| + char data[1];
|
| + ASSERT_FALSE(Send(data, sizeof(data)));
|
| + EXPECT_EQ(0, sent_packets_);
|
| +}
|
| +
|
| } // namespace cricket
|
|
|