Switch audio hang monitor to default-off. Enable for non-beta,stable.
[chromium-blink-merge.git] / remoting / test / test_chromoting_client.h
blob69f39670c490126acd1f43828b9956e99f774709
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.
5 #ifndef REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_
6 #define REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
13 #include "remoting/client/chromoting_client.h"
14 #include "remoting/client/client_user_interface.h"
15 #include "remoting/protocol/clipboard_filter.h"
16 #include "remoting/protocol/cursor_shape_stub.h"
17 #include "remoting/test/remote_connection_observer.h"
18 #include "remoting/test/remote_host_info.h"
20 namespace remoting {
22 class ClientContext;
23 class XmppSignalStrategy;
24 class VideoRenderer;
26 namespace protocol {
27 class ClipboardStub;
28 class HostStub;
29 class InputStub;
32 namespace test {
34 // Manages a chromoting connection to a remote host. Destroying a
35 // TestChromotingClient object with an active connection will close it.
36 // Must be used from a thread running an IO message loop.
37 // RemoteConnectionObserver objects must not destroy this class within a
38 // callback.
39 class TestChromotingClient : public ClientUserInterface,
40 public protocol::ClipboardStub,
41 public protocol::CursorShapeStub {
42 public:
43 TestChromotingClient();
44 ~TestChromotingClient() override;
46 // Starts a chromoting connection with the specified remote host.
47 void StartConnection(const std::string& user_name,
48 const std::string& access_token,
49 const RemoteHostInfo& remote_host_info);
51 // Ends the current remote connection and updates the connection state.
52 void EndConnection();
54 // Stubs used to send messages to the remote host.
55 protocol::ClipboardStub* clipboard_forwarder() {
56 return chromoting_client_->clipboard_forwarder();
58 protocol::HostStub* host_stub() { return chromoting_client_->host_stub(); }
59 protocol::InputStub* input_stub() { return chromoting_client_->input_stub(); }
61 // Registers an observer which will be notfied when remote connection events
62 // occur. Registered Observers must not tear-down this object on receipt of
63 // these callbacks. The callbacks should be used for informational purposes.
64 void AddRemoteConnectionObserver(RemoteConnectionObserver* observer);
66 // Unregisters an observerer from notifications for remote connection events.
67 void RemoveRemoteConnectionObserver(RemoteConnectionObserver* observer);
69 // Used to set a fake/mock connection object for TestChromotingClient tests.
70 void SetConnectionToHostForTests(
71 scoped_ptr<protocol::ConnectionToHost> connection_to_host);
73 private:
74 // ClientUserInterface interface.
75 void OnConnectionState(protocol::ConnectionToHost::State state,
76 protocol::ErrorCode error_code) override;
77 void OnConnectionReady(bool ready) override;
78 void OnRouteChanged(const std::string& channel_name,
79 const protocol::TransportRoute& route) override;
80 void SetCapabilities(const std::string& capabilities) override;
81 void SetPairingResponse(
82 const protocol::PairingResponse& pairing_response) override;
83 void DeliverHostMessage(const protocol::ExtensionMessage& message) override;
84 protocol::ClipboardStub* GetClipboardStub() override;
85 protocol::CursorShapeStub* GetCursorShapeStub() override;
87 // protocol::ClipboardStub interface.
88 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override;
90 // protocol::CursorShapeStub interface.
91 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override;
93 // Tracks the current connection state.
94 protocol::ConnectionToHost::State connection_to_host_state_;
96 // Tracks the most recent connection error code seen.
97 protocol::ErrorCode connection_error_code_;
99 // List of observers which are notified when remote connection events occur.
100 // We specify true below for the 'check_empty' flag so the list will check to
101 // see if all observers have been unregistered when it is destroyed.
102 ObserverList<RemoteConnectionObserver, true> connection_observers_;
104 // ConnectionToHost used by TestChromotingClient tests.
105 scoped_ptr<protocol::ConnectionToHost> test_connection_to_host_;
107 // Creates and manages the connection to the remote host.
108 scoped_ptr<ChromotingClient> chromoting_client_;
110 // Manages the threads and task runners for |chromoting_client_|.
111 scoped_ptr<ClientContext> client_context_;
113 // Processes video packets from the host.
114 scoped_ptr<VideoRenderer> video_renderer_;
116 // Used to establish an XMPP connection with the google talk service.
117 scoped_ptr<XmppSignalStrategy> signal_strategy_;
119 DISALLOW_COPY_AND_ASSIGN(TestChromotingClient);
122 } // namespace test
123 } // namespace remoting
125 #endif // REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_