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

Side by Side Diff: net/socket/unix_domain_socket_posix_unittest.cc

Issue 24616002: Clean up a few unused globals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
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 <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <poll.h> 7 #include <poll.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/time.h> 10 #include <sys/time.h>
(...skipping 22 matching lines...) Expand all
33 #include "net/socket/unix_domain_socket_posix.h" 33 #include "net/socket/unix_domain_socket_posix.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 35
36 using std::queue; 36 using std::queue;
37 using std::string; 37 using std::string;
38 38
39 namespace net { 39 namespace net {
40 namespace { 40 namespace {
41 41
42 const char kSocketFilename[] = "unix_domain_socket_for_testing"; 42 const char kSocketFilename[] = "unix_domain_socket_for_testing";
43 const char kFallbackSocketName[] = "unix_domain_socket_for_testing_2";
44 const char kInvalidSocketPath[] = "/invalid/path"; 43 const char kInvalidSocketPath[] = "/invalid/path";
45 const char kMsg[] = "hello"; 44 const char kMsg[] = "hello";
46 45
47 enum EventType { 46 enum EventType {
48 EVENT_ACCEPT, 47 EVENT_ACCEPT,
49 EVENT_AUTH_DENIED, 48 EVENT_AUTH_DENIED,
50 EVENT_AUTH_GRANTED, 49 EVENT_AUTH_GRANTED,
51 EVENT_CLOSE, 50 EVENT_CLOSE,
52 EVENT_LISTEN, 51 EVENT_LISTEN,
53 EVENT_READ, 52 EVENT_READ,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 scoped_ptr<UnixDomainSocket> existing_socket = 267 scoped_ptr<UnixDomainSocket> existing_socket =
269 UnixDomainSocket::CreateAndListenWithAbstractNamespace( 268 UnixDomainSocket::CreateAndListenWithAbstractNamespace(
270 file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback()); 269 file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
271 EXPECT_FALSE(existing_socket.get() == NULL); 270 EXPECT_FALSE(existing_socket.get() == NULL);
272 // First, try to bind socket with the same name with no fallback name. 271 // First, try to bind socket with the same name with no fallback name.
273 socket_ = 272 socket_ =
274 UnixDomainSocket::CreateAndListenWithAbstractNamespace( 273 UnixDomainSocket::CreateAndListenWithAbstractNamespace(
275 file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback()); 274 file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
276 EXPECT_TRUE(socket_.get() == NULL); 275 EXPECT_TRUE(socket_.get() == NULL);
277 // Now with a fallback name. 276 // Now with a fallback name.
277 const char kFallbackSocketName[] = "unix_domain_socket_for_testing_2";
278 socket_ = UnixDomainSocket::CreateAndListenWithAbstractNamespace( 278 socket_ = UnixDomainSocket::CreateAndListenWithAbstractNamespace(
279 file_path_.value(), 279 file_path_.value(),
280 MakeSocketPath(kFallbackSocketName), 280 MakeSocketPath(kFallbackSocketName),
281 socket_delegate_.get(), 281 socket_delegate_.get(),
282 MakeAuthCallback()); 282 MakeAuthCallback());
283 EXPECT_FALSE(socket_.get() == NULL); 283 EXPECT_FALSE(socket_.get() == NULL);
284 } 284 }
285 #endif 285 #endif
286 286
287 TEST_F(UnixDomainSocketTest, TestWithClient) { 287 TEST_F(UnixDomainSocketTest, TestWithClient) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 // Send() must fail. 330 // Send() must fail.
331 ssize_t ret = HANDLE_EINTR(send(sock, kMsg, sizeof(kMsg), 0)); 331 ssize_t ret = HANDLE_EINTR(send(sock, kMsg, sizeof(kMsg), 0));
332 ASSERT_EQ(-1, ret); 332 ASSERT_EQ(-1, ret);
333 ASSERT_EQ(EPIPE, errno); 333 ASSERT_EQ(EPIPE, errno);
334 ASSERT_FALSE(event_manager_->HasPendingEvent()); 334 ASSERT_FALSE(event_manager_->HasPendingEvent());
335 } 335 }
336 336
337 } // namespace 337 } // namespace
338 } // namespace net 338 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698