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

Side by Side Diff: remoting/test/chromoting_test_driver.cc

Issue 1238343002: Added ConnectionTimeObserver to calculate the times to authenticate and connect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced with recent changes to connect to local host and cleaned up Connection Time Observer. 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 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 #include <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/test/test_suite.h" 15 #include "base/test/test_suite.h"
16 #include "base/test/test_switches.h" 16 #include "base/test/test_switches.h"
17 #include "google_apis/google_api_keys.h" 17 #include "google_apis/google_api_keys.h"
18 #include "net/base/escape.h" 18 #include "net/base/escape.h"
19 #include "remoting/test/access_token_fetcher.h" 19 #include "remoting/test/access_token_fetcher.h"
20 #include "remoting/test/connection_time_observer.h"
20 #include "remoting/test/host_info.h" 21 #include "remoting/test/host_info.h"
21 #include "remoting/test/host_list_fetcher.h" 22 #include "remoting/test/host_list_fetcher.h"
22 #include "remoting/test/refresh_token_store.h" 23 #include "remoting/test/refresh_token_store.h"
23 #include "remoting/test/test_chromoting_client.h" 24 #include "remoting/test/test_chromoting_client.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 namespace switches { 27 namespace switches {
27 const char kAuthCodeSwitchName[] = "authcode"; 28 const char kAuthCodeSwitchName[] = "authcode";
28 const char kPinSwitchName[] = "pin"; 29 const char kPinSwitchName[] = "pin";
29 const char kHelpSwitchName[] = "help"; 30 const char kHelpSwitchName[] = "help";
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 299
299 // Check if requested host is online and ready to receive connections. 300 // Check if requested host is online and ready to receive connections.
300 auto it = std::find_if(hostlist.begin(), hostlist.end(), 301 auto it = std::find_if(hostlist.begin(), hostlist.end(),
301 [&hostname](const remoting::test::HostInfo& host_info) { 302 [&hostname](const remoting::test::HostInfo& host_info) {
302 return host_info.host_name == hostname && 303 return host_info.host_name == hostname &&
303 host_info.IsReadyForConnection(); 304 host_info.IsReadyForConnection();
304 }); 305 });
305 if (it != hostlist.end()) { 306 if (it != hostlist.end()) {
306 // Host is online and ready, initiate a remote session. 307 // Host is online and ready, initiate a remote session.
307 base::Timer timer(true, false); 308 base::Timer timer(true, false);
309 remoting::test::ConnectionTimeObserver observer;
310 test_chromoting_client.AddRemoteConnectionObserver(&observer);
311
312 // The timer will forcefully end the chromoting connection process in
313 // |kConnectionTimeoutSeconds| seconds. The set limit on time to connect
314 // stops the client from waiting indefinitely for a connection.
308 timer.Start(FROM_HERE, 315 timer.Start(FROM_HERE,
309 base::TimeDelta::FromSeconds(kConnectionTimeoutSeconds), 316 base::TimeDelta::FromSeconds(kConnectionTimeoutSeconds),
310 run_loop->QuitClosure()); 317 run_loop->QuitClosure());
311 test_chromoting_client.StartConnection( 318 test_chromoting_client.StartConnection(
312 it->GenerateConnectionSetupInfo(access_token, username, pin)); 319 it->GenerateConnectionSetupInfo(access_token, username, pin));
313 run_loop->Run(); 320 run_loop->Run();
321
322 test_chromoting_client.RemoveRemoteConnectionObserver(&observer);
314 test_chromoting_client.EndConnection(); 323 test_chromoting_client.EndConnection();
315 } else { 324 } else {
316 LOG(ERROR) << "Requested host not found or not ready to connect"; 325 LOG(ERROR) << "Requested host not found or not ready to connect";
317 } 326 }
318 327
319 return 0; 328 return 0;
320 } 329 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698