Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc

Issue 16959007: [NaCl SDK] httpfs now sets errno to an appropriate value on non-200 response. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Simplify code using HTTPStatusCodeToErrno. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_node_http.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f7c21de5abbddc74730baba4a0efa0c0fea6f469 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,40 @@ TEST_F(MountHttpNodeTest, OpenAndCloseNoCache) {
OpenNode();
}
+TEST_F(MountHttpNodeTest, OpenAndCloseNotFound) {
+ StringMap_t smap;
+ smap["cache_content"] = "false";
+ SetMountArgs(StringMap_t());
+ ExpectOpen("HEAD");
+ ExpectHeaders("");
+ SetResponseExpectFail(404, "");
+ ASSERT_EQ(ENOENT, mnt_->Open(Path(path_), O_RDONLY, &node_));
+}
+
+TEST_F(MountHttpNodeTest, OpenAndCloseServerError) {
+ StringMap_t smap;
+ smap["cache_content"] = "false";
+ SetMountArgs(StringMap_t());
+ ExpectOpen("HEAD");
+ ExpectHeaders("");
+ SetResponseExpectFail(500, "");
+ ASSERT_EQ(EIO, mnt_->Open(Path(path_), O_RDONLY, &node_));
+}
+
+TEST_F(MountHttpNodeTest, GetStat) {
+ StringMap_t smap;
+ smap["cache_content"] = "false";
+ SetMountArgs(StringMap_t());
+ ExpectOpen("HEAD");
+ ExpectHeaders("");
+ SetResponse(200, "Content-Length: 42\n");
+ OpenNode();
+
+ struct stat stat;
+ EXPECT_EQ(0, node_->GetStat(&stat));
+ EXPECT_EQ(42, stat.st_size);
+}
+
TEST_F(MountHttpNodeTest, ReadCached) {
size_t result_size = 0;
int result_bytes = 0;
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_node_http.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698