OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/extension_record_api.h" | 5 #include "chrome/browser/extensions/extension_record_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 scoped_ptr<base::ListValue>* out_list) { | 222 scoped_ptr<base::ListValue>* out_list) { |
223 | 223 |
224 scoped_refptr<CaptureURLsFunction> capture_function( | 224 scoped_refptr<CaptureURLsFunction> capture_function( |
225 new CaptureURLsFunction(new TestProcessStrategy(&temp_files_))); | 225 new CaptureURLsFunction(new TestProcessStrategy(&temp_files_))); |
226 | 226 |
227 std::string escaped_user_data_dir; | 227 std::string escaped_user_data_dir; |
228 ReplaceChars(user_data_dir.AsUTF8Unsafe(), "\\", "\\\\", | 228 ReplaceChars(user_data_dir.AsUTF8Unsafe(), "\\", "\\\\", |
229 &escaped_user_data_dir); | 229 &escaped_user_data_dir); |
230 | 230 |
231 out_list->reset(utils::ToList( | 231 out_list->reset(utils::ToList( |
232 utils::RunFunctionAndReturnResult(capture_function.get(), | 232 utils::RunFunctionAndReturnSingleResult(capture_function.get(), |
233 base::StringPrintf(kCaptureArgs1, escaped_user_data_dir.c_str()), | 233 base::StringPrintf(kCaptureArgs1, escaped_user_data_dir.c_str()), |
234 browser()))); | 234 browser()))); |
235 | 235 |
236 return capture_function; | 236 return capture_function; |
237 } | 237 } |
238 | 238 |
239 // Verify that the URL list of good and bad URLs was properly handled. | 239 // Verify that the URL list of good and bad URLs was properly handled. |
240 // Needed by several tests. | 240 // Needed by several tests. |
241 bool VerifyURLHandling(const ListValue* result, | 241 bool VerifyURLHandling(const ListValue* result, |
242 const TestProcessStrategy& strategy) { | 242 const TestProcessStrategy& strategy) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 scoped_ptr<base::ListValue> capture_result; | 306 scoped_ptr<base::ListValue> capture_result; |
307 RunCapture(user_data_dir.path(), &capture_result); | 307 RunCapture(user_data_dir.path(), &capture_result); |
308 | 308 |
309 std::string escaped_user_data_dir; | 309 std::string escaped_user_data_dir; |
310 ReplaceChars(user_data_dir.path().AsUTF8Unsafe(), "\\", "\\\\", | 310 ReplaceChars(user_data_dir.path().AsUTF8Unsafe(), "\\", "\\\\", |
311 &escaped_user_data_dir); | 311 &escaped_user_data_dir); |
312 | 312 |
313 scoped_refptr<ReplayURLsFunction> playback_function(new ReplayURLsFunction( | 313 scoped_refptr<ReplayURLsFunction> playback_function(new ReplayURLsFunction( |
314 new TestProcessStrategy(&temp_files_))); | 314 new TestProcessStrategy(&temp_files_))); |
315 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( | 315 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
316 utils::RunFunctionAndReturnResult(playback_function, | 316 utils::RunFunctionAndReturnSingleResult(playback_function, |
317 base::StringPrintf(kPlaybackArgs1, escaped_user_data_dir.c_str()), | 317 base::StringPrintf(kPlaybackArgs1, escaped_user_data_dir.c_str()), |
318 browser()))); | 318 browser()))); |
319 | 319 |
320 // Check that command line user-data-dir was overridden. (That | 320 // Check that command line user-data-dir was overridden. (That |
321 // it was *consistently* overridden in both capture and replay | 321 // it was *consistently* overridden in both capture and replay |
322 // is verified elsewhere. | 322 // is verified elsewhere. |
323 const TestProcessStrategy &strategy = | 323 const TestProcessStrategy &strategy = |
324 static_cast<const TestProcessStrategy &>( | 324 static_cast<const TestProcessStrategy &>( |
325 playback_function->GetProcessStrategy()); | 325 playback_function->GetProcessStrategy()); |
326 const CommandLine& command_line = strategy.GetCommandLine(); | 326 const CommandLine& command_line = strategy.GetCommandLine(); |
327 | 327 |
328 EXPECT_TRUE(command_line.HasSwitch(switches::kUserDataDir)); | 328 EXPECT_TRUE(command_line.HasSwitch(switches::kUserDataDir)); |
329 EXPECT_TRUE(command_line.GetSwitchValuePath(switches::kUserDataDir) != | 329 EXPECT_TRUE(command_line.GetSwitchValuePath(switches::kUserDataDir) != |
330 FilePath(kDummyDirName)); | 330 FilePath(kDummyDirName)); |
331 | 331 |
332 // Check that command line load-extension was overridden. | 332 // Check that command line load-extension was overridden. |
333 EXPECT_TRUE(command_line.HasSwitch(switches::kLoadExtension) && | 333 EXPECT_TRUE(command_line.HasSwitch(switches::kLoadExtension) && |
334 command_line.GetSwitchValuePath(switches::kLoadExtension) | 334 command_line.GetSwitchValuePath(switches::kLoadExtension) |
335 != FilePath(kDummyDirName)); | 335 != FilePath(kDummyDirName)); |
336 | 336 |
337 // Check for return value with proper stats. | 337 // Check for return value with proper stats. |
338 EXPECT_EQ(kTestStatistics, utils::GetString(result.get(), kStatsKey)); | 338 EXPECT_EQ(kTestStatistics, utils::GetString(result.get(), kStatsKey)); |
339 | 339 |
340 ListValue* errors = NULL; | 340 ListValue* errors = NULL; |
341 EXPECT_TRUE(result->GetList(kErrorsKey, &errors)); | 341 EXPECT_TRUE(result->GetList(kErrorsKey, &errors)); |
342 EXPECT_TRUE(VerifyURLHandling(errors, strategy)); | 342 EXPECT_TRUE(VerifyURLHandling(errors, strategy)); |
343 } | 343 } |
OLD | NEW |