Compute if a layer is clipped outside CalcDrawProps
[chromium-blink-merge.git] / remoting / test / test_chromoting_client.h
blob03c942f7bb822ee5639bc27e0c0f3ff8ee52eaa4
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 // A VideoRenderer can be passed in to customize the connection.
40 class TestChromotingClient : public ClientUserInterface,
41 public protocol::ClipboardStub,
42 public protocol::CursorShapeStub {
43 public:
44 TestChromotingClient();
45 explicit TestChromotingClient(scoped_ptr<VideoRenderer> video_renderer);
46 ~TestChromotingClient() override;
48 // Starts a chromoting connection with the specified remote host.
49 void StartConnection(const std::string& user_name,
50 const std::string& access_token,
51 const RemoteHostInfo& remote_host_info);
53 // Ends the current remote connection and updates the connection state.
54 void EndConnection();
56 // Stubs used to send messages to the remote host.
57 protocol::ClipboardStub* clipboard_forwarder() {
58 return chromoting_client_->clipboard_forwarder();
60 protocol::HostStub* host_stub() { return chromoting_client_->host_stub(); }
61 protocol::InputStub* input_stub() { return chromoting_client_->input_stub(); }
63 // Registers an observer which will be notfied when remote connection events
64 // occur. Registered Observers must not tear-down this object on receipt of
65 // these callbacks. The callbacks should be used for informational purposes.
66 void AddRemoteConnectionObserver(RemoteConnectionObserver* observer);
68 // Unregisters an observerer from notifications for remote connection events.
69 void RemoveRemoteConnectionObserver(RemoteConnectionObserver* observer);
71 // Used to set a fake/mock connection object for TestChromotingClient tests.
72 void SetConnectionToHostForTests(
73 scoped_ptr<protocol::ConnectionToHost> connection_to_host);
75 private:
76 // ClientUserInterface interface.
77 void OnConnectionState(protocol::ConnectionToHost::State state,
78 protocol::ErrorCode error_code) override;
79 void OnConnectionReady(bool ready) override;
80 void OnRouteChanged(const std::string& channel_name,
81 const protocol::TransportRoute& route) override;
82 void SetCapabilities(const std::string& capabilities) override;
83 void SetPairingResponse(
84 const protocol::PairingResponse& pairing_response) override;
85 void DeliverHostMessage(const protocol::ExtensionMessage& message) override;
86 protocol::ClipboardStub* GetClipboardStub() override;
87 protocol::CursorShapeStub* GetCursorShapeStub() override;
89 // protocol::ClipboardStub interface.
90 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override;
92 // protocol::CursorShapeStub interface.
93 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override;
95 // Tracks the current connection state.
96 protocol::ConnectionToHost::State connection_to_host_state_;
98 // Tracks the most recent connection error code seen.
99 protocol::ErrorCode connection_error_code_;
101 // List of observers which are notified when remote connection events occur.
102 // We specify true below for the 'check_empty' flag so the list will check to
103 // see if all observers have been unregistered when it is destroyed.
104 base::ObserverList<RemoteConnectionObserver, true> connection_observers_;
106 // ConnectionToHost used by TestChromotingClient tests.
107 scoped_ptr<protocol::ConnectionToHost> test_connection_to_host_;
109 // Creates and manages the connection to the remote host.
110 scoped_ptr<ChromotingClient> chromoting_client_;
112 // Manages the threads and task runners for |chromoting_client_|.
113 scoped_ptr<ClientContext> client_context_;
115 // Processes video packets from the host.
116 scoped_ptr<VideoRenderer> video_renderer_;
118 // Used to establish an XMPP connection with the google talk service.
119 scoped_ptr<XmppSignalStrategy> signal_strategy_;
121 DISALLOW_COPY_AND_ASSIGN(TestChromotingClient);
124 } // namespace test
125 } // namespace remoting
127 #endif // REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_