| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 11 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 12 #include "webrtc/p2p/base/relayport.h" | 12 #include "webrtc/p2p/base/relayport.h" |
| 13 #include "webrtc/p2p/base/stunport.h" | 13 #include "webrtc/p2p/base/stunport.h" |
| 14 #include "webrtc/p2p/base/tcpport.h" | 14 #include "webrtc/p2p/base/tcpport.h" |
| 15 #include "webrtc/p2p/base/testrelayserver.h" | 15 #include "webrtc/p2p/base/testrelayserver.h" |
| 16 #include "webrtc/p2p/base/teststunserver.h" | 16 #include "webrtc/p2p/base/teststunserver.h" |
| 17 #include "webrtc/p2p/base/testturnserver.h" | 17 #include "webrtc/p2p/base/testturnserver.h" |
| 18 #include "webrtc/p2p/base/transport.h" | 18 #include "webrtc/p2p/base/transport.h" |
| 19 #include "webrtc/p2p/base/turnport.h" | 19 #include "webrtc/p2p/base/turnport.h" |
| 20 #include "webrtc/base/arraysize.h" |
| 20 #include "webrtc/base/crc32.h" | 21 #include "webrtc/base/crc32.h" |
| 21 #include "webrtc/base/gunit.h" | 22 #include "webrtc/base/gunit.h" |
| 22 #include "webrtc/base/helpers.h" | 23 #include "webrtc/base/helpers.h" |
| 23 #include "webrtc/base/logging.h" | 24 #include "webrtc/base/logging.h" |
| 24 #include "webrtc/base/natserver.h" | 25 #include "webrtc/base/natserver.h" |
| 25 #include "webrtc/base/natsocketfactory.h" | 26 #include "webrtc/base/natsocketfactory.h" |
| 26 #include "webrtc/base/physicalsocketserver.h" | 27 #include "webrtc/base/physicalsocketserver.h" |
| 27 #include "webrtc/base/scoped_ptr.h" | 28 #include "webrtc/base/scoped_ptr.h" |
| 28 #include "webrtc/base/socketaddress.h" | 29 #include "webrtc/base/socketaddress.h" |
| 29 #include "webrtc/base/ssladapter.h" | 30 #include "webrtc/base/ssladapter.h" |
| (...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2216 // Send a ping from src to dst. | 2217 // Send a ping from src to dst. |
| 2217 ch1.CreateConnection(GetCandidate(port2)); | 2218 ch1.CreateConnection(GetCandidate(port2)); |
| 2218 ASSERT_TRUE(ch1.conn() != NULL); | 2219 ASSERT_TRUE(ch1.conn() != NULL); |
| 2219 EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); | 2220 EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); |
| 2220 EXPECT_TRUE_WAIT(ch1.conn()->connected(), kTimeout); // for TCP connect | 2221 EXPECT_TRUE_WAIT(ch1.conn()->connected(), kTimeout); // for TCP connect |
| 2221 ch1.Ping(); | 2222 ch1.Ping(); |
| 2222 WAIT(!ch2.remote_address().IsNil(), kTimeout); | 2223 WAIT(!ch2.remote_address().IsNil(), kTimeout); |
| 2223 | 2224 |
| 2224 // Data should be unsendable until the connection is accepted. | 2225 // Data should be unsendable until the connection is accepted. |
| 2225 char data[] = "abcd"; | 2226 char data[] = "abcd"; |
| 2226 int data_size = ARRAY_SIZE(data); | 2227 int data_size = arraysize(data); |
| 2227 rtc::PacketOptions options; | 2228 rtc::PacketOptions options; |
| 2228 EXPECT_EQ(SOCKET_ERROR, ch1.conn()->Send(data, data_size, options)); | 2229 EXPECT_EQ(SOCKET_ERROR, ch1.conn()->Send(data, data_size, options)); |
| 2229 | 2230 |
| 2230 // Accept the connection to return the binding response, transition to | 2231 // Accept the connection to return the binding response, transition to |
| 2231 // writable, and allow data to be sent. | 2232 // writable, and allow data to be sent. |
| 2232 ch2.AcceptConnection(GetCandidate(port1)); | 2233 ch2.AcceptConnection(GetCandidate(port1)); |
| 2233 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), | 2234 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), |
| 2234 kTimeout); | 2235 kTimeout); |
| 2235 EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options)); | 2236 EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options)); |
| 2236 | 2237 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2442 StartConnectAndStopChannels(&ch1, &ch2); | 2443 StartConnectAndStopChannels(&ch1, &ch2); |
| 2443 // Switch the role after all connections are destroyed. | 2444 // Switch the role after all connections are destroyed. |
| 2444 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); | 2445 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); |
| 2445 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); | 2446 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| 2446 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); | 2447 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| 2447 | 2448 |
| 2448 // After the connection is destroyed, the port should not be destroyed. | 2449 // After the connection is destroyed, the port should not be destroyed. |
| 2449 rtc::Thread::Current()->ProcessMessages(kTimeout); | 2450 rtc::Thread::Current()->ProcessMessages(kTimeout); |
| 2450 EXPECT_FALSE(destroyed()); | 2451 EXPECT_FALSE(destroyed()); |
| 2451 } | 2452 } |
| OLD | NEW |