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