Index: remoting/test/chromoting_test_driver.cc |
diff --git a/remoting/test/chromoting_test_driver.cc b/remoting/test/chromoting_test_driver.cc |
index 5641f1c15164b06feebd6c6149659956d4d44298..cdddbb56fe674fed409475e273dd96dbaeda22a8 100644 |
--- a/remoting/test/chromoting_test_driver.cc |
+++ b/remoting/test/chromoting_test_driver.cc |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
#include <string> |
+#include <vector> |
#include "base/bind.h" |
#include "base/command_line.h" |
@@ -16,6 +17,7 @@ |
#include "google_apis/google_api_keys.h" |
#include "net/base/escape.h" |
#include "remoting/test/access_token_fetcher.h" |
+#include "remoting/test/chromoting_host_info.h" |
#include "remoting/test/refresh_token_store.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -63,13 +65,20 @@ void PrintUsage() { |
printf("\nRequired Parameters:\n"); |
printf(" %s: Specifies which account to use when running tests\n", |
switches::kUserNameSwitchName); |
+ printf(" %s: Specifies which host to connect to when running tests\n", |
+ switches::kHostNameSwitchName); |
printf("\nOptional Parameters:\n"); |
printf(" %s: Exchanged for a refresh and access token for authentication\n", |
switches::kAuthCodeSwitchName); |
- printf(" %s: Path to a JSON file containing username/refresh_token KVPs\n", |
- switches::kRefreshTokenPathSwitchName); |
printf(" %s: Displays additional usage information\n", |
switches::kHelpSwitchName); |
+ printf(" %s: Path to a JSON file containing username/refresh_token KVPs\n", |
+ switches::kRefreshTokenPathSwitchName); |
+ printf( |
+ " %s: Specifies the optional logging level of the tool (0-3)." |
joedow
2015/07/01 03:39:34
Why is this indented down? I think there is enoug
tonychun
2015/07/06 20:11:50
Done.
|
+ " [default: off]\n", |
+ switches::kLoggingLevelSwitchName); |
+ |
} |
void PrintAuthCodeInfo() { |
@@ -127,6 +136,11 @@ void PrintJsonFileInfo() { |
switches::kRefreshTokenPathSwitchName); |
joedow
2015/07/01 03:39:34
hostname?
tonychun
2015/07/06 20:11:50
Done.
|
} |
+// TODO(TonyChun): Using a namespace global temp string variable that is used to |
+// save the access_token value in the callback. Will be removed once an |
+// environment is created. |
+std::string temp_access_token; |
joedow
2015/07/01 03:39:34
A cleaner way to do this would be to add an extra
tonychun
2015/07/06 20:11:50
Done.
|
+ |
} // namespace |
void OnAccessTokenRetrieved( |
@@ -135,9 +149,21 @@ void OnAccessTokenRetrieved( |
const std::string& refresh_token) { |
DVLOG(1) << "OnAccessTokenRetrieved() Called"; |
- |
DVLOG(1) << "Access Token: " << access_token; |
+ temp_access_token = access_token; |
+ |
+ done_closure.Run(); |
+} |
+ |
+void OnHostlistRetrieved( |
+ base::Closure done_closure, |
+ std::vector<remoting::test::ChromotingHostInfo>* hostlist, |
+ const std::vector<remoting::test::ChromotingHostInfo>& retrieved_hostlist) { |
+ DVLOG(1) << "OnHostlistRetrieved() Called"; |
+ |
joedow
2015/07/01 03:39:34
DCHECK(hostlist);
tonychun
2015/07/06 20:11:50
Done.
|
+ *hostlist = retrieved_hostlist; |
+ |
done_closure.Run(); |
} |
@@ -221,10 +247,11 @@ int main(int argc, char* argv[]) { |
// Uses the refresh token to get the access token from GAIA. |
remoting::test::AccessTokenFetcher access_token_fetcher; |
- base::RunLoop run_loop; |
+ // Thread to handle callback from GAIA. |
+ base::RunLoop access_token_run_loop; |
joedow
2015/07/01 03:39:34
nit: if you use a scoped_ptr<base::RunLoop> you ca
tonychun
2015/07/06 20:11:50
Done.
|
remoting::test::AccessTokenCallback access_token_callback = |
- base::Bind(&OnAccessTokenRetrieved, run_loop.QuitClosure()); |
+ base::Bind(&OnAccessTokenRetrieved, access_token_run_loop.QuitClosure()); |
if (!auth_code.empty()) { |
access_token_fetcher.GetAccessTokenFromAuthCode(auth_code, |
@@ -235,7 +262,25 @@ int main(int argc, char* argv[]) { |
access_token_callback); |
} |
- run_loop.Run(); |
+ access_token_run_loop.Run(); |
+ |
+ // Thread to handle callback from Directory service. |
joedow
2015/07/01 03:39:34
This isn't a thread, it's a runloop which just yie
tonychun
2015/07/06 20:11:50
Done.
|
+ base::RunLoop hostlist_run_loop; |
+ |
+ std::vector<remoting::test::ChromotingHostInfo> hostlist; |
+ |
+ remoting::test::HostlistCallback hostlist_fetch_callback = base::Bind( |
+ &OnHostlistRetrieved, hostlist_run_loop.QuitClosure(), &hostlist); |
+ |
+ // Uses the access token to get the hostlist from the Directory service. |
+ remoting::test::HostlistFetcher hostlist_fetcher; |
+ |
+ hostlist_fetcher.RetrieveHostlist( |
+ temp_access_token, |
+ remoting::test::ServiceEnvironment::kProductionEnvironment, |
+ hostlist_fetch_callback); |
+ |
+ hostlist_run_loop.Run(); |
return 0; |
} |