| 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 "CopySourceFiltering run %d test %" PRIuS, loop_count, i); | 298 "CopySourceFiltering run %d test %" PRIuS, loop_count, i); |
| 299 base::PlatformFileError expectation = base::PLATFORM_FILE_OK; | 299 base::PlatformFileError expectation = base::PLATFORM_FILE_OK; |
| 300 if (loop_count == 0 || !kFilteringTestCases[i].visible) { | 300 if (loop_count == 0 || !kFilteringTestCases[i].visible) { |
| 301 // If the source does not exist or is not visible. | 301 // If the source does not exist or is not visible. |
| 302 expectation = base::PLATFORM_FILE_ERROR_NOT_FOUND; | 302 expectation = base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 303 } else if (!kFilteringTestCases[i].is_directory) { | 303 } else if (!kFilteringTestCases[i].is_directory) { |
| 304 // Cannot copy a visible file to a directory. | 304 // Cannot copy a visible file to a directory. |
| 305 expectation = base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | 305 expectation = base::PLATFORM_FILE_ERROR_INVALID_OPERATION; |
| 306 } | 306 } |
| 307 operation_runner()->Copy( | 307 operation_runner()->Copy( |
| 308 url, dest_url, base::Bind(&ExpectEqHelper, test_name, expectation)); | 308 url, dest_url, |
| 309 fileapi::FileSystemOperationRunner::CopyProgressCallback(), |
| 310 base::Bind(&ExpectEqHelper, test_name, expectation)); |
| 309 base::MessageLoop::current()->RunUntilIdle(); | 311 base::MessageLoop::current()->RunUntilIdle(); |
| 310 } | 312 } |
| 311 } | 313 } |
| 312 } | 314 } |
| 313 | 315 |
| 314 TEST_F(NativeMediaFileUtilTest, CopyDestFiltering) { | 316 TEST_F(NativeMediaFileUtilTest, CopyDestFiltering) { |
| 315 // Run the loop twice. The first run has no destination files. | 317 // Run the loop twice. The first run has no destination files. |
| 316 // The second run does. | 318 // The second run does. |
| 317 for (int loop_count = 0; loop_count < 2; ++loop_count) { | 319 for (int loop_count = 0; loop_count < 2; ++loop_count) { |
| 318 if (loop_count == 1) { | 320 if (loop_count == 1) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 expectation = base::PLATFORM_FILE_ERROR_SECURITY; | 362 expectation = base::PLATFORM_FILE_ERROR_SECURITY; |
| 361 } else if (kFilteringTestCases[i].is_directory) { | 363 } else if (kFilteringTestCases[i].is_directory) { |
| 362 // Cannot copy a file to a directory. | 364 // Cannot copy a file to a directory. |
| 363 expectation = base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | 365 expectation = base::PLATFORM_FILE_ERROR_INVALID_OPERATION; |
| 364 } else { | 366 } else { |
| 365 // Copying from a file to a visible file that exists is ok. | 367 // Copying from a file to a visible file that exists is ok. |
| 366 expectation = base::PLATFORM_FILE_OK; | 368 expectation = base::PLATFORM_FILE_OK; |
| 367 } | 369 } |
| 368 } | 370 } |
| 369 operation_runner()->Copy( | 371 operation_runner()->Copy( |
| 370 src_url, url, base::Bind(&ExpectEqHelper, test_name, expectation)); | 372 src_url, url, |
| 373 fileapi::FileSystemOperationRunner::CopyProgressCallback(), |
| 374 base::Bind(&ExpectEqHelper, test_name, expectation)); |
| 371 base::MessageLoop::current()->RunUntilIdle(); | 375 base::MessageLoop::current()->RunUntilIdle(); |
| 372 } | 376 } |
| 373 } | 377 } |
| 374 } | 378 } |
| 375 | 379 |
| 376 TEST_F(NativeMediaFileUtilTest, MoveSourceFiltering) { | 380 TEST_F(NativeMediaFileUtilTest, MoveSourceFiltering) { |
| 377 base::FilePath dest_path = root_path().AppendASCII("dest"); | 381 base::FilePath dest_path = root_path().AppendASCII("dest"); |
| 378 FileSystemURL dest_url = CreateURL(FPL("dest")); | 382 FileSystemURL dest_url = CreateURL(FPL("dest")); |
| 379 | 383 |
| 380 // Run the loop twice. The first run has no source files. The second run does. | 384 // Run the loop twice. The first run has no source files. The second run does. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 expected_error = base::PLATFORM_FILE_ERROR_SECURITY; | 533 expected_error = base::PLATFORM_FILE_ERROR_SECURITY; |
| 530 error = base::PLATFORM_FILE_ERROR_FAILED; | 534 error = base::PLATFORM_FILE_ERROR_FAILED; |
| 531 operation_runner()->CreateSnapshotFile(url, | 535 operation_runner()->CreateSnapshotFile(url, |
| 532 base::Bind(CreateSnapshotCallback, &error)); | 536 base::Bind(CreateSnapshotCallback, &error)); |
| 533 base::MessageLoop::current()->RunUntilIdle(); | 537 base::MessageLoop::current()->RunUntilIdle(); |
| 534 ASSERT_EQ(expected_error, error); | 538 ASSERT_EQ(expected_error, error); |
| 535 } | 539 } |
| 536 } | 540 } |
| 537 | 541 |
| 538 } // namespace chrome | 542 } // namespace chrome |
| OLD | NEW |