| Index: native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc
|
| diff --git a/native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc b/native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc
|
| index 1bc75068f10a3da0d0863bf5f652e72a9ecfd438..a8d725380be252f01ae3beef48d491cf6ec4108f 100644
|
| --- a/native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc
|
| +++ b/native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc
|
| @@ -176,6 +176,9 @@ class MountHttpNodeTest : public MountHttpTest {
|
| void ExpectHeaders(const char* headers);
|
| void OpenNode();
|
| void SetResponse(int status_code, const char* headers);
|
| + // Set a response code, but expect the request to fail. Certain function calls
|
| + // expected by SetResponse are not expected here.
|
| + void SetResponseExpectFail(int status_code, const char* headers);
|
| void SetResponseBody(const char* body);
|
| void ResetMocks();
|
|
|
| @@ -283,6 +286,18 @@ void MountHttpNodeTest::SetResponse(int status_code, const char* headers) {
|
| Return(headers)));
|
| }
|
|
|
| +void MountHttpNodeTest::SetResponseExpectFail(int status_code,
|
| + const char* headers) {
|
| + ON_CALL(*response_, GetProperty(response_resource_, _))
|
| + .WillByDefault(Return(PP_MakeUndefined()));
|
| +
|
| + PP_Var var_headers = MakeString(348);
|
| + EXPECT_CALL(*response_,
|
| + GetProperty(response_resource_,
|
| + PP_URLRESPONSEPROPERTY_STATUSCODE))
|
| + .WillOnce(Return(PP_MakeInt32(status_code)));
|
| +}
|
| +
|
| ACTION_P3(ReadResponseBodyAction, offset, body, body_length) {
|
| char* buf = static_cast<char*>(arg1);
|
| size_t read_length = arg2;
|
| @@ -337,6 +352,37 @@ TEST_F(MountHttpNodeTest, OpenAndCloseNoCache) {
|
| OpenNode();
|
| }
|
|
|
| +TEST_F(MountHttpNodeTest, Access) {
|
| + StringMap_t smap;
|
| + smap["cache_content"] = "false";
|
| + SetMountArgs(StringMap_t());
|
| + ExpectOpen("HEAD");
|
| + ExpectHeaders("");
|
| + SetResponse(200, "");
|
| + ASSERT_EQ(0, mnt_->Access(Path(path_), R_OK));
|
| +}
|
| +
|
| +TEST_F(MountHttpNodeTest, AccessWrite) {
|
| + StringMap_t smap;
|
| + smap["cache_content"] = "false";
|
| + SetMountArgs(StringMap_t());
|
| + ExpectOpen("HEAD");
|
| + ExpectHeaders("");
|
| + SetResponse(200, "");
|
| + ASSERT_EQ(EACCES, mnt_->Access(Path(path_), W_OK));
|
| +}
|
| +
|
| +TEST_F(MountHttpNodeTest, AccessNotFound) {
|
| + StringMap_t smap;
|
| + smap["cache_content"] = "false";
|
| + SetMountArgs(StringMap_t());
|
| + ExpectOpen("HEAD");
|
| + ExpectHeaders("");
|
| + SetResponseExpectFail(404, "");
|
| + // TODO(mgiuca): Expect ENOENT instead. http://crbug.com/251662.
|
| + ASSERT_EQ(EINVAL, mnt_->Access(Path(path_), R_OK));
|
| +}
|
| +
|
| TEST_F(MountHttpNodeTest, ReadCached) {
|
| size_t result_size = 0;
|
| int result_bytes = 0;
|
|
|