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 #include "chrome/service/service_ipc_server.h" | 5 #include "chrome/service/service_ipc_server.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 base::Thread io_thread_; | 109 base::Thread io_thread_; |
110 base::WaitableEvent shutdown_event_; | 110 base::WaitableEvent shutdown_event_; |
111 std::unique_ptr<ServiceIPCServer> server_; | 111 std::unique_ptr<ServiceIPCServer> server_; |
112 FakeChannelListener client_process_channel_listener_; | 112 FakeChannelListener client_process_channel_listener_; |
113 std::unique_ptr<IPC::SyncChannel> client_process_channel_; | 113 std::unique_ptr<IPC::SyncChannel> client_process_channel_; |
114 }; | 114 }; |
115 | 115 |
116 ServiceIPCServerTest::ServiceIPCServerTest() | 116 ServiceIPCServerTest::ServiceIPCServerTest() |
117 : channel_handle_(IPC::Channel::GenerateUniqueRandomChannelID()), | 117 : channel_handle_(IPC::Channel::GenerateUniqueRandomChannelID()), |
118 io_thread_("ServiceIPCServerTest IO"), | 118 io_thread_("ServiceIPCServerTest IO"), |
119 shutdown_event_(true /* manual_reset */, false /* initially_signaled */) { | 119 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
120 } | 120 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
121 | 121 |
122 void ServiceIPCServerTest::SetUp() { | 122 void ServiceIPCServerTest::SetUp() { |
123 base::Thread::Options options; | 123 base::Thread::Options options; |
124 options.message_loop_type = base::MessageLoop::TYPE_IO; | 124 options.message_loop_type = base::MessageLoop::TYPE_IO; |
125 ASSERT_TRUE(io_thread_.StartWithOptions(options)); | 125 ASSERT_TRUE(io_thread_.StartWithOptions(options)); |
126 | 126 |
127 server_.reset(new ServiceIPCServer(&service_process_client_, | 127 server_.reset(new ServiceIPCServer(&service_process_client_, |
128 io_thread_.task_runner(), | 128 io_thread_.task_runner(), |
129 channel_handle_, | 129 channel_handle_, |
130 &shutdown_event_)); | 130 &shutdown_event_)); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 new FakeMessageHandler(true /* should_handle */); | 256 new FakeMessageHandler(true /* should_handle */); |
257 server_->AddMessageHandler(base::WrapUnique(handler2)); | 257 server_->AddMessageHandler(base::WrapUnique(handler2)); |
258 FakeMessageHandler* handler3 = | 258 FakeMessageHandler* handler3 = |
259 new FakeMessageHandler(true /* should_handle */); | 259 new FakeMessageHandler(true /* should_handle */); |
260 server_->AddMessageHandler(base::WrapUnique(handler3)); | 260 server_->AddMessageHandler(base::WrapUnique(handler3)); |
261 SendToServiceProcess(new ServiceMsg_DisableCloudPrintProxy()); | 261 SendToServiceProcess(new ServiceMsg_DisableCloudPrintProxy()); |
262 ASSERT_EQ(1, handler1->handle_message_calls_); | 262 ASSERT_EQ(1, handler1->handle_message_calls_); |
263 ASSERT_EQ(1, handler2->handle_message_calls_); | 263 ASSERT_EQ(1, handler2->handle_message_calls_); |
264 ASSERT_EQ(0, handler3->handle_message_calls_); | 264 ASSERT_EQ(0, handler3->handle_message_calls_); |
265 } | 265 } |
OLD | NEW |