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

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: Fixed comment. Created 9 years, 4 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 "chrome/browser/download/download_util.h" 9 #include "chrome/browser/download/download_util.h"
10 #include "chrome/browser/download/mock_download_manager_delegate.h" 10 #include "chrome/browser/download/mock_download_manager_delegate.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 EXPECT_FALSE((*file)->in_progress()); 72 EXPECT_FALSE((*file)->in_progress());
73 EXPECT_EQ(static_cast<int64>(expected_data_.size()), 73 EXPECT_EQ(static_cast<int64>(expected_data_.size()),
74 (*file)->bytes_so_far()); 74 (*file)->bytes_so_far());
75 75
76 // Make sure the data has been properly written to disk. 76 // Make sure the data has been properly written to disk.
77 std::string disk_data; 77 std::string disk_data;
78 EXPECT_TRUE(file_util::ReadFileToString((*file)->full_path(), 78 EXPECT_TRUE(file_util::ReadFileToString((*file)->full_path(),
79 &disk_data)); 79 &disk_data));
80 EXPECT_EQ(expected_data_, disk_data); 80 EXPECT_EQ(expected_data_, disk_data);
81 81
82 // Make sure the mock BrowserThread outlives the DownloadFile to satisfy 82 // Make sure the Browser and File threads outlive the DownloadFile
83 // thread checks inside it. 83 // to satisfy thread checks inside it.
84 file->reset(); 84 file->reset();
85 } 85 }
86 86
87 void AppendDataToFile(scoped_ptr<DownloadFile>* file, 87 void AppendDataToFile(scoped_ptr<DownloadFile>* file,
88 const std::string& data) { 88 const std::string& data) {
89 EXPECT_TRUE((*file)->in_progress()); 89 EXPECT_TRUE((*file)->in_progress());
90 (*file)->AppendDataToFile(data.data(), data.size()); 90 (*file)->AppendDataToFile(data.data(), data.size());
91 expected_data_ += data; 91 expected_data_ += data;
92 EXPECT_EQ(static_cast<int64>(expected_data_.size()), 92 EXPECT_EQ(static_cast<int64>(expected_data_.size()),
93 (*file)->bytes_so_far()); 93 (*file)->bytes_so_far());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Check the files. 187 // Check the files.
188 EXPECT_FALSE(file_util::PathExists(path_3)); 188 EXPECT_FALSE(file_util::PathExists(path_3));
189 EXPECT_TRUE(file_util::PathExists(path_4)); 189 EXPECT_TRUE(file_util::PathExists(path_4));
190 190
191 // Check the hash. 191 // Check the hash.
192 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); 192 EXPECT_TRUE(download_file_->GetSha256Hash(&hash));
193 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); 193 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size()));
194 194
195 DestroyDownloadFile(&download_file_, 0); 195 DestroyDownloadFile(&download_file_, 0);
196 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698