| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 StringMap_t map; | 383 StringMap_t map; |
| 384 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); | 384 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); |
| 385 | 385 |
| 386 ScopedNode node; | 386 ScopedNode node; |
| 387 ASSERT_EQ(0, fs->Open(Path("/file"), O_RDONLY, &node)); | 387 ASSERT_EQ(0, fs->Open(Path("/file"), O_RDONLY, &node)); |
| 388 | 388 |
| 389 struct stat statbuf; | 389 struct stat statbuf; |
| 390 EXPECT_EQ(0, node->GetStat(&statbuf)); | 390 EXPECT_EQ(0, node->GetStat(&statbuf)); |
| 391 EXPECT_EQ(S_IFREG, statbuf.st_mode & S_IFMT); | 391 EXPECT_EQ(S_IFREG, statbuf.st_mode & S_IFMT); |
| 392 EXPECT_EQ(S_IRUSR | S_IRGRP | S_IROTH | | 392 EXPECT_EQ(S_IRALL | S_IWALL | S_IXALL, statbuf.st_mode & ~S_IFMT); |
| 393 S_IWUSR | S_IWGRP | S_IWOTH, statbuf.st_mode & ~S_IFMT); | |
| 394 EXPECT_EQ(strlen(contents), statbuf.st_size); | 393 EXPECT_EQ(strlen(contents), statbuf.st_size); |
| 395 EXPECT_EQ(access_time, statbuf.st_atime); | 394 EXPECT_EQ(access_time, statbuf.st_atime); |
| 396 EXPECT_EQ(creation_time, statbuf.st_ctime); | 395 EXPECT_EQ(creation_time, statbuf.st_ctime); |
| 397 EXPECT_EQ(modified_time, statbuf.st_mtime); | 396 EXPECT_EQ(modified_time, statbuf.st_mtime); |
| 398 | 397 |
| 399 // Test Get* and Isa* methods. | 398 // Test Get* and Isa* methods. |
| 400 off_t size; | 399 off_t size; |
| 401 EXPECT_EQ(0, node->GetSize(&size)); | 400 EXPECT_EQ(0, node->GetSize(&size)); |
| 402 EXPECT_EQ(strlen(contents), size); | 401 EXPECT_EQ(strlen(contents), size); |
| 403 EXPECT_FALSE(node->IsaDir()); | 402 EXPECT_FALSE(node->IsaDir()); |
| 404 EXPECT_TRUE(node->IsaFile()); | 403 EXPECT_TRUE(node->IsaFile()); |
| 405 EXPECT_EQ(ENOTTY, node->Isatty()); | 404 EXPECT_EQ(ENOTTY, node->Isatty()); |
| 406 | 405 |
| 407 // GetStat on a directory... | 406 // GetStat on a directory... |
| 408 EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node)); | 407 EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node)); |
| 409 EXPECT_EQ(0, node->GetStat(&statbuf)); | 408 EXPECT_EQ(0, node->GetStat(&statbuf)); |
| 410 EXPECT_EQ(S_IFDIR, statbuf.st_mode & S_IFMT); | 409 EXPECT_EQ(S_IFDIR, statbuf.st_mode & S_IFMT); |
| 411 EXPECT_EQ(S_IRUSR | S_IRGRP | S_IROTH | | 410 EXPECT_EQ(S_IRALL | S_IWALL | S_IXALL, statbuf.st_mode & ~S_IFMT); |
| 412 S_IWUSR | S_IWGRP | S_IWOTH, statbuf.st_mode & ~S_IFMT); | |
| 413 EXPECT_EQ(0, statbuf.st_size); | 411 EXPECT_EQ(0, statbuf.st_size); |
| 414 EXPECT_EQ(access_time, statbuf.st_atime); | 412 EXPECT_EQ(access_time, statbuf.st_atime); |
| 415 EXPECT_EQ(creation_time, statbuf.st_ctime); | 413 EXPECT_EQ(creation_time, statbuf.st_ctime); |
| 416 EXPECT_EQ(modified_time, statbuf.st_mtime); | 414 EXPECT_EQ(modified_time, statbuf.st_mtime); |
| 417 | 415 |
| 418 // Test Get* and Isa* methods. | 416 // Test Get* and Isa* methods. |
| 419 EXPECT_EQ(0, node->GetSize(&size)); | 417 EXPECT_EQ(0, node->GetSize(&size)); |
| 420 EXPECT_EQ(0, size); | 418 EXPECT_EQ(0, size); |
| 421 EXPECT_TRUE(node->IsaDir()); | 419 EXPECT_TRUE(node->IsaDir()); |
| 422 EXPECT_FALSE(node->IsaFile()); | 420 EXPECT_FALSE(node->IsaFile()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 EXPECT_EQ(sizeof(dirent), dirents[i].d_reclen); | 522 EXPECT_EQ(sizeof(dirent), dirents[i].d_reclen); |
| 525 dirnames.insert(dirents[i].d_name); | 523 dirnames.insert(dirents[i].d_name); |
| 526 } | 524 } |
| 527 | 525 |
| 528 EXPECT_EQ(1, dirnames.count("file")); | 526 EXPECT_EQ(1, dirnames.count("file")); |
| 529 EXPECT_EQ(1, dirnames.count("file2")); | 527 EXPECT_EQ(1, dirnames.count("file2")); |
| 530 EXPECT_EQ(1, dirnames.count(".")); | 528 EXPECT_EQ(1, dirnames.count(".")); |
| 531 EXPECT_EQ(1, dirnames.count("..")); | 529 EXPECT_EQ(1, dirnames.count("..")); |
| 532 } | 530 } |
| 533 } | 531 } |
| OLD | NEW |