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

Side by Side Diff: chrome/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: 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_create_info.h" 9 #include "chrome/browser/download/download_create_info.h"
10 #include "chrome/browser/download/download_file.h" 10 #include "chrome/browser/download/download_file.h"
(...skipping 21 matching lines...) Expand all
32 // We need a UI |BrowserThread| in order to destruct |download_manager_|, 32 // We need a UI |BrowserThread| in order to destruct |download_manager_|,
33 // which has trait |BrowserThread::DeleteOnUIThread|. Without this, 33 // which has trait |BrowserThread::DeleteOnUIThread|. Without this,
34 // calling Release() on |download_manager_| won't ever result in its 34 // calling Release() on |download_manager_| won't ever result in its
35 // destructor being called and we get a leak. 35 // destructor being called and we get a leak.
36 DownloadFileTest() : 36 DownloadFileTest() :
37 ui_thread_(BrowserThread::UI, &loop_), 37 ui_thread_(BrowserThread::UI, &loop_),
38 file_thread_(BrowserThread::FILE, &loop_) { 38 file_thread_(BrowserThread::FILE, &loop_) {
39 } 39 }
40 40
41 ~DownloadFileTest() { 41 ~DownloadFileTest() {
42 // Need to destroy the |DownloadFile| before |file_thread_|.
43 download_file_.reset(NULL);
cbentzel 2011/08/16 15:50:36 Was this a leak? Why is this needed now?
ahendrickson 2011/08/18 21:52:01 I did need that at one point, but it doesn't look
42 } 44 }
43 45
44 virtual void SetUp() { 46 virtual void SetUp() {
45 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 47 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
46 download_manager_delegate_.reset(new MockDownloadManagerDelegate()); 48 download_manager_delegate_.reset(new MockDownloadManagerDelegate());
47 download_manager_ = new MockDownloadManager( 49 download_manager_ = new MockDownloadManager(
48 download_manager_delegate_.get(), &download_status_updater_); 50 download_manager_delegate_.get(), &download_status_updater_);
49 } 51 }
50 52
51 virtual void TearDown() { 53 virtual void TearDown() {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Check the files. 189 // Check the files.
188 EXPECT_FALSE(file_util::PathExists(path_3)); 190 EXPECT_FALSE(file_util::PathExists(path_3));
189 EXPECT_TRUE(file_util::PathExists(path_4)); 191 EXPECT_TRUE(file_util::PathExists(path_4));
190 192
191 // Check the hash. 193 // Check the hash.
192 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); 194 EXPECT_TRUE(download_file_->GetSha256Hash(&hash));
193 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); 195 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size()));
194 196
195 DestroyDownloadFile(&download_file_, 0); 197 DestroyDownloadFile(&download_file_, 0);
196 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698