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

Side by Side Diff: remoting/protocol/chromium_socket_factory_unittest.cc

Issue 1542203002: Switch to standard integer types in remoting/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@int-remoting-host
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "remoting/protocol/chromium_socket_factory.h" 5 #include "remoting/protocol/chromium_socket_factory.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 11 #include "base/run_loop.h"
9 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/webrtc/base/asyncpacketsocket.h" 14 #include "third_party/webrtc/base/asyncpacketsocket.h"
12 #include "third_party/webrtc/base/socketaddress.h" 15 #include "third_party/webrtc/base/socketaddress.h"
13 16
14 namespace remoting { 17 namespace remoting {
15 namespace protocol { 18 namespace protocol {
16 19
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 80
78 VerifyCanSendAndReceive(sending_socket.get()); 81 VerifyCanSendAndReceive(sending_socket.get());
79 } 82 }
80 83
81 TEST_F(ChromiumSocketFactoryTest, SetOptions) { 84 TEST_F(ChromiumSocketFactoryTest, SetOptions) {
82 EXPECT_EQ(0, socket_->SetOption(rtc::Socket::OPT_SNDBUF, 4096)); 85 EXPECT_EQ(0, socket_->SetOption(rtc::Socket::OPT_SNDBUF, 4096));
83 EXPECT_EQ(0, socket_->SetOption(rtc::Socket::OPT_RCVBUF, 4096)); 86 EXPECT_EQ(0, socket_->SetOption(rtc::Socket::OPT_RCVBUF, 4096));
84 } 87 }
85 88
86 TEST_F(ChromiumSocketFactoryTest, PortRange) { 89 TEST_F(ChromiumSocketFactoryTest, PortRange) {
87 const uint16 kMinPort = 12400; 90 const uint16_t kMinPort = 12400;
88 const uint16 kMaxPort = 12410; 91 const uint16_t kMaxPort = 12410;
89 socket_.reset(socket_factory_->CreateUdpSocket( 92 socket_.reset(socket_factory_->CreateUdpSocket(
90 rtc::SocketAddress("127.0.0.1", 0), kMaxPort, kMaxPort)); 93 rtc::SocketAddress("127.0.0.1", 0), kMaxPort, kMaxPort));
91 ASSERT_TRUE(socket_.get() != nullptr); 94 ASSERT_TRUE(socket_.get() != nullptr);
92 EXPECT_EQ(socket_->GetState(), rtc::AsyncPacketSocket::STATE_BOUND); 95 EXPECT_EQ(socket_->GetState(), rtc::AsyncPacketSocket::STATE_BOUND);
93 EXPECT_GE(socket_->GetLocalAddress().port(), kMinPort); 96 EXPECT_GE(socket_->GetLocalAddress().port(), kMinPort);
94 EXPECT_LE(socket_->GetLocalAddress().port(), kMaxPort); 97 EXPECT_LE(socket_->GetLocalAddress().port(), kMaxPort);
95 } 98 }
96 99
97 TEST_F(ChromiumSocketFactoryTest, TransientError) { 100 TEST_F(ChromiumSocketFactoryTest, TransientError) {
98 scoped_ptr<rtc::AsyncPacketSocket> sending_socket( 101 scoped_ptr<rtc::AsyncPacketSocket> sending_socket(
99 socket_factory_->CreateUdpSocket( 102 socket_factory_->CreateUdpSocket(
100 rtc::SocketAddress("127.0.0.1", 0), 0, 0)); 103 rtc::SocketAddress("127.0.0.1", 0), 0, 0));
101 std::string test_packet("TEST"); 104 std::string test_packet("TEST");
102 105
103 // Try sending a packet to an IPv6 address from a socket that's bound to an 106 // Try sending a packet to an IPv6 address from a socket that's bound to an
104 // IPv4 address. This send is expected to fail, but the socket should still be 107 // IPv4 address. This send is expected to fail, but the socket should still be
105 // functional. 108 // functional.
106 sending_socket->SendTo(test_packet.data(), test_packet.size(), 109 sending_socket->SendTo(test_packet.data(), test_packet.size(),
107 rtc::SocketAddress("::1", 0), 110 rtc::SocketAddress("::1", 0),
108 rtc::PacketOptions()); 111 rtc::PacketOptions());
109 112
110 // Verify that socket is still usable. 113 // Verify that socket is still usable.
111 VerifyCanSendAndReceive(sending_socket.get()); 114 VerifyCanSendAndReceive(sending_socket.get());
112 } 115 }
113 116
114 } // namespace protocol 117 } // namespace protocol
115 } // namespace remoting 118 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/chromium_socket_factory.cc ('k') | remoting/protocol/client_control_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698