| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_io.h" | 5 #include "ppapi/tests/test_file_io.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/dev/ppb_file_io_dev.h" | 10 #include "ppapi/c/dev/ppb_file_io_dev.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Try opening a file that doesn't exist. | 106 // Try opening a file that doesn't exist. |
| 107 pp::FileRef_Dev nonexistent_file_ref(file_system, "/nonexistent_file"); | 107 pp::FileRef_Dev nonexistent_file_ref(file_system, "/nonexistent_file"); |
| 108 pp::FileIO_Dev nonexistent_file_io; | 108 pp::FileIO_Dev nonexistent_file_io; |
| 109 rv = nonexistent_file_io.Open( | 109 rv = nonexistent_file_io.Open( |
| 110 nonexistent_file_ref, PP_FILEOPENFLAG_READ, callback); | 110 nonexistent_file_ref, PP_FILEOPENFLAG_READ, callback); |
| 111 if (rv == PP_ERROR_WOULDBLOCK) | 111 if (rv == PP_ERROR_WOULDBLOCK) |
| 112 rv = callback.WaitForResult(); | 112 rv = callback.WaitForResult(); |
| 113 if (rv != PP_ERROR_FILENOTFOUND) | 113 if (rv != PP_ERROR_FILENOTFOUND) |
| 114 return ReportError("FileIO::Open", rv); | 114 return ReportError("FileIO::Open", rv); |
| 115 | 115 |
| 116 return ""; | 116 PASS(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 std::string TestFileIO::TestReadWriteSetLength() { | 119 std::string TestFileIO::TestReadWriteSetLength() { |
| 120 TestCompletionCallback callback; | 120 TestCompletionCallback callback; |
| 121 | 121 |
| 122 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 122 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 123 pp::FileRef_Dev file_ref(file_system, "/file_read_write_setlength"); | 123 pp::FileRef_Dev file_ref(file_system, "/file_read_write_setlength"); |
| 124 int32_t rv = file_system.Open(1024, callback); | 124 int32_t rv = file_system.Open(1024, callback); |
| 125 if (rv == PP_ERROR_WOULDBLOCK) | 125 if (rv == PP_ERROR_WOULDBLOCK) |
| 126 rv = callback.WaitForResult(); | 126 rv = callback.WaitForResult(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 // Read from the middle of the file. | 221 // Read from the middle of the file. |
| 222 read_buffer.clear(); | 222 read_buffer.clear(); |
| 223 rv = ReadEntireFile(&file_io, 4, &read_buffer); | 223 rv = ReadEntireFile(&file_io, 4, &read_buffer); |
| 224 if (rv != PP_OK) | 224 if (rv != PP_OK) |
| 225 return ReportError("FileIO::Read", rv); | 225 return ReportError("FileIO::Read", rv); |
| 226 if (read_buffer != std::string("testtest\0\0\0\0", 12)) | 226 if (read_buffer != std::string("testtest\0\0\0\0", 12)) |
| 227 return ReportMismatch("FileIO::Read", read_buffer, | 227 return ReportMismatch("FileIO::Read", read_buffer, |
| 228 std::string("testtest\0\0\0\0", 12)); | 228 std::string("testtest\0\0\0\0", 12)); |
| 229 | 229 |
| 230 return ""; | 230 PASS(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 std::string TestFileIO::TestTouchQuery() { | 233 std::string TestFileIO::TestTouchQuery() { |
| 234 TestCompletionCallback callback; | 234 TestCompletionCallback callback; |
| 235 | 235 |
| 236 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 236 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 237 int32_t rv = file_system.Open(1024, callback); | 237 int32_t rv = file_system.Open(1024, callback); |
| 238 if (rv == PP_ERROR_WOULDBLOCK) | 238 if (rv == PP_ERROR_WOULDBLOCK) |
| 239 rv = callback.WaitForResult(); | 239 rv = callback.WaitForResult(); |
| 240 if (rv != PP_OK) | 240 if (rv != PP_OK) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 if (rv != PP_OK) | 274 if (rv != PP_OK) |
| 275 return ReportError("FileSystem::Query", rv); | 275 return ReportError("FileSystem::Query", rv); |
| 276 | 276 |
| 277 if ((info.size != 4) || | 277 if ((info.size != 4) || |
| 278 (info.type != PP_FILETYPE_REGULAR) || | 278 (info.type != PP_FILETYPE_REGULAR) || |
| 279 (info.system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) || | 279 (info.system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) || |
| 280 (info.last_access_time != last_access_time) || | 280 (info.last_access_time != last_access_time) || |
| 281 (info.last_modified_time != last_modified_time)) | 281 (info.last_modified_time != last_modified_time)) |
| 282 return "FileSystem::Query() has returned bad data."; | 282 return "FileSystem::Query() has returned bad data."; |
| 283 | 283 |
| 284 return ""; | 284 PASS(); |
| 285 } | 285 } |
| OLD | NEW |