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

Side by Side Diff: webrtc/p2p/base/relayserver_unittest.cc

Issue 2828223002: Delete method MessageQueue::set_socketserver (Closed)
Patch Set: Use unique_ptr, fixing one leak in VirtualSocketServerTest. Created 3 years, 7 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 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 23 matching lines...) Expand all
34 "purpose is to make the parser go 'ack'. it doesn't " 34 "purpose is to make the parser go 'ack'. it doesn't "
35 "look anything like a normal stun message"; 35 "look anything like a normal stun message";
36 static const char* msg1 = "spamspamspamspamspamspamspambakedbeansspam"; 36 static const char* msg1 = "spamspamspamspamspamspamspambakedbeansspam";
37 static const char* msg2 = "Lobster Thermidor a Crevette with a mornay sauce..."; 37 static const char* msg2 = "Lobster Thermidor a Crevette with a mornay sauce...";
38 38
39 class RelayServerTest : public testing::Test { 39 class RelayServerTest : public testing::Test {
40 public: 40 public:
41 RelayServerTest() 41 RelayServerTest()
42 : pss_(new rtc::PhysicalSocketServer), 42 : pss_(new rtc::PhysicalSocketServer),
43 ss_(new rtc::VirtualSocketServer(pss_.get())), 43 ss_(new rtc::VirtualSocketServer(pss_.get())),
44 ss_scope_(ss_.get()), 44 thread_(ss_.get()),
45 username_(rtc::CreateRandomString(12)), 45 username_(rtc::CreateRandomString(12)),
46 password_(rtc::CreateRandomString(12)) {} 46 password_(rtc::CreateRandomString(12)) {}
47 47
48 protected: 48 protected:
49 virtual void SetUp() { 49 virtual void SetUp() {
50 server_.reset(new RelayServer(rtc::Thread::Current())); 50 server_.reset(new RelayServer(rtc::Thread::Current()));
51 51
52 server_->AddInternalSocket( 52 server_->AddInternalSocket(
53 rtc::AsyncUDPSocket::Create(ss_.get(), server_int_addr)); 53 rtc::AsyncUDPSocket::Create(ss_.get(), server_int_addr));
54 server_->AddExternalSocket( 54 server_->AddExternalSocket(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 static void AddDestinationAttr(StunMessage* msg, const SocketAddress& addr) { 163 static void AddDestinationAttr(StunMessage* msg, const SocketAddress& addr) {
164 auto attr = StunAttribute::CreateAddress(STUN_ATTR_DESTINATION_ADDRESS); 164 auto attr = StunAttribute::CreateAddress(STUN_ATTR_DESTINATION_ADDRESS);
165 attr->SetIP(addr.ipaddr()); 165 attr->SetIP(addr.ipaddr());
166 attr->SetPort(addr.port()); 166 attr->SetPort(addr.port());
167 msg->AddAttribute(std::move(attr)); 167 msg->AddAttribute(std::move(attr));
168 } 168 }
169 169
170 std::unique_ptr<rtc::PhysicalSocketServer> pss_; 170 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
171 std::unique_ptr<rtc::VirtualSocketServer> ss_; 171 std::unique_ptr<rtc::VirtualSocketServer> ss_;
172 rtc::SocketServerScope ss_scope_; 172 rtc::AutoSocketServerThread thread_;
173 std::unique_ptr<RelayServer> server_; 173 std::unique_ptr<RelayServer> server_;
174 std::unique_ptr<rtc::TestClient> client1_; 174 std::unique_ptr<rtc::TestClient> client1_;
175 std::unique_ptr<rtc::TestClient> client2_; 175 std::unique_ptr<rtc::TestClient> client2_;
176 std::string username_; 176 std::string username_;
177 std::string password_; 177 std::string password_;
178 }; 178 };
179 179
180 // Send a complete nonsense message and verify that it is eaten. 180 // Send a complete nonsense message and verify that it is eaten.
181 TEST_F(RelayServerTest, TestBadRequest) { 181 TEST_F(RelayServerTest, TestBadRequest) {
182 SendRaw1(bad, static_cast<int>(strlen(bad))); 182 SendRaw1(bad, static_cast<int>(strlen(bad)));
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 const StunErrorCodeAttribute* err = res->GetErrorCode(); 508 const StunErrorCodeAttribute* err = res->GetErrorCode();
509 ASSERT_TRUE(err != NULL); 509 ASSERT_TRUE(err != NULL);
510 EXPECT_EQ(6, err->eclass()); 510 EXPECT_EQ(6, err->eclass());
511 EXPECT_EQ(0, err->number()); 511 EXPECT_EQ(0, err->number());
512 EXPECT_EQ("Operation Not Supported", err->reason()); 512 EXPECT_EQ("Operation Not Supported", err->reason());
513 513
514 // Also verify that traffic from the external client is ignored. 514 // Also verify that traffic from the external client is ignored.
515 SendRaw2(msg2, static_cast<int>(strlen(msg2))); 515 SendRaw2(msg2, static_cast<int>(strlen(msg2)));
516 EXPECT_TRUE(ReceiveRaw1().empty()); 516 EXPECT_TRUE(ReceiveRaw1().empty());
517 } 517 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698