OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ | 5 #ifndef REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ |
6 #define REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ | 6 #define REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "remoting/client/chromoting_client.h" | 14 #include "remoting/client/chromoting_client.h" |
15 #include "remoting/client/client_user_interface.h" | 15 #include "remoting/client/client_user_interface.h" |
16 #include "remoting/protocol/clipboard_filter.h" | 16 #include "remoting/protocol/clipboard_filter.h" |
17 #include "remoting/protocol/cursor_shape_stub.h" | 17 #include "remoting/protocol/cursor_shape_stub.h" |
18 #include "remoting/test/remote_connection_observer.h" | 18 #include "remoting/test/remote_connection_observer.h" |
19 | 19 |
20 namespace remoting { | 20 namespace remoting { |
21 | 21 |
22 class ClientContext; | 22 class ClientContext; |
(...skipping 15 matching lines...) Expand all Loading... |
38 // Must be used from a thread running an IO message loop. | 38 // Must be used from a thread running an IO message loop. |
39 // RemoteConnectionObserver objects must not destroy this class within a | 39 // RemoteConnectionObserver objects must not destroy this class within a |
40 // callback. | 40 // callback. |
41 // A VideoRenderer can be passed in to customize the connection. | 41 // A VideoRenderer can be passed in to customize the connection. |
42 class TestChromotingClient : public ClientUserInterface, | 42 class TestChromotingClient : public ClientUserInterface, |
43 public protocol::ClipboardStub, | 43 public protocol::ClipboardStub, |
44 public protocol::CursorShapeStub { | 44 public protocol::CursorShapeStub { |
45 public: | 45 public: |
46 TestChromotingClient(); | 46 TestChromotingClient(); |
47 explicit TestChromotingClient( | 47 explicit TestChromotingClient( |
48 scoped_ptr<protocol::VideoRenderer> video_renderer); | 48 std::unique_ptr<protocol::VideoRenderer> video_renderer); |
49 ~TestChromotingClient() override; | 49 ~TestChromotingClient() override; |
50 | 50 |
51 // Starts a Chromoting connection using the specified connection setup info. | 51 // Starts a Chromoting connection using the specified connection setup info. |
52 void StartConnection(const ConnectionSetupInfo& connection_setup_info); | 52 void StartConnection(const ConnectionSetupInfo& connection_setup_info); |
53 | 53 |
54 // Ends the current remote connection and updates the connection state. | 54 // Ends the current remote connection and updates the connection state. |
55 void EndConnection(); | 55 void EndConnection(); |
56 | 56 |
57 // Stubs used to send messages to the remote host. | 57 // Stubs used to send messages to the remote host. |
58 protocol::ClipboardStub* clipboard_forwarder() { | 58 protocol::ClipboardStub* clipboard_forwarder() { |
59 return chromoting_client_->clipboard_forwarder(); | 59 return chromoting_client_->clipboard_forwarder(); |
60 } | 60 } |
61 protocol::HostStub* host_stub() { return chromoting_client_->host_stub(); } | 61 protocol::HostStub* host_stub() { return chromoting_client_->host_stub(); } |
62 protocol::InputStub* input_stub() { return chromoting_client_->input_stub(); } | 62 protocol::InputStub* input_stub() { return chromoting_client_->input_stub(); } |
63 | 63 |
64 // Registers an observer which will be notfied when remote connection events | 64 // Registers an observer which will be notfied when remote connection events |
65 // occur. Registered Observers must not tear-down this object on receipt of | 65 // occur. Registered Observers must not tear-down this object on receipt of |
66 // these callbacks. The callbacks should be used for informational purposes. | 66 // these callbacks. The callbacks should be used for informational purposes. |
67 void AddRemoteConnectionObserver(RemoteConnectionObserver* observer); | 67 void AddRemoteConnectionObserver(RemoteConnectionObserver* observer); |
68 | 68 |
69 // Unregisters an observerer from notifications for remote connection events. | 69 // Unregisters an observerer from notifications for remote connection events. |
70 void RemoveRemoteConnectionObserver(RemoteConnectionObserver* observer); | 70 void RemoveRemoteConnectionObserver(RemoteConnectionObserver* observer); |
71 | 71 |
72 // Used to set a fake/mock dependencies for tests. | 72 // Used to set a fake/mock dependencies for tests. |
73 void SetSignalStrategyForTests(scoped_ptr<SignalStrategy> signal_strategy); | 73 void SetSignalStrategyForTests( |
| 74 std::unique_ptr<SignalStrategy> signal_strategy); |
74 void SetConnectionToHostForTests( | 75 void SetConnectionToHostForTests( |
75 scoped_ptr<protocol::ConnectionToHost> connection_to_host); | 76 std::unique_ptr<protocol::ConnectionToHost> connection_to_host); |
76 | 77 |
77 private: | 78 private: |
78 // ClientUserInterface interface. | 79 // ClientUserInterface interface. |
79 void OnConnectionState(protocol::ConnectionToHost::State state, | 80 void OnConnectionState(protocol::ConnectionToHost::State state, |
80 protocol::ErrorCode error_code) override; | 81 protocol::ErrorCode error_code) override; |
81 void OnConnectionReady(bool ready) override; | 82 void OnConnectionReady(bool ready) override; |
82 void OnRouteChanged(const std::string& channel_name, | 83 void OnRouteChanged(const std::string& channel_name, |
83 const protocol::TransportRoute& route) override; | 84 const protocol::TransportRoute& route) override; |
84 void SetCapabilities(const std::string& capabilities) override; | 85 void SetCapabilities(const std::string& capabilities) override; |
85 void SetPairingResponse( | 86 void SetPairingResponse( |
(...skipping 15 matching lines...) Expand all Loading... |
101 | 102 |
102 // Tracks the most recent connection error code seen. | 103 // Tracks the most recent connection error code seen. |
103 protocol::ErrorCode connection_error_code_; | 104 protocol::ErrorCode connection_error_code_; |
104 | 105 |
105 // List of observers which are notified when remote connection events occur. | 106 // List of observers which are notified when remote connection events occur. |
106 // We specify true below for the 'check_empty' flag so the list will check to | 107 // We specify true below for the 'check_empty' flag so the list will check to |
107 // see if all observers have been unregistered when it is destroyed. | 108 // see if all observers have been unregistered when it is destroyed. |
108 base::ObserverList<RemoteConnectionObserver, true> connection_observers_; | 109 base::ObserverList<RemoteConnectionObserver, true> connection_observers_; |
109 | 110 |
110 // ConnectionToHost used by TestChromotingClient tests. | 111 // ConnectionToHost used by TestChromotingClient tests. |
111 scoped_ptr<protocol::ConnectionToHost> test_connection_to_host_; | 112 std::unique_ptr<protocol::ConnectionToHost> test_connection_to_host_; |
112 | 113 |
113 // Creates and manages the connection to the remote host. | 114 // Creates and manages the connection to the remote host. |
114 scoped_ptr<ChromotingClient> chromoting_client_; | 115 std::unique_ptr<ChromotingClient> chromoting_client_; |
115 | 116 |
116 // Manages the threads and task runners for |chromoting_client_|. | 117 // Manages the threads and task runners for |chromoting_client_|. |
117 scoped_ptr<ClientContext> client_context_; | 118 std::unique_ptr<ClientContext> client_context_; |
118 | 119 |
119 // Processes video packets from the host. | 120 // Processes video packets from the host. |
120 scoped_ptr<protocol::VideoRenderer> video_renderer_; | 121 std::unique_ptr<protocol::VideoRenderer> video_renderer_; |
121 | 122 |
122 // SignalStrategy used for connection signaling. | 123 // SignalStrategy used for connection signaling. |
123 scoped_ptr<SignalStrategy> signal_strategy_; | 124 std::unique_ptr<SignalStrategy> signal_strategy_; |
124 | 125 |
125 DISALLOW_COPY_AND_ASSIGN(TestChromotingClient); | 126 DISALLOW_COPY_AND_ASSIGN(TestChromotingClient); |
126 }; | 127 }; |
127 | 128 |
128 } // namespace test | 129 } // namespace test |
129 } // namespace remoting | 130 } // namespace remoting |
130 | 131 |
131 #endif // REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ | 132 #endif // REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ |
OLD | NEW |