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

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: Lint fixes 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 {
akalin 2011/04/15 17:41:05 Add a TODO to move chrome/test/test_url_request_co
sanjeevr 2011/04/15 18:04:33 We may not be able to do that since chrome/test/te
16 // Used to return a dummy context.
17 class TestURLRequestContextGetter : public net::URLRequestContextGetter {
18 public:
19 TestURLRequestContextGetter()
20 : message_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()) {
21 }
22 virtual ~TestURLRequestContextGetter() { }
23
24 // net::URLRequestContextGetter:
25 virtual net::URLRequestContext* GetURLRequestContext() {
26 if (!context_)
27 context_ = new TestURLRequestContext();
28 return context_.get();
29 }
30 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const {
31 return message_loop_proxy_;
32 }
33
34 private:
35 scoped_refptr<net::URLRequestContext> context_;
36 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
37 };
38 } // namespace
39
40 namespace notifier {
41
42 class ProxyResolvingClientSocketTest : public testing::Test {
43 protected:
44 ProxyResolvingClientSocketTest()
45 : url_request_context_getter_(new TestURLRequestContextGetter()),
46 capturing_net_log_(net::CapturingNetLog::kUnbounded),
47 connect_callback_(ALLOW_THIS_IN_INITIALIZER_LIST(this),
48 &ProxyResolvingClientSocketTest::NetCallback) { }
49
50 virtual ~ProxyResolvingClientSocketTest() {}
51
52 virtual void TearDown() {
53 // Clear out any messages posted by ProxyResolvingClientSocket's
54 // destructor.
55 message_loop_.RunAllPending();
56 }
57
58 MOCK_METHOD1(NetCallback, void(int status));
59
60 // Needed by XmppConnection.
61 MessageLoop message_loop_;
62 scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_;
63 net::CapturingNetLog capturing_net_log_;
64 net::CompletionCallbackImpl<ProxyResolvingClientSocketTest> connect_callback_;
65 };
66
67 TEST_F(ProxyResolvingClientSocketTest, ConnectError) {
68 net::HostPortPair dest("0.0.0.0", 0);
69 ProxyResolvingClientSocket proxy_resolving_socket(
70 url_request_context_getter_,
71 net::SSLConfig(),
72 dest,
73 &capturing_net_log_);
74 // ProxyResolvingClientSocket::Connect() will always return an error of
75 // ERR_ADDRESS_INVALID for a 0 IP address.
76 EXPECT_CALL(*this, NetCallback(net::ERR_ADDRESS_INVALID)).Times(1);
77 int status = proxy_resolving_socket.Connect(&connect_callback_);
78 // Connect always returns ERR_IO_PENDING because it is always asynchronous.
79 EXPECT_EQ(status, net::ERR_IO_PENDING);
80 message_loop_.RunAllPending();
81 }
82
83 // TODO(sanjeevr): Add more unit-tests.
84 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698