OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <stdint.h> | 5 #include <stdint.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/scoped_file.h" | 14 #include "base/files/scoped_file.h" |
15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/threading/platform_thread.h" // For |Sleep()|. | 20 #include "base/threading/platform_thread.h" // For |Sleep()|. |
21 #include "build/build_config.h" // TODO(vtl): Remove this. | 21 #include "build/build_config.h" // TODO(vtl): Remove this. |
22 #include "mojo/common/test/test_utils.h" | 22 #include "mojo/common/test/test_utils.h" |
23 #include "mojo/embedder/platform_channel_pair.h" | 23 #include "mojo/embedder/platform_channel_pair.h" |
24 #include "mojo/embedder/platform_shared_buffer.h" | 24 #include "mojo/embedder/platform_shared_buffer.h" |
25 #include "mojo/embedder/scoped_platform_handle.h" | 25 #include "mojo/embedder/scoped_platform_handle.h" |
| 26 #include "mojo/embedder/simple_platform_support.h" |
26 #include "mojo/system/channel.h" | 27 #include "mojo/system/channel.h" |
27 #include "mojo/system/local_message_pipe_endpoint.h" | 28 #include "mojo/system/local_message_pipe_endpoint.h" |
28 #include "mojo/system/message_pipe.h" | 29 #include "mojo/system/message_pipe.h" |
29 #include "mojo/system/message_pipe_dispatcher.h" | 30 #include "mojo/system/message_pipe_dispatcher.h" |
30 #include "mojo/system/platform_handle_dispatcher.h" | 31 #include "mojo/system/platform_handle_dispatcher.h" |
31 #include "mojo/system/proxy_message_pipe_endpoint.h" | 32 #include "mojo/system/proxy_message_pipe_endpoint.h" |
32 #include "mojo/system/raw_channel.h" | 33 #include "mojo/system/raw_channel.h" |
33 #include "mojo/system/shared_buffer_dispatcher.h" | 34 #include "mojo/system/shared_buffer_dispatcher.h" |
34 #include "mojo/system/test_utils.h" | 35 #include "mojo/system/test_utils.h" |
35 #include "mojo/system/waiter.h" | 36 #include "mojo/system/waiter.h" |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 695 |
695 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 696 scoped_refptr<MessagePipe> mp0(new MessagePipe( |
696 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 697 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), |
697 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | 698 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); |
698 scoped_refptr<MessagePipe> mp1(new MessagePipe( | 699 scoped_refptr<MessagePipe> mp1(new MessagePipe( |
699 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | 700 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), |
700 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | 701 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); |
701 ConnectMessagePipes(mp0, mp1); | 702 ConnectMessagePipes(mp0, mp1); |
702 | 703 |
703 // We'll try to pass this dispatcher. | 704 // We'll try to pass this dispatcher. |
| 705 embedder::SimplePlatformSupport platform_support; |
704 scoped_refptr<SharedBufferDispatcher> dispatcher; | 706 scoped_refptr<SharedBufferDispatcher> dispatcher; |
705 EXPECT_EQ( | 707 EXPECT_EQ(MOJO_RESULT_OK, |
706 MOJO_RESULT_OK, | 708 SharedBufferDispatcher::Create( |
707 SharedBufferDispatcher::Create( | 709 &platform_support, |
708 SharedBufferDispatcher::kDefaultCreateOptions, 100, &dispatcher)); | 710 SharedBufferDispatcher::kDefaultCreateOptions, |
| 711 100, |
| 712 &dispatcher)); |
709 ASSERT_TRUE(dispatcher); | 713 ASSERT_TRUE(dispatcher); |
710 | 714 |
711 // Make a mapping. | 715 // Make a mapping. |
712 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping0; | 716 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping0; |
713 EXPECT_EQ( | 717 EXPECT_EQ( |
714 MOJO_RESULT_OK, | 718 MOJO_RESULT_OK, |
715 dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping0)); | 719 dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping0)); |
716 ASSERT_TRUE(mapping0); | 720 ASSERT_TRUE(mapping0); |
717 ASSERT_TRUE(mapping0->GetBase()); | 721 ASSERT_TRUE(mapping0->GetBase()); |
718 ASSERT_EQ(100u, mapping0->GetLength()); | 722 ASSERT_EQ(100u, mapping0->GetLength()); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 | 967 |
964 mp1->Close(1); | 968 mp1->Close(1); |
965 | 969 |
966 RestoreInitialState(); | 970 RestoreInitialState(); |
967 } | 971 } |
968 } | 972 } |
969 | 973 |
970 } // namespace | 974 } // namespace |
971 } // namespace system | 975 } // namespace system |
972 } // namespace mojo | 976 } // namespace mojo |
OLD | NEW |