| 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/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" | 10 #include "remoting/host/audio_capturer.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 void DoNothing() { | 64 void DoNothing() { |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 class MockDesktopEnvironmentFactory : public DesktopEnvironmentFactory { | 69 class MockDesktopEnvironmentFactory : public DesktopEnvironmentFactory { |
| 70 public: | 70 public: |
| 71 MockDesktopEnvironmentFactory(); | 71 MockDesktopEnvironmentFactory(); |
| 72 virtual ~MockDesktopEnvironmentFactory(); | 72 virtual ~MockDesktopEnvironmentFactory(); |
| 73 | 73 |
| 74 virtual scoped_ptr<DesktopEnvironment> Create() OVERRIDE; | 74 virtual scoped_ptr<DesktopEnvironment> Create( |
| 75 scoped_refptr<ChromotingHost> host) OVERRIDE; |
| 75 | 76 |
| 76 private: | 77 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(MockDesktopEnvironmentFactory); | 78 DISALLOW_COPY_AND_ASSIGN(MockDesktopEnvironmentFactory); |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 MockDesktopEnvironmentFactory::MockDesktopEnvironmentFactory() | 81 MockDesktopEnvironmentFactory::MockDesktopEnvironmentFactory() |
| 81 : DesktopEnvironmentFactory(NULL, NULL) { | 82 : DesktopEnvironmentFactory(NULL, NULL) { |
| 82 } | 83 } |
| 83 | 84 |
| 84 MockDesktopEnvironmentFactory::~MockDesktopEnvironmentFactory() { | 85 MockDesktopEnvironmentFactory::~MockDesktopEnvironmentFactory() { |
| 85 } | 86 } |
| 86 | 87 |
| 87 scoped_ptr<DesktopEnvironment> MockDesktopEnvironmentFactory::Create() { | 88 scoped_ptr<DesktopEnvironment> MockDesktopEnvironmentFactory::Create( |
| 89 scoped_refptr<ChromotingHost> host) { |
| 88 scoped_ptr<EventExecutor> event_executor(new EventExecutorFake()); | 90 scoped_ptr<EventExecutor> event_executor(new EventExecutorFake()); |
| 89 scoped_ptr<VideoFrameCapturer> video_capturer(new VideoFrameCapturerFake()); | 91 scoped_ptr<VideoFrameCapturer> video_capturer(new VideoFrameCapturerFake()); |
| 90 return scoped_ptr<DesktopEnvironment>(new DesktopEnvironment( | 92 return scoped_ptr<DesktopEnvironment>(new DesktopEnvironment( |
| 91 scoped_ptr<AudioCapturer>(NULL), | 93 scoped_ptr<AudioCapturer>(NULL), |
| 92 event_executor.Pass(), | 94 event_executor.Pass(), |
| 93 video_capturer.Pass())); | 95 video_capturer.Pass())); |
| 94 } | 96 } |
| 95 | 97 |
| 96 class ChromotingHostTest : public testing::Test { | 98 class ChromotingHostTest : public testing::Test { |
| 97 public: | 99 public: |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 223 } |
| 222 | 224 |
| 223 // Helper method to pretend a client is connected to ChromotingHost. | 225 // Helper method to pretend a client is connected to ChromotingHost. |
| 224 void SimulateClientConnection(int connection_index, bool authenticate, | 226 void SimulateClientConnection(int connection_index, bool authenticate, |
| 225 bool reject) { | 227 bool reject) { |
| 226 scoped_ptr<protocol::ConnectionToClient> connection = | 228 scoped_ptr<protocol::ConnectionToClient> connection = |
| 227 ((connection_index == 0) ? owned_connection1_ : owned_connection2_). | 229 ((connection_index == 0) ? owned_connection1_ : owned_connection2_). |
| 228 PassAs<protocol::ConnectionToClient>(); | 230 PassAs<protocol::ConnectionToClient>(); |
| 229 protocol::ConnectionToClient* connection_ptr = connection.get(); | 231 protocol::ConnectionToClient* connection_ptr = connection.get(); |
| 230 scoped_ptr<DesktopEnvironment> desktop_environment = | 232 scoped_ptr<DesktopEnvironment> desktop_environment = |
| 231 host_->desktop_environment_factory_->Create(); | 233 host_->desktop_environment_factory_->Create(host_); |
| 232 connection_ptr->set_input_stub(desktop_environment->event_executor()); | 234 connection_ptr->set_input_stub(desktop_environment->event_executor()); |
| 233 | 235 |
| 234 scoped_refptr<ClientSession> client = new ClientSession( | 236 scoped_refptr<ClientSession> client = new ClientSession( |
| 235 host_.get(), | 237 host_.get(), |
| 236 context_.capture_task_runner(), | 238 context_.capture_task_runner(), |
| 237 context_.encode_task_runner(), | 239 context_.encode_task_runner(), |
| 238 context_.network_task_runner(), | 240 context_.network_task_runner(), |
| 239 connection.Pass(), | 241 connection.Pass(), |
| 240 desktop_environment.Pass(), | 242 desktop_environment.Pass(), |
| 241 base::TimeDelta()); | 243 base::TimeDelta()); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 ExpectClientDisconnected(0, true, video_packet_sent, | 677 ExpectClientDisconnected(0, true, video_packet_sent, |
| 676 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 678 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 677 EXPECT_CALL(host_status_observer_, OnShutdown()); | 679 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 678 | 680 |
| 679 host_->Start(xmpp_login_); | 681 host_->Start(xmpp_login_); |
| 680 SimulateClientConnection(0, true, false); | 682 SimulateClientConnection(0, true, false); |
| 681 message_loop_.Run(); | 683 message_loop_.Run(); |
| 682 } | 684 } |
| 683 | 685 |
| 684 } // namespace remoting | 686 } // namespace remoting |
| OLD | NEW |