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