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

Side by Side Diff: content/browser/download/download_file_unittest.cc

Issue 7646025: Detect file system errors during downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk. Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/scoped_temp_dir.h" 7 #include "base/scoped_temp_dir.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "content/browser/browser_thread.h" 9 #include "content/browser/browser_thread.h"
10 #include "content/browser/download/download_create_info.h" 10 #include "content/browser/download/download_create_info.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 EXPECT_FALSE((*file)->in_progress()); 71 EXPECT_FALSE((*file)->in_progress());
72 EXPECT_EQ(static_cast<int64>(expected_data_.size()), 72 EXPECT_EQ(static_cast<int64>(expected_data_.size()),
73 (*file)->bytes_so_far()); 73 (*file)->bytes_so_far());
74 74
75 // Make sure the data has been properly written to disk. 75 // Make sure the data has been properly written to disk.
76 std::string disk_data; 76 std::string disk_data;
77 EXPECT_TRUE(file_util::ReadFileToString((*file)->full_path(), 77 EXPECT_TRUE(file_util::ReadFileToString((*file)->full_path(),
78 &disk_data)); 78 &disk_data));
79 EXPECT_EQ(expected_data_, disk_data); 79 EXPECT_EQ(expected_data_, disk_data);
80 80
81 // Make sure the mock BrowserThread outlives the DownloadFile to satisfy 81 // Make sure the Browser and File threads outlive the DownloadFile
82 // thread checks inside it. 82 // to satisfy thread checks inside it.
83 file->reset(); 83 file->reset();
84 } 84 }
85 85
86 void AppendDataToFile(scoped_ptr<DownloadFile>* file, 86 void AppendDataToFile(scoped_ptr<DownloadFile>* file,
87 const std::string& data) { 87 const std::string& data) {
88 EXPECT_TRUE((*file)->in_progress()); 88 EXPECT_TRUE((*file)->in_progress());
89 (*file)->AppendDataToFile(data.data(), data.size()); 89 (*file)->AppendDataToFile(data.data(), data.size());
90 expected_data_ += data; 90 expected_data_ += data;
91 EXPECT_EQ(static_cast<int64>(expected_data_.size()), 91 EXPECT_EQ(static_cast<int64>(expected_data_.size()),
92 (*file)->bytes_so_far()); 92 (*file)->bytes_so_far());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Check the files. 186 // Check the files.
187 EXPECT_FALSE(file_util::PathExists(path_3)); 187 EXPECT_FALSE(file_util::PathExists(path_3));
188 EXPECT_TRUE(file_util::PathExists(path_4)); 188 EXPECT_TRUE(file_util::PathExists(path_4));
189 189
190 // Check the hash. 190 // Check the hash.
191 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); 191 EXPECT_TRUE(download_file_->GetSha256Hash(&hash));
192 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); 192 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size()));
193 193
194 DestroyDownloadFile(&download_file_, 0); 194 DestroyDownloadFile(&download_file_, 0);
195 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698