Compute if a layer is clipped outside CalcDrawProps
[chromium-blink-merge.git] / remoting / test / app_remoting_connection_helper.h
blobdd6dad3e470cf9d5a80270af766a57ae4c347212
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_APP_REMOTING_CONNECTION_HELPER_H_
6 #define REMOTING_TEST_APP_REMOTING_CONNECTION_HELPER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread_checker.h"
13 #include "remoting/test/remote_connection_observer.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 namespace base {
17 class RunLoop;
18 class Timer;
19 class Lock;
22 namespace remoting {
23 namespace test {
25 struct RemoteApplicationDetails;
26 class TestChromotingClient;
28 // Allows for custom handling of ExtensionMessage messages.
29 typedef base::Callback<void(const protocol::ExtensionMessage& message)>
30 HostMessageReceivedCallback;
32 // Creates a connection to a remote host which is available for tests to use.
33 // A TestChromotingClient is required from caller.
34 class AppRemotingConnectionHelper
35 : public RemoteConnectionObserver {
36 public:
37 explicit AppRemotingConnectionHelper(
38 const RemoteApplicationDetails& application_details);
39 ~AppRemotingConnectionHelper() override;
41 // Initialize internal structures.
42 void Initialize(scoped_ptr<TestChromotingClient> test_chromoting_client);
44 // Starts a connection with the remote host.
45 // NOTE: Initialize() must be called before calling this method.
46 bool StartConnection();
48 // Stubs used to send messages to the remote host. Caller should not release
49 // the objects.
50 protocol::ClipboardStub* clipboard_forwarder();
51 protocol::HostStub* host_stub();
52 protocol::InputStub* input_stub();
54 // Setter for |host_message_received_callback_|.
55 void SetHostMessageReceivedCallback(
56 HostMessageReceivedCallback host_message_received_callback);
58 private:
59 // RemoteConnectionObserver interface.
60 void ConnectionStateChanged(protocol::ConnectionToHost::State state,
61 protocol::ErrorCode error_code) override;
62 void ConnectionReady(bool ready) override;
63 void HostMessageReceived(const protocol::ExtensionMessage& message) override;
65 // Sends client details to the host in order to complete the connection.
66 void SendClientConnectionDetailsToHost();
68 // Handles onWindowAdded messages from the host.
69 void HandleOnWindowAddedMessage(
70 const remoting::protocol::ExtensionMessage& message);
72 // Contains the details for the application being tested.
73 const RemoteApplicationDetails& application_details_;
75 // Called when an ExtensionMessage is received from the host. Used to
76 // override default message handling.
77 HostMessageReceivedCallback host_message_received_callback_;
79 // Indicates whether the remote connection is ready to be used for testing.
80 // True when a chromoting connection to the remote host has been established
81 // and the main application window is visible.
82 bool connection_is_ready_for_tests_;
84 // Used to run the thread's message loop.
85 scoped_ptr<base::RunLoop> run_loop_;
87 // Used for setting timeouts and delays.
88 scoped_ptr<base::Timer> timer_;
90 // Used to ensure RemoteConnectionObserver methods are called on the same
91 // thread.
92 base::ThreadChecker thread_checker_;
94 // Creates and manages the connection to the remote host.
95 scoped_ptr<TestChromotingClient> client_;
97 DISALLOW_COPY_AND_ASSIGN(AppRemotingConnectionHelper);
100 } // namespace test
101 } // namespace remoting
103 #endif // REMOTING_TEST_APP_REMOTING_CONNECTION_HELPER_H_