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

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

Issue 10408067: [net] Switch TestURLRequestContext to use MockCachingHostResolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to trunk. Created 8 years, 7 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/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 a38b9041c6c1b8a32853871256dd0101907423e4..f856ac8c85627ac4a5c37d9037f4400c8e34cf0a 100644
--- a/jingle/notifier/base/proxy_resolving_client_socket_unittest.cc
+++ b/jingle/notifier/base/proxy_resolving_client_socket_unittest.cc
@@ -9,6 +9,7 @@
#include "base/message_loop.h"
#include "net/base/mock_host_resolver.h"
#include "net/base/test_completion_callback.h"
+#include "net/proxy/proxy_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"
@@ -16,31 +17,15 @@
namespace {
-class ProxyTestURLRequestContextGetter : public TestURLRequestContextGetter {
+class MyTestURLRequestContext : public TestURLRequestContext {
public:
- 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;
+ MyTestURLRequestContext() : TestURLRequestContext(true) {
+ context_storage_.set_proxy_service(
+ net::ProxyService::CreateFixedFromPacResult(
+ "PROXY bad:99; PROXY maybe:80; DIRECT"));
+ Init();
}
-
- protected:
- virtual ~ProxyTestURLRequestContextGetter() {}
-
- private:
- bool set_context_members_;
+ virtual ~MyTestURLRequestContext() {}
};
} // namespace
@@ -50,7 +35,9 @@ namespace notifier {
class ProxyResolvingClientSocketTest : public testing::Test {
protected:
ProxyResolvingClientSocketTest()
- : url_request_context_getter_(new ProxyTestURLRequestContextGetter()) {}
+ : url_request_context_getter_(new TestURLRequestContextGetter(
+ base::MessageLoopProxy::current(),
+ scoped_ptr<TestURLRequestContext>(new MyTestURLRequestContext))) {}
virtual ~ProxyResolvingClientSocketTest() {}
@@ -61,7 +48,7 @@ class ProxyResolvingClientSocketTest : public testing::Test {
}
MessageLoop message_loop_;
- scoped_refptr<ProxyTestURLRequestContextGetter> url_request_context_getter_;
+ scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_;
};
// TODO(sanjeevr): Fix this test on Linux.

Powered by Google App Engine
This is Rietveld 408576698