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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // Quits |message_loop_|. | 138 // Quits |message_loop_|. |
139 void QuitMessageLoop(); | 139 void QuitMessageLoop(); |
140 | 140 |
141 void StartDaemonProcess(); | 141 void StartDaemonProcess(); |
142 | 142 |
143 const DaemonProcess::DesktopSessionList& desktop_sessions() const { | 143 const DaemonProcess::DesktopSessionList& desktop_sessions() const { |
144 return daemon_process_->desktop_sessions(); | 144 return daemon_process_->desktop_sessions(); |
145 } | 145 } |
146 | 146 |
147 protected: | 147 protected: |
148 MessageLoop message_loop_; | 148 base::MessageLoop message_loop_; |
149 | 149 |
150 scoped_ptr<MockDaemonProcess> daemon_process_; | 150 scoped_ptr<MockDaemonProcess> daemon_process_; |
151 int terminal_id_; | 151 int terminal_id_; |
152 }; | 152 }; |
153 | 153 |
154 | |
155 DaemonProcessTest::DaemonProcessTest() | 154 DaemonProcessTest::DaemonProcessTest() |
156 : message_loop_(MessageLoop::TYPE_IO), | 155 : message_loop_(base::MessageLoop::TYPE_IO), terminal_id_(0) { |
157 terminal_id_(0) { | |
158 } | 156 } |
159 | 157 |
160 DaemonProcessTest::~DaemonProcessTest() { | 158 DaemonProcessTest::~DaemonProcessTest() { |
161 } | 159 } |
162 | 160 |
163 void DaemonProcessTest::SetUp() { | 161 void DaemonProcessTest::SetUp() { |
164 scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner( | 162 scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner( |
165 message_loop_.message_loop_proxy(), | 163 message_loop_.message_loop_proxy(), |
166 base::Bind(&DaemonProcessTest::QuitMessageLoop, | 164 base::Bind(&DaemonProcessTest::QuitMessageLoop, |
167 base::Unretained(this))); | 165 base::Unretained(this))); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 void DaemonProcessTest::LaunchNetworkProcess() { | 200 void DaemonProcessTest::LaunchNetworkProcess() { |
203 terminal_id_ = 0; | 201 terminal_id_ = 0; |
204 daemon_process_->OnChannelConnected(0); | 202 daemon_process_->OnChannelConnected(0); |
205 } | 203 } |
206 | 204 |
207 void DaemonProcessTest::DeleteDaemonProcess() { | 205 void DaemonProcessTest::DeleteDaemonProcess() { |
208 daemon_process_.reset(); | 206 daemon_process_.reset(); |
209 } | 207 } |
210 | 208 |
211 void DaemonProcessTest::QuitMessageLoop() { | 209 void DaemonProcessTest::QuitMessageLoop() { |
212 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 210 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
213 } | 211 } |
214 | 212 |
215 void DaemonProcessTest::StartDaemonProcess() { | 213 void DaemonProcessTest::StartDaemonProcess() { |
216 // DaemonProcess::Initialize() sets up the config watcher that this test does | 214 // DaemonProcess::Initialize() sets up the config watcher that this test does |
217 // not support. Launch the process directly. | 215 // not support. Launch the process directly. |
218 daemon_process_->LaunchNetworkProcess(); | 216 daemon_process_->LaunchNetworkProcess(); |
219 } | 217 } |
220 | 218 |
221 MATCHER_P(Message, type, "") { | 219 MATCHER_P(Message, type, "") { |
222 return arg.type() == static_cast<uint32>(type); | 220 return arg.type() == static_cast<uint32>(type); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 EXPECT_EQ(1u, desktop_sessions().size()); | 334 EXPECT_EQ(1u, desktop_sessions().size()); |
337 EXPECT_EQ(id, desktop_sessions().front()->id()); | 335 EXPECT_EQ(id, desktop_sessions().front()->id()); |
338 | 336 |
339 EXPECT_TRUE(daemon_process_->OnMessageReceived( | 337 EXPECT_TRUE(daemon_process_->OnMessageReceived( |
340 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false))); | 338 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false))); |
341 EXPECT_TRUE(desktop_sessions().empty()); | 339 EXPECT_TRUE(desktop_sessions().empty()); |
342 EXPECT_EQ(0, terminal_id_); | 340 EXPECT_EQ(0, terminal_id_); |
343 } | 341 } |
344 | 342 |
345 } // namespace remoting | 343 } // namespace remoting |
OLD | NEW |