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

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

Issue 9562037: Move TestURLRequestContextGetter to url_request_test_util.{h,cc} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change comment Created 8 years, 10 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
« no previous file with comments | « content/common/net/url_fetcher_impl_unittest.cc ('k') | jingle/notifier/base/xmpp_connection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a38b9041c6c1b8a32853871256dd0101907423e4 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,34 @@
#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) {}
+
+ // Override GetURLRequestContext to set the host resolver and proxy
+ // service (used by the unit tests).
+ virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE {
+ 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 +50,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 +60,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.
« no previous file with comments | « content/common/net/url_fetcher_impl_unittest.cc ('k') | jingle/notifier/base/xmpp_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698