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

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

Issue 1946763002: EDK: Add MojoHandleRights to DispatcherTransport. (Closed) Base URL: https://github.com/domokit/mojo.git@work788_edk_handle_10
Patch Set: Created 4 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: mojo/edk/system/remote_data_pipe_impl_unittest.cc
diff --git a/mojo/edk/system/remote_data_pipe_impl_unittest.cc b/mojo/edk/system/remote_data_pipe_impl_unittest.cc
index 36e426ef7fe3178db3df2602ddf75932d8328e69..b118a7aa31dce724e49b6340acef6fe21fe13672 100644
--- a/mojo/edk/system/remote_data_pipe_impl_unittest.cc
+++ b/mojo/edk/system/remote_data_pipe_impl_unittest.cc
@@ -18,6 +18,7 @@
#include "mojo/edk/system/data_pipe.h"
#include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
#include "mojo/edk/system/data_pipe_producer_dispatcher.h"
+#include "mojo/edk/system/handle.h"
#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/memory.h"
#include "mojo/edk/system/message_pipe.h"
@@ -176,6 +177,9 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerWithClosedProducer) {
// This is the consumer dispatcher we'll send.
auto consumer = DataPipeConsumerDispatcher::Create();
consumer->Init(dp.Clone());
+ Handle consumer_handle(std::move(consumer), MOJO_HANDLE_RIGHT_TRANSFER |
+ MOJO_HANDLE_RIGHT_READ |
+ MOJO_HANDLE_RIGHT_WRITE);
// Write to the producer and close it, before sending the consumer.
int32_t elements[10] = {123};
@@ -195,7 +199,7 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerWithClosedProducer) {
0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr));
{
DispatcherTransport transport(
- test::DispatcherTryStartTransport(consumer.get()));
+ test::HandleTryStartTransport(consumer_handle));
EXPECT_TRUE(transport.is_valid());
std::vector<DispatcherTransport> transports;
@@ -205,10 +209,10 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerWithClosedProducer) {
MOJO_WRITE_MESSAGE_FLAG_NONE));
transport.End();
- // |consumer| should have been closed. This is |DCHECK()|ed when it is
- // destroyed.
- EXPECT_TRUE(consumer->HasOneRef());
- consumer = nullptr;
+ // |consumer_handle.dispatcher| should have been closed. This is
+ // |DCHECK()|ed when it is destroyed.
+ EXPECT_TRUE(consumer_handle.dispatcher->HasOneRef());
+ consumer_handle.reset();
}
EXPECT_EQ(MOJO_RESULT_OK, waiter.Wait(test::ActionTimeout(), &context));
EXPECT_EQ(123u, context);
@@ -297,6 +301,9 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerDuringTwoPhaseWrite) {
// This is the consumer dispatcher we'll send.
auto consumer = DataPipeConsumerDispatcher::Create();
consumer->Init(dp.Clone());
+ Handle consumer_handle(std::move(consumer), MOJO_HANDLE_RIGHT_TRANSFER |
+ MOJO_HANDLE_RIGHT_READ |
+ MOJO_HANDLE_RIGHT_WRITE);
void* write_ptr = nullptr;
uint32_t num_bytes = 0u;
@@ -314,7 +321,7 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerDuringTwoPhaseWrite) {
0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr));
{
DispatcherTransport transport(
- test::DispatcherTryStartTransport(consumer.get()));
+ test::HandleTryStartTransport(consumer_handle));
EXPECT_TRUE(transport.is_valid());
std::vector<DispatcherTransport> transports;
@@ -324,10 +331,10 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerDuringTwoPhaseWrite) {
MOJO_WRITE_MESSAGE_FLAG_NONE));
transport.End();
- // |consumer| should have been closed. This is |DCHECK()|ed when it is
- // destroyed.
- EXPECT_TRUE(consumer->HasOneRef());
- consumer = nullptr;
+ // |consumer_handle.dispatcher| should have been closed. This is
+ // |DCHECK()|ed when it is destroyed.
+ EXPECT_TRUE(consumer_handle.dispatcher->HasOneRef());
+ consumer_handle.reset();
}
EXPECT_EQ(MOJO_RESULT_OK, waiter.Wait(test::ActionTimeout(), &context));
EXPECT_EQ(123u, context);
@@ -410,6 +417,9 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerDuringSecondTwoPhaseWrite) {
// This is the consumer dispatcher we'll send.
auto consumer = DataPipeConsumerDispatcher::Create();
consumer->Init(dp.Clone());
+ Handle consumer_handle(std::move(consumer), MOJO_HANDLE_RIGHT_TRANSFER |
+ MOJO_HANDLE_RIGHT_READ |
+ MOJO_HANDLE_RIGHT_WRITE);
void* write_ptr = nullptr;
uint32_t num_bytes = 0u;
@@ -437,7 +447,7 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerDuringSecondTwoPhaseWrite) {
0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr));
{
DispatcherTransport transport(
- test::DispatcherTryStartTransport(consumer.get()));
+ test::HandleTryStartTransport(consumer_handle));
EXPECT_TRUE(transport.is_valid());
std::vector<DispatcherTransport> transports;
@@ -447,10 +457,10 @@ TEST_F(RemoteDataPipeImplTest, SendConsumerDuringSecondTwoPhaseWrite) {
MOJO_WRITE_MESSAGE_FLAG_NONE));
transport.End();
- // |consumer| should have been closed. This is |DCHECK()|ed when it is
- // destroyed.
- EXPECT_TRUE(consumer->HasOneRef());
- consumer = nullptr;
+ // |consumer_handle.dispatcher| should have been closed. This is
+ // |DCHECK()|ed when it is destroyed.
+ EXPECT_TRUE(consumer_handle.dispatcher->HasOneRef());
+ consumer_handle.reset();
}
EXPECT_EQ(MOJO_RESULT_OK, waiter.Wait(test::ActionTimeout(), &context));
EXPECT_EQ(123u, context);
« no previous file with comments | « mojo/edk/system/platform_handle_dispatcher_unittest.cc ('k') | mojo/edk/system/remote_message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698