| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
| 10 #include "chrome/browser/download/download_file.h" | 10 #include "chrome/browser/download/download_file.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 class DownloadManagerTest : public testing::Test { | 31 class DownloadManagerTest : public testing::Test { |
| 32 public: | 32 public: |
| 33 DownloadManagerTest() | 33 DownloadManagerTest() |
| 34 : profile_(new TestingProfile()), | 34 : profile_(new TestingProfile()), |
| 35 download_manager_(new MockDownloadManager()), | 35 download_manager_(new MockDownloadManager()), |
| 36 ui_thread_(ChromeThread::UI, &message_loop_) { | 36 ui_thread_(ChromeThread::UI, &message_loop_) { |
| 37 download_manager_->Init(profile_.get()); | 37 download_manager_->Init(profile_.get()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 ~DownloadManagerTest() { | 40 ~DownloadManagerTest() { |
| 41 download_manager_->Shutdown(); |
| 41 // profile_ must outlive download_manager_, so we explicitly delete | 42 // profile_ must outlive download_manager_, so we explicitly delete |
| 42 // download_manager_ first. | 43 // download_manager_ first. |
| 43 download_manager_ = NULL; | 44 download_manager_ = NULL; |
| 44 profile_.reset(NULL); | 45 profile_.reset(NULL); |
| 45 message_loop_.RunAllPending(); | 46 message_loop_.RunAllPending(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void AddDownloadToFileManager(int id, DownloadFile* download) { | 49 void AddDownloadToFileManager(int id, DownloadFile* download) { |
| 49 file_manager()->downloads_[id] = download; | 50 file_manager()->downloads_[id] = download; |
| 50 } | 51 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 { FILE_PATH_LITERAL("unconfirmed xxx.crdownload"), | 173 { FILE_PATH_LITERAL("unconfirmed xxx.crdownload"), |
| 173 true, | 174 true, |
| 174 false, | 175 false, |
| 175 false, | 176 false, |
| 176 1, }, | 177 1, }, |
| 177 }; | 178 }; |
| 178 | 179 |
| 179 class MockDownloadFile : public DownloadFile { | 180 class MockDownloadFile : public DownloadFile { |
| 180 public: | 181 public: |
| 181 explicit MockDownloadFile(DownloadCreateInfo* info) | 182 explicit MockDownloadFile(DownloadCreateInfo* info) |
| 182 : DownloadFile(info), renamed_count_(0) { } | 183 : DownloadFile(info, NULL), renamed_count_(0) { } |
| 183 virtual ~MockDownloadFile() { Destructed(); } | 184 virtual ~MockDownloadFile() { Destructed(); } |
| 184 MOCK_METHOD2(Rename, bool(const FilePath&, bool)); | 185 MOCK_METHOD2(Rename, bool(const FilePath&, bool)); |
| 185 MOCK_METHOD0(DeleteCrDownload, void()); | 186 MOCK_METHOD0(DeleteCrDownload, void()); |
| 186 MOCK_METHOD0(Destructed, void()); | 187 MOCK_METHOD0(Destructed, void()); |
| 187 | 188 |
| 188 bool TestMultipleRename( | 189 bool TestMultipleRename( |
| 189 int expected_count, bool expected_final, const FilePath& expected, | 190 int expected_count, bool expected_final, const FilePath& expected, |
| 190 const FilePath& path, bool is_final_rename) { | 191 const FilePath& path, bool is_final_rename) { |
| 191 ++renamed_count_; | 192 ++renamed_count_; |
| 192 EXPECT_EQ(expected_count, renamed_count_); | 193 EXPECT_EQ(expected_count, renamed_count_); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 download_manager_->DownloadFinished(i, 1024); | 246 download_manager_->DownloadFinished(i, 1024); |
| 246 download_manager_->FileSelected(new_path, i, info); | 247 download_manager_->FileSelected(new_path, i, info); |
| 247 } else { | 248 } else { |
| 248 download_manager_->FileSelected(new_path, i, info); | 249 download_manager_->FileSelected(new_path, i, info); |
| 249 download_manager_->DownloadFinished(i, 1024); | 250 download_manager_->DownloadFinished(i, 1024); |
| 250 } | 251 } |
| 251 | 252 |
| 252 message_loop_.RunAllPending(); | 253 message_loop_.RunAllPending(); |
| 253 } | 254 } |
| 254 } | 255 } |
| OLD | NEW |