Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: remoting/test/test_chromoting_client.h

Issue 1008043003: Adding Test Fixture for initial test cases for the App Remoting Test Driver. Also includes the pub… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "remoting/client/chromoting_client.h"
13 #include "remoting/client/client_user_interface.h" 14 #include "remoting/client/client_user_interface.h"
14 #include "remoting/protocol/clipboard_filter.h" 15 #include "remoting/protocol/clipboard_filter.h"
15 #include "remoting/protocol/cursor_shape_stub.h" 16 #include "remoting/protocol/cursor_shape_stub.h"
16 #include "remoting/test/remote_connection_observer.h" 17 #include "remoting/test/remote_connection_observer.h"
17 #include "remoting/test/remote_host_info.h" 18 #include "remoting/test/remote_host_info.h"
18 19
19 namespace remoting { 20 namespace remoting {
20 class ChromotingClient;
21 class ClientContext; 21 class ClientContext;
22 class XmppSignalStrategy; 22 class XmppSignalStrategy;
23 class VideoRenderer; 23 class VideoRenderer;
24
25 namespace protocol {
26 class ClipboardStub;
27 class HostStub;
28 class InputStub;
29 }
24 } 30 }
25 31
26 namespace remoting { 32 namespace remoting {
27 namespace test { 33 namespace test {
28 34
29 // Manages a chromoting connection to a remote host. Destroying a 35 // Manages a chromoting connection to a remote host. Destroying a
30 // TestChromotingClient object with an active connection will close it. 36 // TestChromotingClient object with an active connection will close it.
31 // Must be used from a thread running an IO message loop. 37 // Must be used from a thread running an IO message loop.
32 // RemoteConnectionObserver objects must not destroy this class within a 38 // RemoteConnectionObserver objects must not destroy this class within a
33 // callback. 39 // callback.
34 class TestChromotingClient : public ClientUserInterface, 40 class TestChromotingClient : public ClientUserInterface,
35 public protocol::ClipboardStub, 41 public protocol::ClipboardStub,
36 public protocol::CursorShapeStub { 42 public protocol::CursorShapeStub {
37 public: 43 public:
38 TestChromotingClient(); 44 TestChromotingClient();
39 ~TestChromotingClient() override; 45 ~TestChromotingClient() override;
40 46
41 // Starts a chromoting connection with the specified remote host. 47 // Starts a chromoting connection with the specified remote host.
42 void StartConnection(const std::string& user_name, 48 void StartConnection(const std::string& user_name,
43 const std::string& access_token, 49 const std::string& access_token,
44 const RemoteHostInfo& remote_host_info); 50 const RemoteHostInfo& remote_host_info);
45 51
46 // Ends the current remote connection and updates the connection state. 52 // Ends the current remote connection and updates the connection state.
47 void EndConnection(); 53 void EndConnection();
48 54
55 // Stubs used to send messages to the remote host.
56 protocol::ClipboardStub* clipboard_forwarder() {
57 return chromoting_client_->clipboard_forwarder();
58 }
59 protocol::HostStub* host_stub() { return chromoting_client_->host_stub(); }
60 protocol::InputStub* input_stub() { return chromoting_client_->input_stub(); }
61
49 // Registers an observer which will be notfied when remote connection events 62 // Registers an observer which will be notfied when remote connection events
50 // occur. Registered Observers must not tear-down this object on receipt of 63 // occur. Registered Observers must not tear-down this object on receipt of
51 // these callbacks. The callbacks should be used for informational purposes. 64 // these callbacks. The callbacks should be used for informational purposes.
52 void AddRemoteConnectionObserver(RemoteConnectionObserver* observer); 65 void AddRemoteConnectionObserver(RemoteConnectionObserver* observer);
53 66
54 // Unregisters an observerer from notifications for remote connection events. 67 // Unregisters an observerer from notifications for remote connection events.
55 void RemoveRemoteConnectionObserver(RemoteConnectionObserver* observer); 68 void RemoveRemoteConnectionObserver(RemoteConnectionObserver* observer);
56 69
57 // Used to set a fake/mock connection object for TestChromotingClient tests. 70 // Used to set a fake/mock connection object for TestChromotingClient tests.
58 void SetConnectionToHostForTests( 71 void SetConnectionToHostForTests(
59 scoped_ptr<protocol::ConnectionToHost> connection_to_host); 72 scoped_ptr<protocol::ConnectionToHost> connection_to_host);
60 73
74 const protocol::ConnectionToHost::State& connection_to_host_state() {
75 return connection_to_host_state_;
76 }
77 const protocol::ErrorCode& connection_error_code() {
78 return connection_error_code_;
79 }
80
61 private: 81 private:
62 // ClientUserInterface interface. 82 // ClientUserInterface interface.
63 void OnConnectionState(protocol::ConnectionToHost::State state, 83 void OnConnectionState(protocol::ConnectionToHost::State state,
64 protocol::ErrorCode error_code) override; 84 protocol::ErrorCode error_code) override;
65 void OnConnectionReady(bool ready) override; 85 void OnConnectionReady(bool ready) override;
66 void OnRouteChanged(const std::string& channel_name, 86 void OnRouteChanged(const std::string& channel_name,
67 const protocol::TransportRoute& route) override; 87 const protocol::TransportRoute& route) override;
68 void SetCapabilities(const std::string& capabilities) override; 88 void SetCapabilities(const std::string& capabilities) override;
69 void SetPairingResponse( 89 void SetPairingResponse(
70 const protocol::PairingResponse& pairing_response) override; 90 const protocol::PairingResponse& pairing_response) override;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Used to establish an XMPP connection with the google talk service. 124 // Used to establish an XMPP connection with the google talk service.
105 scoped_ptr<XmppSignalStrategy> signal_strategy_; 125 scoped_ptr<XmppSignalStrategy> signal_strategy_;
106 126
107 DISALLOW_COPY_AND_ASSIGN(TestChromotingClient); 127 DISALLOW_COPY_AND_ASSIGN(TestChromotingClient);
108 }; 128 };
109 129
110 } // namespace test 130 } // namespace test
111 } // namespace remoting 131 } // namespace remoting
112 132
113 #endif // REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_ 133 #endif // REMOTING_TEST_TEST_CHROMOTING_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698