Chromium Code Reviews| 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..682d90d71ab2f7dba1ca3e259243587296cff8a5 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 kClientPINSwitchName[] = "client-pin"; |
|
joedow
2015/07/14 19:58:44
kClientPinSwitchName, also, is this a client pin?
tonychun
2015/07/15 17:32:50
Changed it to kPinSwitchName.
|
| 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::kClientPINSwitchName); |
| 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,24 @@ 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; |
| + // For some connection, a client_pin is not required. Thus, I did not make it |
|
joedow
2015/07/14 19:58:44
s/connection/connections
tonychun
2015/07/15 17:32:50
Done.
|
| + // a requirement. |
|
joedow
2015/07/14 19:58:44
Actually, I'm wondering if this comment is needed.
tonychun
2015/07/15 17:32:50
Removed.
|
| + const std::string client_pin = |
| + command_line->GetSwitchValueASCII(switches::kClientPINSwitchName); |
| + |
| // 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 +280,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 +293,27 @@ int main(int argc, char* argv[]) { |
| run_loop->Run(); |
| + run_loop.reset(new base::RunLoop()); |
| + |
| + base::Timer* timer = new base::Timer(true, false); |
|
joedow
2015/07/14 19:58:44
If this needs to be a pointer then use a scoped_pt
tonychun
2015/07/15 17:32:50
Done.
|
| + |
| + remoting::test::TestChromotingClient test_chromoting_client; |
| + |
| + // Find the requested online host info and initiate a session. |
| + for (auto host_info : hostlist) { |
|
joedow
2015/07/14 19:58:44
Instead of using a loop here, just use find() on h
tonychun
2015/07/15 17:32:50
Done.
|
| + if (host_info.IsReadyForConnection() && host_info.host_name == hostname) { |
| + // Total time to connect to a remote host before aborting the connection. |
| + timer->Start(FROM_HERE, base::TimeDelta::FromSeconds(10), |
| + run_loop->QuitClosure()); |
| + test_chromoting_client.StartConnection(username, access_token, |
| + client_pin, host_info); |
| + run_loop->Run(); |
| + timer->Stop(); |
| + break; |
| + } |
| + } |
| + |
| + test_chromoting_client.EndConnection(); |
| + |
| return 0; |
| } |