| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 EXPECT_EQ(access_time, statbuf.st_atime); | 357 EXPECT_EQ(access_time, statbuf.st_atime); |
| 358 EXPECT_EQ(creation_time, statbuf.st_ctime); | 358 EXPECT_EQ(creation_time, statbuf.st_ctime); |
| 359 EXPECT_EQ(modified_time, statbuf.st_mtime); | 359 EXPECT_EQ(modified_time, statbuf.st_mtime); |
| 360 | 360 |
| 361 // Test Get* and Isa* methods. | 361 // Test Get* and Isa* methods. |
| 362 size_t size; | 362 size_t size; |
| 363 EXPECT_EQ(0, node->GetSize(&size)); | 363 EXPECT_EQ(0, node->GetSize(&size)); |
| 364 EXPECT_EQ(strlen(contents), size); | 364 EXPECT_EQ(strlen(contents), size); |
| 365 EXPECT_FALSE(node->IsaDir()); | 365 EXPECT_FALSE(node->IsaDir()); |
| 366 EXPECT_TRUE(node->IsaFile()); | 366 EXPECT_TRUE(node->IsaFile()); |
| 367 EXPECT_FALSE(node->IsaTTY()); | 367 EXPECT_EQ(ENOTTY, node->Isatty()); |
| 368 | 368 |
| 369 // GetStat on a directory... | 369 // GetStat on a directory... |
| 370 EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node)); | 370 EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node)); |
| 371 EXPECT_EQ(0, node->GetStat(&statbuf)); | 371 EXPECT_EQ(0, node->GetStat(&statbuf)); |
| 372 EXPECT_EQ(S_IFDIR, statbuf.st_mode & S_IFMT); | 372 EXPECT_EQ(S_IFDIR, statbuf.st_mode & S_IFMT); |
| 373 EXPECT_EQ(S_IRUSR | S_IRGRP | S_IROTH | | 373 EXPECT_EQ(S_IRUSR | S_IRGRP | S_IROTH | |
| 374 S_IWUSR | S_IWGRP | S_IWOTH, statbuf.st_mode & ~S_IFMT); | 374 S_IWUSR | S_IWGRP | S_IWOTH, statbuf.st_mode & ~S_IFMT); |
| 375 EXPECT_EQ(0, statbuf.st_size); | 375 EXPECT_EQ(0, statbuf.st_size); |
| 376 EXPECT_EQ(access_time, statbuf.st_atime); | 376 EXPECT_EQ(access_time, statbuf.st_atime); |
| 377 EXPECT_EQ(creation_time, statbuf.st_ctime); | 377 EXPECT_EQ(creation_time, statbuf.st_ctime); |
| 378 EXPECT_EQ(modified_time, statbuf.st_mtime); | 378 EXPECT_EQ(modified_time, statbuf.st_mtime); |
| 379 | 379 |
| 380 // Test Get* and Isa* methods. | 380 // Test Get* and Isa* methods. |
| 381 EXPECT_EQ(0, node->GetSize(&size)); | 381 EXPECT_EQ(0, node->GetSize(&size)); |
| 382 EXPECT_EQ(0, size); | 382 EXPECT_EQ(0, size); |
| 383 EXPECT_TRUE(node->IsaDir()); | 383 EXPECT_TRUE(node->IsaDir()); |
| 384 EXPECT_FALSE(node->IsaFile()); | 384 EXPECT_FALSE(node->IsaFile()); |
| 385 EXPECT_FALSE(node->IsaTTY()); | 385 EXPECT_EQ(ENOTTY, node->Isatty()); |
| 386 } | 386 } |
| 387 | 387 |
| 388 TEST_F(Html5FsTest, FTruncate) { | 388 TEST_F(Html5FsTest, FTruncate) { |
| 389 const char contents[] = "contents"; | 389 const char contents[] = "contents"; |
| 390 EXPECT_TRUE( | 390 EXPECT_TRUE( |
| 391 ppapi_html5_.filesystem_template()->AddFile("/file", contents, NULL)); | 391 ppapi_html5_.filesystem_template()->AddFile("/file", contents, NULL)); |
| 392 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL)); | 392 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL)); |
| 393 | 393 |
| 394 StringMap_t map; | 394 StringMap_t map; |
| 395 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); | 395 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 EXPECT_EQ(sizeof(dirent), dirents[i].d_reclen); | 486 EXPECT_EQ(sizeof(dirent), dirents[i].d_reclen); |
| 487 dirnames.insert(dirents[i].d_name); | 487 dirnames.insert(dirents[i].d_name); |
| 488 } | 488 } |
| 489 | 489 |
| 490 EXPECT_EQ(1, dirnames.count("file")); | 490 EXPECT_EQ(1, dirnames.count("file")); |
| 491 EXPECT_EQ(1, dirnames.count("file2")); | 491 EXPECT_EQ(1, dirnames.count("file2")); |
| 492 EXPECT_EQ(1, dirnames.count(".")); | 492 EXPECT_EQ(1, dirnames.count(".")); |
| 493 EXPECT_EQ(1, dirnames.count("..")); | 493 EXPECT_EQ(1, dirnames.count("..")); |
| 494 } | 494 } |
| 495 } | 495 } |
| OLD | NEW |