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

Side by Side Diff: remoting/host/chromoting_host_unittest.cc

Issue 11260053: Use correct thread for audio capturing and encoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
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/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "remoting/base/auto_thread_task_runner.h" 8 #include "remoting/base/auto_thread_task_runner.h"
9 #include "remoting/jingle_glue/mock_objects.h" 9 #include "remoting/jingle_glue/mock_objects.h"
10 #include "remoting/host/audio_capturer.h"
11 #include "remoting/host/chromoting_host_context.h" 10 #include "remoting/host/chromoting_host_context.h"
12 #include "remoting/host/chromoting_host.h" 11 #include "remoting/host/chromoting_host.h"
13 #include "remoting/host/desktop_environment.h" 12 #include "remoting/host/desktop_environment.h"
14 #include "remoting/host/desktop_environment_factory.h" 13 #include "remoting/host/desktop_environment_factory.h"
15 #include "remoting/host/event_executor_fake.h" 14 #include "remoting/host/event_executor_fake.h"
16 #include "remoting/host/host_mock_objects.h" 15 #include "remoting/host/host_mock_objects.h"
17 #include "remoting/host/it2me_host_user_interface.h" 16 #include "remoting/host/it2me_host_user_interface.h"
18 #include "remoting/host/video_frame_capturer_fake.h" 17 #include "remoting/host/video_frame_capturer_fake.h"
19 #include "remoting/proto/video.pb.h" 18 #include "remoting/proto/video.pb.h"
20 #include "remoting/protocol/errors.h" 19 #include "remoting/protocol/errors.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 .Times(AnyNumber()) 137 .Times(AnyNumber())
139 .WillRepeatedly(Invoke(this, 138 .WillRepeatedly(Invoke(this,
140 &ChromotingHostTest::CreateDesktopEnvironment)); 139 &ChromotingHostTest::CreateDesktopEnvironment));
141 140
142 session_manager_ = new protocol::MockSessionManager(); 141 session_manager_ = new protocol::MockSessionManager();
143 142
144 host_ = new ChromotingHost( 143 host_ = new ChromotingHost(
145 &signal_strategy_, 144 &signal_strategy_,
146 desktop_environment_factory_.get(), 145 desktop_environment_factory_.get(),
147 scoped_ptr<protocol::SessionManager>(session_manager_), 146 scoped_ptr<protocol::SessionManager>(session_manager_),
147 context_.audio_task_runner(),
148 context_.capture_task_runner(), 148 context_.capture_task_runner(),
149 context_.encode_task_runner(), 149 context_.encode_task_runner(),
150 context_.network_task_runner()); 150 context_.network_task_runner());
151 host_->AddStatusObserver(&host_status_observer_); 151 host_->AddStatusObserver(&host_status_observer_);
152 152
153 disconnect_window_ = new MockDisconnectWindow(); 153 disconnect_window_ = new MockDisconnectWindow();
154 continue_window_ = new MockContinueWindow(); 154 continue_window_ = new MockContinueWindow();
155 local_input_monitor_ = new MockLocalInputMonitor(); 155 local_input_monitor_ = new MockLocalInputMonitor();
156 it2me_host_user_interface_.reset( 156 it2me_host_user_interface_.reset(
157 new MockIt2MeHostUserInterface(context_.network_task_runner(), 157 new MockIt2MeHostUserInterface(context_.network_task_runner(),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 // Helper method to pretend a client is connected to ChromotingHost. 245 // Helper method to pretend a client is connected to ChromotingHost.
246 void SimulateClientConnection(int connection_index, bool authenticate, 246 void SimulateClientConnection(int connection_index, bool authenticate,
247 bool reject) { 247 bool reject) {
248 scoped_ptr<protocol::ConnectionToClient> connection = 248 scoped_ptr<protocol::ConnectionToClient> connection =
249 ((connection_index == 0) ? owned_connection1_ : owned_connection2_). 249 ((connection_index == 0) ? owned_connection1_ : owned_connection2_).
250 PassAs<protocol::ConnectionToClient>(); 250 PassAs<protocol::ConnectionToClient>();
251 protocol::ConnectionToClient* connection_ptr = connection.get(); 251 protocol::ConnectionToClient* connection_ptr = connection.get();
252 scoped_refptr<ClientSession> client = new ClientSession( 252 scoped_refptr<ClientSession> client = new ClientSession(
253 host_.get(), 253 host_.get(),
254 context_.audio_task_runner(),
254 context_.capture_task_runner(), 255 context_.capture_task_runner(),
255 context_.encode_task_runner(), 256 context_.encode_task_runner(),
256 context_.network_task_runner(), 257 context_.network_task_runner(),
257 connection.Pass(), 258 connection.Pass(),
258 desktop_environment_factory_.get(), 259 desktop_environment_factory_.get(),
259 base::TimeDelta()); 260 base::TimeDelta());
260 connection_ptr->set_host_stub(client); 261 connection_ptr->set_host_stub(client);
261 connection_ptr->set_input_stub( 262 connection_ptr->set_input_stub(
262 client->desktop_environment()->event_executor()); 263 client->desktop_environment()->event_executor());
263 264
(...skipping 28 matching lines...) Expand all
292 293
293 // Change the session route for |client1_|. 294 // Change the session route for |client1_|.
294 void ChangeSessionRoute(const std::string& channel_name, 295 void ChangeSessionRoute(const std::string& channel_name,
295 const protocol::TransportRoute& route) { 296 const protocol::TransportRoute& route) {
296 host_->OnSessionRouteChange(get_client(0), channel_name, route); 297 host_->OnSessionRouteChange(get_client(0), channel_name, route);
297 } 298 }
298 299
299 DesktopEnvironment* CreateDesktopEnvironment(ClientSession* client) { 300 DesktopEnvironment* CreateDesktopEnvironment(ClientSession* client) {
300 scoped_ptr<EventExecutor> event_executor(new EventExecutorFake()); 301 scoped_ptr<EventExecutor> event_executor(new EventExecutorFake());
301 scoped_ptr<VideoFrameCapturer> video_capturer(new VideoFrameCapturerFake()); 302 scoped_ptr<VideoFrameCapturer> video_capturer(new VideoFrameCapturerFake());
302 return new DesktopEnvironment(scoped_ptr<AudioCapturer>(NULL), 303 return new DesktopEnvironment(event_executor.Pass(),
303 event_executor.Pass(),
304 video_capturer.Pass()); 304 video_capturer.Pass());
305 } 305 }
306 306
307 void DisconnectAllClients() { 307 void DisconnectAllClients() {
308 host_->DisconnectAllClients(); 308 host_->DisconnectAllClients();
309 } 309 }
310 310
311 // Helper method to disconnect client 1 from the host. 311 // Helper method to disconnect client 1 from the host.
312 void DisconnectClient1() { 312 void DisconnectClient1() {
313 client1_->OnConnectionClosed(connection1_, protocol::OK); 313 client1_->OnConnectionClosed(connection1_, protocol::OK);
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 ExpectClientDisconnected(0, true, video_packet_sent, 703 ExpectClientDisconnected(0, true, video_packet_sent,
704 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 704 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
705 EXPECT_CALL(host_status_observer_, OnShutdown()); 705 EXPECT_CALL(host_status_observer_, OnShutdown());
706 706
707 host_->Start(xmpp_login_); 707 host_->Start(xmpp_login_);
708 SimulateClientConnection(0, true, false); 708 SimulateClientConnection(0, true, false);
709 message_loop_.Run(); 709 message_loop_.Run();
710 } 710 }
711 711
712 } // namespace remoting 712 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698