OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 // TODO(ellyjones): Remove once http://crbug.com/523296 is fixed. | 6 // TODO(ellyjones): Remove once http://crbug.com/523296 is fixed. |
7 #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR | 7 #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR |
8 #include "base/ios/ios_util.h" | 8 #include "base/ios/ios_util.h" |
9 #endif | 9 #endif |
10 #include "base/sync_socket.h" | 10 #include "base/sync_socket.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 SocketType socket_a, socket_b; | 87 SocketType socket_a, socket_b; |
88 ASSERT_TRUE(SocketType::CreatePair(&socket_a, &socket_b)); | 88 ASSERT_TRUE(SocketType::CreatePair(&socket_a, &socket_b)); |
89 SendReceivePeek(&socket_a, &socket_b); | 89 SendReceivePeek(&socket_a, &socket_b); |
90 } | 90 } |
91 | 91 |
92 template <class SocketType> | 92 template <class SocketType> |
93 void ClonedSendReceivePeek() { | 93 void ClonedSendReceivePeek() { |
94 SocketType socket_a, socket_b; | 94 SocketType socket_a, socket_b; |
95 ASSERT_TRUE(SocketType::CreatePair(&socket_a, &socket_b)); | 95 ASSERT_TRUE(SocketType::CreatePair(&socket_a, &socket_b)); |
96 | 96 |
97 // Create new SyncSockets from the paired handles. | 97 SendReceivePeek(&socket_a, &socket_b); |
brucedawson
2015/09/16 00:30:52
This fixes 520305. Duplicating handles like that w
DaleCurtis
2015/09/16 00:43:19
This is just the same as the NormalSendReceivePeek
brucedawson
2015/09/16 18:29:00
Tests deleted.
| |
98 SocketType socket_c(socket_a.handle()), socket_d(socket_b.handle()); | |
99 SendReceivePeek(&socket_c, &socket_d); | |
100 } | 98 } |
101 | 99 |
102 } // namespace | 100 } // namespace |
103 | 101 |
104 TEST(SyncSocket, NormalSendReceivePeek) { | 102 TEST(SyncSocket, NormalSendReceivePeek) { |
105 NormalSendReceivePeek<base::SyncSocket>(); | 103 NormalSendReceivePeek<base::SyncSocket>(); |
106 } | 104 } |
107 | 105 |
108 TEST(SyncSocket, ClonedSendReceivePeek) { | 106 TEST(SyncSocket, ClonedSendReceivePeek) { |
109 ClonedSendReceivePeek<base::SyncSocket>(); | 107 ClonedSendReceivePeek<base::SyncSocket>(); |
(...skipping 21 matching lines...) Expand all Loading... | |
131 ASSERT_TRUE(socket_b.Shutdown()); | 129 ASSERT_TRUE(socket_b.Shutdown()); |
132 thread.Stop(); | 130 thread.Stop(); |
133 | 131 |
134 // Ensure the receive didn't just timeout. | 132 // Ensure the receive didn't just timeout. |
135 ASSERT_LT((base::TimeTicks::Now() - start).InMilliseconds(), | 133 ASSERT_LT((base::TimeTicks::Now() - start).InMilliseconds(), |
136 kReceiveTimeoutInMilliseconds); | 134 kReceiveTimeoutInMilliseconds); |
137 | 135 |
138 ASSERT_TRUE(socket_a.Close()); | 136 ASSERT_TRUE(socket_a.Close()); |
139 ASSERT_TRUE(socket_b.Close()); | 137 ASSERT_TRUE(socket_b.Close()); |
140 } | 138 } |
OLD | NEW |