| 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> |
| 11 | 11 |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "mojo/edk/embedder/platform_channel_pair.h" | 18 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 19 #include "mojo/edk/embedder/simple_platform_support.h" | 19 #include "mojo/edk/embedder/simple_platform_support.h" |
| 20 #include "mojo/edk/system/channel.h" | 20 #include "mojo/edk/system/channel.h" |
| 21 #include "mojo/edk/system/channel_endpoint.h" | 21 #include "mojo/edk/system/channel_endpoint.h" |
| 22 #include "mojo/edk/system/data_pipe.h" | 22 #include "mojo/edk/system/data_pipe.h" |
| 23 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" | 23 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
| 24 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" | 24 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
| 25 #include "mojo/edk/system/memory.h" | 25 #include "mojo/edk/system/memory.h" |
| 26 #include "mojo/edk/system/message_pipe.h" | 26 #include "mojo/edk/system/message_pipe.h" |
| 27 #include "mojo/edk/system/raw_channel.h" | 27 #include "mojo/edk/system/raw_channel.h" |
| 28 #include "mojo/edk/system/ref_ptr.h" | 28 #include "mojo/edk/system/ref_ptr.h" |
| 29 #include "mojo/edk/system/test/sleep.h" | 29 #include "mojo/edk/system/test/sleep.h" |
| 30 #include "mojo/edk/system/test/test_io_thread.h" |
| 30 #include "mojo/edk/system/test/timeouts.h" | 31 #include "mojo/edk/system/test/timeouts.h" |
| 31 #include "mojo/edk/system/waiter.h" | 32 #include "mojo/edk/system/waiter.h" |
| 32 #include "mojo/edk/test/test_io_thread.h" | |
| 33 #include "mojo/public/cpp/system/macros.h" | 33 #include "mojo/public/cpp/system/macros.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 35 | 35 |
| 36 namespace mojo { | 36 namespace mojo { |
| 37 namespace system { | 37 namespace system { |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | | 40 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | |
| 41 MOJO_HANDLE_SIGNAL_WRITABLE | | 41 MOJO_HANDLE_SIGNAL_WRITABLE | |
| 42 MOJO_HANDLE_SIGNAL_PEER_CLOSED; | 42 MOJO_HANDLE_SIGNAL_PEER_CLOSED; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() |
| 227 : io_thread_(mojo::test::TestIOThread::StartMode::AUTO) {} | 227 : io_thread_(test::TestIOThread::StartMode::AUTO) {} |
| 228 ~RemoteDataPipeImplTestHelper() override {} | 228 ~RemoteDataPipeImplTestHelper() override {} |
| 229 | 229 |
| 230 void SetUp() override { | 230 void SetUp() override { |
| 231 RefPtr<ChannelEndpoint> ep[2]; | 231 RefPtr<ChannelEndpoint> ep[2]; |
| 232 message_pipes_[0] = MessagePipe::CreateLocalProxy(&ep[0]); | 232 message_pipes_[0] = MessagePipe::CreateLocalProxy(&ep[0]); |
| 233 message_pipes_[1] = MessagePipe::CreateLocalProxy(&ep[1]); | 233 message_pipes_[1] = MessagePipe::CreateLocalProxy(&ep[1]); |
| 234 | 234 |
| 235 io_thread_.PostTaskAndWait(base::Bind( | 235 io_thread_.PostTaskAndWait(base::Bind( |
| 236 &RemoteDataPipeImplTestHelper::SetUpOnIOThread, base::Unretained(this), | 236 &RemoteDataPipeImplTestHelper::SetUpOnIOThread, base::Unretained(this), |
| 237 base::Passed(&ep[0]), base::Passed(&ep[1]))); | 237 base::Passed(&ep[0]), base::Passed(&ep[1]))); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 channels_[0]->Shutdown(); | 338 channels_[0]->Shutdown(); |
| 339 channels_[0] = nullptr; | 339 channels_[0] = nullptr; |
| 340 } | 340 } |
| 341 if (channels_[1]) { | 341 if (channels_[1]) { |
| 342 channels_[1]->Shutdown(); | 342 channels_[1]->Shutdown(); |
| 343 channels_[1] = nullptr; | 343 channels_[1] = nullptr; |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 embedder::SimplePlatformSupport platform_support_; | 347 embedder::SimplePlatformSupport platform_support_; |
| 348 mojo::test::TestIOThread io_thread_; | 348 test::TestIOThread io_thread_; |
| 349 RefPtr<Channel> channels_[2]; | 349 RefPtr<Channel> channels_[2]; |
| 350 RefPtr<MessagePipe> message_pipes_[2]; | 350 RefPtr<MessagePipe> message_pipes_[2]; |
| 351 | 351 |
| 352 RefPtr<DataPipe> dp_; | 352 RefPtr<DataPipe> dp_; |
| 353 | 353 |
| 354 MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteDataPipeImplTestHelper); | 354 MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteDataPipeImplTestHelper); |
| 355 }; | 355 }; |
| 356 | 356 |
| 357 // RemoteProducerDataPipeImplTestHelper ---------------------------------------- | 357 // RemoteProducerDataPipeImplTestHelper ---------------------------------------- |
| 358 | 358 |
| (...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 test::Sleep(10u); | 2492 test::Sleep(10u); |
| 2493 | 2493 |
| 2494 EXPECT_EQ(MOJO_RESULT_OK, this->ConsumerEndReadData(num_bytes)); | 2494 EXPECT_EQ(MOJO_RESULT_OK, this->ConsumerEndReadData(num_bytes)); |
| 2495 | 2495 |
| 2496 this->ConsumerClose(); | 2496 this->ConsumerClose(); |
| 2497 } | 2497 } |
| 2498 | 2498 |
| 2499 } // namespace | 2499 } // namespace |
| 2500 } // namespace system | 2500 } // namespace system |
| 2501 } // namespace mojo | 2501 } // namespace mojo |
| OLD | NEW |