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 | 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 318 pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
319 int32_t rv = file_system.Open(1024, callback); | 319 int32_t rv = file_system.Open(1024, callback); |
320 if (rv == PP_OK_COMPLETIONPENDING) | 320 if (rv == PP_OK_COMPLETIONPENDING) |
321 rv = callback.WaitForResult(); | 321 rv = callback.WaitForResult(); |
322 if (rv != PP_OK) | 322 if (rv != PP_OK) |
323 return ReportError("FileSystem::Open", rv); | 323 return ReportError("FileSystem::Open", rv); |
324 | 324 |
325 pp::FileRef_Dev file_ref(file_system, "/file_touch"); | 325 pp::FileRef_Dev file_ref(file_system, "/file_touch"); |
326 pp::FileIO_Dev file_io(instance_); | 326 pp::FileIO_Dev file_io(instance_); |
327 rv = file_io.Open(file_ref, | 327 rv = file_io.Open(file_ref, |
328 PP_FILEOPENFLAG_CREATE | PP_FILEOPENFLAG_WRITE, | 328 PP_FILEOPENFLAG_CREATE | |
| 329 PP_FILEOPENFLAG_TRUNCATE | |
| 330 PP_FILEOPENFLAG_WRITE, |
329 callback); | 331 callback); |
330 if (rv == PP_OK_COMPLETIONPENDING) | 332 if (rv == PP_OK_COMPLETIONPENDING) |
331 rv = callback.WaitForResult(); | 333 rv = callback.WaitForResult(); |
332 if (rv != PP_OK) | 334 if (rv != PP_OK) |
333 return ReportError("FileIO::Open", rv); | 335 return ReportError("FileIO::Open", rv); |
334 | 336 |
335 // Write some data to have a non-zero file size. | 337 // Write some data to have a non-zero file size. |
336 rv = file_io.Write(0, "test", 4, callback); | 338 rv = file_io.Write(0, "test", 4, callback); |
337 if (rv == PP_OK_COMPLETIONPENDING) | 339 if (rv == PP_OK_COMPLETIONPENDING) |
338 rv = callback.WaitForResult(); | 340 rv = callback.WaitForResult(); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 if (rv == PP_OK_COMPLETIONPENDING) { | 558 if (rv == PP_OK_COMPLETIONPENDING) { |
557 rv = callback.WaitForResult(); | 559 rv = callback.WaitForResult(); |
558 if (rv != PP_ERROR_ABORTED) | 560 if (rv != PP_ERROR_ABORTED) |
559 return "FileSystem::Rename not aborted."; | 561 return "FileSystem::Rename not aborted."; |
560 } else if (rv != PP_OK) { | 562 } else if (rv != PP_OK) { |
561 return ReportError("FileSystem::Rename", rv); | 563 return ReportError("FileSystem::Rename", rv); |
562 } | 564 } |
563 | 565 |
564 PASS(); | 566 PASS(); |
565 } | 567 } |
OLD | NEW |