Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: base/sync_socket_unittest.cc

Issue 1356743003: Revert of Check for CloseHandle failures even when not debugging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process/kill_win.cc ('k') | base/sync_socket_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ASSERT_TRUE(socket_b->Close()); 82 ASSERT_TRUE(socket_b->Close());
83 } 83 }
84 84
85 template <class SocketType> 85 template <class SocketType>
86 void NormalSendReceivePeek() { 86 void NormalSendReceivePeek() {
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>
93 void ClonedSendReceivePeek() {
94 SocketType socket_a, socket_b;
95 ASSERT_TRUE(SocketType::CreatePair(&socket_a, &socket_b));
96
97 // Create new SyncSockets from the paired handles.
98 SocketType socket_c(socket_a.handle()), socket_d(socket_b.handle());
99 SendReceivePeek(&socket_c, &socket_d);
100 }
101
92 } // namespace 102 } // namespace
93 103
94 TEST(SyncSocket, NormalSendReceivePeek) { 104 TEST(SyncSocket, NormalSendReceivePeek) {
95 NormalSendReceivePeek<base::SyncSocket>(); 105 NormalSendReceivePeek<base::SyncSocket>();
96 } 106 }
97 107
108 TEST(SyncSocket, ClonedSendReceivePeek) {
109 ClonedSendReceivePeek<base::SyncSocket>();
110 }
111
98 TEST(CancelableSyncSocket, NormalSendReceivePeek) { 112 TEST(CancelableSyncSocket, NormalSendReceivePeek) {
99 NormalSendReceivePeek<base::CancelableSyncSocket>(); 113 NormalSendReceivePeek<base::CancelableSyncSocket>();
100 } 114 }
101 115
116 TEST(CancelableSyncSocket, ClonedSendReceivePeek) {
117 ClonedSendReceivePeek<base::CancelableSyncSocket>();
118 }
119
102 TEST(CancelableSyncSocket, CancelReceiveShutdown) { 120 TEST(CancelableSyncSocket, CancelReceiveShutdown) {
103 // TODO(ellyjones): This test fails on iOS 7 devices. http://crbug.com/523296 121 // TODO(ellyjones): This test fails on iOS 7 devices. http://crbug.com/523296
104 #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR 122 #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR
105 if (!base::ios::IsRunningOnIOS8OrLater()) 123 if (!base::ios::IsRunningOnIOS8OrLater())
106 return; 124 return;
107 #endif 125 #endif
108 base::CancelableSyncSocket socket_a, socket_b; 126 base::CancelableSyncSocket socket_a, socket_b;
109 ASSERT_TRUE(base::CancelableSyncSocket::CreatePair(&socket_a, &socket_b)); 127 ASSERT_TRUE(base::CancelableSyncSocket::CreatePair(&socket_a, &socket_b));
110 128
111 base::TimeTicks start = base::TimeTicks::Now(); 129 base::TimeTicks start = base::TimeTicks::Now();
112 HangingReceiveThread thread(&socket_b); 130 HangingReceiveThread thread(&socket_b);
113 ASSERT_TRUE(socket_b.Shutdown()); 131 ASSERT_TRUE(socket_b.Shutdown());
114 thread.Stop(); 132 thread.Stop();
115 133
116 // Ensure the receive didn't just timeout. 134 // Ensure the receive didn't just timeout.
117 ASSERT_LT((base::TimeTicks::Now() - start).InMilliseconds(), 135 ASSERT_LT((base::TimeTicks::Now() - start).InMilliseconds(),
118 kReceiveTimeoutInMilliseconds); 136 kReceiveTimeoutInMilliseconds);
119 137
120 ASSERT_TRUE(socket_a.Close()); 138 ASSERT_TRUE(socket_a.Close());
121 ASSERT_TRUE(socket_b.Close()); 139 ASSERT_TRUE(socket_b.Close());
122 } 140 }
OLDNEW
« no previous file with comments | « base/process/kill_win.cc ('k') | base/sync_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698