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

Unified Diff: mojo/edk/system/message_pipe_dispatcher_unittest.cc

Issue 728133002: Update mojo sdk to rev e01f9a49449381a5eb430c1fd88bf2cae73ec35a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + ios gyp fixes Created 6 years, 1 month 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 | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/edk/system/message_pipe_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/message_pipe_dispatcher_unittest.cc
diff --git a/mojo/edk/system/message_pipe_dispatcher_unittest.cc b/mojo/edk/system/message_pipe_dispatcher_unittest.cc
index ae651fa981d5f7f4caaf236a77f4148789398472..8076a99410d3ac68456e4d260026be2f17f337e2 100644
--- a/mojo/edk/system/message_pipe_dispatcher_unittest.cc
+++ b/mojo/edk/system/message_pipe_dispatcher_unittest.cc
@@ -68,10 +68,8 @@ TEST(MessagePipeDispatcherTest, Basic) {
d0->AddWaiter(&w, MOJO_HANDLE_SIGNAL_READABLE, 1, nullptr));
buffer[0] = 123456789;
EXPECT_EQ(MOJO_RESULT_OK,
- d1->WriteMessage(UserPointer<const void>(buffer),
- kBufferSize,
- nullptr,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d1->WriteMessage(UserPointer<const void>(buffer), kBufferSize,
+ nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
stopwatch.Start();
EXPECT_EQ(MOJO_RESULT_OK, w.Wait(MOJO_DEADLINE_INDEFINITE, &context));
EXPECT_EQ(1u, context);
@@ -99,9 +97,7 @@ TEST(MessagePipeDispatcherTest, Basic) {
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
d0->ReadMessage(UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size),
- 0,
- nullptr,
+ MakeUserPointer(&buffer_size), 0, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(123456789, buffer[0]);
@@ -157,8 +153,7 @@ TEST(MessagePipeDispatcherTest, InvalidParams) {
// Huge buffer size.
EXPECT_EQ(MOJO_RESULT_RESOURCE_EXHAUSTED,
d0->WriteMessage(UserPointer<const void>(buffer),
- std::numeric_limits<uint32_t>::max(),
- nullptr,
+ std::numeric_limits<uint32_t>::max(), nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(MOJO_RESULT_OK, d0->Close());
@@ -186,26 +181,21 @@ TEST(MessagePipeDispatcherTest, InvalidParamsDeath) {
// |WriteMessage|:
// Null buffer with nonzero buffer size.
- EXPECT_DEATH_IF_SUPPORTED(
- d0->WriteMessage(
- NullUserPointer(), 1, nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE),
- kMemoryCheckFailedRegex);
+ EXPECT_DEATH_IF_SUPPORTED(d0->WriteMessage(NullUserPointer(), 1, nullptr,
+ MOJO_WRITE_MESSAGE_FLAG_NONE),
+ kMemoryCheckFailedRegex);
// |ReadMessage|:
// Null buffer with nonzero buffer size.
// First write something so that we actually have something to read.
EXPECT_EQ(MOJO_RESULT_OK,
- d1->WriteMessage(UserPointer<const void>("x"),
- 1,
- nullptr,
+ d1->WriteMessage(UserPointer<const void>("x"), 1, nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
uint32_t buffer_size = 1;
- EXPECT_DEATH_IF_SUPPORTED(d0->ReadMessage(NullUserPointer(),
- MakeUserPointer(&buffer_size),
- 0,
- nullptr,
- MOJO_READ_MESSAGE_FLAG_NONE),
- kMemoryCheckFailedRegex);
+ EXPECT_DEATH_IF_SUPPORTED(
+ d0->ReadMessage(NullUserPointer(), MakeUserPointer(&buffer_size), 0,
+ nullptr, MOJO_READ_MESSAGE_FLAG_NONE),
+ kMemoryCheckFailedRegex);
EXPECT_EQ(MOJO_RESULT_OK, d0->Close());
EXPECT_EQ(MOJO_RESULT_OK, d1->Close());
@@ -234,16 +224,12 @@ TEST(MessagePipeDispatcherTest, BasicClosed) {
// Write (twice) to |d1|.
buffer[0] = 123456789;
EXPECT_EQ(MOJO_RESULT_OK,
- d1->WriteMessage(UserPointer<const void>(buffer),
- kBufferSize,
- nullptr,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d1->WriteMessage(UserPointer<const void>(buffer), kBufferSize,
+ nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
buffer[0] = 234567890;
EXPECT_EQ(MOJO_RESULT_OK,
- d1->WriteMessage(UserPointer<const void>(buffer),
- kBufferSize,
- nullptr,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d1->WriteMessage(UserPointer<const void>(buffer), kBufferSize,
+ nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
// Try waiting for readable on |d0|; should fail (already satisfied).
w.Init();
@@ -260,9 +246,7 @@ TEST(MessagePipeDispatcherTest, BasicClosed) {
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT,
d1->ReadMessage(UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size),
- 0,
- nullptr,
+ MakeUserPointer(&buffer_size), 0, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
// Close |d1|.
@@ -281,9 +265,7 @@ TEST(MessagePipeDispatcherTest, BasicClosed) {
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
d0->ReadMessage(UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size),
- 0,
- nullptr,
+ MakeUserPointer(&buffer_size), 0, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(123456789, buffer[0]);
@@ -301,9 +283,7 @@ TEST(MessagePipeDispatcherTest, BasicClosed) {
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
d0->ReadMessage(UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size),
- 0,
- nullptr,
+ MakeUserPointer(&buffer_size), 0, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(234567890, buffer[0]);
@@ -330,18 +310,14 @@ TEST(MessagePipeDispatcherTest, BasicClosed) {
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
d0->ReadMessage(UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size),
- 0,
- nullptr,
+ MakeUserPointer(&buffer_size), 0, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
// Try writing to |d0|; should fail (other end closed).
buffer[0] = 345678901;
EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
- d0->WriteMessage(UserPointer<const void>(buffer),
- kBufferSize,
- nullptr,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d0->WriteMessage(UserPointer<const void>(buffer), kBufferSize,
+ nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(MOJO_RESULT_OK, d0->Close());
}
@@ -378,24 +354,17 @@ TEST(MessagePipeDispatcherTest, MAYBE_BasicThreaded) {
// Wait for readable on |d1|, which will become readable after some time.
{
- test::WaiterThread thread(d1,
- MOJO_HANDLE_SIGNAL_READABLE,
- MOJO_DEADLINE_INDEFINITE,
- 1,
- &did_wait,
- &result,
- &context,
- &hss);
+ test::WaiterThread thread(d1, MOJO_HANDLE_SIGNAL_READABLE,
+ MOJO_DEADLINE_INDEFINITE, 1, &did_wait, &result,
+ &context, &hss);
stopwatch.Start();
thread.Start();
base::PlatformThread::Sleep(2 * test::EpsilonTimeout());
// Wake it up by writing to |d0|.
buffer[0] = 123456789;
EXPECT_EQ(MOJO_RESULT_OK,
- d0->WriteMessage(UserPointer<const void>(buffer),
- kBufferSize,
- nullptr,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ d0->WriteMessage(UserPointer<const void>(buffer), kBufferSize,
+ nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
} // Joins the thread.
elapsed = stopwatch.Elapsed();
EXPECT_GT(elapsed, (2 - 1) * test::EpsilonTimeout());
@@ -410,14 +379,9 @@ TEST(MessagePipeDispatcherTest, MAYBE_BasicThreaded) {
// Now |d1| is already readable. Try waiting for it again.
{
- test::WaiterThread thread(d1,
- MOJO_HANDLE_SIGNAL_READABLE,
- MOJO_DEADLINE_INDEFINITE,
- 2,
- &did_wait,
- &result,
- &context,
- &hss);
+ test::WaiterThread thread(d1, MOJO_HANDLE_SIGNAL_READABLE,
+ MOJO_DEADLINE_INDEFINITE, 2, &did_wait, &result,
+ &context, &hss);
stopwatch.Start();
thread.Start();
} // Joins the thread.
@@ -434,9 +398,7 @@ TEST(MessagePipeDispatcherTest, MAYBE_BasicThreaded) {
buffer_size = kBufferSize;
EXPECT_EQ(MOJO_RESULT_OK,
d1->ReadMessage(UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size),
- 0,
- nullptr,
+ MakeUserPointer(&buffer_size), 0, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kBufferSize, buffer_size);
EXPECT_EQ(123456789, buffer[0]);
@@ -444,14 +406,9 @@ TEST(MessagePipeDispatcherTest, MAYBE_BasicThreaded) {
// Wait for readable on |d1| and close |d0| after some time, which should
// cancel that wait.
{
- test::WaiterThread thread(d1,
- MOJO_HANDLE_SIGNAL_READABLE,
- MOJO_DEADLINE_INDEFINITE,
- 3,
- &did_wait,
- &result,
- &context,
- &hss);
+ test::WaiterThread thread(d1, MOJO_HANDLE_SIGNAL_READABLE,
+ MOJO_DEADLINE_INDEFINITE, 3, &did_wait, &result,
+ &context, &hss);
stopwatch.Start();
thread.Start();
base::PlatformThread::Sleep(2 * test::EpsilonTimeout());
@@ -483,14 +440,9 @@ TEST(MessagePipeDispatcherTest, MAYBE_BasicThreaded) {
// Wait for readable on |d1| and close |d1| after some time, which should
// cancel that wait.
{
- test::WaiterThread thread(d1,
- MOJO_HANDLE_SIGNAL_READABLE,
- MOJO_DEADLINE_INDEFINITE,
- 4,
- &did_wait,
- &result,
- &context,
- &hss);
+ test::WaiterThread thread(d1, MOJO_HANDLE_SIGNAL_READABLE,
+ MOJO_DEADLINE_INDEFINITE, 4, &did_wait, &result,
+ &context, &hss);
stopwatch.Start();
thread.Start();
base::PlatformThread::Sleep(2 * test::EpsilonTimeout());
@@ -546,18 +498,15 @@ class WriterThread : public base::SimpleThread {
base::RandInt(1, static_cast<int>(kMaxMessageSize)));
EXPECT_EQ(MOJO_RESULT_OK,
write_dispatcher_->WriteMessage(UserPointer<const void>(buffer),
- bytes_to_write,
- nullptr,
+ bytes_to_write, nullptr,
MOJO_WRITE_MESSAGE_FLAG_NONE));
*bytes_written_ += bytes_to_write;
}
// Write one last "quit" message.
- EXPECT_EQ(MOJO_RESULT_OK,
- write_dispatcher_->WriteMessage(UserPointer<const void>("quit"),
- 4,
- nullptr,
- MOJO_WRITE_MESSAGE_FLAG_NONE));
+ EXPECT_EQ(MOJO_RESULT_OK, write_dispatcher_->WriteMessage(
+ UserPointer<const void>("quit"), 4, nullptr,
+ MOJO_WRITE_MESSAGE_FLAG_NONE));
}
const scoped_refptr<Dispatcher> write_dispatcher_;
@@ -612,11 +561,9 @@ class ReaderThread : public base::SimpleThread {
// Clear the buffer so that we can check the result.
memset(buffer, 0, sizeof(buffer));
uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
- result = read_dispatcher_->ReadMessage(UserPointer<void>(buffer),
- MakeUserPointer(&buffer_size),
- 0,
- nullptr,
- MOJO_READ_MESSAGE_FLAG_NONE);
+ result = read_dispatcher_->ReadMessage(
+ UserPointer<void>(buffer), MakeUserPointer(&buffer_size), 0, nullptr,
+ MOJO_READ_MESSAGE_FLAG_NONE);
EXPECT_TRUE(result == MOJO_RESULT_OK || result == MOJO_RESULT_SHOULD_WAIT)
<< "result: " << result;
// We're racing with others to read, so maybe we failed.
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/edk/system/message_pipe_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698