| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <errno.h> | 5 #include <errno.h> |
| 6 #include <fcntl.h> | 6 #include <fcntl.h> |
| 7 #include <pthread.h> | 7 #include <pthread.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 } | 511 } |
| 512 | 512 |
| 513 protected: | 513 protected: |
| 514 ScopedNode node_; | 514 ScopedNode node_; |
| 515 }; | 515 }; |
| 516 | 516 |
| 517 const int JsFsNodeTest::fd = 123; | 517 const int JsFsNodeTest::fd = 123; |
| 518 | 518 |
| 519 } // namespace | 519 } // namespace |
| 520 | 520 |
| 521 TEST_F(JsFsTest, Access) { | |
| 522 int a_mode = R_OK | W_OK | X_OK; | |
| 523 | |
| 524 PP_Var expected; | |
| 525 ASSERT_EQ(true, CreateDict(&expected)); | |
| 526 ASSERT_EQ(true, SetDictKeyValue(&expected, "id", 1)); | |
| 527 ASSERT_EQ(true, SetDictKeyValue(&expected, "cmd", "access")); | |
| 528 ASSERT_EQ(true, SetDictKeyValue(&expected, "path", "/foo")); | |
| 529 ASSERT_EQ(true, SetDictKeyValue(&expected, "amode", a_mode)); | |
| 530 | |
| 531 PP_Var response; | |
| 532 ASSERT_EQ(true, CreateDict(&response)); | |
| 533 ASSERT_EQ(true, SetDictKeyValue(&response, "id", 1)); | |
| 534 ASSERT_EQ(true, SetDictKeyValue(&response, "error", 0)); | |
| 535 | |
| 536 Expect(expected, response); | |
| 537 StartJsThread(); | |
| 538 | |
| 539 EXPECT_EQ(0, fs_->Access(Path("/foo"), a_mode)); | |
| 540 } | |
| 541 | |
| 542 TEST_F(JsFsTest, Open) { | 521 TEST_F(JsFsTest, Open) { |
| 543 PP_Var expected; | 522 PP_Var expected; |
| 544 ASSERT_EQ(true, CreateDict(&expected)); | 523 ASSERT_EQ(true, CreateDict(&expected)); |
| 545 ASSERT_EQ(true, SetDictKeyValue(&expected, "id", 1)); | 524 ASSERT_EQ(true, SetDictKeyValue(&expected, "id", 1)); |
| 546 ASSERT_EQ(true, SetDictKeyValue(&expected, "cmd", "open")); | 525 ASSERT_EQ(true, SetDictKeyValue(&expected, "cmd", "open")); |
| 547 ASSERT_EQ(true, SetDictKeyValue(&expected, "path", "/foo")); | 526 ASSERT_EQ(true, SetDictKeyValue(&expected, "path", "/foo")); |
| 548 ASSERT_EQ(true, SetDictKeyValue(&expected, "oflag", O_RDONLY)); | 527 ASSERT_EQ(true, SetDictKeyValue(&expected, "oflag", O_RDONLY)); |
| 549 | 528 |
| 550 PP_Var response; | 529 PP_Var response; |
| 551 ASSERT_EQ(true, CreateDict(&response)); | 530 ASSERT_EQ(true, CreateDict(&response)); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 EXPECT_EQ(sizeof(dirent) * 2, bytes_written); | 823 EXPECT_EQ(sizeof(dirent) * 2, bytes_written); |
| 845 EXPECT_EQ(2, buf[0].d_ino); | 824 EXPECT_EQ(2, buf[0].d_ino); |
| 846 EXPECT_EQ(sizeof(dirent), buf[0].d_off); | 825 EXPECT_EQ(sizeof(dirent), buf[0].d_off); |
| 847 EXPECT_EQ(sizeof(dirent), buf[0].d_reclen); | 826 EXPECT_EQ(sizeof(dirent), buf[0].d_reclen); |
| 848 EXPECT_STREQ(".", buf[0].d_name); | 827 EXPECT_STREQ(".", buf[0].d_name); |
| 849 EXPECT_EQ(3, buf[1].d_ino); | 828 EXPECT_EQ(3, buf[1].d_ino); |
| 850 EXPECT_EQ(sizeof(dirent), buf[1].d_off); | 829 EXPECT_EQ(sizeof(dirent), buf[1].d_off); |
| 851 EXPECT_EQ(sizeof(dirent), buf[1].d_reclen); | 830 EXPECT_EQ(sizeof(dirent), buf[1].d_reclen); |
| 852 EXPECT_STREQ("..", buf[1].d_name); | 831 EXPECT_STREQ("..", buf[1].d_name); |
| 853 } | 832 } |
| OLD | NEW |