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. |
| 7 #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR |
| 8 #include "base/ios/ios_util.h" |
| 9 #endif |
6 #include "base/sync_socket.h" | 10 #include "base/sync_socket.h" |
7 #include "base/threading/simple_thread.h" | 11 #include "base/threading/simple_thread.h" |
8 #include "base/time/time.h" | 12 #include "base/time/time.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
10 | 14 |
11 namespace { | 15 namespace { |
12 | 16 |
13 const int kReceiveTimeoutInMilliseconds = 750; | 17 const int kReceiveTimeoutInMilliseconds = 750; |
14 | 18 |
15 class HangingReceiveThread : public base::DelegateSimpleThread::Delegate { | 19 class HangingReceiveThread : public base::DelegateSimpleThread::Delegate { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 111 |
108 TEST(CancelableSyncSocket, NormalSendReceivePeek) { | 112 TEST(CancelableSyncSocket, NormalSendReceivePeek) { |
109 NormalSendReceivePeek<base::CancelableSyncSocket>(); | 113 NormalSendReceivePeek<base::CancelableSyncSocket>(); |
110 } | 114 } |
111 | 115 |
112 TEST(CancelableSyncSocket, ClonedSendReceivePeek) { | 116 TEST(CancelableSyncSocket, ClonedSendReceivePeek) { |
113 ClonedSendReceivePeek<base::CancelableSyncSocket>(); | 117 ClonedSendReceivePeek<base::CancelableSyncSocket>(); |
114 } | 118 } |
115 | 119 |
116 TEST(CancelableSyncSocket, CancelReceiveShutdown) { | 120 TEST(CancelableSyncSocket, CancelReceiveShutdown) { |
| 121 // TODO(ellyjones): This test fails on iOS 7 devices. http://crbug.com/523296 |
| 122 #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR |
| 123 if (!base::ios::IsRunningOnIOS8OrLater()) |
| 124 return; |
| 125 #endif |
117 base::CancelableSyncSocket socket_a, socket_b; | 126 base::CancelableSyncSocket socket_a, socket_b; |
118 ASSERT_TRUE(base::CancelableSyncSocket::CreatePair(&socket_a, &socket_b)); | 127 ASSERT_TRUE(base::CancelableSyncSocket::CreatePair(&socket_a, &socket_b)); |
119 | 128 |
120 base::TimeTicks start = base::TimeTicks::Now(); | 129 base::TimeTicks start = base::TimeTicks::Now(); |
121 HangingReceiveThread thread(&socket_b); | 130 HangingReceiveThread thread(&socket_b); |
122 ASSERT_TRUE(socket_b.Shutdown()); | 131 ASSERT_TRUE(socket_b.Shutdown()); |
123 thread.Stop(); | 132 thread.Stop(); |
124 | 133 |
125 // Ensure the receive didn't just timeout. | 134 // Ensure the receive didn't just timeout. |
126 ASSERT_LT((base::TimeTicks::Now() - start).InMilliseconds(), | 135 ASSERT_LT((base::TimeTicks::Now() - start).InMilliseconds(), |
127 kReceiveTimeoutInMilliseconds); | 136 kReceiveTimeoutInMilliseconds); |
128 | 137 |
129 ASSERT_TRUE(socket_a.Close()); | 138 ASSERT_TRUE(socket_a.Close()); |
130 ASSERT_TRUE(socket_b.Close()); | 139 ASSERT_TRUE(socket_b.Close()); |
131 } | 140 } |
OLD | NEW |