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

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

Issue 11419265: Revert 170360 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "remoting/base/auto_thread_task_runner.h" 9 #include "remoting/base/auto_thread_task_runner.h"
10 #include "remoting/jingle_glue/mock_objects.h" 10 #include "remoting/jingle_glue/mock_objects.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 public: 111 public:
112 ChromotingHostTest() { 112 ChromotingHostTest() {
113 } 113 }
114 114
115 virtual void SetUp() OVERRIDE { 115 virtual void SetUp() OVERRIDE {
116 ui_task_runner_ = new AutoThreadTaskRunner( 116 ui_task_runner_ = new AutoThreadTaskRunner(
117 message_loop_.message_loop_proxy(), 117 message_loop_.message_loop_proxy(),
118 base::Bind(&ChromotingHostTest::QuitMainMessageLoop, 118 base::Bind(&ChromotingHostTest::QuitMainMessageLoop,
119 base::Unretained(this))); 119 base::Unretained(this)));
120 120
121 EXPECT_CALL(context_, ui_task_runner())
122 .Times(AnyNumber())
123 .WillRepeatedly(Return(ui_task_runner_.get()));
124 EXPECT_CALL(context_, capture_task_runner())
125 .Times(AnyNumber())
126 .WillRepeatedly(Return(ui_task_runner_.get()));
127 EXPECT_CALL(context_, encode_task_runner())
128 .Times(AnyNumber())
129 .WillRepeatedly(Return(ui_task_runner_.get()));
130 EXPECT_CALL(context_, network_task_runner())
131 .Times(AnyNumber())
132 .WillRepeatedly(Return(ui_task_runner_.get()));
133
121 desktop_environment_factory_.reset(new MockDesktopEnvironmentFactory()); 134 desktop_environment_factory_.reset(new MockDesktopEnvironmentFactory());
122 EXPECT_CALL(*desktop_environment_factory_, CreatePtr(_)) 135 EXPECT_CALL(*desktop_environment_factory_, CreatePtr(_))
123 .Times(AnyNumber()) 136 .Times(AnyNumber())
124 .WillRepeatedly(Invoke(this, 137 .WillRepeatedly(Invoke(this,
125 &ChromotingHostTest::CreateDesktopEnvironment)); 138 &ChromotingHostTest::CreateDesktopEnvironment));
126 139
127 session_manager_ = new protocol::MockSessionManager(); 140 session_manager_ = new protocol::MockSessionManager();
128 141
129 host_ = new ChromotingHost( 142 host_ = new ChromotingHost(
130 &signal_strategy_, 143 &signal_strategy_,
131 desktop_environment_factory_.get(), 144 desktop_environment_factory_.get(),
132 scoped_ptr<protocol::SessionManager>(session_manager_), 145 scoped_ptr<protocol::SessionManager>(session_manager_),
133 ui_task_runner_, // Audio 146 context_.audio_task_runner(),
134 ui_task_runner_, // Video capture 147 context_.capture_task_runner(),
135 ui_task_runner_, // Video encode 148 context_.encode_task_runner(),
136 ui_task_runner_); // Network 149 context_.network_task_runner());
137 host_->AddStatusObserver(&host_status_observer_); 150 host_->AddStatusObserver(&host_status_observer_);
138 151
139 disconnect_window_ = new MockDisconnectWindow(); 152 disconnect_window_ = new MockDisconnectWindow();
140 continue_window_ = new MockContinueWindow(); 153 continue_window_ = new MockContinueWindow();
141 local_input_monitor_ = new MockLocalInputMonitor(); 154 local_input_monitor_ = new MockLocalInputMonitor();
142 it2me_host_user_interface_.reset( 155 it2me_host_user_interface_.reset(
143 new MockIt2MeHostUserInterface(ui_task_runner_, ui_task_runner_)); 156 new MockIt2MeHostUserInterface(context_.network_task_runner(),
157 context_.ui_task_runner()));
144 it2me_host_user_interface_->InitFrom( 158 it2me_host_user_interface_->InitFrom(
145 scoped_ptr<DisconnectWindow>(disconnect_window_), 159 scoped_ptr<DisconnectWindow>(disconnect_window_),
146 scoped_ptr<ContinueWindow>(continue_window_), 160 scoped_ptr<ContinueWindow>(continue_window_),
147 scoped_ptr<LocalInputMonitor>(local_input_monitor_)); 161 scoped_ptr<LocalInputMonitor>(local_input_monitor_));
148 162
149 it2me_host_user_interface_->Start( 163 it2me_host_user_interface_->Start(
150 host_, base::Bind(&ChromotingHost::Shutdown, host_, base::Closure())); 164 host_, base::Bind(&ChromotingHost::Shutdown, host_, base::Closure()));
151 165
152 xmpp_login_ = "host@domain"; 166 xmpp_login_ = "host@domain";
153 session1_ = new MockSession(); 167 session1_ = new MockSession();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 243
230 // Helper method to pretend a client is connected to ChromotingHost. 244 // Helper method to pretend a client is connected to ChromotingHost.
231 void SimulateClientConnection(int connection_index, bool authenticate, 245 void SimulateClientConnection(int connection_index, bool authenticate,
232 bool reject) { 246 bool reject) {
233 scoped_ptr<protocol::ConnectionToClient> connection = 247 scoped_ptr<protocol::ConnectionToClient> connection =
234 ((connection_index == 0) ? owned_connection1_ : owned_connection2_). 248 ((connection_index == 0) ? owned_connection1_ : owned_connection2_).
235 PassAs<protocol::ConnectionToClient>(); 249 PassAs<protocol::ConnectionToClient>();
236 protocol::ConnectionToClient* connection_ptr = connection.get(); 250 protocol::ConnectionToClient* connection_ptr = connection.get();
237 scoped_refptr<ClientSession> client = new ClientSession( 251 scoped_refptr<ClientSession> client = new ClientSession(
238 host_.get(), 252 host_.get(),
239 ui_task_runner_, // Audio 253 context_.audio_task_runner(),
240 ui_task_runner_, // Video capture 254 context_.capture_task_runner(),
241 ui_task_runner_, // Video encode 255 context_.encode_task_runner(),
242 ui_task_runner_, // Network 256 context_.network_task_runner(),
243 connection.Pass(), 257 connection.Pass(),
244 desktop_environment_factory_.get(), 258 desktop_environment_factory_.get(),
245 base::TimeDelta()); 259 base::TimeDelta());
246 connection_ptr->set_host_stub(client); 260 connection_ptr->set_host_stub(client);
247 connection_ptr->set_input_stub( 261 connection_ptr->set_input_stub(
248 client->desktop_environment()->event_executor()); 262 client->desktop_environment()->event_executor());
249 263
250 ui_task_runner_->PostTask( 264 context_.network_task_runner()->PostTask(
251 FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost, 265 FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost,
252 host_, client)); 266 host_, client));
253 267
254 if (authenticate) { 268 if (authenticate) {
255 ui_task_runner_->PostTask( 269 context_.network_task_runner()->PostTask(
256 FROM_HERE, base::Bind(&ClientSession::OnConnectionAuthenticated, 270 FROM_HERE, base::Bind(&ClientSession::OnConnectionAuthenticated,
257 client, connection_ptr)); 271 client, connection_ptr));
258 if (!reject) { 272 if (!reject) {
259 ui_task_runner_->PostTask( 273 context_.network_task_runner()->PostTask(
260 FROM_HERE, 274 FROM_HERE,
261 base::Bind(&ClientSession::OnConnectionChannelsConnected, 275 base::Bind(&ClientSession::OnConnectionChannelsConnected,
262 client, connection_ptr)); 276 client, connection_ptr));
263 } 277 }
264 } else { 278 } else {
265 ui_task_runner_->PostTask( 279 context_.network_task_runner()->PostTask(
266 FROM_HERE, base::Bind(&ClientSession::OnConnectionClosed, 280 FROM_HERE, base::Bind(&ClientSession::OnConnectionClosed,
267 client, connection_ptr, 281 client, connection_ptr,
268 protocol::AUTHENTICATION_FAILED)); 282 protocol::AUTHENTICATION_FAILED));
269 } 283 }
270 284
271 get_client(connection_index) = client; 285 get_client(connection_index) = client;
272 } 286 }
273 287
274 virtual void TearDown() OVERRIDE { 288 virtual void TearDown() OVERRIDE {
275 // Make sure that the host has been properly deleted. 289 // Make sure that the host has been properly deleted.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 EXPECT_CALL(host_status_observer_, OnClientDisconnected(session_jid)) 436 EXPECT_CALL(host_status_observer_, OnClientDisconnected(session_jid))
423 .After(after) 437 .After(after)
424 .WillOnce(action) 438 .WillOnce(action)
425 .RetiresOnSaturation(); 439 .RetiresOnSaturation();
426 } 440 }
427 } 441 }
428 442
429 protected: 443 protected:
430 MessageLoop message_loop_; 444 MessageLoop message_loop_;
431 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; 445 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
446 MockChromotingHostContext context_;
432 MockConnectionToClientEventHandler handler_; 447 MockConnectionToClientEventHandler handler_;
433 MockSignalStrategy signal_strategy_; 448 MockSignalStrategy signal_strategy_;
434 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory_; 449 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory_;
435 scoped_ptr<MockIt2MeHostUserInterface> it2me_host_user_interface_; 450 scoped_ptr<MockIt2MeHostUserInterface> it2me_host_user_interface_;
436 scoped_refptr<ChromotingHost> host_; 451 scoped_refptr<ChromotingHost> host_;
437 MockHostStatusObserver host_status_observer_; 452 MockHostStatusObserver host_status_observer_;
438 protocol::MockSessionManager* session_manager_; 453 protocol::MockSessionManager* session_manager_;
439 std::string xmpp_login_; 454 std::string xmpp_login_;
440 MockConnectionToClient* connection1_; 455 MockConnectionToClient* connection1_;
441 scoped_ptr<MockConnectionToClient> owned_connection1_; 456 scoped_ptr<MockConnectionToClient> owned_connection1_;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 ExpectClientDisconnected(0, true, video_packet_sent, 704 ExpectClientDisconnected(0, true, video_packet_sent,
690 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 705 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
691 EXPECT_CALL(host_status_observer_, OnShutdown()); 706 EXPECT_CALL(host_status_observer_, OnShutdown());
692 707
693 host_->Start(xmpp_login_); 708 host_->Start(xmpp_login_);
694 SimulateClientConnection(0, true, false); 709 SimulateClientConnection(0, true, false);
695 message_loop_.Run(); 710 message_loop_.Run();
696 } 711 }
697 712
698 } // namespace remoting 713 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host_context_unittest.cc ('k') | remoting/host/desktop_environment_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698