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

Unified Diff: chrome/browser/download/download_manager_unittest.cc

Issue 6990044: Fixed memory leaks in download manager unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk. Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_manager_unittest.cc
diff --git a/chrome/browser/download/download_manager_unittest.cc b/chrome/browser/download/download_manager_unittest.cc
index fe1376cbcbedb7dfb7b78b7fa609b097cab2a6d8..cc896a1b6c650c1334516f1b374540b065d68f23 100644
--- a/chrome/browser/download/download_manager_unittest.cc
+++ b/chrome/browser/download/download_manager_unittest.cc
@@ -313,23 +313,14 @@ TEST_F(DownloadManagerTest, StartDownload) {
AddDownloadToFileManager(info->download_id, download_file);
download_file->Initialize(false);
download_manager_->StartDownload(info->download_id);
+ delete info;
Paweł Hajdan Jr. 2011/05/24 10:08:05 Could you use a scoped_ptr instead? Manually manag
ahendrickson 2011/05/24 15:34:34 Done.
message_loop_.RunAllPending();
- // NOTE: At this point, |ContinueDownloadWithPath| will have been run if
- // we don't need to prompt the user, so |info| could have been destructed.
- // This means that we can't check any of its values.
- // However, SelectFileObserver will have recorded any attempt to open the
+ // SelectFileObserver will have recorded any attempt to open the
// select file dialog.
+ // Note that DownloadManager::FileSelectionCanceled() is never called.
EXPECT_EQ(kStartDownloadCases[i].expected_save_as,
observer.ShowedFileDialogForId(i));
-
- // If the Save As dialog pops up, it never reached
- // DownloadManager::ContinueDownloadWithPath(), and never deleted info or
- // completed. This cleans up info.
- // Note that DownloadManager::FileSelectionCanceled() is never called.
- if (observer.ShowedFileDialogForId(i)) {
- delete info;
- }
}
}
@@ -371,6 +362,7 @@ TEST_F(DownloadManagerTest, DownloadRenameTest) {
2, new_path))));
}
download_manager_->CreateDownloadItem(info);
+ delete info;
Paweł Hajdan Jr. 2011/05/24 10:08:05 Same here, please use scoped_ptr (in fact, applies
ahendrickson 2011/05/24 15:34:34 Done.
int32* id_ptr = new int32;
*id_ptr = i; // Deleted in FileSelected().
@@ -418,6 +410,7 @@ TEST_F(DownloadManagerTest, DownloadInterruptTest) {
EXPECT_CALL(*download_file, Rename(cr_path)).WillOnce(Return(true));
download_manager_->CreateDownloadItem(info);
+ delete info;
DownloadItem* download = GetActiveDownloadItem(0);
ASSERT_TRUE(download != NULL);
@@ -483,6 +476,7 @@ TEST_F(DownloadManagerTest, DownloadCancelTest) {
EXPECT_CALL(*download_file, Rename(cr_path)).WillOnce(Return(true));
download_manager_->CreateDownloadItem(info);
+ delete info;
DownloadItem* download = GetActiveDownloadItem(0);
ASSERT_TRUE(download != NULL);
@@ -549,6 +543,7 @@ TEST_F(DownloadManagerTest, DownloadOverwriteTest) {
info->is_dangerous_url = false;
download_manager_->CreateDownloadItem(info);
+ delete info;
DownloadItem* download = GetActiveDownloadItem(0);
ASSERT_TRUE(download != NULL);
@@ -567,6 +562,7 @@ TEST_F(DownloadManagerTest, DownloadOverwriteTest) {
download_file->Initialize(false);
// |download_file| is owned by DownloadFileManager.
AddDownloadToFileManager(info->download_id, download_file);
+ delete info;
ContinueDownloadWithPath(download, new_path);
message_loop_.RunAllPending();
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698