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

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

Issue 24364005: Update webrtc to r4819. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « remoting/jingle_glue/chromium_socket_factory.cc ('k') | third_party/libjingle/README.chromium » ('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) 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 "remoting/jingle_glue/chromium_socket_factory.h" 5 #include "remoting/jingle_glue/chromium_socket_factory.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 talk_base::SocketAddress("127.0.0.1", 0), 0, 0)); 59 talk_base::SocketAddress("127.0.0.1", 0), 0, 0));
60 ASSERT_TRUE(sending_socket.get() != NULL); 60 ASSERT_TRUE(sending_socket.get() != NULL);
61 EXPECT_EQ(sending_socket->GetState(), 61 EXPECT_EQ(sending_socket->GetState(),
62 talk_base::AsyncPacketSocket::STATE_BOUND); 62 talk_base::AsyncPacketSocket::STATE_BOUND);
63 address = sending_socket->GetLocalAddress(); 63 address = sending_socket->GetLocalAddress();
64 64
65 std::string test_packet("TEST PACKET"); 65 std::string test_packet("TEST PACKET");
66 int attempts = 0; 66 int attempts = 0;
67 while (last_packet_.empty() && attempts++ < kMaxAttempts) { 67 while (last_packet_.empty() && attempts++ < kMaxAttempts) {
68 sending_socket->SendTo(test_packet.data(), test_packet.size(), 68 sending_socket->SendTo(test_packet.data(), test_packet.size(),
69 socket_->GetLocalAddress()); 69 socket_->GetLocalAddress(),
70 talk_base::DSCP_NO_CHANGE);
70 message_loop_.PostDelayedTask(FROM_HERE, run_loop_.QuitClosure(), 71 message_loop_.PostDelayedTask(FROM_HERE, run_loop_.QuitClosure(),
71 kAttemptPeriod); 72 kAttemptPeriod);
72 run_loop_.Run(); 73 run_loop_.Run();
73 } 74 }
74 EXPECT_EQ(test_packet, last_packet_); 75 EXPECT_EQ(test_packet, last_packet_);
75 EXPECT_EQ(address, last_address_); 76 EXPECT_EQ(address, last_address_);
76 } 77 }
77 78
78 TEST_F(ChromiumSocketFactoryTest, SetOptions) { 79 TEST_F(ChromiumSocketFactoryTest, SetOptions) {
79 EXPECT_EQ(0, socket_->SetOption(talk_base::Socket::OPT_SNDBUF, 4096)); 80 EXPECT_EQ(0, socket_->SetOption(talk_base::Socket::OPT_SNDBUF, 4096));
80 EXPECT_EQ(0, socket_->SetOption(talk_base::Socket::OPT_RCVBUF, 4096)); 81 EXPECT_EQ(0, socket_->SetOption(talk_base::Socket::OPT_RCVBUF, 4096));
81 } 82 }
82 83
83 TEST_F(ChromiumSocketFactoryTest, PortRange) { 84 TEST_F(ChromiumSocketFactoryTest, PortRange) {
84 const int kMinPort = 12400; 85 const int kMinPort = 12400;
85 const int kMaxPort = 12410; 86 const int kMaxPort = 12410;
86 socket_.reset(socket_factory_->CreateUdpSocket( 87 socket_.reset(socket_factory_->CreateUdpSocket(
87 talk_base::SocketAddress("127.0.0.1", 0), kMaxPort, kMaxPort)); 88 talk_base::SocketAddress("127.0.0.1", 0), kMaxPort, kMaxPort));
88 ASSERT_TRUE(socket_.get() != NULL); 89 ASSERT_TRUE(socket_.get() != NULL);
89 EXPECT_EQ(socket_->GetState(), talk_base::AsyncPacketSocket::STATE_BOUND); 90 EXPECT_EQ(socket_->GetState(), talk_base::AsyncPacketSocket::STATE_BOUND);
90 EXPECT_GE(socket_->GetLocalAddress().port(), kMinPort); 91 EXPECT_GE(socket_->GetLocalAddress().port(), kMinPort);
91 EXPECT_LE(socket_->GetLocalAddress().port(), kMaxPort); 92 EXPECT_LE(socket_->GetLocalAddress().port(), kMaxPort);
92 } 93 }
93 94
94 } // namespace remoting 95 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/jingle_glue/chromium_socket_factory.cc ('k') | third_party/libjingle/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698