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