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

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

Issue 13212009: Made DesktopEnvironment responsible for creation of the disconnect window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Mac Created 7 years, 8 months 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
« no previous file with comments | « remoting/host/basic_desktop_environment.cc ('k') | remoting/host/desktop_process_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/video/capture/screen/screen_capturer_fake.h" 9 #include "media/video/capture/screen/screen_capturer_fake.h"
10 #include "remoting/base/auto_thread_task_runner.h" 10 #include "remoting/base/auto_thread_task_runner.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 } // namespace 63 } // namespace
64 64
65 class MockIt2MeHostUserInterface : public It2MeHostUserInterface { 65 class MockIt2MeHostUserInterface : public It2MeHostUserInterface {
66 public: 66 public:
67 MockIt2MeHostUserInterface( 67 MockIt2MeHostUserInterface(
68 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 68 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
69 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); 69 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
70 70
71 void InitFrom( 71 void InitFrom(scoped_ptr<ContinueWindow> continue_window);
72 scoped_ptr<DisconnectWindow> disconnect_window,
73 scoped_ptr<ContinueWindow> continue_window);
74 72
75 // A test-only version of Start that does not register a HostStatusObserver. 73 // A test-only version of Start that does not register a HostStatusObserver.
76 // TODO(rmsousa): Make the unit tests work with the regular Start(). 74 // TODO(rmsousa): Make the unit tests work with the regular Start().
77 virtual void Start(ChromotingHost* host, 75 virtual void Start(ChromotingHost* host,
78 const base::Closure& disconnect_callback) OVERRIDE; 76 const base::Closure& disconnect_callback) OVERRIDE;
79 }; 77 };
80 78
81 MockIt2MeHostUserInterface::MockIt2MeHostUserInterface( 79 MockIt2MeHostUserInterface::MockIt2MeHostUserInterface(
82 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 80 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
83 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) 81 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
84 : It2MeHostUserInterface(network_task_runner, ui_task_runner, UiStrings()) { 82 : It2MeHostUserInterface(network_task_runner, ui_task_runner, UiStrings()) {
85 } 83 }
86 84
87 void MockIt2MeHostUserInterface::InitFrom( 85 void MockIt2MeHostUserInterface::InitFrom(
88 scoped_ptr<DisconnectWindow> disconnect_window,
89 scoped_ptr<ContinueWindow> continue_window) { 86 scoped_ptr<ContinueWindow> continue_window) {
90 DCHECK(ui_task_runner()->BelongsToCurrentThread()); 87 DCHECK(ui_task_runner()->BelongsToCurrentThread());
91 88
92 disconnect_window_ = disconnect_window.Pass();
93 continue_window_ = continue_window.Pass(); 89 continue_window_ = continue_window.Pass();
94 } 90 }
95 91
96 void MockIt2MeHostUserInterface::Start( 92 void MockIt2MeHostUserInterface::Start(
97 ChromotingHost* host, const base::Closure& disconnect_callback) { 93 ChromotingHost* host, const base::Closure& disconnect_callback) {
98 DCHECK(network_task_runner()->BelongsToCurrentThread()); 94 DCHECK(network_task_runner()->BelongsToCurrentThread());
99 DCHECK(host_ == NULL); 95 DCHECK(host_ == NULL);
100 96
101 host_ = host; 97 host_ = host;
102 disconnect_callback_ = disconnect_callback; 98 disconnect_callback_ = disconnect_callback;
(...skipping 26 matching lines...) Expand all
129 desktop_environment_factory_.get(), 125 desktop_environment_factory_.get(),
130 scoped_ptr<protocol::SessionManager>(session_manager_), 126 scoped_ptr<protocol::SessionManager>(session_manager_),
131 ui_task_runner_, // Audio 127 ui_task_runner_, // Audio
132 ui_task_runner_, // Input 128 ui_task_runner_, // Input
133 ui_task_runner_, // Video capture 129 ui_task_runner_, // Video capture
134 ui_task_runner_, // Video encode 130 ui_task_runner_, // Video encode
135 ui_task_runner_, // Network 131 ui_task_runner_, // Network
136 ui_task_runner_); // UI 132 ui_task_runner_); // UI
137 host_->AddStatusObserver(&host_status_observer_); 133 host_->AddStatusObserver(&host_status_observer_);
138 134
139 disconnect_window_ = new MockDisconnectWindow();
140 continue_window_ = new MockContinueWindow(); 135 continue_window_ = new MockContinueWindow();
141 it2me_host_user_interface_.reset( 136 it2me_host_user_interface_.reset(
142 new MockIt2MeHostUserInterface(ui_task_runner_, ui_task_runner_)); 137 new MockIt2MeHostUserInterface(ui_task_runner_, ui_task_runner_));
143 it2me_host_user_interface_->InitFrom( 138 it2me_host_user_interface_->InitFrom(
144 scoped_ptr<DisconnectWindow>(disconnect_window_),
145 scoped_ptr<ContinueWindow>(continue_window_)); 139 scoped_ptr<ContinueWindow>(continue_window_));
146 140
147 it2me_host_user_interface_->Start( 141 it2me_host_user_interface_->Start(
148 host_, base::Bind(&ChromotingHost::Shutdown, host_, base::Closure())); 142 host_, base::Bind(&ChromotingHost::Shutdown, host_, base::Closure()));
149 143
150 xmpp_login_ = "host@domain"; 144 xmpp_login_ = "host@domain";
151 session1_ = new MockSession(); 145 session1_ = new MockSession();
152 session2_ = new MockSession(); 146 session2_ = new MockSession();
153 session_unowned1_.reset(new MockSession()); 147 session_unowned1_.reset(new MockSession());
154 session_unowned2_.reset(new MockSession()); 148 session_unowned2_.reset(new MockSession());
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 host_ = NULL; 358 host_ = NULL;
365 desktop_environment_factory_.reset(); 359 desktop_environment_factory_.reset();
366 } 360 }
367 361
368 void QuitMainMessageLoop() { 362 void QuitMainMessageLoop() {
369 PostQuitTask(&message_loop_); 363 PostQuitTask(&message_loop_);
370 } 364 }
371 365
372 // Expect the host to start. 366 // Expect the host to start.
373 void ExpectHostStart() { 367 void ExpectHostStart() {
374 EXPECT_CALL(*disconnect_window_, Hide());
375 EXPECT_CALL(*continue_window_, Hide()); 368 EXPECT_CALL(*continue_window_, Hide());
376 } 369 }
377 370
378 // Expect the host and session manager to start, and return the expectation 371 // Expect the host and session manager to start, and return the expectation
379 // that the session manager has started. 372 // that the session manager has started.
380 Expectation ExpectHostAndSessionManagerStart() { 373 Expectation ExpectHostAndSessionManagerStart() {
381 ExpectHostStart(); 374 ExpectHostStart();
382 EXPECT_CALL(host_status_observer_, OnStart(xmpp_login_)); 375 EXPECT_CALL(host_status_observer_, OnStart(xmpp_login_));
383 return EXPECT_CALL(*session_manager_, Init(_, host_.get())); 376 return EXPECT_CALL(*session_manager_, Init(_, host_.get()));
384 } 377 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 SessionConfig session_unowned_config1_; 478 SessionConfig session_unowned_config1_;
486 std::string session_unowned_jid1_; 479 std::string session_unowned_jid1_;
487 scoped_ptr<MockSession> session_unowned2_; // Not owned by a connection. 480 scoped_ptr<MockSession> session_unowned2_; // Not owned by a connection.
488 SessionConfig session_unowned_config2_; 481 SessionConfig session_unowned_config2_;
489 std::string session_unowned_jid2_; 482 std::string session_unowned_jid2_;
490 protocol::Session::EventHandler* session_event_handler_; 483 protocol::Session::EventHandler* session_event_handler_;
491 scoped_ptr<protocol::CandidateSessionConfig> empty_candidate_config_; 484 scoped_ptr<protocol::CandidateSessionConfig> empty_candidate_config_;
492 scoped_ptr<protocol::CandidateSessionConfig> default_candidate_config_; 485 scoped_ptr<protocol::CandidateSessionConfig> default_candidate_config_;
493 486
494 // Owned by |host_|. 487 // Owned by |host_|.
495 MockDisconnectWindow* disconnect_window_;
496 MockContinueWindow* continue_window_; 488 MockContinueWindow* continue_window_;
497 489
498 MockConnectionToClient*& get_connection(int connection_index) { 490 MockConnectionToClient*& get_connection(int connection_index) {
499 return (connection_index == 0) ? connection1_ : connection2_; 491 return (connection_index == 0) ? connection1_ : connection2_;
500 } 492 }
501 493
502 ClientSession*& get_client(int connection_index) { 494 ClientSession*& get_client(int connection_index) {
503 return (connection_index == 0) ? client1_ : client2_; 495 return (connection_index == 0) ? client1_ : client2_;
504 } 496 }
505 497
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 ExpectClientDisconnected(0, true, video_packet_sent, 706 ExpectClientDisconnected(0, true, video_packet_sent,
715 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 707 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
716 EXPECT_CALL(host_status_observer_, OnShutdown()); 708 EXPECT_CALL(host_status_observer_, OnShutdown());
717 709
718 host_->Start(xmpp_login_); 710 host_->Start(xmpp_login_);
719 SimulateClientConnection(0, true, false); 711 SimulateClientConnection(0, true, false);
720 message_loop_.Run(); 712 message_loop_.Run();
721 } 713 }
722 714
723 } // namespace remoting 715 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/basic_desktop_environment.cc ('k') | remoting/host/desktop_process_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698