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

Side by Side 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, 1 month 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 937
938 d.set_cancel_in_received_data_pending(true); 938 d.set_cancel_in_received_data_pending(true);
939 939
940 base::RunLoop().Run(); 940 base::RunLoop().Run();
941 } 941 }
942 942
943 // Take out mock resource provider. 943 // Take out mock resource provider.
944 NetModule::SetResourceProvider(NULL); 944 NetModule::SetResourceProvider(NULL);
945 } 945 }
946 946
947 TEST_F(URLRequestTest, FileDirOutputSanity) {
948 // Verify the general sanity of the the output of the file:
949 // directory lister by checking for the output of a known existing
950 // file.
951 const char sentinel_name[] = "filedir-sentinel";
952
953 base::FilePath path;
954 PathService::Get(base::DIR_SOURCE_ROOT, &path);
955 path = path.Append(FILE_PATH_LITERAL("net"));
956 path = path.Append(FILE_PATH_LITERAL("data"));
957 path = path.Append(FILE_PATH_LITERAL("url_request_unittest"));
958
959 TestDelegate d;
960 URLRequest req(FilePathToFileURL(path), &d, &default_context_);
961 req.Start();
962 base::RunLoop().Run();
963
964 // Generate entry for the sentinel file.
965 base::FilePath sentinel_path = path.AppendASCII(sentinel_name);
966 base::PlatformFileInfo info;
967 EXPECT_TRUE(file_util::GetFileInfo(sentinel_path, &info));
968 EXPECT_GT(info.size, 0);
969 std::string sentinel_output = GetDirectoryListingEntry(
970 base::string16(sentinel_name, sentinel_name + strlen(sentinel_name)),
971 std::string(sentinel_name),
972 false /* is_dir */,
973 info.size,
974 info.last_modified);
975
976 ASSERT_LT(0, d.bytes_received());
977 ASSERT_FALSE(d.request_failed());
978 ASSERT_TRUE(req.status().is_success());
979 // Check for the entry generated for the "sentinel" file.
980 const std::string& data = d.data_received();
981 ASSERT_NE(data.find(sentinel_output), std::string::npos);
982 }
983
947 TEST_F(URLRequestTest, FileDirRedirectNoCrash) { 984 TEST_F(URLRequestTest, FileDirRedirectNoCrash) {
948 // There is an implicit redirect when loading a file path that matches a 985 // There is an implicit redirect when loading a file path that matches a
949 // directory and does not end with a slash. Ensure that following such 986 // directory and does not end with a slash. Ensure that following such
950 // redirects does not crash. See http://crbug.com/18686. 987 // redirects does not crash. See http://crbug.com/18686.
951 988
952 base::FilePath path; 989 base::FilePath path;
953 PathService::Get(base::DIR_SOURCE_ROOT, &path); 990 PathService::Get(base::DIR_SOURCE_ROOT, &path);
954 path = path.Append(FILE_PATH_LITERAL("net")); 991 path = path.Append(FILE_PATH_LITERAL("net"));
955 path = path.Append(FILE_PATH_LITERAL("data")); 992 path = path.Append(FILE_PATH_LITERAL("data"));
956 path = path.Append(FILE_PATH_LITERAL("url_request_unittest")); 993 path = path.Append(FILE_PATH_LITERAL("url_request_unittest"));
(...skipping 6009 matching lines...) Expand 10 before | Expand all | Expand 10 after
6966 7003
6967 EXPECT_FALSE(r.is_pending()); 7004 EXPECT_FALSE(r.is_pending());
6968 EXPECT_EQ(1, d->response_started_count()); 7005 EXPECT_EQ(1, d->response_started_count());
6969 EXPECT_FALSE(d->received_data_before_response()); 7006 EXPECT_FALSE(d->received_data_before_response());
6970 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 7007 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
6971 } 7008 }
6972 } 7009 }
6973 #endif // !defined(DISABLE_FTP_SUPPORT) 7010 #endif // !defined(DISABLE_FTP_SUPPORT)
6974 7011
6975 } // namespace net 7012 } // namespace net
OLDNEW
« 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