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

Unified Diff: remoting/test/chromoting_test_driver.cc

Issue 1237093004: Support for connecting to localhost on the chromoting test driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored App Remoting and Chromoting code to share StartConnection method. 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/chromoting_test_driver.cc
diff --git a/remoting/test/chromoting_test_driver.cc b/remoting/test/chromoting_test_driver.cc
index bae3ca7713427369038505a01edac12f1e4b9ff6..cb7f41a86b2cee615e5ada35c547616cde15682b 100644
--- a/remoting/test/chromoting_test_driver.cc
+++ b/remoting/test/chromoting_test_driver.cc
@@ -20,10 +20,12 @@
#include "remoting/test/host_info.h"
#include "remoting/test/host_list_fetcher.h"
#include "remoting/test/refresh_token_store.h"
+#include "remoting/test/test_chromoting_client.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace switches {
const char kAuthCodeSwitchName[] = "authcode";
+const char kPinSwitchName[] = "pin";
const char kHelpSwitchName[] = "help";
const char kHostNameSwitchName[] = "hostname";
const char kLoggingLevelSwitchName[] = "verbosity";
@@ -76,9 +78,11 @@ void PrintUsage() {
switches::kHelpSwitchName);
printf(" %s: Path to a JSON file containing username/refresh_token KVPs\n",
switches::kRefreshTokenPathSwitchName);
+ printf(" %s: Used to authenticate a chromoting connection with the host\n",
+ switches::kPinSwitchName);
printf(" %s: Specifies the optional logging level of the tool (0-3)."
" [default: off]\n",
- switches::kLoggingLevelSwitchName);
+ switches::kLoggingLevelSwitchName);
}
void PrintAuthCodeInfo() {
@@ -205,9 +209,8 @@ int main(int argc, char* argv[]) {
// The username is used to run the tests and determines which refresh token to
// select in the refresh token file.
- std::string username =
+ const std::string username =
command_line->GetSwitchValueASCII(switches::kUserNameSwitchName);
-
if (username.empty()) {
LOG(ERROR) << "No username passed in, can't authenticate or run tests!";
return -1;
@@ -219,20 +222,22 @@ int main(int argc, char* argv[]) {
std::string auth_code =
command_line->GetSwitchValueASCII(switches::kAuthCodeSwitchName);
- base::FilePath refresh_token_path =
+ const base::FilePath refresh_token_path =
command_line->GetSwitchValuePath(switches::kRefreshTokenPathSwitchName);
// The hostname determines which host to initiate a session with from the list
// returned from the directory service.
- std::string hostname =
+ const std::string hostname =
command_line->GetSwitchValueASCII(switches::kHostNameSwitchName);
-
if (hostname.empty()) {
- LOG(ERROR) << "No hostname passed in, connect to host requires hostname!";
+ LOG(ERROR) << "No hostname passed in, finding the host requires hostname!";
return -1;
}
VLOG(1) << "Chromoting tests will connect to: " << hostname;
+ const std::string pin =
+ command_line->GetSwitchValueASCII(switches::kPinSwitchName);
+
// TODO(TonyChun): Move this logic into a shared environment class.
scoped_ptr<remoting::test::RefreshTokenStore> refresh_token_store =
remoting::test::RefreshTokenStore::OnDisk(username, refresh_token_path);
@@ -273,7 +278,7 @@ int main(int argc, char* argv[]) {
run_loop->Run();
- // RunLoop to handle callback from directory service.
+ // Reset runloop to use it to retrieve hostlist from directory service.
run_loop.reset(new base::RunLoop());
std::vector<remoting::test::HostInfo> hostlist;
@@ -286,5 +291,29 @@ int main(int argc, char* argv[]) {
run_loop->Run();
+ run_loop.reset(new base::RunLoop());
+
+ scoped_ptr<base::Timer> timer =
+ make_scoped_ptr<base::Timer>(new base::Timer(true, false));
+
+ remoting::test::TestChromotingClient test_chromoting_client;
+
+ // Find the requested online host info and initiate a session.
anandc 2015/07/15 21:12:29 "Check if requested host is online and ready to re
tonychun 2015/07/16 23:12:08 Done.
+ auto it = std::find_if(hostlist.begin(), hostlist.end(),
+ [&hostname](const remoting::test::HostInfo& host_info) {
+ return host_info.host_name == hostname &&
+ host_info.IsReadyForConnection();
+ });
+ if (it != hostlist.end()) {
+ // Total time to connect to a remote host before aborting the connection.
anandc 2015/07/15 21:12:29 "Host is online and ready, initiate a remote sessi
tonychun 2015/07/16 23:12:08 Done.
+ timer->Start(FROM_HERE, base::TimeDelta::FromSeconds(10),
anandc 2015/07/15 21:12:29 Make it a constant? Or explain the reason for usin
tonychun 2015/07/16 23:12:08 Done.
+ run_loop->QuitClosure());
+ test_chromoting_client.StartConnection(
+ it->GenerateConnectionInfo(access_token, username, pin));
+ run_loop->Run();
+ timer->Stop();
+ test_chromoting_client.EndConnection();
+ }
+
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698