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) {} |
alexeypa (please no reviews)
2013/04/29 17:17:41
nit: Please move the closing bracket to the next l
xhwang
2013/04/30 00:02:36
Done.
| |
157 terminal_id_(0) { | |
158 } | |
159 | 156 |
160 DaemonProcessTest::~DaemonProcessTest() { | 157 DaemonProcessTest::~DaemonProcessTest() { |
161 } | 158 } |
162 | 159 |
163 void DaemonProcessTest::SetUp() { | 160 void DaemonProcessTest::SetUp() { |
164 scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner( | 161 scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner( |
165 message_loop_.message_loop_proxy(), | 162 message_loop_.message_loop_proxy(), |
166 base::Bind(&DaemonProcessTest::QuitMessageLoop, | 163 base::Bind(&DaemonProcessTest::QuitMessageLoop, |
167 base::Unretained(this))); | 164 base::Unretained(this))); |
168 daemon_process_.reset( | 165 daemon_process_.reset( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 void DaemonProcessTest::LaunchNetworkProcess() { | 199 void DaemonProcessTest::LaunchNetworkProcess() { |
203 terminal_id_ = 0; | 200 terminal_id_ = 0; |
204 daemon_process_->OnChannelConnected(0); | 201 daemon_process_->OnChannelConnected(0); |
205 } | 202 } |
206 | 203 |
207 void DaemonProcessTest::DeleteDaemonProcess() { | 204 void DaemonProcessTest::DeleteDaemonProcess() { |
208 daemon_process_.reset(); | 205 daemon_process_.reset(); |
209 } | 206 } |
210 | 207 |
211 void DaemonProcessTest::QuitMessageLoop() { | 208 void DaemonProcessTest::QuitMessageLoop() { |
212 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 209 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
213 } | 210 } |
214 | 211 |
215 void DaemonProcessTest::StartDaemonProcess() { | 212 void DaemonProcessTest::StartDaemonProcess() { |
216 // DaemonProcess::Initialize() sets up the config watcher that this test does | 213 // DaemonProcess::Initialize() sets up the config watcher that this test does |
217 // not support. Launch the process directly. | 214 // not support. Launch the process directly. |
218 daemon_process_->LaunchNetworkProcess(); | 215 daemon_process_->LaunchNetworkProcess(); |
219 } | 216 } |
220 | 217 |
221 MATCHER_P(Message, type, "") { | 218 MATCHER_P(Message, type, "") { |
222 return arg.type() == static_cast<uint32>(type); | 219 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()); | 333 EXPECT_EQ(1u, desktop_sessions().size()); |
337 EXPECT_EQ(id, desktop_sessions().front()->id()); | 334 EXPECT_EQ(id, desktop_sessions().front()->id()); |
338 | 335 |
339 EXPECT_TRUE(daemon_process_->OnMessageReceived( | 336 EXPECT_TRUE(daemon_process_->OnMessageReceived( |
340 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false))); | 337 ChromotingNetworkHostMsg_ConnectTerminal(id, resolution, false))); |
341 EXPECT_TRUE(desktop_sessions().empty()); | 338 EXPECT_TRUE(desktop_sessions().empty()); |
342 EXPECT_EQ(0, terminal_id_); | 339 EXPECT_EQ(0, terminal_id_); |
343 } | 340 } |
344 | 341 |
345 } // namespace remoting | 342 } // namespace remoting |
OLD | NEW |