| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/tests/test_file_ref.h" | 5 #include "ppapi/tests/test_file_ref.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 return "FileSystem::Rename not aborted."; | 674 return "FileSystem::Rename not aborted."; |
| 675 } else if (rv != PP_OK) { | 675 } else if (rv != PP_OK) { |
| 676 return ReportError("FileSystem::Rename", rv); | 676 return ReportError("FileSystem::Rename", rv); |
| 677 } | 677 } |
| 678 | 678 |
| 679 PASS(); | 679 PASS(); |
| 680 } | 680 } |
| 681 | 681 |
| 682 #ifndef PPAPI_OS_NACL | 682 #ifndef PPAPI_OS_NACL |
| 683 std::string TestFileRef::TestFileNameEscaping() { | 683 std::string TestFileRef::TestFileNameEscaping() { |
| 684 // The directory methods we need only work in-process and not in NaCl for now. | |
| 685 if (testing_interface_->IsOutOfProcess()) | |
| 686 PASS(); | |
| 687 | |
| 688 TestCompletionCallback callback(instance_->pp_instance(), force_async_); | 684 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
| 689 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 685 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 690 int32_t rv = file_system.Open(1024, callback); | 686 int32_t rv = file_system.Open(1024, callback); |
| 691 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) | 687 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 692 return ReportError("FileSystem::Open force_async", rv); | 688 return ReportError("FileSystem::Open force_async", rv); |
| 693 if (rv == PP_OK_COMPLETIONPENDING) | 689 if (rv == PP_OK_COMPLETIONPENDING) |
| 694 rv = callback.WaitForResult(); | 690 rv = callback.WaitForResult(); |
| 695 if (rv != PP_OK) | 691 if (rv != PP_OK) |
| 696 return ReportError("FileSystem::Open", rv); | 692 return ReportError("FileSystem::Open", rv); |
| 697 | 693 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 711 pp::FileRef file_ref(file_system, full_file_path.c_str()); | 707 pp::FileRef file_ref(file_system, full_file_path.c_str()); |
| 712 pp::FileIO file_io(instance_); | 708 pp::FileIO file_io(instance_); |
| 713 rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback); | 709 rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback); |
| 714 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) | 710 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 715 return ReportError("FileIO::Open force_async", rv); | 711 return ReportError("FileIO::Open force_async", rv); |
| 716 if (rv == PP_OK_COMPLETIONPENDING) | 712 if (rv == PP_OK_COMPLETIONPENDING) |
| 717 rv = callback.WaitForResult(); | 713 rv = callback.WaitForResult(); |
| 718 if (rv != PP_OK) | 714 if (rv != PP_OK) |
| 719 return ReportError("FileIO::Open", rv); | 715 return ReportError("FileIO::Open", rv); |
| 720 | 716 |
| 721 pp::DirectoryReader_Dev directory_reader(test_dir_ref); | 717 // DirectoryReader only works out-of-process. |
| 722 pp::DirectoryEntry_Dev entry; | 718 if (testing_interface_->IsOutOfProcess()) { |
| 719 pp::DirectoryReader_Dev directory_reader(test_dir_ref); |
| 720 pp::DirectoryEntry_Dev entry; |
| 723 | 721 |
| 724 rv = directory_reader.GetNextEntry(&entry, callback); | 722 rv = directory_reader.GetNextEntry(&entry, callback); |
| 725 if (rv == PP_OK_COMPLETIONPENDING) | 723 if (rv == PP_OK_COMPLETIONPENDING) |
| 726 rv = callback.WaitForResult(); | 724 rv = callback.WaitForResult(); |
| 727 if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND) | 725 if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND) |
| 728 return ReportError("DirectoryEntry_Dev::GetNextEntry", rv); | 726 return ReportError("DirectoryEntry_Dev::GetNextEntry", rv); |
| 729 if (entry.is_null()) | 727 if (entry.is_null()) |
| 730 return "Entry was not found."; | 728 return "Entry was not found."; |
| 731 if (entry.file_ref().GetName().AsString() != kTerribleName) | 729 if (entry.file_ref().GetName().AsString() != kTerribleName) |
| 732 return "Entry name did not match."; | 730 return "Entry name did not match."; |
| 733 | 731 |
| 734 rv = directory_reader.GetNextEntry(&entry, callback); | 732 rv = directory_reader.GetNextEntry(&entry, callback); |
| 735 if (rv == PP_OK_COMPLETIONPENDING) | 733 if (rv == PP_OK_COMPLETIONPENDING) |
| 736 rv = callback.WaitForResult(); | 734 rv = callback.WaitForResult(); |
| 737 if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND) | 735 if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND) |
| 738 return ReportError("DirectoryEntry_Dev::GetNextEntry", rv); | 736 return ReportError("DirectoryEntry_Dev::GetNextEntry", rv); |
| 739 if (!entry.is_null()) | 737 if (!entry.is_null()) |
| 740 return "Directory had too many entries."; | 738 return "Directory had too many entries."; |
| 739 } |
| 741 | 740 |
| 742 PASS(); | 741 PASS(); |
| 743 } | 742 } |
| 744 #endif | 743 #endif |
| OLD | NEW |