Index: net/url_request/url_request_unittest.cc |
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc |
index e55af568da125feefd7ba94c3ae04001d9d0c14a..08aa1b15e277ef30bc889e182bdc1ea8e89d764f 100644 |
--- a/net/url_request/url_request_unittest.cc |
+++ b/net/url_request/url_request_unittest.cc |
@@ -944,6 +944,43 @@ TEST_F(URLRequestTest, FileDirCancelTest) { |
NetModule::SetResourceProvider(NULL); |
} |
+TEST_F(URLRequestTest, FileDirOutputSanity) { |
+ // Verify the general sanity of the the output of the file: |
+ // directory lister by checking for the output of a known existing |
+ // file. |
+ const char sentinel_name[] = "filedir-sentinel"; |
+ |
+ base::FilePath path; |
+ PathService::Get(base::DIR_SOURCE_ROOT, &path); |
+ path = path.Append(FILE_PATH_LITERAL("net")); |
+ path = path.Append(FILE_PATH_LITERAL("data")); |
+ path = path.Append(FILE_PATH_LITERAL("url_request_unittest")); |
+ |
+ TestDelegate d; |
+ URLRequest req(FilePathToFileURL(path), &d, &default_context_); |
+ req.Start(); |
+ base::RunLoop().Run(); |
+ |
+ // Generate entry for the sentinel file. |
+ base::FilePath sentinel_path = path.AppendASCII(sentinel_name); |
+ base::PlatformFileInfo info; |
+ EXPECT_TRUE(file_util::GetFileInfo(sentinel_path, &info)); |
+ EXPECT_GT(info.size, 0); |
+ std::string sentinel_output = GetDirectoryListingEntry( |
+ base::string16(sentinel_name, sentinel_name + strlen(sentinel_name)), |
+ std::string(sentinel_name), |
+ false /* is_dir */, |
+ info.size, |
+ info.last_modified); |
+ |
+ ASSERT_LT(0, d.bytes_received()); |
+ ASSERT_FALSE(d.request_failed()); |
+ ASSERT_TRUE(req.status().is_success()); |
+ // Check for the entry generated for the "sentinel" file. |
+ const std::string& data = d.data_received(); |
+ ASSERT_NE(data.find(sentinel_output), std::string::npos); |
+} |
+ |
TEST_F(URLRequestTest, FileDirRedirectNoCrash) { |
// There is an implicit redirect when loading a file path that matches a |
// directory and does not end with a slash. Ensure that following such |