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

Side by Side Diff: jingle/notifier/base/proxy_resolving_client_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: Review comments 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "jingle/notifier/base/proxy_resolving_client_socket.h"
6
7 #include "base/basictypes.h"
8 #include "base/message_loop.h"
9 #include "net/base/capturing_net_log.h"
10 #include "net/url_request/url_request_context_getter.h"
11 #include "net/url_request/url_request_test_util.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace {
16 // TODO(sanjeevr): Move this to net_test_support.
17 // Used to return a dummy context.
18 class TestURLRequestContextGetter : public net::URLRequestContextGetter {
19 public:
20 TestURLRequestContextGetter()
21 : message_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()) {
22 }
23 virtual ~TestURLRequestContextGetter() { }
24
25 // net::URLRequestContextGetter:
26 virtual net::URLRequestContext* GetURLRequestContext() {
27 if (!context_)
28 context_ = new TestURLRequestContext();
29 return context_.get();
30 }
31 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const {
32 return message_loop_proxy_;
33 }
34
35 private:
36 scoped_refptr<net::URLRequestContext> context_;
37 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
38 };
39 } // namespace
40
41 namespace notifier {
42
43 class ProxyResolvingClientSocketTest : public testing::Test {
44 protected:
45 ProxyResolvingClientSocketTest()
46 : url_request_context_getter_(new TestURLRequestContextGetter()),
47 capturing_net_log_(net::CapturingNetLog::kUnbounded),
48 connect_callback_(ALLOW_THIS_IN_INITIALIZER_LIST(this),
49 &ProxyResolvingClientSocketTest::NetCallback) { }
50
51 virtual ~ProxyResolvingClientSocketTest() {}
52
53 virtual void TearDown() {
54 // Clear out any messages posted by ProxyResolvingClientSocket's
55 // destructor.
56 message_loop_.RunAllPending();
57 }
58
59 MOCK_METHOD1(NetCallback, void(int status));
60
61 // Needed by XmppConnection.
62 MessageLoop message_loop_;
63 scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_;
64 net::CapturingNetLog capturing_net_log_;
65 net::CompletionCallbackImpl<ProxyResolvingClientSocketTest> connect_callback_;
66 };
67
68 TEST_F(ProxyResolvingClientSocketTest, ConnectError) {
69 net::HostPortPair dest("0.0.0.0", 0);
70 ProxyResolvingClientSocket proxy_resolving_socket(
71 url_request_context_getter_,
72 net::SSLConfig(),
73 dest,
74 &capturing_net_log_);
75 // ProxyResolvingClientSocket::Connect() will always return an error of
76 // ERR_ADDRESS_INVALID for a 0 IP address.
77 EXPECT_CALL(*this, NetCallback(net::ERR_ADDRESS_INVALID)).Times(1);
78 int status = proxy_resolving_socket.Connect(&connect_callback_);
79 // Connect always returns ERR_IO_PENDING because it is always asynchronous.
80 EXPECT_EQ(status, net::ERR_IO_PENDING);
81 message_loop_.RunAllPending();
82 }
83
84 // TODO(sanjeevr): Add more unit-tests.
85 } // namespace notifier
OLDNEW
« no previous file with comments | « jingle/notifier/base/proxy_resolving_client_socket.cc ('k') | jingle/notifier/base/resolving_client_socket_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698