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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 options.host_jid = | 212 options.host_jid = |
213 command_line->GetSwitchValueASCII(switches::kHostJidSwitchName); | 213 command_line->GetSwitchValueASCII(switches::kHostJidSwitchName); |
214 VLOG(1) << "host_jid: '" << options.host_jid << "'"; | 214 VLOG(1) << "host_jid: '" << options.host_jid << "'"; |
215 | 215 |
216 options.pin = command_line->GetSwitchValueASCII(switches::kPinSwitchName); | 216 options.pin = command_line->GetSwitchValueASCII(switches::kPinSwitchName); |
217 | 217 |
218 // Create and register our global test data object. It will handle | 218 // Create and register our global test data object. It will handle |
219 // retrieving an access token or host list for the user. The GTest framework | 219 // retrieving an access token or host list for the user. The GTest framework |
220 // will own the lifetime of this object once it is registered below. | 220 // will own the lifetime of this object once it is registered below. |
221 scoped_ptr<remoting::test::ChromotingTestDriverEnvironment> shared_data( | 221 std::unique_ptr<remoting::test::ChromotingTestDriverEnvironment> shared_data( |
222 new remoting::test::ChromotingTestDriverEnvironment(options)); | 222 new remoting::test::ChromotingTestDriverEnvironment(options)); |
223 | 223 |
224 if (!shared_data->Initialize(auth_code)) { | 224 if (!shared_data->Initialize(auth_code)) { |
225 VLOG(1) << "Failed to initialize ChromotingTestDriverEnvironment instance."; | 225 VLOG(1) << "Failed to initialize ChromotingTestDriverEnvironment instance."; |
226 // If we failed to initialize our shared data object, then bail. | 226 // If we failed to initialize our shared data object, then bail. |
227 return -1; | 227 return -1; |
228 } | 228 } |
229 | 229 |
230 // This method is necessary as there are occasional propagation delays in the | 230 // This method is necessary as there are occasional propagation delays in the |
231 // backend and we don't want the test to fail because of that. | 231 // backend and we don't want the test to fail because of that. |
232 if (!shared_data->WaitForHostOnline(options.host_jid, options.host_name)) { | 232 if (!shared_data->WaitForHostOnline(options.host_jid, options.host_name)) { |
233 VLOG(1) << "The expected host was not available for connections."; | 233 VLOG(1) << "The expected host was not available for connections."; |
234 // Host is not online. No point running further tests. | 234 // Host is not online. No point running further tests. |
235 return -1; | 235 return -1; |
236 } | 236 } |
237 | 237 |
238 // Since we've successfully set up our shared_data object, we'll assign the | 238 // Since we've successfully set up our shared_data object, we'll assign the |
239 // value to our global* and transfer ownership to the framework. | 239 // value to our global* and transfer ownership to the framework. |
240 remoting::test::g_chromoting_shared_data = shared_data.release(); | 240 remoting::test::g_chromoting_shared_data = shared_data.release(); |
241 testing::AddGlobalTestEnvironment(remoting::test::g_chromoting_shared_data); | 241 testing::AddGlobalTestEnvironment(remoting::test::g_chromoting_shared_data); |
242 | 242 |
243 // Running the tests serially will avoid clients from connecting to the same | 243 // Running the tests serially will avoid clients from connecting to the same |
244 // host. | 244 // host. |
245 return base::LaunchUnitTestsSerially( | 245 return base::LaunchUnitTestsSerially( |
246 argc, argv, | 246 argc, argv, |
247 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); | 247 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); |
248 } | 248 } |
OLD | NEW |