| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains tests that are shared between different implementations of | 5 // This file contains tests that are shared between different implementations of |
| 6 // |DataPipeImpl|. | 6 // |DataPipeImpl|. |
| 7 | 7 |
| 8 #include "mojo/edk/system/data_pipe_impl.h" | 8 #include "mojo/edk/system/data_pipe_impl.h" |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 void DoTransfer() override {} | 206 void DoTransfer() override {} |
| 207 | 207 |
| 208 // Returns the |DataPipe| object for the producer and consumer, respectively. | 208 // Returns the |DataPipe| object for the producer and consumer, respectively. |
| 209 DataPipe* DataPipeForProducer() override { return dp_.get(); } | 209 DataPipe* DataPipeForProducer() override { return dp_.get(); } |
| 210 DataPipe* DataPipeForConsumer() override { return dp_.get(); } | 210 DataPipe* DataPipeForConsumer() override { return dp_.get(); } |
| 211 | 211 |
| 212 void ProducerClose() override { dp_->ProducerClose(); } | 212 void ProducerClose() override { dp_->ProducerClose(); } |
| 213 void ConsumerClose() override { dp_->ConsumerClose(); } | 213 void ConsumerClose() override { dp_->ConsumerClose(); } |
| 214 | 214 |
| 215 private: | 215 private: |
| 216 scoped_refptr<DataPipe> dp_; | 216 RefPtr<DataPipe> dp_; |
| 217 | 217 |
| 218 MOJO_DISALLOW_COPY_AND_ASSIGN(LocalDataPipeImplTestHelper); | 218 MOJO_DISALLOW_COPY_AND_ASSIGN(LocalDataPipeImplTestHelper); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 // RemoteDataPipeImplTestHelper ------------------------------------------------ | 221 // RemoteDataPipeImplTestHelper ------------------------------------------------ |
| 222 | 222 |
| 223 // Base class for |Remote{Producer,Consumer}DataPipeImplTestHelper|. | 223 // Base class for |Remote{Producer,Consumer}DataPipeImplTestHelper|. |
| 224 class RemoteDataPipeImplTestHelper : public DataPipeImplTestHelper { | 224 class RemoteDataPipeImplTestHelper : public DataPipeImplTestHelper { |
| 225 public: | 225 public: |
| 226 RemoteDataPipeImplTestHelper() | 226 RemoteDataPipeImplTestHelper() |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 &read_num_dispatchers, MOJO_READ_MESSAGE_FLAG_NONE)); | 299 &read_num_dispatchers, MOJO_READ_MESSAGE_FLAG_NONE)); |
| 300 EXPECT_EQ(0u, static_cast<size_t>(read_buffer_size)); | 300 EXPECT_EQ(0u, static_cast<size_t>(read_buffer_size)); |
| 301 ASSERT_EQ(1u, read_dispatchers.size()); | 301 ASSERT_EQ(1u, read_dispatchers.size()); |
| 302 ASSERT_EQ(1u, read_num_dispatchers); | 302 ASSERT_EQ(1u, read_num_dispatchers); |
| 303 ASSERT_TRUE(read_dispatchers[0]); | 303 ASSERT_TRUE(read_dispatchers[0]); |
| 304 EXPECT_TRUE(read_dispatchers[0]->HasOneRef()); | 304 EXPECT_TRUE(read_dispatchers[0]->HasOneRef()); |
| 305 | 305 |
| 306 *to_receive = read_dispatchers[0]; | 306 *to_receive = read_dispatchers[0]; |
| 307 } | 307 } |
| 308 | 308 |
| 309 scoped_refptr<MessagePipe> message_pipe(size_t i) { | 309 RefPtr<MessagePipe> message_pipe(size_t i) { return message_pipes_[i]; } |
| 310 return message_pipes_[i]; | 310 RefPtr<DataPipe> dp() { return dp_; } |
| 311 } | |
| 312 scoped_refptr<DataPipe> dp() { return dp_; } | |
| 313 | 311 |
| 314 private: | 312 private: |
| 315 void EnsureMessagePipeClosed(size_t i) { | 313 void EnsureMessagePipeClosed(size_t i) { |
| 316 if (!message_pipes_[i]) | 314 if (!message_pipes_[i]) |
| 317 return; | 315 return; |
| 318 message_pipes_[i]->Close(0); | 316 message_pipes_[i]->Close(0); |
| 319 message_pipes_[i] = nullptr; | 317 message_pipes_[i] = nullptr; |
| 320 } | 318 } |
| 321 | 319 |
| 322 // TODO(vtl): The arguments should be rvalue references, but that doesn't | 320 // TODO(vtl): The arguments should be rvalue references, but that doesn't |
| (...skipping 20 matching lines...) Expand all Loading... |
| 343 } | 341 } |
| 344 if (channels_[1]) { | 342 if (channels_[1]) { |
| 345 channels_[1]->Shutdown(); | 343 channels_[1]->Shutdown(); |
| 346 channels_[1] = nullptr; | 344 channels_[1] = nullptr; |
| 347 } | 345 } |
| 348 } | 346 } |
| 349 | 347 |
| 350 embedder::SimplePlatformSupport platform_support_; | 348 embedder::SimplePlatformSupport platform_support_; |
| 351 mojo::test::TestIOThread io_thread_; | 349 mojo::test::TestIOThread io_thread_; |
| 352 RefPtr<Channel> channels_[2]; | 350 RefPtr<Channel> channels_[2]; |
| 353 scoped_refptr<MessagePipe> message_pipes_[2]; | 351 RefPtr<MessagePipe> message_pipes_[2]; |
| 354 | 352 |
| 355 scoped_refptr<DataPipe> dp_; | 353 RefPtr<DataPipe> dp_; |
| 356 | 354 |
| 357 MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteDataPipeImplTestHelper); | 355 MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteDataPipeImplTestHelper); |
| 358 }; | 356 }; |
| 359 | 357 |
| 360 // RemoteProducerDataPipeImplTestHelper ---------------------------------------- | 358 // RemoteProducerDataPipeImplTestHelper ---------------------------------------- |
| 361 | 359 |
| 362 // Note about naming confusion: This class is named after the "local" class, | 360 // Note about naming confusion: This class is named after the "local" class, |
| 363 // i.e., |dp_| will have a |RemoteProducerDataPipeImpl|. The remote side, of | 361 // i.e., |dp_| will have a |RemoteProducerDataPipeImpl|. The remote side, of |
| 364 // course, will have a |RemoteConsumerDataPipeImpl|. | 362 // course, will have a |RemoteConsumerDataPipeImpl|. |
| 365 class RemoteProducerDataPipeImplTestHelper | 363 class RemoteProducerDataPipeImplTestHelper |
| (...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2497 test::Sleep(10u); | 2495 test::Sleep(10u); |
| 2498 | 2496 |
| 2499 EXPECT_EQ(MOJO_RESULT_OK, this->ConsumerEndReadData(num_bytes)); | 2497 EXPECT_EQ(MOJO_RESULT_OK, this->ConsumerEndReadData(num_bytes)); |
| 2500 | 2498 |
| 2501 this->ConsumerClose(); | 2499 this->ConsumerClose(); |
| 2502 } | 2500 } |
| 2503 | 2501 |
| 2504 } // namespace | 2502 } // namespace |
| 2505 } // namespace system | 2503 } // namespace system |
| 2506 } // namespace mojo | 2504 } // namespace mojo |
| OLD | NEW |