OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 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 | 5 |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <gmock/gmock.h> | 7 #include <gmock/gmock.h> |
8 #include <ppapi/c/ppb_file_io.h> | 8 #include <ppapi/c/ppb_file_io.h> |
9 #include <ppapi/c/pp_errors.h> | 9 #include <ppapi/c/pp_errors.h> |
10 #include <ppapi/c/pp_instance.h> | 10 #include <ppapi/c/pp_instance.h> |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 ExpectOpen("HEAD"); | 379 ExpectOpen("HEAD"); |
380 ExpectHeaders(""); | 380 ExpectHeaders(""); |
381 SetResponse(200, "Content-Length: 42\n"); | 381 SetResponse(200, "Content-Length: 42\n"); |
382 OpenNode(); | 382 OpenNode(); |
383 | 383 |
384 struct stat stat; | 384 struct stat stat; |
385 EXPECT_EQ(0, node_->GetStat(&stat)); | 385 EXPECT_EQ(0, node_->GetStat(&stat)); |
386 EXPECT_EQ(42, stat.st_size); | 386 EXPECT_EQ(42, stat.st_size); |
387 } | 387 } |
388 | 388 |
| 389 TEST_F(MountHttpNodeTest, Access) { |
| 390 StringMap_t smap; |
| 391 smap["cache_content"] = "false"; |
| 392 SetMountArgs(StringMap_t()); |
| 393 ExpectOpen("HEAD"); |
| 394 ExpectHeaders(""); |
| 395 SetResponse(200, ""); |
| 396 ASSERT_EQ(0, mnt_->Access(Path(path_), R_OK)); |
| 397 } |
| 398 |
| 399 TEST_F(MountHttpNodeTest, AccessWrite) { |
| 400 StringMap_t smap; |
| 401 smap["cache_content"] = "false"; |
| 402 SetMountArgs(StringMap_t()); |
| 403 ExpectOpen("HEAD"); |
| 404 ExpectHeaders(""); |
| 405 SetResponse(200, ""); |
| 406 ASSERT_EQ(EACCES, mnt_->Access(Path(path_), W_OK)); |
| 407 } |
| 408 |
| 409 TEST_F(MountHttpNodeTest, AccessNotFound) { |
| 410 StringMap_t smap; |
| 411 smap["cache_content"] = "false"; |
| 412 SetMountArgs(StringMap_t()); |
| 413 ExpectOpen("HEAD"); |
| 414 ExpectHeaders(""); |
| 415 SetResponseExpectFail(404, ""); |
| 416 ASSERT_EQ(ENOENT, mnt_->Access(Path(path_), R_OK)); |
| 417 } |
| 418 |
389 TEST_F(MountHttpNodeTest, ReadCached) { | 419 TEST_F(MountHttpNodeTest, ReadCached) { |
390 size_t result_size = 0; | 420 size_t result_size = 0; |
391 int result_bytes = 0; | 421 int result_bytes = 0; |
392 | 422 |
393 SetMountArgs(StringMap_t()); | 423 SetMountArgs(StringMap_t()); |
394 ExpectOpen("HEAD"); | 424 ExpectOpen("HEAD"); |
395 ExpectHeaders(""); | 425 ExpectHeaders(""); |
396 SetResponse(200, "Content-Length: 42\n"); | 426 SetResponse(200, "Content-Length: 42\n"); |
397 OpenNode(); | 427 OpenNode(); |
398 ResetMocks(); | 428 ResetMocks(); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 memset(&buf[0], 0, sizeof(buf)); | 599 memset(&buf[0], 0, sizeof(buf)); |
570 | 600 |
571 ExpectOpen("GET"); | 601 ExpectOpen("GET"); |
572 ExpectHeaders("Range: bytes=10-18\n"); | 602 ExpectHeaders("Range: bytes=10-18\n"); |
573 SetResponse(200, "Content-Length: 20\n"); | 603 SetResponse(200, "Content-Length: 20\n"); |
574 SetResponseBody("0123456789abcdefghij"); | 604 SetResponseBody("0123456789abcdefghij"); |
575 EXPECT_EQ(0, node_->Read(10, buf, sizeof(buf) - 1, &result_bytes)); | 605 EXPECT_EQ(0, node_->Read(10, buf, sizeof(buf) - 1, &result_bytes)); |
576 EXPECT_EQ(sizeof(buf) - 1, result_bytes); | 606 EXPECT_EQ(sizeof(buf) - 1, result_bytes); |
577 EXPECT_STREQ("abcdefghi", &buf[0]); | 607 EXPECT_STREQ("abcdefghi", &buf[0]); |
578 } | 608 } |
OLD | NEW |