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_LATENCY_TEST_FIXTURE_H_
6 #define REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_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"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
29 struct RemoteApplicationDetails
;
30 class AppRemotingConnectionHelper
;
31 class TestVideoRenderer
;
33 // Creates a connection to a remote host which is available for tests to use.
34 // Provides convenient methods to create test cases to measure the input and
35 // rendering latency between client and the remote host.
36 // NOTE: This is an abstract class. To use it, please derive from this class
37 // and initialize the application names in constructor.
38 class AppRemotingLatencyTestFixture
: public testing::Test
{
40 AppRemotingLatencyTestFixture();
41 ~AppRemotingLatencyTestFixture() override
;
44 // Set expected image pattern for comparison and a matched reply will be
45 // called when the pattern is matched.
46 void SetExpectedImagePattern(const webrtc::DesktopRect
& expected_rect
,
47 uint32_t expected_avg_color
);
49 // Waits for an image pattern matched reply up to |max_wait_time|. Returns
50 // true if we received a response within the maximum time limit.
51 // NOTE: SetExpectedImagePattern() must be called before calling this method.
52 bool WaitForImagePatternMatched(const base::TimeDelta
& max_wait_time
);
54 // Name of the application being tested.
55 // NOTE: Must be initialized in the constructor of derived class.
56 std::string application_name_
;
59 // testing::Test interface.
60 void SetUp() override
;
61 void TearDown() override
;
63 // Contains the details for the application being tested.
64 const RemoteApplicationDetails
& application_details_
;
66 // Used to run the thread's message loop.
67 scoped_ptr
<base::RunLoop
> run_loop_
;
69 // Used for setting timeouts and delays.
70 scoped_ptr
<base::Timer
> timer_
;
72 // Creates and manages the connection to the remote host.
73 scoped_ptr
<AppRemotingConnectionHelper
> connection_helper_
;
75 // Used to ensure RemoteConnectionObserver methods are called on the same
77 base::ThreadChecker thread_checker_
;
79 // Using WeakPtr to keep a reference to TestVideoRenderer while let the
80 // TestChromotingClient own its lifetime.
81 base::WeakPtr
<TestVideoRenderer
> test_video_renderer_
;
83 DISALLOW_COPY_AND_ASSIGN(AppRemotingLatencyTestFixture
);
87 } // namespace remoting
89 #endif // REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_