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

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

Issue 1253613002: Updated latency fixture and refactored connection helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "Changed cstdint to stdint.h to compile on mac" Created 5 years, 4 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_APP_REMOTING_LATENCY_TEST_FIXTURE_H_ 5 #ifndef REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_
6 #define REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_ 6 #define REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
13 #include "remoting/test/remote_connection_observer.h" 14 #include "remoting/test/remote_connection_observer.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 16 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
16 17
17 namespace base { 18 namespace base {
18 class RunLoop; 19 class RunLoop;
19 class Timer; 20 class Timer;
20 class TimeDelta; 21 class TimeDelta;
21 } 22 }
22 23
23 namespace webrtc { 24 namespace webrtc {
24 class DesktopRect; 25 class DesktopRect;
25 } 26 }
26 27
27 namespace remoting { 28 namespace remoting {
28 namespace test { 29 namespace test {
29 30
30 struct RemoteApplicationDetails; 31 struct RemoteApplicationDetails;
32 struct RGBValue;
31 class AppRemotingConnectionHelper; 33 class AppRemotingConnectionHelper;
32 class TestVideoRenderer; 34 class TestVideoRenderer;
33 35
36 // Allows for custom handling of ExtensionMessage messages.
37 typedef base::Callback<void(const protocol::ExtensionMessage& message)>
38 HostMessageReceivedCallback;
39
34 // Called to wait for expected image pattern to be matched within up to a max 40 // Called to wait for expected image pattern to be matched within up to a max
35 // wait time. 41 // wait time.
36 typedef base::Callback<bool(const base::TimeDelta& max_wait_time)> 42 typedef base::Callback<bool(const base::TimeDelta& max_wait_time)>
37 WaitForImagePatternMatchCallback; 43 WaitForImagePatternMatchCallback;
38 44
39 // Creates a connection to a remote host which is available for tests to use. 45 // Creates a connection to a remote host which is available for tests to use.
40 // Provides convenient methods to create test cases to measure the input and 46 // Provides convenient methods to create test cases to measure the input and
41 // rendering latency between client and the remote host. 47 // rendering latency between client and the remote host.
42 // NOTE: This is an abstract class. To use it, please derive from this class 48 // NOTE: This is an abstract class. To use it, please derive from this class
43 // and implement GetApplicationDetails to specify the application details. 49 // and implement GetApplicationDetails to specify the application details.
44 class AppRemotingLatencyTestFixture : public testing::Test { 50 class AppRemotingLatencyTestFixture : public testing::Test,
51 public RemoteConnectionObserver {
45 public: 52 public:
46 AppRemotingLatencyTestFixture(); 53 AppRemotingLatencyTestFixture();
47 ~AppRemotingLatencyTestFixture() override; 54 ~AppRemotingLatencyTestFixture() override;
48 55
49 protected: 56 protected:
50 // Set expected image pattern for comparison. 57 // Set expected image pattern for comparison.
51 // A WaitForImagePatternMatchCallback is returned to allow waiting for the 58 // A WaitForImagePatternMatchCallback is returned to allow waiting for the
52 // expected image pattern to be matched. 59 // expected image pattern to be matched.
53 WaitForImagePatternMatchCallback SetExpectedImagePattern( 60 WaitForImagePatternMatchCallback SetExpectedImagePattern(
54 const webrtc::DesktopRect& expected_rect, 61 const webrtc::DesktopRect& expected_rect,
55 uint32_t expected_avg_color); 62 const RGBValue& expected_avg_color);
56 63
57 // Inject press & release key event. 64 // Inject press & release key event.
58 void PressAndReleaseKey(uint32_t usb_keycode); 65 void PressAndReleaseKey(uint32_t usb_keycode);
59 66
60 // Inject press & release a combination of key events. 67 // Inject press & release a combination of key events.
61 void PressAndReleaseKeyCombination(const std::vector<uint32_t>& usb_keycodes); 68 void PressAndReleaseKeyCombination(const std::vector<uint32_t>& usb_keycodes);
62 69
70 // Setter for |host_message_received_callback_|.
71 void SetHostMessageReceivedCallback(
72 const HostMessageReceivedCallback& host_message_received_callback);
73
74 // Reset |host_message_received_callback_| to null.
75 void ResetHostMessageReceivedCallback();
76
77 // Get the details of the application to be run.
78 virtual const RemoteApplicationDetails& GetApplicationDetails() = 0;
79
80 // Used to ensure the application under test is ready for testing.
81 virtual bool PrepareApplicationForTesting() = 0;
82
63 // Clean up the running application to initial state. 83 // Clean up the running application to initial state.
64 virtual void ResetApplicationState(); 84 virtual void ResetApplicationState();
65 85
66 // Get the details of the application to be run.
67 virtual const RemoteApplicationDetails& GetApplicationDetails() = 0;
68
69 // Creates and manages the connection to the remote host. 86 // Creates and manages the connection to the remote host.
70 scoped_ptr<AppRemotingConnectionHelper> connection_helper_; 87 scoped_ptr<AppRemotingConnectionHelper> connection_helper_;
71 88
72 private: 89 private:
73 // testing::Test interface. 90 // testing::Test interface.
74 void SetUp() override; 91 void SetUp() override;
75 void TearDown() override; 92 void TearDown() override;
76 93
94 private:
95 // RemoteConnectionObserver interface.
96 void HostMessageReceived(const protocol::ExtensionMessage& message) override;
97
77 // Inject press key event. 98 // Inject press key event.
78 void PressKey(uint32_t usb_keycode, bool pressed); 99 void PressKey(uint32_t usb_keycode, bool pressed);
79 100
80 // Waits for an image pattern matched reply up to |max_wait_time|. Returns 101 // Waits for an image pattern matched reply up to |max_wait_time|. Returns
81 // true if we received a response within the maximum time limit. 102 // true if we received a response within the maximum time limit.
82 // NOTE: This method should only be run when as a returned callback by 103 // NOTE: This method should only be run when as a returned callback by
83 // SetExpectedImagePattern. 104 // SetExpectedImagePattern.
84 bool WaitForImagePatternMatch(scoped_ptr<base::RunLoop> run_loop, 105 bool WaitForImagePatternMatch(scoped_ptr<base::RunLoop> run_loop,
85 const base::TimeDelta& max_wait_time); 106 const base::TimeDelta& max_wait_time);
86 107
87 // Used to run the thread's message loop. 108 // Used to run the thread's message loop.
88 scoped_ptr<base::RunLoop> run_loop_; 109 scoped_ptr<base::RunLoop> run_loop_;
89 110
90 // Used for setting timeouts and delays. 111 // Used for setting timeouts and delays.
91 scoped_ptr<base::Timer> timer_; 112 scoped_ptr<base::Timer> timer_;
92 113
93 // Used to ensure RemoteConnectionObserver methods are called on the same 114 // Used to ensure RemoteConnectionObserver methods are called on the same
94 // thread. 115 // thread.
95 base::ThreadChecker thread_checker_; 116 base::ThreadChecker thread_checker_;
96 117
97 // Using WeakPtr to keep a reference to TestVideoRenderer while let the 118 // Used to maintain a reference to the TestVideoRenderer instance while it
98 // TestChromotingClient own its lifetime. 119 // exists.
99 base::WeakPtr<TestVideoRenderer> test_video_renderer_; 120 base::WeakPtr<TestVideoRenderer> test_video_renderer_;
100 121
122 // Called when an ExtensionMessage is received from the host. Used to
123 // override default message handling.
124 HostMessageReceivedCallback host_message_received_callback_;
125
101 DISALLOW_COPY_AND_ASSIGN(AppRemotingLatencyTestFixture); 126 DISALLOW_COPY_AND_ASSIGN(AppRemotingLatencyTestFixture);
102 }; 127 };
103 128
104 } // namespace test 129 } // namespace test
105 } // namespace remoting 130 } // namespace remoting
106 131
107 #endif // REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_ 132 #endif // REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_
OLDNEW
« no previous file with comments | « remoting/test/app_remoting_connection_helper.cc ('k') | remoting/test/app_remoting_latency_test_fixture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698