| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/download/download_history.h" | 10 #include "chrome/browser/download/download_history.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 public: | 196 public: |
| 197 // Generic callback that receives a pointer to a StrictMockDownloadItem. | 197 // Generic callback that receives a pointer to a StrictMockDownloadItem. |
| 198 typedef base::Callback<void(content::MockDownloadItem*)> DownloadItemCallback; | 198 typedef base::Callback<void(content::MockDownloadItem*)> DownloadItemCallback; |
| 199 | 199 |
| 200 DownloadHistoryTest() | 200 DownloadHistoryTest() |
| 201 : ui_thread_(content::BrowserThread::UI, &loop_), | 201 : ui_thread_(content::BrowserThread::UI, &loop_), |
| 202 manager_(new content::MockDownloadManager()), | 202 manager_(new content::MockDownloadManager()), |
| 203 history_(NULL), | 203 history_(NULL), |
| 204 manager_observer_(NULL), | 204 manager_observer_(NULL), |
| 205 download_created_index_(0) {} | 205 download_created_index_(0) {} |
| 206 virtual ~DownloadHistoryTest() { | 206 ~DownloadHistoryTest() override { STLDeleteElements(&items_); } |
| 207 STLDeleteElements(&items_); | |
| 208 } | |
| 209 | 207 |
| 210 protected: | 208 protected: |
| 211 virtual void TearDown() override { | 209 void TearDown() override { download_history_.reset(); } |
| 212 download_history_.reset(); | |
| 213 } | |
| 214 | 210 |
| 215 content::MockDownloadManager& manager() { return *manager_.get(); } | 211 content::MockDownloadManager& manager() { return *manager_.get(); } |
| 216 content::MockDownloadItem& item(size_t index) { return *items_[index]; } | 212 content::MockDownloadItem& item(size_t index) { return *items_[index]; } |
| 217 DownloadHistory* download_history() { return download_history_.get(); } | 213 DownloadHistory* download_history() { return download_history_.get(); } |
| 218 | 214 |
| 219 void SetManagerObserver( | 215 void SetManagerObserver( |
| 220 content::DownloadManager::Observer* manager_observer) { | 216 content::DownloadManager::Observer* manager_observer) { |
| 221 manager_observer_ = manager_observer; | 217 manager_observer_ = manager_observer; |
| 222 } | 218 } |
| 223 content::DownloadManager::Observer* manager_observer() { | 219 content::DownloadManager::Observer* manager_observer() { |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 FinishCreateDownload(); | 857 FinishCreateDownload(); |
| 862 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); | 858 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); |
| 863 | 859 |
| 864 // ItemAdded should call OnDownloadUpdated, which should detect that the item | 860 // ItemAdded should call OnDownloadUpdated, which should detect that the item |
| 865 // changed while it was being added and call UpdateDownload immediately. | 861 // changed while it was being added and call UpdateDownload immediately. |
| 866 info.opened = true; | 862 info.opened = true; |
| 867 ExpectDownloadUpdated(info); | 863 ExpectDownloadUpdated(info); |
| 868 } | 864 } |
| 869 | 865 |
| 870 } // anonymous namespace | 866 } // anonymous namespace |
| OLD | NEW |