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

Unified Diff: content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc

Issue 17132012: Proxy support for P2P TCP Socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc
===================================================================
--- content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc (revision 206737)
+++ content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc (working copy)
@@ -9,6 +9,8 @@
#include "base/sys_byteorder.h"
#include "content/browser/renderer_host/p2p/socket_host_test_utils.h"
#include "net/socket/stream_socket.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -19,14 +21,22 @@
namespace content {
-class P2PSocketHostTcpTest : public testing::Test {
+class P2PSocketHostTcpTestBase : public testing::Test {
protected:
+ explicit P2PSocketHostTcpTestBase(P2PSocketType type)
+ : socket_type_(type) {}
+
virtual void SetUp() OVERRIDE {
EXPECT_CALL(sender_, Send(
MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID))))
.WillOnce(DoAll(DeleteArg<0>(), Return(true)));
- socket_host_.reset(new P2PSocketHostTcp(&sender_, 0));
+ if (socket_type_ == P2P_SOCKET_TCP_CLIENT)
Sergey Ulanov 2013/06/20 01:50:02 add {} for multi-line if.
Mallinath (Gone from Chromium) 2013/06/20 05:24:15 Done.
+ socket_host_.reset(new P2PSocketHostTcp(
+ &sender_, 0, NULL));
Sergey Ulanov 2013/06/20 01:50:02 this can fit on the previous line.
Mallinath (Gone from Chromium) 2013/06/20 05:24:15 Done.
+ else
+ socket_host_.reset(new P2PSocketHostStunTcp(
+ &sender_, 0, NULL));
socket_ = new FakeSocket(&sent_data_);
socket_->SetLocalAddress(ParseAddress(kTestLocalIpAddress, kTestPort1));
socket_host_->socket_.reset(socket_);
@@ -50,53 +60,26 @@
std::string sent_data_;
FakeSocket* socket_; // Owned by |socket_host_|.
- scoped_ptr<P2PSocketHostTcp> socket_host_;
+ scoped_ptr<P2PSocketHostTcpBase> socket_host_;
MockIPCSender sender_;
net::IPEndPoint local_address_;
net::IPEndPoint dest_;
net::IPEndPoint dest2_;
+
+ P2PSocketType socket_type_;
};
-class P2PSocketHostStunTcpTest : public testing::Test {
+class P2PSocketHostTcpTest : public P2PSocketHostTcpTestBase {
protected:
- virtual void SetUp() OVERRIDE {
- EXPECT_CALL(sender_, Send(
- MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID))))
- .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
+ P2PSocketHostTcpTest() : P2PSocketHostTcpTestBase(P2P_SOCKET_TCP_CLIENT) {}
+};
- socket_host_.reset(new P2PSocketHostStunTcp(&sender_, 0));
- socket_ = new FakeSocket(&sent_data_);
- socket_->SetLocalAddress(ParseAddress(kTestLocalIpAddress, kTestPort1));
- socket_host_->socket_.reset(socket_);
-
- dest_ = ParseAddress(kTestIpAddress1, kTestPort1);
-
- local_address_ = ParseAddress(kTestLocalIpAddress, kTestPort1);
-
- socket_host_->remote_address_ = dest_;
- socket_host_->state_ = P2PSocketHost::STATE_CONNECTING;
- socket_host_->OnConnected(net::OK);
- }
-
- std::string IntToSize(int size) {
- std::string result;
- uint16 size16 = base::HostToNet16(size);
- result.resize(sizeof(size16));
- memcpy(&result[0], &size16, sizeof(size16));
- return result;
- }
-
- std::string sent_data_;
- FakeSocket* socket_; // Owned by |socket_host_|.
- scoped_ptr<P2PSocketHostStunTcp> socket_host_;
- MockIPCSender sender_;
-
- net::IPEndPoint local_address_;
-
- net::IPEndPoint dest_;
- net::IPEndPoint dest2_;
+class P2PSocketHostStunTcpTest : public P2PSocketHostTcpTestBase {
+ protected:
+ P2PSocketHostStunTcpTest()
+ : P2PSocketHostTcpTestBase(P2P_SOCKET_STUN_TCP_CLIENT) {}
Sergey Ulanov 2013/06/20 01:50:02 nit: move } to the next line.
Mallinath (Gone from Chromium) 2013/06/20 05:24:15 Done.
};
// Verify that we can send STUN message and that they are formatted

Powered by Google App Engine
This is Rietveld 408576698