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/api/record/record_api.h" | 5 #include "chrome/browser/extensions/api/record/record_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 scoped_ptr<base::ListValue> capture_result; | 312 scoped_ptr<base::ListValue> capture_result; |
313 RunCapture(user_data_dir.path(), &capture_result); | 313 RunCapture(user_data_dir.path(), &capture_result); |
314 | 314 |
315 std::string escaped_user_data_dir; | 315 std::string escaped_user_data_dir; |
316 ReplaceChars(user_data_dir.path().AsUTF8Unsafe(), "\\", "\\\\", | 316 ReplaceChars(user_data_dir.path().AsUTF8Unsafe(), "\\", "\\\\", |
317 &escaped_user_data_dir); | 317 &escaped_user_data_dir); |
318 | 318 |
319 scoped_refptr<RecordReplayURLsFunction> playback_function( | 319 scoped_refptr<RecordReplayURLsFunction> playback_function( |
320 new RecordReplayURLsFunction( | 320 new RecordReplayURLsFunction( |
321 new TestProcessStrategy(&temp_files_))); | 321 new TestProcessStrategy(&temp_files_))); |
322 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( | 322 scoped_ptr<base::DictionaryValue> result( |
323 utils::RunFunctionAndReturnSingleResult(playback_function, | 323 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
324 base::StringPrintf(kPlaybackArgs1, escaped_user_data_dir.c_str()), | 324 playback_function.get(), |
325 browser()))); | 325 base::StringPrintf(kPlaybackArgs1, escaped_user_data_dir.c_str()), |
| 326 browser()))); |
326 | 327 |
327 // Check that command line user-data-dir was overridden. (That | 328 // Check that command line user-data-dir was overridden. (That |
328 // it was *consistently* overridden in both capture and replay | 329 // it was *consistently* overridden in both capture and replay |
329 // is verified elsewhere. | 330 // is verified elsewhere. |
330 const TestProcessStrategy &strategy = | 331 const TestProcessStrategy &strategy = |
331 static_cast<const TestProcessStrategy &>( | 332 static_cast<const TestProcessStrategy &>( |
332 playback_function->GetProcessStrategy()); | 333 playback_function->GetProcessStrategy()); |
333 const CommandLine& command_line = strategy.GetCommandLine(); | 334 const CommandLine& command_line = strategy.GetCommandLine(); |
334 | 335 |
335 EXPECT_TRUE(command_line.HasSwitch(switches::kUserDataDir)); | 336 EXPECT_TRUE(command_line.HasSwitch(switches::kUserDataDir)); |
336 EXPECT_TRUE(command_line.GetSwitchValuePath(switches::kUserDataDir) != | 337 EXPECT_TRUE(command_line.GetSwitchValuePath(switches::kUserDataDir) != |
337 base::FilePath(kDummyDirName)); | 338 base::FilePath(kDummyDirName)); |
338 | 339 |
339 // Check that command line load-extension was overridden. | 340 // Check that command line load-extension was overridden. |
340 EXPECT_TRUE(command_line.HasSwitch(switches::kLoadExtension) && | 341 EXPECT_TRUE(command_line.HasSwitch(switches::kLoadExtension) && |
341 command_line.GetSwitchValuePath(switches::kLoadExtension) | 342 command_line.GetSwitchValuePath(switches::kLoadExtension) |
342 != base::FilePath(kDummyDirName)); | 343 != base::FilePath(kDummyDirName)); |
343 | 344 |
344 // Check for return value with proper stats. | 345 // Check for return value with proper stats. |
345 EXPECT_EQ(kTestStatistics, utils::GetString(result.get(), kStatsKey)); | 346 EXPECT_EQ(kTestStatistics, utils::GetString(result.get(), kStatsKey)); |
346 | 347 |
347 ListValue* errors = NULL; | 348 ListValue* errors = NULL; |
348 EXPECT_TRUE(result->GetList(kErrorsKey, &errors)); | 349 EXPECT_TRUE(result->GetList(kErrorsKey, &errors)); |
349 EXPECT_TRUE(VerifyURLHandling(errors, strategy)); | 350 EXPECT_TRUE(VerifyURLHandling(errors, strategy)); |
350 } | 351 } |
351 | 352 |
352 } // namespace extensions | 353 } // namespace extensions |
OLD | NEW |