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

Side by Side Diff: net/base/listen_socket_unittest.cc

Issue 9716020: Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 9 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
« no previous file with comments | « net/base/listen_socket.cc ('k') | net/base/net_util.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/base/listen_socket_unittest.h" 5 #include "net/base/listen_socket_unittest.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/eintr_wrapper.h" 11 #include "base/eintr_wrapper.h"
12 #include "base/sys_byteorder.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 const int ListenSocketTester::kTestPort = 9999; 18 const int ListenSocketTester::kTestPort = 9999;
18 19
19 static const int kReadBufSize = 1024; 20 static const int kReadBufSize = 1024;
20 static const char kHelloWorld[] = "HELLO, WORLD"; 21 static const char kHelloWorld[] = "HELLO, WORLD";
21 static const int kMaxQueueSize = 20; 22 static const int kMaxQueueSize = 20;
(...skipping 21 matching lines...) Expand all
43 NextAction(); 44 NextAction();
44 ASSERT_FALSE(server_ == NULL); 45 ASSERT_FALSE(server_ == NULL);
45 ASSERT_EQ(ACTION_LISTEN, last_action_.type()); 46 ASSERT_EQ(ACTION_LISTEN, last_action_.type());
46 47
47 // verify the connect/accept and setup test_socket_ 48 // verify the connect/accept and setup test_socket_
48 test_socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 49 test_socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
49 ASSERT_NE(INVALID_SOCKET, test_socket_); 50 ASSERT_NE(INVALID_SOCKET, test_socket_);
50 struct sockaddr_in client; 51 struct sockaddr_in client;
51 client.sin_family = AF_INET; 52 client.sin_family = AF_INET;
52 client.sin_addr.s_addr = inet_addr(kLoopback); 53 client.sin_addr.s_addr = inet_addr(kLoopback);
53 client.sin_port = htons(kTestPort); 54 client.sin_port = base::HostToNet16(kTestPort);
54 int ret = HANDLE_EINTR( 55 int ret = HANDLE_EINTR(
55 connect(test_socket_, reinterpret_cast<sockaddr*>(&client), 56 connect(test_socket_, reinterpret_cast<sockaddr*>(&client),
56 sizeof(client))); 57 sizeof(client)));
57 ASSERT_NE(ret, SOCKET_ERROR); 58 ASSERT_NE(ret, SOCKET_ERROR);
58 59
59 NextAction(); 60 NextAction();
60 ASSERT_EQ(ACTION_ACCEPT, last_action_.type()); 61 ASSERT_EQ(ACTION_ACCEPT, last_action_.type());
61 } 62 }
62 63
63 void ListenSocketTester::TearDown() { 64 void ListenSocketTester::TearDown() {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 239
239 TEST_F(ListenSocketTest, ClientSendLong) { 240 TEST_F(ListenSocketTest, ClientSendLong) {
240 tester_->TestClientSendLong(); 241 tester_->TestClientSendLong();
241 } 242 }
242 243
243 TEST_F(ListenSocketTest, ServerSend) { 244 TEST_F(ListenSocketTest, ServerSend) {
244 tester_->TestServerSend(); 245 tester_->TestServerSend();
245 } 246 }
246 247
247 } // namespace net 248 } // namespace net
OLDNEW
« no previous file with comments | « net/base/listen_socket.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698