Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: ipc/ipc_channel_proxy_unittest.cc

Issue 2455583002: Revert of Change most IPC tests to use ChannelMojo. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_channel_mojo_unittest.cc ('k') | ipc/ipc_fuzzing_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 ~MessageCountFilter() override {} 225 ~MessageCountFilter() override {}
226 226
227 size_t messages_received_; 227 size_t messages_received_;
228 uint32_t supported_message_class_; 228 uint32_t supported_message_class_;
229 bool is_global_filter_; 229 bool is_global_filter_;
230 230
231 FilterEvent last_filter_event_; 231 FilterEvent last_filter_event_;
232 bool message_filtering_enabled_; 232 bool message_filtering_enabled_;
233 }; 233 };
234 234
235 class IPCChannelProxyTest : public IPCChannelMojoTestBase { 235 class IPCChannelProxyTest : public IPCTestBase {
236 public: 236 public:
237 IPCChannelProxyTest() {} 237 IPCChannelProxyTest() {}
238 ~IPCChannelProxyTest() override {} 238 ~IPCChannelProxyTest() override {}
239 239
240 void SetUp() override { 240 void SetUp() override {
241 IPCChannelMojoTestBase::SetUp(); 241 IPCTestBase::SetUp();
242 242
243 Init("ChannelProxyClient"); 243 Init("ChannelProxyClient");
244 244
245 thread_.reset(new base::Thread("ChannelProxyTestServerThread")); 245 thread_.reset(new base::Thread("ChannelProxyTestServerThread"));
246 base::Thread::Options options; 246 base::Thread::Options options;
247 options.message_loop_type = base::MessageLoop::TYPE_IO; 247 options.message_loop_type = base::MessageLoop::TYPE_IO;
248 thread_->StartWithOptions(options); 248 thread_->StartWithOptions(options);
249 249
250 listener_.reset(new QuitListener()); 250 listener_.reset(new QuitListener());
251 channel_proxy_ = IPC::ChannelProxy::Create( 251 CreateChannelProxy(listener_.get(), thread_->task_runner().get());
252 TakeHandle().release(), IPC::Channel::MODE_SERVER, listener_.get(), 252
253 thread_->task_runner()); 253 ASSERT_TRUE(StartClient());
254 } 254 }
255 255
256 void TearDown() override { 256 void TearDown() override {
257 channel_proxy_.reset(); 257 DestroyChannelProxy();
258 thread_.reset(); 258 thread_.reset();
259 listener_.reset(); 259 listener_.reset();
260 IPCChannelMojoTestBase::TearDown(); 260 IPCTestBase::TearDown();
261 } 261 }
262 262
263 void SendQuitMessageAndWaitForIdle() { 263 void SendQuitMessageAndWaitForIdle() {
264 sender()->Send(new WorkerMsg_Quit); 264 sender()->Send(new WorkerMsg_Quit);
265 base::RunLoop().Run(); 265 base::RunLoop().Run();
266 EXPECT_TRUE(WaitForClientShutdown()); 266 EXPECT_TRUE(WaitForClientShutdown());
267 } 267 }
268 268
269 bool DidListenerGetBadMessage() { 269 bool DidListenerGetBadMessage() {
270 return listener_->bad_message_received_; 270 return listener_->bad_message_received_;
271 } 271 }
272 272
273 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); }
274 IPC::Sender* sender() { return channel_proxy_.get(); }
275
276 private: 273 private:
277 std::unique_ptr<base::Thread> thread_; 274 std::unique_ptr<base::Thread> thread_;
278 std::unique_ptr<QuitListener> listener_; 275 std::unique_ptr<QuitListener> listener_;
279 std::unique_ptr<IPC::ChannelProxy> channel_proxy_;
280 }; 276 };
281 277
282 TEST_F(IPCChannelProxyTest, MessageClassFilters) { 278 TEST_F(IPCChannelProxyTest, MessageClassFilters) {
283 // Construct a filter per message class. 279 // Construct a filter per message class.
284 std::vector<scoped_refptr<MessageCountFilter> > class_filters; 280 std::vector<scoped_refptr<MessageCountFilter> > class_filters;
285 class_filters.push_back(make_scoped_refptr( 281 class_filters.push_back(make_scoped_refptr(
286 new MessageCountFilter(TestMsgStart))); 282 new MessageCountFilter(TestMsgStart)));
287 class_filters.push_back(make_scoped_refptr( 283 class_filters.push_back(make_scoped_refptr(
288 new MessageCountFilter(UtilityMsgStart))); 284 new MessageCountFilter(UtilityMsgStart)));
289 for (size_t i = 0; i < class_filters.size(); ++i) 285 for (size_t i = 0; i < class_filters.size(); ++i)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // TODO(jam): for some reason this is flaky on win buildbots. 418 // TODO(jam): for some reason this is flaky on win buildbots.
423 TEST_F(IPCChannelBadMessageTest, BadMessage) { 419 TEST_F(IPCChannelBadMessageTest, BadMessage) {
424 sender()->Send(new TestMsg_SendBadMessage()); 420 sender()->Send(new TestMsg_SendBadMessage());
425 SendQuitMessageAndWaitForIdle(); 421 SendQuitMessageAndWaitForIdle();
426 EXPECT_TRUE(DidListenerGetBadMessage()); 422 EXPECT_TRUE(DidListenerGetBadMessage());
427 } 423 }
428 #endif 424 #endif
429 425
430 #endif 426 #endif
431 427
432 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ChannelProxyClient) { 428 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ChannelProxyClient) {
429 base::MessageLoopForIO main_message_loop;
433 ChannelReflectorListener listener; 430 ChannelReflectorListener listener;
434 Connect(&listener); 431 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
435 listener.Init(channel()); 432 IPCTestBase::GetChannelName("ChannelProxyClient"), &listener,
433 main_message_loop.task_runner()));
434 CHECK(channel->Connect());
435 listener.Init(channel.get());
436 436
437 base::RunLoop().Run(); 437 base::RunLoop().Run();
438 Close(); 438 return 0;
439 } 439 }
440 440
441 } // namespace 441 } // namespace
OLDNEW
« no previous file with comments | « ipc/ipc_channel_mojo_unittest.cc ('k') | ipc/ipc_fuzzing_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698