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

Unified 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: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: remoting/test/app_remoting_latency_test_fixture.h
diff --git a/remoting/test/app_remoting_latency_test_fixture.h b/remoting/test/app_remoting_latency_test_fixture.h
index b23465ebc516ed27a1c7f13f5dcaabdd1c417dd8..4ea52ccb4ffa272d3a360c534e25b7c3940b49e2 100644
--- a/remoting/test/app_remoting_latency_test_fixture.h
+++ b/remoting/test/app_remoting_latency_test_fixture.h
@@ -5,8 +5,10 @@
#ifndef REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_
#define REMOTING_TEST_APP_REMOTING_LATENCY_TEST_FIXTURE_H_
+#include <string>
#include <vector>
+#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
@@ -30,6 +32,11 @@ namespace test {
struct RemoteApplicationDetails;
class AppRemotingConnectionHelper;
class TestVideoRenderer;
+class TestChromotingClient;
+
+// Allows for custom handling of ExtensionMessage messages.
+typedef base::Callback<void(const protocol::ExtensionMessage& message)>
+ HostMessageReceivedCallback;
// Called to wait for expected image pattern to be matched within up to a max
// wait time.
@@ -41,7 +48,8 @@ typedef base::Callback<bool(const base::TimeDelta& max_wait_time)>
// rendering latency between client and the remote host.
// NOTE: This is an abstract class. To use it, please derive from this class
// and implement GetApplicationDetails to specify the application details.
-class AppRemotingLatencyTestFixture : public testing::Test {
+class AppRemotingLatencyTestFixture : public testing::Test,
+ public RemoteConnectionObserver {
public:
AppRemotingLatencyTestFixture();
~AppRemotingLatencyTestFixture() override;
@@ -60,12 +68,25 @@ class AppRemotingLatencyTestFixture : public testing::Test {
// Inject press & release a combination of key events.
void PressAndReleaseKeyCombination(const std::vector<uint32_t>& usb_keycodes);
- // Clean up the running application to initial state.
- virtual void ResetApplicationState();
+ // Setter for |host_message_received_callback_|.
+ void SetHostMessageReceivedCallback(
+ HostMessageReceivedCallback host_message_received_callback) {
+ host_message_received_callback_ = host_message_received_callback;
+ }
+
+ void ResetHostMessageReceivedCallback() {
+ host_message_received_callback_.Reset();
+ }
// Get the details of the application to be run.
virtual const RemoteApplicationDetails& GetApplicationDetails() = 0;
+ // Create a fresh document for test.
+ virtual bool CreateNewDocument() = 0;
joedow 2015/07/23 20:26:56 I probably wouldn't name this 'CreateNewDocument'
liaoyuke 2015/07/24 02:07:28 Done.
+
+ // Clean up the running application to initial state.
+ virtual void ResetApplicationState();
+
// Creates and manages the connection to the remote host.
scoped_ptr<AppRemotingConnectionHelper> connection_helper_;
@@ -74,6 +95,10 @@ class AppRemotingLatencyTestFixture : public testing::Test {
void SetUp() override;
void TearDown() override;
+ private:
+ // RemoteConnectionObserver interface.
+ void HostMessageReceived(const protocol::ExtensionMessage& message) override;
+
// Inject press key event.
void PressKey(uint32_t usb_keycode, bool pressed);
@@ -95,9 +120,17 @@ class AppRemotingLatencyTestFixture : public testing::Test {
base::ThreadChecker thread_checker_;
// Using WeakPtr to keep a reference to TestVideoRenderer while let the
- // TestChromotingClient own its lifetime.
+ // AppRemotingConnectionHelper own its lifetime.
joedow 2015/07/23 20:26:56 nit: reword this: "Used to maintain a reference to
liaoyuke 2015/07/24 02:07:28 Done.
base::WeakPtr<TestVideoRenderer> test_video_renderer_;
+ // Using WeakPtr to keep a reference to TestChromotingClient while let the
+ // AppRemotingConnectionHelper own its lifetime.
joedow 2015/07/23 20:26:56 nit: reword this: "Used to maintain a reference to
liaoyuke 2015/07/24 02:07:28 Acknowledged.
+ base::WeakPtr<TestChromotingClient> test_chromoting_client_;
+
+ // Called when an ExtensionMessage is received from the host. Used to
+ // override default message handling.
+ HostMessageReceivedCallback host_message_received_callback_;
+
DISALLOW_COPY_AND_ASSIGN(AppRemotingLatencyTestFixture);
};

Powered by Google App Engine
This is Rietveld 408576698