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_CONNECTED_CLIENT_FIXTURE_H_
6 #define REMOTING_TEST_APP_REMOTING_CONNECTED_CLIENT_FIXTURE_H_
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"
24 struct RemoteApplicationDetails
;
25 class AppRemotingConnectionHelper
;
27 // Creates a connection to a remote host which is available for tests to use.
28 // All callbacks must occur on the same thread the object was created on.
29 class AppRemotingConnectedClientFixture
30 : public testing::TestWithParam
<const char*> {
32 AppRemotingConnectedClientFixture();
33 ~AppRemotingConnectedClientFixture() override
;
36 // Sends the request to the host and waits for a reply up to |max_wait_time|.
37 // Returns true if we received a response within the maximum time limit.
38 bool VerifyResponseForSimpleHostMessage(
39 const std::string
& message_request_title
,
40 const std::string
& message_response_title
,
41 const std::string
& message_payload
,
42 const base::TimeDelta
& max_wait_time
);
45 // testing::Test interface.
46 void SetUp() override
;
47 void TearDown() override
;
49 // Contains the details for the application being tested.
50 const RemoteApplicationDetails
& application_details_
;
52 // Used to run the thread's message loop.
53 scoped_ptr
<base::RunLoop
> run_loop_
;
55 // Used for setting timeouts and delays.
56 scoped_ptr
<base::Timer
> timer_
;
58 // Used to ensure RemoteConnectionObserver methods are called on the same
60 base::ThreadChecker thread_checker_
;
62 // Creates and manages the connection to the remote host.
63 scoped_ptr
<AppRemotingConnectionHelper
> connection_helper_
;
65 DISALLOW_COPY_AND_ASSIGN(AppRemotingConnectedClientFixture
);
69 } // namespace remoting
71 #endif // REMOTING_TEST_APP_REMOTING_CONNECTED_CLIENT_FIXTURE_H_