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

Side by Side Diff: webrtc/base/proxy_unittest.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 26 matching lines...) Expand all
37 : AutoDetectProxy(agent) {} 37 : AutoDetectProxy(agent) {}
38 void Run() { 38 void Run() {
39 DoWork(); 39 DoWork();
40 Thread::Current()->Restart(); // needed to reset the messagequeue 40 Thread::Current()->Restart(); // needed to reset the messagequeue
41 } 41 }
42 }; 42 };
43 43
44 // Sets up a virtual socket server and HTTPS/SOCKS5 proxy servers. 44 // Sets up a virtual socket server and HTTPS/SOCKS5 proxy servers.
45 class ProxyTest : public testing::Test { 45 class ProxyTest : public testing::Test {
46 public: 46 public:
47 ProxyTest() : ss_(new rtc::VirtualSocketServer(NULL)) { 47 ProxyTest() : ss_(new rtc::VirtualSocketServer(nullptr)) {
48 Thread::Current()->set_socketserver(ss_.get()); 48 Thread::Current()->set_socketserver(ss_.get());
49 socks_.reset(new rtc::SocksProxyServer( 49 socks_.reset(new rtc::SocksProxyServer(
50 ss_.get(), kSocksProxyIntAddr, ss_.get(), kSocksProxyExtAddr)); 50 ss_.get(), kSocksProxyIntAddr, ss_.get(), kSocksProxyExtAddr));
51 https_.reset(new rtc::HttpListenServer()); 51 https_.reset(new rtc::HttpListenServer());
52 https_->Listen(kHttpsProxyIntAddr); 52 https_->Listen(kHttpsProxyIntAddr);
53 } 53 }
54 ~ProxyTest() { 54 ~ProxyTest() { Thread::Current()->set_socketserver(nullptr); }
55 Thread::Current()->set_socketserver(NULL);
56 }
57 55
58 rtc::SocketServer* ss() { return ss_.get(); } 56 rtc::SocketServer* ss() { return ss_.get(); }
59 57
60 rtc::ProxyType DetectProxyType(const SocketAddress& address) { 58 rtc::ProxyType DetectProxyType(const SocketAddress& address) {
61 rtc::ProxyType type; 59 rtc::ProxyType type;
62 AutoDetectProxyRunner* detect = new AutoDetectProxyRunner("unittest/1.0"); 60 AutoDetectProxyRunner* detect = new AutoDetectProxyRunner("unittest/1.0");
63 detect->set_proxy(address); 61 detect->set_proxy(address);
64 detect->Run(); // blocks until done 62 detect->Run(); // blocks until done
65 type = detect->proxy().type; 63 type = detect->proxy().type;
66 detect->Destroy(false); 64 detect->Destroy(false);
(...skipping 14 matching lines...) Expand all
81 rtc::AsyncSocksProxySocket* proxy_socket = 79 rtc::AsyncSocksProxySocket* proxy_socket =
82 new rtc::AsyncSocksProxySocket(socket, kSocksProxyIntAddr, 80 new rtc::AsyncSocksProxySocket(socket, kSocksProxyIntAddr,
83 "", rtc::CryptString()); 81 "", rtc::CryptString());
84 // TODO: IPv6-ize these tests when proxy supports IPv6. 82 // TODO: IPv6-ize these tests when proxy supports IPv6.
85 83
86 rtc::TestEchoServer server(Thread::Current(), 84 rtc::TestEchoServer server(Thread::Current(),
87 SocketAddress(INADDR_ANY, 0)); 85 SocketAddress(INADDR_ANY, 0));
88 86
89 rtc::AsyncTCPSocket* packet_socket = rtc::AsyncTCPSocket::Create( 87 rtc::AsyncTCPSocket* packet_socket = rtc::AsyncTCPSocket::Create(
90 proxy_socket, SocketAddress(INADDR_ANY, 0), server.address()); 88 proxy_socket, SocketAddress(INADDR_ANY, 0), server.address());
91 EXPECT_TRUE(packet_socket != NULL); 89 EXPECT_TRUE(packet_socket != nullptr);
92 rtc::TestClient client(packet_socket); 90 rtc::TestClient client(packet_socket);
93 91
94 EXPECT_EQ(Socket::CS_CONNECTING, proxy_socket->GetState()); 92 EXPECT_EQ(Socket::CS_CONNECTING, proxy_socket->GetState());
95 EXPECT_TRUE(client.CheckConnected()); 93 EXPECT_TRUE(client.CheckConnected());
96 EXPECT_EQ(Socket::CS_CONNECTED, proxy_socket->GetState()); 94 EXPECT_EQ(Socket::CS_CONNECTED, proxy_socket->GetState());
97 EXPECT_EQ(server.address(), client.remote_address()); 95 EXPECT_EQ(server.address(), client.remote_address());
98 client.Send("foo", 3); 96 client.Send("foo", 3);
99 EXPECT_TRUE(client.CheckNextPacket("foo", 3, NULL)); 97 EXPECT_TRUE(client.CheckNextPacket("foo", 3, nullptr));
100 EXPECT_TRUE(client.CheckNoPacket()); 98 EXPECT_TRUE(client.CheckNoPacket());
101 } 99 }
102 100
103 /* 101 /*
104 // Tests whether we can use a HTTPS proxy to connect to a server. 102 // Tests whether we can use a HTTPS proxy to connect to a server.
105 TEST_F(ProxyTest, TestHttpsConnect) { 103 TEST_F(ProxyTest, TestHttpsConnect) {
106 AsyncSocket* socket = ss()->CreateAsyncSocket(SOCK_STREAM); 104 AsyncSocket* socket = ss()->CreateAsyncSocket(SOCK_STREAM);
107 AsyncHttpsProxySocket* proxy_socket = new AsyncHttpsProxySocket( 105 AsyncHttpsProxySocket* proxy_socket = new AsyncHttpsProxySocket(
108 socket, "unittest/1.0", kHttpsProxyIntAddress, "", CryptString()); 106 socket, "unittest/1.0", kHttpsProxyIntAddress, "", CryptString());
109 TestClient client(new AsyncTCPSocket(proxy_socket)); 107 TestClient client(new AsyncTCPSocket(proxy_socket));
110 TestEchoServer server(Thread::Current(), SocketAddress()); 108 TestEchoServer server(Thread::Current(), SocketAddress());
111 109
112 EXPECT_TRUE(client.Connect(server.address())); 110 EXPECT_TRUE(client.Connect(server.address()));
113 EXPECT_TRUE(client.CheckConnected()); 111 EXPECT_TRUE(client.CheckConnected());
114 EXPECT_EQ(server.address(), client.remote_address()); 112 EXPECT_EQ(server.address(), client.remote_address());
115 client.Send("foo", 3); 113 client.Send("foo", 3);
116 EXPECT_TRUE(client.CheckNextPacket("foo", 3, NULL)); 114 EXPECT_TRUE(client.CheckNextPacket("foo", 3, nullptr));
117 EXPECT_TRUE(client.CheckNoPacket()); 115 EXPECT_TRUE(client.CheckNoPacket());
118 } 116 }
119 */ 117 */
120 118
121 // Tests whether we can autodetect a SOCKS5 proxy. 119 // Tests whether we can autodetect a SOCKS5 proxy.
122 TEST_F(ProxyTest, TestAutoDetectSocks5) { 120 TEST_F(ProxyTest, TestAutoDetectSocks5) {
123 EXPECT_EQ(rtc::PROXY_SOCKS5, DetectProxyType(kSocksProxyIntAddr)); 121 EXPECT_EQ(rtc::PROXY_SOCKS5, DetectProxyType(kSocksProxyIntAddr));
124 } 122 }
125 123
126 /* 124 /*
127 // Tests whether we can autodetect a HTTPS proxy. 125 // Tests whether we can autodetect a HTTPS proxy.
128 TEST_F(ProxyTest, TestAutoDetectHttps) { 126 TEST_F(ProxyTest, TestAutoDetectHttps) {
129 EXPECT_EQ(rtc::PROXY_HTTPS, DetectProxyType(kHttpsProxyIntAddr)); 127 EXPECT_EQ(rtc::PROXY_HTTPS, DetectProxyType(kHttpsProxyIntAddr));
130 } 128 }
131 */ 129 */
132 130
133 // Tests whether we fail properly for no proxy. 131 // Tests whether we fail properly for no proxy.
134 TEST_F(ProxyTest, TestAutoDetectBogus) { 132 TEST_F(ProxyTest, TestAutoDetectBogus) {
135 EXPECT_EQ(rtc::PROXY_UNKNOWN, DetectProxyType(kBogusProxyIntAddr)); 133 EXPECT_EQ(rtc::PROXY_UNKNOWN, DetectProxyType(kBogusProxyIntAddr));
136 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698