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

Unified Diff: jingle/notifier/base/chrome_async_socket_unittest.cc

Issue 6833031: Changed the jingle network code in ChromeAsyncSocket to use the client socket pool. This also all... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Lint fix Created 9 years, 8 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: jingle/notifier/base/chrome_async_socket_unittest.cc
===================================================================
--- jingle/notifier/base/chrome_async_socket_unittest.cc (revision 81429)
+++ jingle/notifier/base/chrome_async_socket_unittest.cc (working copy)
@@ -11,11 +11,13 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
+#include "base/message_loop_proxy.h"
#include "net/base/capturing_net_log.h"
-#include "net/base/cert_verifier.h"
#include "net/base/net_errors.h"
#include "net/base/ssl_config_service.h"
#include "net/socket/socket_test_util.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_test_util.h"
#include "talk/base/sigslot.h"
#include "talk/base/socketaddress.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -24,6 +26,29 @@
namespace {
+// Used to return a dummy context.
+class TestURLRequestContextGetter : public net::URLRequestContextGetter {
+ public:
+ TestURLRequestContextGetter()
+ : message_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()) {
+ }
+ virtual ~TestURLRequestContextGetter() { }
+
+ // net::URLRequestContextGetter:
+ virtual net::URLRequestContext* GetURLRequestContext() {
+ if (!context_)
+ context_ = new TestURLRequestContext();
+ return context_.get();
+ }
+ virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const {
+ return message_loop_proxy_;
+ }
+
+ private:
+ scoped_refptr<net::URLRequestContext> context_;
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
+};
+
// Data provider that handles reads/writes for ChromeAsyncSocket.
class AsyncSocketDataProvider : public net::SocketDataProvider {
public:
@@ -102,6 +127,7 @@
ChromeAsyncSocketTest()
: ssl_socket_data_provider_(true, net::OK),
capturing_net_log_(net::CapturingNetLog::kUnbounded),
+ url_request_context_getter_(new TestURLRequestContextGetter()),
addr_(0xaabbccdd, 35) {}
virtual ~ChromeAsyncSocketTest() {}
@@ -115,10 +141,11 @@
&ssl_socket_data_provider_);
chrome_async_socket_.reset(
- new ChromeAsyncSocket(mock_client_socket_factory.release(),
- ssl_config_, &cert_verifier_, 14, 20,
- &capturing_net_log_)),
-
+ new ChromeAsyncSocket(ssl_config_, url_request_context_getter_, false,
+ 14, 20,
+ &capturing_net_log_));
+ chrome_async_socket_->set_client_socket_factory(
+ mock_client_socket_factory.release());
chrome_async_socket_->SignalConnected.connect(
this, &ChromeAsyncSocketTest::OnConnect);
chrome_async_socket_->SignalSSLConnected.connect(
@@ -373,7 +400,7 @@
net::CapturingNetLog capturing_net_log_;
net::SSLConfig ssl_config_;
- net::CertVerifier cert_verifier_;
+ scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_;
scoped_ptr<ChromeAsyncSocket> chrome_async_socket_;
std::deque<SignalSocketState> signal_socket_states_;
const talk_base::SocketAddress addr_;
@@ -417,16 +444,6 @@
ExpectClosed();
}
-TEST_F(ChromeAsyncSocketTest, UnresolvedConnect) {
- const talk_base::SocketAddress unresolved_addr(0, 0);
- EXPECT_FALSE(chrome_async_socket_->Connect(unresolved_addr));
- ExpectErrorState(ChromeAsyncSocket::STATE_CLOSED,
- ChromeAsyncSocket::ERROR_DNS);
-
- EXPECT_TRUE(chrome_async_socket_->Close());
- ExpectClosed();
-}
-
TEST_F(ChromeAsyncSocketTest, DoubleConnect) {
EXPECT_DEBUG_DEATH({
DoOpenClosed();

Powered by Google App Engine
This is Rietveld 408576698