| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/jingle_glue/chromium_socket_factory.h" | 5 #include "remoting/jingle_glue/chromium_socket_factory.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 socket_.reset(socket_factory_->CreateUdpSocket( | 22 socket_.reset(socket_factory_->CreateUdpSocket( |
| 23 talk_base::SocketAddress("127.0.0.1", 0), 0, 0)); | 23 talk_base::SocketAddress("127.0.0.1", 0), 0, 0)); |
| 24 ASSERT_TRUE(socket_.get() != NULL); | 24 ASSERT_TRUE(socket_.get() != NULL); |
| 25 EXPECT_EQ(socket_->GetState(), talk_base::AsyncPacketSocket::STATE_BOUND); | 25 EXPECT_EQ(socket_->GetState(), talk_base::AsyncPacketSocket::STATE_BOUND); |
| 26 socket_->SignalReadPacket.connect( | 26 socket_->SignalReadPacket.connect( |
| 27 this, &ChromiumSocketFactoryTest::OnPacket); | 27 this, &ChromiumSocketFactoryTest::OnPacket); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void OnPacket(talk_base::AsyncPacketSocket* socket, | 30 void OnPacket(talk_base::AsyncPacketSocket* socket, |
| 31 const char* data, size_t size, | 31 const char* data, size_t size, |
| 32 const talk_base::SocketAddress& address) { | 32 const talk_base::SocketAddress& address, |
| 33 const talk_base::PacketTime& packet_time) { |
| 33 EXPECT_EQ(socket, socket_.get()); | 34 EXPECT_EQ(socket, socket_.get()); |
| 34 last_packet_.assign(data, data + size); | 35 last_packet_.assign(data, data + size); |
| 35 last_address_ = address; | 36 last_address_ = address; |
| 36 run_loop_.Quit(); | 37 run_loop_.Quit(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 protected: | 40 protected: |
| 40 base::MessageLoopForIO message_loop_; | 41 base::MessageLoopForIO message_loop_; |
| 41 base::RunLoop run_loop_; | 42 base::RunLoop run_loop_; |
| 42 | 43 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const int kMaxPort = 12410; | 87 const int kMaxPort = 12410; |
| 87 socket_.reset(socket_factory_->CreateUdpSocket( | 88 socket_.reset(socket_factory_->CreateUdpSocket( |
| 88 talk_base::SocketAddress("127.0.0.1", 0), kMaxPort, kMaxPort)); | 89 talk_base::SocketAddress("127.0.0.1", 0), kMaxPort, kMaxPort)); |
| 89 ASSERT_TRUE(socket_.get() != NULL); | 90 ASSERT_TRUE(socket_.get() != NULL); |
| 90 EXPECT_EQ(socket_->GetState(), talk_base::AsyncPacketSocket::STATE_BOUND); | 91 EXPECT_EQ(socket_->GetState(), talk_base::AsyncPacketSocket::STATE_BOUND); |
| 91 EXPECT_GE(socket_->GetLocalAddress().port(), kMinPort); | 92 EXPECT_GE(socket_->GetLocalAddress().port(), kMinPort); |
| 92 EXPECT_LE(socket_->GetLocalAddress().port(), kMaxPort); | 93 EXPECT_LE(socket_->GetLocalAddress().port(), kMaxPort); |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace remoting | 96 } // namespace remoting |
| OLD | NEW |