| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/pickle.h" | 13 #include "base/pickle.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "ipc/ipc_test_base.h" | 17 #include "ipc/ipc_test_base.h" |
| 18 #include "ipc/ipc_test_channel_listener.h" | 18 #include "ipc/ipc_test_channel_listener.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class IPCChannelTest : public IPCTestBase { | 22 class IPCChannelTest : public IPCTestBase { |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 TEST_F(IPCChannelTest, ChannelTest) { | 25 #if defined(OS_ANDROID) |
| 26 #define MAYBE_ChannelTest DISABLED_ChannelTest |
| 27 #else |
| 28 #define MAYBE_ChannelTest ChannelTest |
| 29 #endif |
| 30 TEST_F(IPCChannelTest, MAYBE_ChannelTest) { |
| 26 Init("GenericClient"); | 31 Init("GenericClient"); |
| 27 | 32 |
| 28 // Set up IPC channel and start client. | 33 // Set up IPC channel and start client. |
| 29 IPC::TestChannelListener listener; | 34 IPC::TestChannelListener listener; |
| 30 CreateChannel(&listener); | 35 CreateChannel(&listener); |
| 31 listener.Init(sender()); | 36 listener.Init(sender()); |
| 32 ASSERT_TRUE(ConnectChannel()); | 37 ASSERT_TRUE(ConnectChannel()); |
| 33 ASSERT_TRUE(StartClient()); | 38 ASSERT_TRUE(StartClient()); |
| 34 | 39 |
| 35 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent"); | 40 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 base::MessageLoop::current()->Run(); | 82 base::MessageLoop::current()->Run(); |
| 78 | 83 |
| 79 // Close the channel so the client's OnChannelError() gets fired. | 84 // Close the channel so the client's OnChannelError() gets fired. |
| 80 channel()->Close(); | 85 channel()->Close(); |
| 81 | 86 |
| 82 EXPECT_TRUE(WaitForClientShutdown()); | 87 EXPECT_TRUE(WaitForClientShutdown()); |
| 83 DestroyChannel(); | 88 DestroyChannel(); |
| 84 } | 89 } |
| 85 #endif // defined (OS_WIN) | 90 #endif // defined (OS_WIN) |
| 86 | 91 |
| 87 TEST_F(IPCChannelTest, ChannelProxyTest) { | 92 #if defined(OS_ANDROID) |
| 93 #define MAYBE_ChannelProxyTest DISABLED_ChannelProxyTest |
| 94 #else |
| 95 #define MAYBE_ChannelProxyTest ChannelProxyTest |
| 96 #endif |
| 97 TEST_F(IPCChannelTest, MAYBE_ChannelProxyTest) { |
| 88 Init("GenericClient"); | 98 Init("GenericClient"); |
| 89 | 99 |
| 90 base::Thread thread("ChannelProxyTestServer"); | 100 base::Thread thread("ChannelProxyTestServer"); |
| 91 base::Thread::Options options; | 101 base::Thread::Options options; |
| 92 options.message_loop_type = base::MessageLoop::TYPE_IO; | 102 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 93 thread.StartWithOptions(options); | 103 thread.StartWithOptions(options); |
| 94 | 104 |
| 95 // Set up IPC channel proxy. | 105 // Set up IPC channel proxy. |
| 96 IPC::TestChannelListener listener; | 106 IPC::TestChannelListener listener; |
| 97 CreateChannelProxy(&listener, thread.task_runner().get()); | 107 CreateChannelProxy(&listener, thread.task_runner().get()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 114 class ChannelListenerWithOnConnectedSend : public IPC::TestChannelListener { | 124 class ChannelListenerWithOnConnectedSend : public IPC::TestChannelListener { |
| 115 public: | 125 public: |
| 116 ChannelListenerWithOnConnectedSend() {} | 126 ChannelListenerWithOnConnectedSend() {} |
| 117 ~ChannelListenerWithOnConnectedSend() override {} | 127 ~ChannelListenerWithOnConnectedSend() override {} |
| 118 | 128 |
| 119 void OnChannelConnected(int32 peer_pid) override { | 129 void OnChannelConnected(int32 peer_pid) override { |
| 120 SendNextMessage(); | 130 SendNextMessage(); |
| 121 } | 131 } |
| 122 }; | 132 }; |
| 123 | 133 |
| 124 #if defined(OS_WIN) | 134 #if defined(OS_WIN) || defined(OS_ANDROID) |
| 125 // Acting flakey in Windows. http://crbug.com/129595 | 135 // Acting flakey in Windows. http://crbug.com/129595 |
| 126 #define MAYBE_SendMessageInChannelConnected DISABLED_SendMessageInChannelConnect
ed | 136 #define MAYBE_SendMessageInChannelConnected DISABLED_SendMessageInChannelConnect
ed |
| 127 #else | 137 #else |
| 128 #define MAYBE_SendMessageInChannelConnected SendMessageInChannelConnected | 138 #define MAYBE_SendMessageInChannelConnected SendMessageInChannelConnected |
| 129 #endif | 139 #endif |
| 130 // This tests the case of a listener sending back an event in its | 140 // This tests the case of a listener sending back an event in its |
| 131 // OnChannelConnected handler. | 141 // OnChannelConnected handler. |
| 132 TEST_F(IPCChannelTest, MAYBE_SendMessageInChannelConnected) { | 142 TEST_F(IPCChannelTest, MAYBE_SendMessageInChannelConnected) { |
| 133 Init("GenericClient"); | 143 Init("GenericClient"); |
| 134 | 144 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 160 IPCTestBase::GetChannelName("GenericClient"), &listener, nullptr)); | 170 IPCTestBase::GetChannelName("GenericClient"), &listener, nullptr)); |
| 161 CHECK(channel->Connect()); | 171 CHECK(channel->Connect()); |
| 162 listener.Init(channel.get()); | 172 listener.Init(channel.get()); |
| 163 IPC::TestChannelListener::SendOneMessage(channel.get(), "hello from child"); | 173 IPC::TestChannelListener::SendOneMessage(channel.get(), "hello from child"); |
| 164 | 174 |
| 165 base::MessageLoop::current()->Run(); | 175 base::MessageLoop::current()->Run(); |
| 166 return 0; | 176 return 0; |
| 167 } | 177 } |
| 168 | 178 |
| 169 } // namespace | 179 } // namespace |
| OLD | NEW |