| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
| 9 #include "content/browser/download/download_create_info.h" | 9 #include "content/browser/download/download_create_info.h" |
| 10 #include "content/browser/download/download_file.h" | 10 #include "content/browser/download/download_file.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 // Rename the file after downloading all the data. | 175 // Rename the file after downloading all the data. |
| 176 EXPECT_EQ(net::OK, download_file_->Rename(path_3)); | 176 EXPECT_EQ(net::OK, download_file_->Rename(path_3)); |
| 177 renamed_path = download_file_->full_path(); | 177 renamed_path = download_file_->full_path(); |
| 178 EXPECT_EQ(path_3, renamed_path); | 178 EXPECT_EQ(path_3, renamed_path); |
| 179 | 179 |
| 180 // Check the files. | 180 // Check the files. |
| 181 EXPECT_FALSE(file_util::PathExists(path_2)); | 181 EXPECT_FALSE(file_util::PathExists(path_2)); |
| 182 EXPECT_TRUE(file_util::PathExists(path_3)); | 182 EXPECT_TRUE(file_util::PathExists(path_3)); |
| 183 | 183 |
| 184 // Should not be able to get the hash until the file is closed. | |
| 185 std::string hash; | |
| 186 EXPECT_FALSE(download_file_->GetSha256Hash(&hash)); | |
| 187 | |
| 188 download_file_->Finish(); | 184 download_file_->Finish(); |
| 189 | 185 |
| 190 // Rename the file after downloading all the data and closing the file. | 186 // Rename the file after downloading all the data and closing the file. |
| 191 EXPECT_EQ(net::OK, download_file_->Rename(path_4)); | 187 EXPECT_EQ(net::OK, download_file_->Rename(path_4)); |
| 192 renamed_path = download_file_->full_path(); | 188 renamed_path = download_file_->full_path(); |
| 193 EXPECT_EQ(path_4, renamed_path); | 189 EXPECT_EQ(path_4, renamed_path); |
| 194 | 190 |
| 195 // Check the files. | 191 // Check the files. |
| 196 EXPECT_FALSE(file_util::PathExists(path_3)); | 192 EXPECT_FALSE(file_util::PathExists(path_3)); |
| 197 EXPECT_TRUE(file_util::PathExists(path_4)); | 193 EXPECT_TRUE(file_util::PathExists(path_4)); |
| 198 | 194 |
| 199 // Check the hash. | 195 // Check the hash. |
| 196 std::string hash; |
| 200 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); | 197 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); |
| 201 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); | 198 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); |
| 202 | 199 |
| 203 DestroyDownloadFile(&download_file_, 0); | 200 DestroyDownloadFile(&download_file_, 0); |
| 204 } | 201 } |
| OLD | NEW |