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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 48113006: Fix scoping of raw_bytes in URLRequestFileDirJob::OnListFile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use AppendASCII in unittest Created 7 years, 2 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 | « net/url_request/url_request_file_dir_job.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « net/url_request/url_request_file_dir_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698