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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 EXPECT_EQ(EEXIST, fs->Mkdir(Path("/"), 0644)); | 177 EXPECT_EQ(EEXIST, fs->Mkdir(Path("/"), 0644)); |
178 | 178 |
179 Path path("/foo"); | 179 Path path("/foo"); |
180 ASSERT_FALSE(fs->Exists("/foo")); | 180 ASSERT_FALSE(fs->Exists("/foo")); |
181 ASSERT_EQ(0, fs->Mkdir(path, 0644)); | 181 ASSERT_EQ(0, fs->Mkdir(path, 0644)); |
182 | 182 |
183 struct stat stat; | 183 struct stat stat; |
184 ScopedNode node; | 184 ScopedNode node; |
185 ASSERT_EQ(0, fs->Open(path, O_RDONLY, &node)); | 185 ASSERT_EQ(0, fs->Open(path, O_RDONLY, &node)); |
186 EXPECT_EQ(0, node->GetStat(&stat)); | 186 EXPECT_EQ(0, node->GetStat(&stat)); |
187 EXPECT_EQ(S_IFDIR, stat.st_mode & S_IFDIR); | 187 EXPECT_TRUE(S_ISDIR(stat.st_mode)); |
188 } | 188 } |
189 | 189 |
190 TEST_F(Html5FsTest, Remove) { | 190 TEST_F(Html5FsTest, Remove) { |
191 const char* kPath = "/foo"; | 191 const char* kPath = "/foo"; |
192 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile(kPath, NULL)); | 192 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile(kPath, NULL)); |
193 | 193 |
194 StringMap_t map; | 194 StringMap_t map; |
195 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); | 195 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); |
196 | 196 |
197 Path path(kPath); | 197 Path path(kPath); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 fake_node->set_last_modified_time(modified_time); | 381 fake_node->set_last_modified_time(modified_time); |
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_TRUE(S_ISREG(statbuf.st_mode)); |
392 EXPECT_EQ(S_IRALL | S_IWALL | S_IXALL, statbuf.st_mode & ~S_IFMT); | 392 EXPECT_EQ(S_IRALL | S_IWALL | S_IXALL, statbuf.st_mode & 0777); |
393 EXPECT_EQ(strlen(contents), statbuf.st_size); | 393 EXPECT_EQ(strlen(contents), statbuf.st_size); |
394 EXPECT_EQ(access_time, statbuf.st_atime); | 394 EXPECT_EQ(access_time, statbuf.st_atime); |
395 EXPECT_EQ(creation_time, statbuf.st_ctime); | 395 EXPECT_EQ(creation_time, statbuf.st_ctime); |
396 EXPECT_EQ(modified_time, statbuf.st_mtime); | 396 EXPECT_EQ(modified_time, statbuf.st_mtime); |
397 | 397 |
398 // Test Get* and Isa* methods. | 398 // Test Get* and Isa* methods. |
399 off_t size; | 399 off_t size; |
400 EXPECT_EQ(0, node->GetSize(&size)); | 400 EXPECT_EQ(0, node->GetSize(&size)); |
401 EXPECT_EQ(strlen(contents), size); | 401 EXPECT_EQ(strlen(contents), size); |
402 EXPECT_FALSE(node->IsaDir()); | 402 EXPECT_FALSE(node->IsaDir()); |
403 EXPECT_TRUE(node->IsaFile()); | 403 EXPECT_TRUE(node->IsaFile()); |
404 EXPECT_EQ(ENOTTY, node->Isatty()); | 404 EXPECT_EQ(ENOTTY, node->Isatty()); |
405 | 405 |
406 // GetStat on a directory... | 406 // GetStat on a directory... |
407 EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node)); | 407 EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node)); |
408 EXPECT_EQ(0, node->GetStat(&statbuf)); | 408 EXPECT_EQ(0, node->GetStat(&statbuf)); |
409 EXPECT_EQ(S_IFDIR, statbuf.st_mode & S_IFMT); | 409 EXPECT_TRUE(S_ISDIR(statbuf.st_mode)); |
410 EXPECT_EQ(S_IRALL | S_IWALL | S_IXALL, statbuf.st_mode & ~S_IFMT); | 410 EXPECT_EQ(S_IRALL | S_IWALL | S_IXALL, statbuf.st_mode & 0777); |
411 EXPECT_EQ(0, statbuf.st_size); | 411 EXPECT_EQ(0, statbuf.st_size); |
412 EXPECT_EQ(access_time, statbuf.st_atime); | 412 EXPECT_EQ(access_time, statbuf.st_atime); |
413 EXPECT_EQ(creation_time, statbuf.st_ctime); | 413 EXPECT_EQ(creation_time, statbuf.st_ctime); |
414 EXPECT_EQ(modified_time, statbuf.st_mtime); | 414 EXPECT_EQ(modified_time, statbuf.st_mtime); |
415 | 415 |
416 // Test Get* and Isa* methods. | 416 // Test Get* and Isa* methods. |
417 EXPECT_EQ(0, node->GetSize(&size)); | 417 EXPECT_EQ(0, node->GetSize(&size)); |
418 EXPECT_EQ(0, size); | 418 EXPECT_EQ(0, size); |
419 EXPECT_TRUE(node->IsaDir()); | 419 EXPECT_TRUE(node->IsaDir()); |
420 EXPECT_FALSE(node->IsaFile()); | 420 EXPECT_FALSE(node->IsaFile()); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 EXPECT_EQ(dirents[i].d_ino, file2_ino); | 538 EXPECT_EQ(dirents[i].d_ino, file2_ino); |
539 } | 539 } |
540 } | 540 } |
541 | 541 |
542 EXPECT_EQ(1, dirnames.count("file")); | 542 EXPECT_EQ(1, dirnames.count("file")); |
543 EXPECT_EQ(1, dirnames.count("file2")); | 543 EXPECT_EQ(1, dirnames.count("file2")); |
544 EXPECT_EQ(1, dirnames.count(".")); | 544 EXPECT_EQ(1, dirnames.count(".")); |
545 EXPECT_EQ(1, dirnames.count("..")); | 545 EXPECT_EQ(1, dirnames.count("..")); |
546 } | 546 } |
547 } | 547 } |
OLD | NEW |