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

Unified Diff: jingle/notifier/base/xmpp_connection_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 side-by-side diff with in-line comments
Download patch
Index: jingle/notifier/base/xmpp_connection_unittest.cc
===================================================================
--- jingle/notifier/base/xmpp_connection_unittest.cc (revision 81535)
+++ jingle/notifier/base/xmpp_connection_unittest.cc (working copy)
@@ -12,6 +12,8 @@
#include "base/message_loop.h"
#include "jingle/notifier/base/weak_xmpp_client.h"
#include "net/base/cert_verifier.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_test_util.h"
#include "talk/xmpp/prexmppauth.h"
#include "talk/xmpp/xmppclientsettings.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -28,6 +30,31 @@
class Task;
} // namespace talk_base
+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 Same.
+// Used to return a dummy context.
+class TestURLRequestContextGetter : public net::URLRequestContextGetter {
+ public:
+ TestURLRequestContextGetter()
+ : message_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()) {
+ }
+ virtual ~TestURLRequestContextGetter() { }
+
+ // net::URLRequestContextGetter:
+ virtual net::URLRequestContext* GetURLRequestContext() {
+ if (!context_)
+ context_ = new TestURLRequestContext();
+ return context_.get();
+ }
+ virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const {
+ return message_loop_proxy_;
+ }
+
+ private:
+ scoped_refptr<net::URLRequestContext> context_;
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
+};
+} // namespace
+
namespace notifier {
using ::testing::_;
@@ -66,7 +93,9 @@
class XmppConnectionTest : public testing::Test {
protected:
- XmppConnectionTest() : mock_pre_xmpp_auth_(new MockPreXmppAuth()) {}
+ XmppConnectionTest()
+ : mock_pre_xmpp_auth_(new MockPreXmppAuth()),
+ url_request_context_getter_(new TestURLRequestContextGetter()) {}
virtual ~XmppConnectionTest() {}
@@ -77,13 +106,14 @@
// Needed by XmppConnection.
MessageLoop message_loop_;
- net::CertVerifier cert_verifier_;
MockXmppConnectionDelegate mock_xmpp_connection_delegate_;
scoped_ptr<MockPreXmppAuth> mock_pre_xmpp_auth_;
+ scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_;
};
TEST_F(XmppConnectionTest, CreateDestroy) {
- XmppConnection xmpp_connection(buzz::XmppClientSettings(), &cert_verifier_,
+ XmppConnection xmpp_connection(buzz::XmppClientSettings(),
+ url_request_context_getter_,
&mock_xmpp_connection_delegate_, NULL);
}
@@ -94,7 +124,8 @@
EXPECT_CALL(mock_xmpp_connection_delegate_,
OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
- XmppConnection xmpp_connection(buzz::XmppClientSettings(), &cert_verifier_,
+ XmppConnection xmpp_connection(buzz::XmppClientSettings(),
+ url_request_context_getter_,
&mock_xmpp_connection_delegate_, NULL);
// We need to do this *before* |xmpp_connection| gets destroyed or
@@ -113,7 +144,7 @@
OnError(buzz::XmppEngine::ERROR_AUTH, 5, NULL));
XmppConnection xmpp_connection(
- buzz::XmppClientSettings(), &cert_verifier_,
+ buzz::XmppClientSettings(), url_request_context_getter_,
&mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release());
// We need to do this *before* |xmpp_connection| gets destroyed or
@@ -131,7 +162,7 @@
OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
XmppConnection xmpp_connection(
- buzz::XmppClientSettings(), &cert_verifier_,
+ buzz::XmppClientSettings(), url_request_context_getter_,
&mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release());
// We need to do this *before* |xmpp_connection| gets destroyed or
@@ -143,7 +174,8 @@
EXPECT_CALL(mock_xmpp_connection_delegate_,
OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
- XmppConnection xmpp_connection(buzz::XmppClientSettings(), &cert_verifier_,
+ XmppConnection xmpp_connection(buzz::XmppClientSettings(),
+ url_request_context_getter_,
&mock_xmpp_connection_delegate_, NULL);
xmpp_connection.weak_xmpp_client_->
@@ -156,7 +188,8 @@
WillOnce(SaveArg<0>(&weak_ptr));
{
- XmppConnection xmpp_connection(buzz::XmppClientSettings(), &cert_verifier_,
+ XmppConnection xmpp_connection(buzz::XmppClientSettings(),
+ url_request_context_getter_,
&mock_xmpp_connection_delegate_, NULL);
xmpp_connection.weak_xmpp_client_->
@@ -173,7 +206,8 @@
EXPECT_CALL(mock_xmpp_connection_delegate_, OnConnect(_)).
WillOnce(SaveArg<0>(&weak_ptr));
- XmppConnection xmpp_connection(buzz::XmppClientSettings(), &cert_verifier_,
+ XmppConnection xmpp_connection(buzz::XmppClientSettings(),
+ url_request_context_getter_,
&mock_xmpp_connection_delegate_, NULL);
xmpp_connection.weak_xmpp_client_->
@@ -194,7 +228,8 @@
EXPECT_CALL(mock_xmpp_connection_delegate_,
OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
- XmppConnection xmpp_connection(buzz::XmppClientSettings(), &cert_verifier_,
+ XmppConnection xmpp_connection(buzz::XmppClientSettings(),
+ url_request_context_getter_,
&mock_xmpp_connection_delegate_, NULL);
xmpp_connection.weak_xmpp_client_->

Powered by Google App Engine
This is Rietveld 408576698