| 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); |
| 909 ASSERT_EQ(PP_OK_COMPLETIONPENDING, rv_1); |
| 907 TestCompletionCallback callback_3(instance_->pp_instance(), force_async_); | 910 TestCompletionCallback callback_3(instance_->pp_instance(), force_async_); |
| 908 PP_FileInfo info; | 911 PP_FileInfo info; |
| 909 int32_t rv_3 = file_io.Query(&info, callback_3); | 912 int32_t rv_3 = file_io.Query(&info, callback_3); |
| 910 if (rv_3 == PP_OK_COMPLETIONPENDING) | 913 if (rv_3 == PP_OK_COMPLETIONPENDING) |
| 911 rv_3 = callback_3.WaitForResult(); | 914 rv_3 = callback_3.WaitForResult(); |
| 912 if (rv_3 != PP_ERROR_INPROGRESS) | 915 if (rv_3 != PP_ERROR_INPROGRESS) |
| 913 return ReportError("FileIO::Query", rv_3); | 916 return ReportError("FileIO::Query", rv_3); |
| 917 callback_1.WaitForResult(); |
| 914 | 918 |
| 915 // Cannot touch while the write is pending. | 919 // Cannot touch while a write is pending. |
| 920 rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), callback_1); |
| 921 ASSERT_EQ(PP_OK_COMPLETIONPENDING, rv_1); |
| 916 TestCompletionCallback callback_4(instance_->pp_instance(), force_async_); | 922 TestCompletionCallback callback_4(instance_->pp_instance(), force_async_); |
| 917 int32_t rv_4 = file_io.Touch(1234.0, 5678.0, callback_4); | 923 int32_t rv_4 = file_io.Touch(1234.0, 5678.0, callback_4); |
| 918 if (rv_4 == PP_OK_COMPLETIONPENDING) | 924 if (rv_4 == PP_OK_COMPLETIONPENDING) |
| 919 rv_4 = callback_4.WaitForResult(); | 925 rv_4 = callback_4.WaitForResult(); |
| 920 if (rv_4 != PP_ERROR_INPROGRESS) | 926 if (rv_4 != PP_ERROR_INPROGRESS) |
| 921 return ReportError("FileIO::Touch", rv_4); | 927 return ReportError("FileIO::Touch", rv_4); |
| 928 callback_1.WaitForResult(); |
| 922 | 929 |
| 923 // Cannot set length while the write is pending. | 930 // Cannot set length while a write is pending. |
| 931 rv_1 = file_io.Write(write_offset_1, buf_1, strlen(buf_1), callback_1); |
| 932 ASSERT_EQ(PP_OK_COMPLETIONPENDING, rv_1); |
| 924 TestCompletionCallback callback_5(instance_->pp_instance(), force_async_); | 933 TestCompletionCallback callback_5(instance_->pp_instance(), force_async_); |
| 925 int32_t rv_5 = file_io.SetLength(123, callback_5); | 934 int32_t rv_5 = file_io.SetLength(123, callback_5); |
| 926 if (rv_5 == PP_OK_COMPLETIONPENDING) | 935 if (rv_5 == PP_OK_COMPLETIONPENDING) |
| 927 rv_5 = callback_5.WaitForResult(); | 936 rv_5 = callback_5.WaitForResult(); |
| 928 if (rv_5 != PP_ERROR_INPROGRESS) | 937 if (rv_5 != PP_ERROR_INPROGRESS) |
| 929 return ReportError("FileIO::SetLength", rv_5); | 938 return ReportError("FileIO::SetLength", rv_5); |
| 930 | |
| 931 callback_1.WaitForResult(); | 939 callback_1.WaitForResult(); |
| 932 | 940 |
| 933 PASS(); | 941 PASS(); |
| 934 } | 942 } |
| 935 | 943 |
| 936 std::string TestFileIO::TestWillWriteWillSetLength() { | 944 std::string TestFileIO::TestWillWriteWillSetLength() { |
| 937 TestCompletionCallback callback(instance_->pp_instance(), force_async_); | 945 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
| 938 | 946 |
| 939 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 947 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 940 pp::FileRef file_ref(file_system, "/file_will_write"); | 948 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(); | 1127 rv = callback.WaitForResult(); |
| 1120 if ((invalid_combination && rv == PP_OK) || | 1128 if ((invalid_combination && rv == PP_OK) || |
| 1121 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) { | 1129 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) { |
| 1122 return ReportOpenError(open_flags); | 1130 return ReportOpenError(open_flags); |
| 1123 } | 1131 } |
| 1124 | 1132 |
| 1125 return std::string(); | 1133 return std::string(); |
| 1126 } | 1134 } |
| 1127 | 1135 |
| 1128 // TODO(viettrungluu): Test Close(). crbug.com/69457 | 1136 // TODO(viettrungluu): Test Close(). crbug.com/69457 |
| OLD | NEW |