summaryrefslogtreecommitdiffstats
path: root/jingle
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-23 12:13:05 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-23 12:13:05 +0000
commite82339d44d0dde725295785b9fea8c448d382621 (patch)
tree3766361fe20911a5a0bf8890266ca42898bb9523 /jingle
parent6e63303067eb0b5610c77e86518e7fbd86fb8672 (diff)
downloadchromium_src-e82339d44d0dde725295785b9fea8c448d382621.zip
chromium_src-e82339d44d0dde725295785b9fea8c448d382621.tar.gz
chromium_src-e82339d44d0dde725295785b9fea8c448d382621.tar.bz2
[Mac] Reland r276808 Use a native MessagePump instead of a MessagePumpDefault
Original CL: https://codereview.chromium.org/331513002/ Relanding after fixing XmppConnectionTest.MultipleConnect test. BUG=356804,385604 TBR=mark@chromium.org,ajwong@chromium.org Review URL: https://codereview.chromium.org/348283002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r--jingle/glue/chrome_async_socket_unittest.cc87
-rw-r--r--jingle/notifier/base/xmpp_connection_unittest.cc23
2 files changed, 62 insertions, 48 deletions
diff --git a/jingle/glue/chrome_async_socket_unittest.cc b/jingle/glue/chrome_async_socket_unittest.cc
index db3d2b0..b3c81b1 100644
--- a/jingle/glue/chrome_async_socket_unittest.cc
+++ b/jingle/glue/chrome_async_socket_unittest.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_pump_default.h"
#include "jingle/glue/resolving_client_socket_factory.h"
#include "net/base/address_list.h"
#include "net/base/net_errors.h"
@@ -143,7 +144,15 @@ class ChromeAsyncSocketTest
protected:
ChromeAsyncSocketTest()
: ssl_socket_data_provider_(net::ASYNC, net::OK),
- addr_("localhost", 35) {}
+ addr_("localhost", 35) {
+ // GTest death tests execute in a fork()ed but not exec()ed process.
+ // On OS X a CoreFoundation-backed message loop will exit with a
+ // __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__
+ // when called.
+ // Explicitly create a MessagePumpDefault which can run in this enivronment.
+ scoped_ptr<base::MessagePump> pump(new base::MessagePumpDefault());
+ message_loop_.reset(new base::MessageLoop(pump.Pass()));
+ }
virtual ~ChromeAsyncSocketTest() {}
@@ -182,7 +191,7 @@ class ChromeAsyncSocketTest
virtual void TearDown() {
// Run any tasks that we forgot to pump.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectClosed();
ExpectNoSignal();
chrome_async_socket_.reset();
@@ -342,7 +351,7 @@ class ChromeAsyncSocketTest
EXPECT_TRUE(chrome_async_socket_->Connect(addr_));
ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING);
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
// We may not necessarily be open; may have been other events
// queued up.
ExpectSignalSocketState(
@@ -372,7 +381,7 @@ class ChromeAsyncSocketTest
EXPECT_EQ(kDummyData, DrainRead(1));
EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectNoSignal();
ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN);
@@ -415,7 +424,7 @@ class ChromeAsyncSocketTest
}
// ChromeAsyncSocket expects a message loop.
- base::MessageLoop message_loop_;
+ scoped_ptr<base::MessageLoop> message_loop_;
AsyncSocketDataProvider async_socket_data_provider_;
net::SSLSocketDataProvider ssl_socket_data_provider_;
@@ -510,7 +519,7 @@ TEST_F(ChromeAsyncSocketTest, ImmediateConnectCloseBeforeRead) {
SignalSocketState::NoError(
SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
TEST_F(ChromeAsyncSocketTest, HangingConnect) {
@@ -532,14 +541,14 @@ TEST_F(ChromeAsyncSocketTest, PendingConnect) {
ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING);
ExpectNoSignal();
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNonErrorState(ChromeAsyncSocket::STATE_OPEN);
ExpectSignalSocketState(
SignalSocketState::NoError(
SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN));
ExpectNoSignal();
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoCloseOpenedNoError();
}
@@ -552,14 +561,14 @@ TEST_F(ChromeAsyncSocketTest, PendingConnectCloseBeforeRead) {
net::MockConnect(net::ASYNC, net::OK));
EXPECT_TRUE(chrome_async_socket_->Connect(addr_));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSignalSocketState(
SignalSocketState::NoError(
SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN));
DoCloseOpenedNoError();
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
TEST_F(ChromeAsyncSocketTest, PendingConnectError) {
@@ -567,7 +576,7 @@ TEST_F(ChromeAsyncSocketTest, PendingConnectError) {
net::MockConnect(net::ASYNC, net::ERR_TIMED_OUT));
EXPECT_TRUE(chrome_async_socket_->Connect(addr_));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSignalSocketState(
SignalSocketState(
@@ -629,7 +638,7 @@ TEST_F(ChromeAsyncSocketTest, Read) {
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoCloseOpenedNoError();
}
@@ -643,7 +652,7 @@ TEST_F(ChromeAsyncSocketTest, ReadTwice) {
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
const char kReadData2[] = "mydatatoread2";
async_socket_data_provider_.AddRead(net::MockRead(kReadData2));
@@ -665,7 +674,7 @@ TEST_F(ChromeAsyncSocketTest, ReadError) {
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
async_socket_data_provider_.AddRead(
net::MockRead(net::SYNCHRONOUS, net::ERR_TIMED_OUT));
@@ -699,7 +708,7 @@ TEST_F(ChromeAsyncSocketTest, PendingRead) {
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoCloseOpenedNoError();
}
@@ -755,12 +764,12 @@ TEST_F(ChromeAsyncSocketTest, SyncWrite) {
DoOpenClosed();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNoSignal();
@@ -778,12 +787,12 @@ TEST_F(ChromeAsyncSocketTest, AsyncWrite) {
net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8));
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNoSignal();
@@ -801,12 +810,12 @@ TEST_F(ChromeAsyncSocketTest, AsyncWriteError) {
net::MockWrite(net::ASYNC, net::ERR_TIMED_OUT));
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSignalSocketState(
SignalSocketState(
@@ -874,7 +883,7 @@ TEST_F(ChromeAsyncSocketTest, ImmediateSSLConnect) {
ExpectReadSignal();
EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectNoSignal();
ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN);
@@ -889,7 +898,7 @@ TEST_F(ChromeAsyncSocketTest, DoubleSSLConnect) {
ExpectReadSignal();
EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectNoSignal();
ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN);
@@ -913,7 +922,7 @@ TEST_F(ChromeAsyncSocketTest, FailedSSLConnect) {
ExpectReadSignal();
EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSignalSocketState(
SignalSocketState(
SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED,
@@ -941,7 +950,7 @@ TEST_F(ChromeAsyncSocketTest, ReadDuringSSLConnecting) {
EXPECT_TRUE(chrome_async_socket_->Read(buf, sizeof(buf), &len_read));
EXPECT_EQ(0U, len_read);
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectSSLReadSignal();
ExpectNoSignal();
@@ -972,11 +981,11 @@ TEST_F(ChromeAsyncSocketTest, WriteDuringSSLConnecting) {
// TODO(akalin): Figure out how to test that the write happens
// *after* the SSL connect.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectNoSignal();
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoSSLCloseOpenedNoError();
}
@@ -1005,7 +1014,7 @@ TEST_F(ChromeAsyncSocketTest, SSLConnectDuringPostedWrite) {
EXPECT_FALSE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoCloseOpened(
SignalSocketState(SIGNAL_CLOSE,
@@ -1020,14 +1029,14 @@ TEST_F(ChromeAsyncSocketTest, SSLConnectDuringPostedWrite) {
TEST_F(ChromeAsyncSocketTest, SSLRead) {
DoSSLOpenClosed();
async_socket_data_provider_.AddRead(net::MockRead(kReadData));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLReadSignal();
ExpectNoSignal();
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoSSLCloseOpenedNoError();
}
@@ -1043,12 +1052,12 @@ TEST_F(ChromeAsyncSocketTest, SSLSyncWrite) {
DoSSLOpenClosed();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNoSignal();
@@ -1066,12 +1075,12 @@ TEST_F(ChromeAsyncSocketTest, SSLAsyncWrite) {
net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8));
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNoSignal();
diff --git a/jingle/notifier/base/xmpp_connection_unittest.cc b/jingle/notifier/base/xmpp_connection_unittest.cc
index 3212abc..0573363c 100644
--- a/jingle/notifier/base/xmpp_connection_unittest.cc
+++ b/jingle/notifier/base/xmpp_connection_unittest.cc
@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_pump_default.h"
#include "jingle/glue/mock_task.h"
#include "jingle/glue/task_pump.h"
#include "jingle/notifier/base/weak_xmpp_client.h"
@@ -74,19 +75,23 @@ class MockXmppConnectionDelegate : public XmppConnection::Delegate {
class XmppConnectionTest : public testing::Test {
protected:
XmppConnectionTest()
- : mock_pre_xmpp_auth_(new MockPreXmppAuth()),
- url_request_context_getter_(new net::TestURLRequestContextGetter(
- message_loop_.message_loop_proxy())) {}
+ : mock_pre_xmpp_auth_(new MockPreXmppAuth()) {
+ scoped_ptr<base::MessagePump> pump(new base::MessagePumpDefault());
+ message_loop_.reset(new base::MessageLoop(pump.Pass()));
+
+ url_request_context_getter_ = new net::TestURLRequestContextGetter(
+ message_loop_->message_loop_proxy());
+ }
virtual ~XmppConnectionTest() {}
virtual void TearDown() {
// Clear out any messages posted by XmppConnection's destructor.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
// Needed by XmppConnection.
- base::MessageLoop message_loop_;
+ scoped_ptr<base::MessageLoop> message_loop_;
MockXmppConnectionDelegate mock_xmpp_connection_delegate_;
scoped_ptr<MockPreXmppAuth> mock_pre_xmpp_auth_;
scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_;
@@ -112,7 +117,7 @@ TEST_F(XmppConnectionTest, ImmediateFailure) {
// We need to do this *before* |xmpp_connection| gets destroyed or
// our delegate won't be called.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
TEST_F(XmppConnectionTest, PreAuthFailure) {
@@ -131,7 +136,7 @@ TEST_F(XmppConnectionTest, PreAuthFailure) {
// We need to do this *before* |xmpp_connection| gets destroyed or
// our delegate won't be called.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
TEST_F(XmppConnectionTest, FailureAfterPreAuth) {
@@ -150,7 +155,7 @@ TEST_F(XmppConnectionTest, FailureAfterPreAuth) {
// We need to do this *before* |xmpp_connection| gets destroyed or
// our delegate won't be called.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
TEST_F(XmppConnectionTest, RaisedError) {
@@ -247,7 +252,7 @@ TEST_F(XmppConnectionTest, TasksDontRunAfterXmppConnectionDestructor) {
}
// This should destroy |task_pump|, but |task| still shouldn't run.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
} // namespace notifier