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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 PP_FILEOPENFLAG_WRITE, | 561 PP_FILEOPENFLAG_WRITE, |
562 callback.GetCallback())); | 562 callback.GetCallback())); |
563 CHECK_CALLBACK_BEHAVIOR(callback); | 563 CHECK_CALLBACK_BEHAVIOR(callback); |
564 ASSERT_EQ(PP_OK, callback.result()); | 564 ASSERT_EQ(PP_OK, callback.result()); |
565 | 565 |
566 // Write some data to have a non-zero file size. | 566 // Write some data to have a non-zero file size. |
567 callback.WaitForResult(file_io.Write(0, "test", 4, callback.GetCallback())); | 567 callback.WaitForResult(file_io.Write(0, "test", 4, callback.GetCallback())); |
568 CHECK_CALLBACK_BEHAVIOR(callback); | 568 CHECK_CALLBACK_BEHAVIOR(callback); |
569 ASSERT_EQ(4, callback.result()); | 569 ASSERT_EQ(4, callback.result()); |
570 | 570 |
571 // last_access_time's granularity is 1 day | 571 const PP_Time last_access_time = 123 * 24 * 3600.0; |
572 // last_modified_time's granularity is 2 seconds | 572 // last_modified_time's granularity is 2 seconds |
573 const PP_Time last_access_time = 123 * 24 * 3600.0; | 573 // NOTE: In NaCl on Windows, NaClDescIO uses _fstat64 to retrieve file info. |
574 const PP_Time last_modified_time = 246.0; | 574 // This function returns strange values for very small time values (near the |
| 575 // Unix Epoch). For a value like 246.0, it returns -1. For larger values, it |
| 576 // returns values that are exactly an hour less. The value below is handled |
| 577 // correctly, and is only 100 days after the start of Unix time. |
| 578 const PP_Time last_modified_time = 100 * 24 * 3600.0; |
575 callback.WaitForResult(file_io.Touch(last_access_time, last_modified_time, | 579 callback.WaitForResult(file_io.Touch(last_access_time, last_modified_time, |
576 callback.GetCallback())); | 580 callback.GetCallback())); |
577 CHECK_CALLBACK_BEHAVIOR(callback); | 581 CHECK_CALLBACK_BEHAVIOR(callback); |
578 ASSERT_EQ(PP_OK, callback.result()); | 582 ASSERT_EQ(PP_OK, callback.result()); |
579 | 583 |
580 PP_FileInfo info; | 584 PP_FileInfo info; |
581 callback.WaitForResult(file_io.Query(&info, callback.GetCallback())); | 585 callback.WaitForResult(file_io.Query(&info, callback.GetCallback())); |
582 CHECK_CALLBACK_BEHAVIOR(callback); | 586 CHECK_CALLBACK_BEHAVIOR(callback); |
583 ASSERT_EQ(PP_OK, callback.result()); | 587 ASSERT_EQ(PP_OK, callback.result()); |
584 | 588 |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 if ((invalid_combination && callback.result() == PP_OK) || | 1413 if ((invalid_combination && callback.result() == PP_OK) || |
1410 (!invalid_combination && | 1414 (!invalid_combination && |
1411 ((callback.result() == PP_OK) != create_if_doesnt_exist))) { | 1415 ((callback.result() == PP_OK) != create_if_doesnt_exist))) { |
1412 return ReportOpenError(open_flags); | 1416 return ReportOpenError(open_flags); |
1413 } | 1417 } |
1414 | 1418 |
1415 return std::string(); | 1419 return std::string(); |
1416 } | 1420 } |
1417 | 1421 |
1418 // TODO(viettrungluu): Test Close(). crbug.com/69457 | 1422 // TODO(viettrungluu): Test Close(). crbug.com/69457 |
OLD | NEW |