| 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 <fcntl.h> | 5 #include <fcntl.h> |
| 6 #include <gmock/gmock.h> | 6 #include <gmock/gmock.h> |
| 7 #include <ppapi/c/ppb_file_io.h> | 7 #include <ppapi/c/ppb_file_io.h> |
| 8 #include <ppapi/c/pp_errors.h> | 8 #include <ppapi/c/pp_errors.h> |
| 9 #include <ppapi/c/pp_instance.h> | 9 #include <ppapi/c/pp_instance.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 EXPECT_FALSE(bar->GetStat(&sbar)); | 367 EXPECT_FALSE(bar->GetStat(&sbar)); |
| 368 | 368 |
| 369 EXPECT_EQ(123, sfoo.st_size); | 369 EXPECT_EQ(123, sfoo.st_size); |
| 370 EXPECT_EQ(S_IFREG | S_IRALL, sfoo.st_mode); | 370 EXPECT_EQ(S_IFREG | S_IRALL, sfoo.st_mode); |
| 371 | 371 |
| 372 EXPECT_EQ(234, sbar.st_size); | 372 EXPECT_EQ(234, sbar.st_size); |
| 373 EXPECT_EQ(S_IFREG | S_IRALL | S_IWALL, sbar.st_mode); | 373 EXPECT_EQ(S_IFREG | S_IRALL | S_IWALL, sbar.st_mode); |
| 374 } | 374 } |
| 375 | 375 |
| 376 TEST(HttpFsBlobUrlTest, Basic) { | 376 TEST(HttpFsBlobUrlTest, Basic) { |
| 377 const char* kUrl = "blob:http%3A//example.com/6b87a5a6-713e"; | 377 const char* kUrl = "blob:http://example.com/6b87a5a6-713e"; |
| 378 const char* kContent = "hello"; | 378 const char* kContent = "hello"; |
| 379 FakePepperInterfaceURLLoader ppapi; | 379 FakePepperInterfaceURLLoader ppapi; |
| 380 ASSERT_TRUE(ppapi.server_template()->SetBlobEntity(kUrl, kContent, NULL)); | 380 ASSERT_TRUE(ppapi.server_template()->SetBlobEntity(kUrl, kContent, NULL)); |
| 381 | 381 |
| 382 StringMap_t args; | 382 StringMap_t args; |
| 383 args["SOURCE"] = kUrl; | 383 args["SOURCE"] = kUrl; |
| 384 | 384 |
| 385 HttpFsForTesting fs(args, &ppapi); | 385 HttpFsForTesting fs(args, &ppapi); |
| 386 | 386 |
| 387 // Any other path than / should fail. | 387 // Any other path than / should fail. |
| 388 ScopedNode node; | 388 ScopedNode node; |
| 389 ASSERT_EQ(ENOENT, fs.Open(Path("/blah"), R_OK, &node)); | 389 ASSERT_EQ(ENOENT, fs.Open(Path("/blah"), R_OK, &node)); |
| 390 | 390 |
| 391 // Check access to blob file | 391 // Check access to blob file |
| 392 ASSERT_EQ(0, fs.Open(Path("/"), O_RDONLY, &node)); | 392 ASSERT_EQ(0, fs.Open(Path("/"), O_RDONLY, &node)); |
| 393 ASSERT_EQ(true, node->IsaFile()); | 393 ASSERT_EQ(true, node->IsaFile()); |
| 394 | 394 |
| 395 // Verify file size and permissions | 395 // Verify file size and permissions |
| 396 struct stat buf; | 396 struct stat buf; |
| 397 ASSERT_EQ(0, node->GetStat(&buf)); | 397 ASSERT_EQ(0, node->GetStat(&buf)); |
| 398 ASSERT_EQ(S_IRUSR, buf.st_mode & S_IRWXU); | 398 ASSERT_EQ(S_IRUSR, buf.st_mode & S_IRWXU); |
| 399 ASSERT_EQ(strlen(kContent), buf.st_size); | 399 ASSERT_EQ(strlen(kContent), buf.st_size); |
| 400 } | 400 } |
| OLD | NEW |