Chromium Code Reviews| Index: jingle/notifier/base/proxy_resolving_client_socket_unittest.cc |
| diff --git a/jingle/notifier/base/proxy_resolving_client_socket_unittest.cc b/jingle/notifier/base/proxy_resolving_client_socket_unittest.cc |
| index ab9253b8f0453bb08417aeba0aec3d784f754230..8f6861646c9ae4cdf1dc20ca00e6c4c956cc0611 100644 |
| --- a/jingle/notifier/base/proxy_resolving_client_socket_unittest.cc |
| +++ b/jingle/notifier/base/proxy_resolving_client_socket_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include "jingle/notifier/base/proxy_resolving_client_socket.h" |
| #include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| #include "base/message_loop.h" |
| #include "net/base/mock_host_resolver.h" |
| #include "net/base/test_completion_callback.h" |
| @@ -14,36 +15,33 @@ |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace { |
| -// TODO(sanjeevr): Move this to net_test_support. |
| -// Used to return a dummy context. |
| -class TestURLRequestContextGetter : public net::URLRequestContextGetter { |
| + |
| +class ProxyTestURLRequestContextGetter : public TestURLRequestContextGetter { |
| public: |
| - TestURLRequestContextGetter() |
| - : message_loop_proxy_(base::MessageLoopProxy::current()) { |
| + ProxyTestURLRequestContextGetter() |
| + : TestURLRequestContextGetter(base::MessageLoopProxy::current()), |
| + set_context_members_(false) {} |
| + |
| + // TestURLRequestContextGetter overrides. |
| + virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE { |
|
Nicolas Zea
2012/03/02 19:12:27
Comment about what this accomplishes.
akalin
2012/03/02 22:55:50
Done.
|
| + TestURLRequestContext* context = |
| + TestURLRequestContextGetter::GetURLRequestContext(); |
| + if (!set_context_members_) { |
| + context->set_host_resolver(new net::MockHostResolver()); |
| + context->set_proxy_service(net::ProxyService::CreateFixedFromPacResult( |
| + "PROXY bad:99; PROXY maybe:80; DIRECT")); |
| + set_context_members_ = true; |
| + } |
| + return context; |
| } |
| - virtual ~TestURLRequestContextGetter() { } |
| - // net::URLRequestContextGetter: |
| - virtual net::URLRequestContext* GetURLRequestContext() { |
| - if (!context_) |
| - CreateURLRequestContext(); |
| - return context_.get(); |
| - } |
| - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { |
| - return message_loop_proxy_; |
| - } |
| + protected: |
| + virtual ~ProxyTestURLRequestContextGetter() {} |
| private: |
| - void CreateURLRequestContext() { |
| - context_ = new TestURLRequestContext(); |
| - context_->set_host_resolver(new net::MockHostResolver()); |
| - context_->set_proxy_service(net::ProxyService::CreateFixedFromPacResult( |
| - "PROXY bad:99; PROXY maybe:80; DIRECT")); |
| - } |
| - |
| - scoped_refptr<net::URLRequestContext> context_; |
| - scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
| + bool set_context_members_; |
| }; |
| + |
| } // namespace |
| namespace notifier { |
| @@ -51,7 +49,7 @@ namespace notifier { |
| class ProxyResolvingClientSocketTest : public testing::Test { |
| protected: |
| ProxyResolvingClientSocketTest() |
| - : url_request_context_getter_(new TestURLRequestContextGetter()) {} |
| + : url_request_context_getter_(new ProxyTestURLRequestContextGetter()) {} |
| virtual ~ProxyResolvingClientSocketTest() {} |
| @@ -61,9 +59,8 @@ class ProxyResolvingClientSocketTest : public testing::Test { |
| message_loop_.RunAllPending(); |
| } |
| - // Needed by XmppConnection. |
| - MessageLoopForIO message_loop_; |
| - scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_; |
| + MessageLoop message_loop_; |
| + scoped_refptr<ProxyTestURLRequestContextGetter> url_request_context_getter_; |
| }; |
| // TODO(sanjeevr): Fix this test on Linux. |