OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 // This is a regression test for crbug.com/243241. | 1131 // This is a regression test for crbug.com/243241. |
1132 std::string TestFileIO::TestRequestOSFileHandleWithOpenExclusive() { | 1132 std::string TestFileIO::TestRequestOSFileHandleWithOpenExclusive() { |
1133 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); | 1133 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
1134 | 1134 |
1135 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 1135 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
1136 pp::FileRef file_ref(file_system, "/file_os_fd2"); | 1136 pp::FileRef file_ref(file_system, "/file_os_fd2"); |
1137 | 1137 |
1138 callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); | 1138 callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); |
1139 ASSERT_EQ(PP_OK, callback.result()); | 1139 ASSERT_EQ(PP_OK, callback.result()); |
1140 | 1140 |
| 1141 // Open with PP_FILEOPENFLAG_CREATE and PP_FILEOPENFLAG_EXCLUSIVE will fail |
| 1142 // if the file already exists. Delete it here to make sure it does not. |
| 1143 callback.WaitForResult(file_ref.Delete(callback.GetCallback())); |
| 1144 |
1141 pp::FileIO_Private file_io(instance_); | 1145 pp::FileIO_Private file_io(instance_); |
1142 callback.WaitForResult(file_io.Open(file_ref, | 1146 callback.WaitForResult(file_io.Open(file_ref, |
1143 PP_FILEOPENFLAG_CREATE | | 1147 PP_FILEOPENFLAG_CREATE | |
1144 PP_FILEOPENFLAG_READ | | 1148 PP_FILEOPENFLAG_READ | |
1145 PP_FILEOPENFLAG_WRITE | | 1149 PP_FILEOPENFLAG_WRITE | |
1146 PP_FILEOPENFLAG_EXCLUSIVE, | 1150 PP_FILEOPENFLAG_EXCLUSIVE, |
1147 callback.GetCallback())); | 1151 callback.GetCallback())); |
1148 ASSERT_EQ(PP_OK, callback.result()); | 1152 ASSERT_EQ(PP_OK, callback.result()); |
1149 | 1153 |
1150 TestCompletionCallbackWithOutput<pp::PassFileHandle> output_callback( | 1154 TestCompletionCallbackWithOutput<pp::PassFileHandle> output_callback( |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 if ((invalid_combination && callback.result() == PP_OK) || | 1409 if ((invalid_combination && callback.result() == PP_OK) || |
1406 (!invalid_combination && | 1410 (!invalid_combination && |
1407 ((callback.result() == PP_OK) != create_if_doesnt_exist))) { | 1411 ((callback.result() == PP_OK) != create_if_doesnt_exist))) { |
1408 return ReportOpenError(open_flags); | 1412 return ReportOpenError(open_flags); |
1409 } | 1413 } |
1410 | 1414 |
1411 return std::string(); | 1415 return std::string(); |
1412 } | 1416 } |
1413 | 1417 |
1414 // TODO(viettrungluu): Test Close(). crbug.com/69457 | 1418 // TODO(viettrungluu): Test Close(). crbug.com/69457 |
OLD | NEW |