| OLD | NEW |
| 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/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "remoting/test/remote_connection_observer.h" | 13 #include "remoting/test/remote_connection_observer.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 16 #include "ui/events/keycodes/dom/dom_code.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 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // A WaitForImagePatternMatchCallback is returned to allow waiting for the | 58 // A WaitForImagePatternMatchCallback is returned to allow waiting for the |
| 58 // expected image pattern to be matched. | 59 // expected image pattern to be matched. |
| 59 WaitForImagePatternMatchCallback SetExpectedImagePattern( | 60 WaitForImagePatternMatchCallback SetExpectedImagePattern( |
| 60 const webrtc::DesktopRect& expected_rect, | 61 const webrtc::DesktopRect& expected_rect, |
| 61 const RGBValue& expected_avg_color); | 62 const RGBValue& expected_avg_color); |
| 62 | 63 |
| 63 // Turn on/off saving video frames to disk. | 64 // Turn on/off saving video frames to disk. |
| 64 void SaveFrameDataToDisk(bool save_frame_data_to_disk); | 65 void SaveFrameDataToDisk(bool save_frame_data_to_disk); |
| 65 | 66 |
| 66 // Inject press & release key event. | 67 // Inject press & release key event. |
| 67 void PressAndReleaseKey(uint32_t usb_keycode); | 68 void PressAndReleaseKey(ui::DomCode usb_keycode); |
| 68 | 69 |
| 69 // Inject press & release a combination of key events. | 70 // Inject press & release a combination of key events. |
| 70 void PressAndReleaseKeyCombination(const std::vector<uint32_t>& usb_keycodes); | 71 void PressAndReleaseKeyCombination( |
| 72 const std::vector<ui::DomCode>& usb_keycodes); |
| 71 | 73 |
| 72 // Setter for |host_message_received_callback_|. | 74 // Setter for |host_message_received_callback_|. |
| 73 void SetHostMessageReceivedCallback( | 75 void SetHostMessageReceivedCallback( |
| 74 const HostMessageReceivedCallback& host_message_received_callback); | 76 const HostMessageReceivedCallback& host_message_received_callback); |
| 75 | 77 |
| 76 // Reset |host_message_received_callback_| to null. | 78 // Reset |host_message_received_callback_| to null. |
| 77 void ResetHostMessageReceivedCallback(); | 79 void ResetHostMessageReceivedCallback(); |
| 78 | 80 |
| 79 // Get the details of the application to be run. | 81 // Get the details of the application to be run. |
| 80 virtual const RemoteApplicationDetails& GetApplicationDetails() = 0; | 82 virtual const RemoteApplicationDetails& GetApplicationDetails() = 0; |
| 81 | 83 |
| 82 // Used to ensure the application under test is ready for testing. | 84 // Used to ensure the application under test is ready for testing. |
| 83 virtual bool PrepareApplicationForTesting() = 0; | 85 virtual bool PrepareApplicationForTesting() = 0; |
| 84 | 86 |
| 85 // Clean up the running application to initial state. | 87 // Clean up the running application to initial state. |
| 86 virtual void ResetApplicationState(); | 88 virtual void ResetApplicationState(); |
| 87 | 89 |
| 88 // Creates and manages the connection to the remote host. | 90 // Creates and manages the connection to the remote host. |
| 89 scoped_ptr<AppRemotingConnectionHelper> connection_helper_; | 91 scoped_ptr<AppRemotingConnectionHelper> connection_helper_; |
| 90 | 92 |
| 91 private: | 93 private: |
| 92 // testing::Test interface. | 94 // testing::Test interface. |
| 93 void SetUp() override; | 95 void SetUp() override; |
| 94 void TearDown() override; | 96 void TearDown() override; |
| 95 | 97 |
| 96 // RemoteConnectionObserver interface. | 98 // RemoteConnectionObserver interface. |
| 97 void HostMessageReceived(const protocol::ExtensionMessage& message) override; | 99 void HostMessageReceived(const protocol::ExtensionMessage& message) override; |
| 98 | 100 |
| 99 // Inject press key event. | 101 // Inject press key event. |
| 100 void PressKey(uint32_t usb_keycode, bool pressed); | 102 void PressKey(ui::DomCode usb_keycode, bool pressed); |
| 101 | 103 |
| 102 // Waits for an image pattern matched reply up to |max_wait_time|. Returns | 104 // Waits for an image pattern matched reply up to |max_wait_time|. Returns |
| 103 // true if we received a response within the maximum time limit. | 105 // true if we received a response within the maximum time limit. |
| 104 // NOTE: This method should only be run when as a returned callback by | 106 // NOTE: This method should only be run when as a returned callback by |
| 105 // SetExpectedImagePattern. | 107 // SetExpectedImagePattern. |
| 106 bool WaitForImagePatternMatch(scoped_ptr<base::RunLoop> run_loop, | 108 bool WaitForImagePatternMatch(scoped_ptr<base::RunLoop> run_loop, |
| 107 const base::TimeDelta& max_wait_time); | 109 const base::TimeDelta& max_wait_time); |
| 108 | 110 |
| 109 // Used to run the thread's message loop. | 111 // Used to run the thread's message loop. |
| 110 scoped_ptr<base::RunLoop> run_loop_; | 112 scoped_ptr<base::RunLoop> run_loop_; |
| 111 | 113 |
| 112 // Used for setting timeouts and delays. | 114 // Used for setting timeouts and delays. |
| 113 scoped_ptr<base::Timer> timer_; | 115 scoped_ptr<base::Timer> timer_; |
| 114 | 116 |
| 115 // Used to maintain a reference to the TestVideoRenderer instance while it | 117 // Used to maintain a reference to the TestVideoRenderer instance while it |
| 116 // exists. | 118 // exists. |
| 117 base::WeakPtr<TestVideoRenderer> test_video_renderer_; | 119 base::WeakPtr<TestVideoRenderer> test_video_renderer_; |
| 118 | 120 |
| 119 // Called when an ExtensionMessage is received from the host. Used to | 121 // Called when an ExtensionMessage is received from the host. Used to |
| 120 // override default message handling. | 122 // override default message handling. |
| 121 HostMessageReceivedCallback host_message_received_callback_; | 123 HostMessageReceivedCallback host_message_received_callback_; |
| 122 | 124 |
| 123 DISALLOW_COPY_AND_ASSIGN(AppRemotingLatencyTestFixture); | 125 DISALLOW_COPY_AND_ASSIGN(AppRemotingLatencyTestFixture); |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 } // namespace test | 128 } // namespace test |
| 127 } // namespace remoting | 129 } // namespace remoting |
| 128 | 130 |
| 129 #endif // REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_ | 131 #endif // REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_ |
| OLD | NEW |