OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ |
| 6 #define REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/observer_list.h" |
| 13 #include "remoting/client/client_user_interface.h" |
| 14 #include "remoting/protocol/cursor_shape_stub.h" |
| 15 #include "remoting/test/remote_connection_observer.h" |
| 16 #include "remoting/test/remote_host_info.h" |
| 17 |
| 18 namespace remoting { |
| 19 class ChromotingClient; |
| 20 class ClientContext; |
| 21 class XmppSignalStrategy; |
| 22 class VideoRenderer; |
| 23 } |
| 24 |
| 25 namespace remoting { |
| 26 namespace test { |
| 27 |
| 28 // Manages a chromoting connection to a remote host. Destroying a |
| 29 // TestChromotingClient object with an active connection will close it. |
| 30 // Must be used from a thread running an IO message loop. |
| 31 // RemoteConnectionObserver objects must not destroy this class within a |
| 32 // callback. |
| 33 class TestChromotingClient : public ClientUserInterface, |
| 34 public protocol::ClipboardStub, |
| 35 public protocol::CursorShapeStub { |
| 36 public: |
| 37 TestChromotingClient(); |
| 38 ~TestChromotingClient() override; |
| 39 |
| 40 // Starts a chromoting connection with the specified remote host. |
| 41 void StartConnection(const std::string& user_name, |
| 42 const std::string& access_token, |
| 43 const RemoteHostInfo& remote_host_info); |
| 44 |
| 45 // Ends the current remote connection and updates the connection state. |
| 46 void EndConnection(); |
| 47 |
| 48 // Registers an observer which will be notfied when remote connection events |
| 49 // occur. Registered Observers must not tear-down this object on receipt of |
| 50 // these callbacks. The callbacks should be used for informational purposes. |
| 51 void AddRemoteConnectionObserver(RemoteConnectionObserver* observer); |
| 52 |
| 53 // Unregisters an observerer from notifications for remote connection events. |
| 54 void RemoveRemoteConnectionObserver(RemoteConnectionObserver* observer); |
| 55 |
| 56 // Used to set a fake/mock connection object for TestChromotingClient tests. |
| 57 void SetConnectionToHostForTests( |
| 58 scoped_ptr<protocol::ConnectionToHost> connection_to_host); |
| 59 |
| 60 private: |
| 61 // ClientUserInterface interface. |
| 62 void OnConnectionState(protocol::ConnectionToHost::State state, |
| 63 protocol::ErrorCode error_code) override; |
| 64 void OnConnectionReady(bool ready) override; |
| 65 void OnRouteChanged(const std::string& channel_name, |
| 66 const protocol::TransportRoute& route) override; |
| 67 void SetCapabilities(const std::string& capabilities) override; |
| 68 void SetPairingResponse( |
| 69 const protocol::PairingResponse& pairing_response) override; |
| 70 void DeliverHostMessage(const protocol::ExtensionMessage& message) override; |
| 71 protocol::ClipboardStub* GetClipboardStub() override; |
| 72 protocol::CursorShapeStub* GetCursorShapeStub() override; |
| 73 |
| 74 // protocol::ClipboardStub interface. |
| 75 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; |
| 76 |
| 77 // protocol::CursorShapeStub interface. |
| 78 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; |
| 79 |
| 80 // Tracks the current connection state. |
| 81 protocol::ConnectionToHost::State connection_to_host_state_; |
| 82 |
| 83 // Tracks the most recent connection error code seen. |
| 84 protocol::ErrorCode connection_error_code_; |
| 85 |
| 86 // List of observers which are notified when remote connection events occur. |
| 87 // We specify true below for the 'check_empty' flag so the list will check to |
| 88 // see if all observers have been unregistered when it is destroyed. |
| 89 ObserverList<RemoteConnectionObserver, true> connection_observers_; |
| 90 |
| 91 // ConnectionToHost used by TestChromotingClient tests. |
| 92 scoped_ptr<protocol::ConnectionToHost> test_connection_to_host_; |
| 93 |
| 94 // Creates and manages the connection to the remote host. |
| 95 scoped_ptr<ChromotingClient> chromoting_client_; |
| 96 |
| 97 // Manages the threads and task runners for |chromoting_client_|. |
| 98 scoped_ptr<ClientContext> client_context_; |
| 99 |
| 100 // Processes video packets from the host. |
| 101 scoped_ptr<VideoRenderer> video_renderer_; |
| 102 |
| 103 // Used to establish an XMPP connection with the google talk service. |
| 104 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
| 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(TestChromotingClient); |
| 107 }; |
| 108 |
| 109 } // namespace test |
| 110 } // namespace remoting |
| 111 |
| 112 #endif // REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ |
OLD | NEW |