OLD | NEW |
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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/test/launcher/unit_test_launcher.h" | 12 #include "base/test/launcher/unit_test_launcher.h" |
13 #include "base/test/test_suite.h" | 13 #include "base/test/test_suite.h" |
14 #include "base/test/test_switches.h" | 14 #include "base/test/test_switches.h" |
15 #include "google_apis/google_api_keys.h" | 15 #include "google_apis/google_api_keys.h" |
16 #include "net/base/escape.h" | 16 #include "net/base/escape.h" |
17 #include "remoting/test/app_remoting_test_driver_environment.h" | 17 #include "remoting/test/app_remoting_test_driver_environment.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace switches { | 20 namespace switches { |
21 const char kAuthCodeSwitchName[] = "authcode"; | 21 const char kAuthCodeSwitchName[] = "authcode"; |
22 const char kHelpSwitchName[] = "help"; | 22 const char kHelpSwitchName[] = "help"; |
23 const char kLoggingLevelSwitchName[] = "verbosity"; | 23 const char kLoggingLevelSwitchName[] = "verbosity"; |
24 const char kRefreshTokenFileSwitchName[] = "refresh-token-file"; | 24 const char kRefreshTokenFileSwitchName[] = "refresh-token-file"; |
25 const char kReleaseHostsAfterTestingSwitchName[] = "release-hosts-after-tests"; | 25 const char kReleaseHostsAfterTestingSwitchName[] = "release-hosts-after-tests"; |
26 const char kServiceEnvironmentSwitchName[] = "environment"; | |
27 const char kShowHostAvailabilitySwitchName[] = "show-host-availability"; | 26 const char kShowHostAvailabilitySwitchName[] = "show-host-availability"; |
28 const char kSingleProcessTestsSwitchName[] = "single-process-tests"; | 27 const char kSingleProcessTestsSwitchName[] = "single-process-tests"; |
29 const char kUserNameSwitchName[] = "username"; | 28 const char kUserNameSwitchName[] = "username"; |
30 } // namespace switches | 29 } // namespace switches |
31 | 30 |
32 namespace { | 31 namespace { |
33 | 32 |
34 // Requested permissions needed for App Remoting tests. The spaces in between | 33 // Requested permissions needed for App Remoting tests. The spaces in between |
35 // scope fragments are necessary and will be escaped properly before use. | 34 // scope fragments are necessary and will be escaped properly before use. |
36 const char kAppRemotingAuthScopeValues[] = | 35 const char kAppRemotingAuthScopeValues[] = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 printf("\nRequired Parameters:\n"); | 67 printf("\nRequired Parameters:\n"); |
69 printf(" %s: Specifies which account to use when running tests\n", | 68 printf(" %s: Specifies which account to use when running tests\n", |
70 switches::kUserNameSwitchName); | 69 switches::kUserNameSwitchName); |
71 printf("\nOptional Parameters:\n"); | 70 printf("\nOptional Parameters:\n"); |
72 printf(" %s: Exchanged for a refresh and access token for authentication\n", | 71 printf(" %s: Exchanged for a refresh and access token for authentication\n", |
73 switches::kAuthCodeSwitchName); | 72 switches::kAuthCodeSwitchName); |
74 printf(" %s: Path to a JSON file containing username/refresh_token KVPs\n", | 73 printf(" %s: Path to a JSON file containing username/refresh_token KVPs\n", |
75 switches::kRefreshTokenFileSwitchName); | 74 switches::kRefreshTokenFileSwitchName); |
76 printf(" %s: Displays additional usage information\n", | 75 printf(" %s: Displays additional usage information\n", |
77 switches::kHelpSwitchName); | 76 switches::kHelpSwitchName); |
78 printf(" %s: Specifies the service api to use (dev|test) [default: dev]\n", | |
79 switches::kServiceEnvironmentSwitchName); | |
80 printf( | 77 printf( |
81 " %s: Retrieves and displays the connection status for all known " | 78 " %s: Retrieves and displays the connection status for all known " |
82 "hosts, no tests will be run\n", | 79 "hosts, no tests will be run\n", |
83 switches::kShowHostAvailabilitySwitchName); | 80 switches::kShowHostAvailabilitySwitchName); |
84 printf( | 81 printf( |
85 " %s: Send a message to the service after all tests have been run to " | 82 " %s: Send a message to the service after all tests have been run to " |
86 "release remote hosts the tool used for testing.\n", | 83 "release remote hosts the tool used for testing.\n", |
87 switches::kReleaseHostsAfterTestingSwitchName); | 84 switches::kReleaseHostsAfterTestingSwitchName); |
88 printf( | 85 printf( |
89 " %s: Specifies the optional logging level of the tool (0-3)." | 86 " %s: Specifies the optional logging level of the tool (0-3)." |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // refreshing their credentials. | 216 // refreshing their credentials. |
220 std::string auth_code( | 217 std::string auth_code( |
221 command_line->GetSwitchValueASCII(switches::kAuthCodeSwitchName)); | 218 command_line->GetSwitchValueASCII(switches::kAuthCodeSwitchName)); |
222 | 219 |
223 options.refresh_token_file_path = | 220 options.refresh_token_file_path = |
224 command_line->GetSwitchValuePath(switches::kRefreshTokenFileSwitchName); | 221 command_line->GetSwitchValuePath(switches::kRefreshTokenFileSwitchName); |
225 | 222 |
226 options.release_hosts_when_done = | 223 options.release_hosts_when_done = |
227 command_line->HasSwitch(switches::kReleaseHostsAfterTestingSwitchName); | 224 command_line->HasSwitch(switches::kReleaseHostsAfterTestingSwitchName); |
228 | 225 |
229 // If the user passed in a service environment, use it, otherwise set a | 226 options.service_environment = |
230 // default value. | |
231 std::string service_environment_switch(command_line->GetSwitchValueASCII( | |
232 switches::kServiceEnvironmentSwitchName)); | |
233 if (service_environment_switch.empty() || | |
234 service_environment_switch == "dev") { | |
235 options.service_environment = | |
236 remoting::test::ServiceEnvironment::kDeveloperEnvironment; | 227 remoting::test::ServiceEnvironment::kDeveloperEnvironment; |
237 } else if (service_environment_switch == "test") { | |
238 options.service_environment = | |
239 remoting::test::ServiceEnvironment::kTestingEnvironment; | |
240 } else if (service_environment_switch == "staging") { | |
241 options.service_environment = | |
242 remoting::test::ServiceEnvironment::kStagingEnvironment; | |
243 } else { | |
244 LOG(ERROR) << "Invalid " << switches::kServiceEnvironmentSwitchName | |
245 << " argument passed in."; | |
246 PrintUsage(); | |
247 return -1; | |
248 } | |
249 | 228 |
250 // Update the logging verbosity level is user specified one. | 229 // Update the logging verbosity level is user specified one. |
251 std::string verbosity_level( | 230 std::string verbosity_level( |
252 command_line->GetSwitchValueASCII(switches::kLoggingLevelSwitchName)); | 231 command_line->GetSwitchValueASCII(switches::kLoggingLevelSwitchName)); |
253 if (!verbosity_level.empty()) { | 232 if (!verbosity_level.empty()) { |
254 // Turn on logging for the test_driver and remoting components. | 233 // Turn on logging for the test_driver and remoting components. |
255 // This switch is parsed during logging::InitLogging. | 234 // This switch is parsed during logging::InitLogging. |
256 command_line->AppendSwitchASCII("vmodule", | 235 command_line->AppendSwitchASCII("vmodule", |
257 "*/remoting/*=" + verbosity_level); | 236 "*/remoting/*=" + verbosity_level); |
258 logging::LoggingSettings logging_settings; | 237 logging::LoggingSettings logging_settings; |
(...skipping 22 matching lines...) Expand all Loading... |
281 // Since we've successfully set up our shared_data object, we'll assign the | 260 // Since we've successfully set up our shared_data object, we'll assign the |
282 // value to our global* and transfer ownership to the framework. | 261 // value to our global* and transfer ownership to the framework. |
283 remoting::test::AppRemotingSharedData = shared_data.release(); | 262 remoting::test::AppRemotingSharedData = shared_data.release(); |
284 testing::AddGlobalTestEnvironment(remoting::test::AppRemotingSharedData); | 263 testing::AddGlobalTestEnvironment(remoting::test::AppRemotingSharedData); |
285 | 264 |
286 // Because many tests may access the same remoting host(s), we need to run | 265 // Because many tests may access the same remoting host(s), we need to run |
287 // the tests sequentially so they do not interfere with each other. | 266 // the tests sequentially so they do not interfere with each other. |
288 return base::LaunchUnitTestsSerially( | 267 return base::LaunchUnitTestsSerially( |
289 argc, argv, base::Bind(&NoAtExitBaseTestSuite::RunTestSuite, argc, argv)); | 268 argc, argv, base::Bind(&NoAtExitBaseTestSuite::RunTestSuite, argc, argv)); |
290 } | 269 } |
OLD | NEW |