Updated latency fixture to match internal classes and refactored
connection helper.

1. Moved the Open new document logic to the SetUp function to enforce
a fresh document for tests.

2. Refactored connection helper to make it as minimum as possible, and
moved the ping response verify logic to the connected client fixture.

BUG=

Review URL: https://codereview.chromium.org/1253613002

Cr-Commit-Position: refs/heads/master@{#340588}
diff --git a/remoting/test/app_remoting_connection_helper.cc b/remoting/test/app_remoting_connection_helper.cc
index 38b86f7..f39b398 100644
--- a/remoting/test/app_remoting_connection_helper.cc
+++ b/remoting/test/app_remoting_connection_helper.cc
@@ -4,7 +4,6 @@
 
 #include "remoting/test/app_remoting_connection_helper.h"
 
-#include "base/callback_helpers.h"
 #include "base/json/json_reader.h"
 #include "base/logging.h"
 #include "base/run_loop.h"
@@ -37,7 +36,9 @@
 AppRemotingConnectionHelper::~AppRemotingConnectionHelper() {
   // |client_| destroys some of its members via DeleteSoon on the message loop's
   // TaskRunner so we need to run the loop until it has no more work to do.
-  client_->RemoveRemoteConnectionObserver(this);
+  if (!connection_is_ready_for_tests_) {
+    client_->RemoveRemoteConnectionObserver(this);
+  }
   client_.reset();
 
   base::RunLoop().RunUntilIdle();
@@ -49,11 +50,6 @@
   client_->AddRemoteConnectionObserver(this);
 }
 
-void AppRemotingConnectionHelper::SetHostMessageReceivedCallback(
-      HostMessageReceivedCallback host_message_received_callback) {
-  host_message_received_callback_ = host_message_received_callback;
-}
-
 bool AppRemotingConnectionHelper::StartConnection() {
   DCHECK(thread_checker_.CalledOnValidThread());
   DCHECK(client_);
@@ -145,11 +141,7 @@
   VLOG(2) << "HostMessage received by HostMessageReceived()."
           << " type: " << message.type() << " data: " << message.data();
 
-  // If a callback is not registered, then the message is passed to a default
-  // handler for the class based on the message type.
-  if (!host_message_received_callback_.is_null()) {
-    base::ResetAndReturn(&host_message_received_callback_).Run(message);
-  } else if (message.type() == "onWindowAdded") {
+  if (message.type() == "onWindowAdded") {
     HandleOnWindowAddedMessage(message);
   } else {
     VLOG(2) << "HostMessage not handled by HostMessageReceived().";
@@ -209,6 +201,7 @@
   std::string main_window_title = application_details_.main_window_title;
   if (current_window_title.find_first_of(main_window_title) == 0) {
     connection_is_ready_for_tests_ = true;
+    client_->RemoveRemoteConnectionObserver(this);
 
     if (timer_->IsRunning()) {
       timer_->Stop();