| 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 "CopySourceFiltering run %d test %" PRIuS, loop_count, i); | 292 "CopySourceFiltering run %d test %" PRIuS, loop_count, i); |
| 293 base::File::Error expectation = base::File::FILE_OK; | 293 base::File::Error expectation = base::File::FILE_OK; |
| 294 if (loop_count == 0 || !kFilteringTestCases[i].visible) { | 294 if (loop_count == 0 || !kFilteringTestCases[i].visible) { |
| 295 // If the source does not exist or is not visible. | 295 // If the source does not exist or is not visible. |
| 296 expectation = base::File::FILE_ERROR_NOT_FOUND; | 296 expectation = base::File::FILE_ERROR_NOT_FOUND; |
| 297 } else if (!kFilteringTestCases[i].is_directory) { | 297 } else if (!kFilteringTestCases[i].is_directory) { |
| 298 // Cannot copy a visible file to a directory. | 298 // Cannot copy a visible file to a directory. |
| 299 expectation = base::File::FILE_ERROR_INVALID_OPERATION; | 299 expectation = base::File::FILE_ERROR_INVALID_OPERATION; |
| 300 } | 300 } |
| 301 operation_runner()->Copy( | 301 operation_runner()->Copy( |
| 302 url, | 302 url, dest_url, storage::FileSystemOperation::OPTION_NONE, |
| 303 dest_url, | 303 storage::FileSystemOperation::ERROR_BEHAVIOR_TERMINATE, |
| 304 storage::FileSystemOperation::OPTION_NONE, | |
| 305 storage::FileSystemOperationRunner::CopyProgressCallback(), | 304 storage::FileSystemOperationRunner::CopyProgressCallback(), |
| 306 base::Bind(&ExpectEqHelper, test_name, expectation)); | 305 base::Bind(&ExpectEqHelper, test_name, expectation)); |
| 307 base::MessageLoop::current()->RunUntilIdle(); | 306 base::MessageLoop::current()->RunUntilIdle(); |
| 308 } | 307 } |
| 309 } | 308 } |
| 310 } | 309 } |
| 311 | 310 |
| 312 TEST_F(NativeMediaFileUtilTest, CopyDestFiltering) { | 311 TEST_F(NativeMediaFileUtilTest, CopyDestFiltering) { |
| 313 // Run the loop twice. The first run has no destination files. | 312 // Run the loop twice. The first run has no destination files. |
| 314 // The second run does. | 313 // The second run does. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 expectation = base::File::FILE_ERROR_SECURITY; | 357 expectation = base::File::FILE_ERROR_SECURITY; |
| 359 } else if (kFilteringTestCases[i].is_directory) { | 358 } else if (kFilteringTestCases[i].is_directory) { |
| 360 // Cannot copy a file to a directory. | 359 // Cannot copy a file to a directory. |
| 361 expectation = base::File::FILE_ERROR_INVALID_OPERATION; | 360 expectation = base::File::FILE_ERROR_INVALID_OPERATION; |
| 362 } else { | 361 } else { |
| 363 // Copying from a file to a visible file that exists is ok. | 362 // Copying from a file to a visible file that exists is ok. |
| 364 expectation = base::File::FILE_OK; | 363 expectation = base::File::FILE_OK; |
| 365 } | 364 } |
| 366 } | 365 } |
| 367 operation_runner()->Copy( | 366 operation_runner()->Copy( |
| 368 src_url, | 367 src_url, url, storage::FileSystemOperation::OPTION_NONE, |
| 369 url, | 368 storage::FileSystemOperation::ERROR_BEHAVIOR_TERMINATE, |
| 370 storage::FileSystemOperation::OPTION_NONE, | |
| 371 storage::FileSystemOperationRunner::CopyProgressCallback(), | 369 storage::FileSystemOperationRunner::CopyProgressCallback(), |
| 372 base::Bind(&ExpectEqHelper, test_name, expectation)); | 370 base::Bind(&ExpectEqHelper, test_name, expectation)); |
| 373 base::MessageLoop::current()->RunUntilIdle(); | 371 base::MessageLoop::current()->RunUntilIdle(); |
| 374 } | 372 } |
| 375 } | 373 } |
| 376 } | 374 } |
| 377 | 375 |
| 378 TEST_F(NativeMediaFileUtilTest, MoveSourceFiltering) { | 376 TEST_F(NativeMediaFileUtilTest, MoveSourceFiltering) { |
| 379 base::FilePath dest_path = root_path().AppendASCII("dest"); | 377 base::FilePath dest_path = root_path().AppendASCII("dest"); |
| 380 FileSystemURL dest_url = CreateURL(FPL("dest")); | 378 FileSystemURL dest_url = CreateURL(FPL("dest")); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 expected_error = base::File::FILE_OK; | 563 expected_error = base::File::FILE_OK; |
| 566 else | 564 else |
| 567 expected_error = base::File::FILE_ERROR_SECURITY; | 565 expected_error = base::File::FILE_ERROR_SECURITY; |
| 568 error = base::File::FILE_ERROR_FAILED; | 566 error = base::File::FILE_ERROR_FAILED; |
| 569 operation_runner()->CreateSnapshotFile(url, | 567 operation_runner()->CreateSnapshotFile(url, |
| 570 base::Bind(CreateSnapshotCallback, &error)); | 568 base::Bind(CreateSnapshotCallback, &error)); |
| 571 base::MessageLoop::current()->RunUntilIdle(); | 569 base::MessageLoop::current()->RunUntilIdle(); |
| 572 ASSERT_EQ(expected_error, error); | 570 ASSERT_EQ(expected_error, error); |
| 573 } | 571 } |
| 574 } | 572 } |
| OLD | NEW |