Chromium Code Reviews| 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_io.h" | 5 #include "ppapi/tests/test_file_io.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 int32_t read_offset_2 = 4; | 895 int32_t read_offset_2 = 4; |
| 896 char buf_2[3]; | 896 char buf_2[3]; |
| 897 int32_t rv_2 = file_io.Read(read_offset_2, buf_2, sizeof(buf_2), | 897 int32_t rv_2 = file_io.Read(read_offset_2, buf_2, sizeof(buf_2), |
| 898 callback_2); | 898 callback_2); |
| 899 if (force_async_ && rv_2 != PP_OK_COMPLETIONPENDING) | 899 if (force_async_ && rv_2 != PP_OK_COMPLETIONPENDING) |
| 900 return ReportError("FileIO::Read force_async", rv_2); | 900 return ReportError("FileIO::Read force_async", rv_2); |
| 901 if (rv_2 == PP_OK_COMPLETIONPENDING) | 901 if (rv_2 == PP_OK_COMPLETIONPENDING) |
| 902 rv_2 = callback_2.WaitForResult(); | 902 rv_2 = callback_2.WaitForResult(); |
| 903 if (rv_2 != PP_ERROR_INPROGRESS) | 903 if (rv_2 != PP_ERROR_INPROGRESS) |
| 904 return ReportError("FileIO::Read", rv_2); | 904 return ReportError("FileIO::Read", rv_2); |
| 905 callback_1.WaitForResult(); | |
| 905 | 906 |
| 906 // Cannot query while the write is pending. | 907 // Cannot query while a write is pending. |
| 908 rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), callback_1); | |
| 907 TestCompletionCallback callback_3(instance_->pp_instance(), force_async_); | 909 TestCompletionCallback callback_3(instance_->pp_instance(), force_async_); |
|
viettrungluu
2012/06/25 21:41:34
(Here and elsewhere:) I suppose you should |ASSERT
dmichael (off chromium)
2012/06/25 22:06:28
Done.
| |
| 908 PP_FileInfo info; | 910 PP_FileInfo info; |
| 909 int32_t rv_3 = file_io.Query(&info, callback_3); | 911 int32_t rv_3 = file_io.Query(&info, callback_3); |
| 910 if (rv_3 == PP_OK_COMPLETIONPENDING) | 912 if (rv_3 == PP_OK_COMPLETIONPENDING) |
| 911 rv_3 = callback_3.WaitForResult(); | 913 rv_3 = callback_3.WaitForResult(); |
| 912 if (rv_3 != PP_ERROR_INPROGRESS) | 914 if (rv_3 != PP_ERROR_INPROGRESS) |
| 913 return ReportError("FileIO::Query", rv_3); | 915 return ReportError("FileIO::Query", rv_3); |
| 916 callback_1.WaitForResult(); | |
| 914 | 917 |
| 915 // Cannot touch while the write is pending. | 918 // Cannot touch while a write is pending. |
| 919 rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), callback_1); | |
| 916 TestCompletionCallback callback_4(instance_->pp_instance(), force_async_); | 920 TestCompletionCallback callback_4(instance_->pp_instance(), force_async_); |
| 917 int32_t rv_4 = file_io.Touch(1234.0, 5678.0, callback_4); | 921 int32_t rv_4 = file_io.Touch(1234.0, 5678.0, callback_4); |
| 918 if (rv_4 == PP_OK_COMPLETIONPENDING) | 922 if (rv_4 == PP_OK_COMPLETIONPENDING) |
| 919 rv_4 = callback_4.WaitForResult(); | 923 rv_4 = callback_4.WaitForResult(); |
| 920 if (rv_4 != PP_ERROR_INPROGRESS) | 924 if (rv_4 != PP_ERROR_INPROGRESS) |
| 921 return ReportError("FileIO::Touch", rv_4); | 925 return ReportError("FileIO::Touch", rv_4); |
| 926 callback_1.WaitForResult(); | |
| 922 | 927 |
| 923 // Cannot set length while the write is pending. | 928 // Cannot set length while a write is pending. |
| 929 rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), callback_1); | |
| 924 TestCompletionCallback callback_5(instance_->pp_instance(), force_async_); | 930 TestCompletionCallback callback_5(instance_->pp_instance(), force_async_); |
| 925 int32_t rv_5 = file_io.SetLength(123, callback_5); | 931 int32_t rv_5 = file_io.SetLength(123, callback_5); |
| 926 if (rv_5 == PP_OK_COMPLETIONPENDING) | 932 if (rv_5 == PP_OK_COMPLETIONPENDING) |
| 927 rv_5 = callback_5.WaitForResult(); | 933 rv_5 = callback_5.WaitForResult(); |
| 928 if (rv_5 != PP_ERROR_INPROGRESS) | 934 if (rv_5 != PP_ERROR_INPROGRESS) |
| 929 return ReportError("FileIO::SetLength", rv_5); | 935 return ReportError("FileIO::SetLength", rv_5); |
| 930 | 936 |
|
viettrungluu
2012/06/25 21:41:34
Nit: For consistency, you may as well remove this
dmichael (off chromium)
2012/06/25 22:06:28
Done.
| |
| 931 callback_1.WaitForResult(); | 937 callback_1.WaitForResult(); |
| 932 | 938 |
| 933 PASS(); | 939 PASS(); |
| 934 } | 940 } |
| 935 | 941 |
| 936 std::string TestFileIO::TestWillWriteWillSetLength() { | 942 std::string TestFileIO::TestWillWriteWillSetLength() { |
| 937 TestCompletionCallback callback(instance_->pp_instance(), force_async_); | 943 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
| 938 | 944 |
| 939 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 945 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 940 pp::FileRef file_ref(file_system, "/file_will_write"); | 946 pp::FileRef file_ref(file_system, "/file_will_write"); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 rv = callback.WaitForResult(); | 1125 rv = callback.WaitForResult(); |
| 1120 if ((invalid_combination && rv == PP_OK) || | 1126 if ((invalid_combination && rv == PP_OK) || |
| 1121 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) { | 1127 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) { |
| 1122 return ReportOpenError(open_flags); | 1128 return ReportOpenError(open_flags); |
| 1123 } | 1129 } |
| 1124 | 1130 |
| 1125 return std::string(); | 1131 return std::string(); |
| 1126 } | 1132 } |
| 1127 | 1133 |
| 1128 // TODO(viettrungluu): Test Close(). crbug.com/69457 | 1134 // TODO(viettrungluu): Test Close(). crbug.com/69457 |
| OLD | NEW |