| OLD | NEW |
| 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // http://crbug.com/105200 | 48 // http://crbug.com/105200 |
| 49 #define MAYBE_StartDownload DISABLED_StartDownload | 49 #define MAYBE_StartDownload DISABLED_StartDownload |
| 50 #define MAYBE_DownloadOverwriteTest DISABLED_DownloadOverwriteTest | 50 #define MAYBE_DownloadOverwriteTest DISABLED_DownloadOverwriteTest |
| 51 #define MAYBE_DownloadRemoveTest DISABLED_DownloadRemoveTest | 51 #define MAYBE_DownloadRemoveTest DISABLED_DownloadRemoveTest |
| 52 #else | 52 #else |
| 53 #define MAYBE_StartDownload StartDownload | 53 #define MAYBE_StartDownload StartDownload |
| 54 #define MAYBE_DownloadOverwriteTest DownloadOverwriteTest | 54 #define MAYBE_DownloadOverwriteTest DownloadOverwriteTest |
| 55 #define MAYBE_DownloadRemoveTest DownloadRemoveTest | 55 #define MAYBE_DownloadRemoveTest DownloadRemoveTest |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 namespace { |
| 59 |
| 60 class MockDownloadFileFactory |
| 61 : public DownloadFileManager::DownloadFileFactory { |
| 62 public: |
| 63 MockDownloadFileFactory() {} |
| 64 |
| 65 virtual DownloadFile* CreateFile(DownloadCreateInfo* info, |
| 66 const DownloadRequestHandle& request_handle, |
| 67 DownloadManager* download_manager) OVERRIDE; |
| 68 }; |
| 69 |
| 70 DownloadFile* MockDownloadFileFactory::CreateFile( |
| 71 DownloadCreateInfo* info, |
| 72 const DownloadRequestHandle& request_handle, |
| 73 DownloadManager* download_manager) { |
| 74 NOTREACHED(); |
| 75 return NULL; |
| 76 } |
| 77 |
| 78 } // namespace |
| 79 |
| 58 using content::BrowserThread; | 80 using content::BrowserThread; |
| 59 | 81 |
| 60 DownloadId::Domain kValidIdDomain = "valid DownloadId::Domain"; | 82 DownloadId::Domain kValidIdDomain = "valid DownloadId::Domain"; |
| 61 | 83 |
| 62 class DownloadManagerTest : public testing::Test { | 84 class DownloadManagerTest : public testing::Test { |
| 63 public: | 85 public: |
| 64 static const char* kTestData; | 86 static const char* kTestData; |
| 65 static const size_t kTestDataLen; | 87 static const size_t kTestDataLen; |
| 66 | 88 |
| 67 DownloadManagerTest() | 89 DownloadManagerTest() |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 scoped_refptr<DownloadIdFactory> id_factory_; | 164 scoped_refptr<DownloadIdFactory> id_factory_; |
| 143 scoped_refptr<DownloadManager> download_manager_; | 165 scoped_refptr<DownloadManager> download_manager_; |
| 144 scoped_refptr<DownloadFileManager> file_manager_; | 166 scoped_refptr<DownloadFileManager> file_manager_; |
| 145 MessageLoopForUI message_loop_; | 167 MessageLoopForUI message_loop_; |
| 146 content::TestBrowserThread ui_thread_; | 168 content::TestBrowserThread ui_thread_; |
| 147 content::TestBrowserThread file_thread_; | 169 content::TestBrowserThread file_thread_; |
| 148 scoped_refptr<content::DownloadBuffer> download_buffer_; | 170 scoped_refptr<content::DownloadBuffer> download_buffer_; |
| 149 | 171 |
| 150 DownloadFileManager* file_manager() { | 172 DownloadFileManager* file_manager() { |
| 151 if (!file_manager_) { | 173 if (!file_manager_) { |
| 152 file_manager_ = new DownloadFileManager(NULL); | 174 file_manager_ = new DownloadFileManager(NULL, |
| 175 new MockDownloadFileFactory); |
| 153 download_manager_->SetFileManager(file_manager_); | 176 download_manager_->SetFileManager(file_manager_); |
| 154 } | 177 } |
| 155 return file_manager_; | 178 return file_manager_; |
| 156 } | 179 } |
| 157 | 180 |
| 158 DISALLOW_COPY_AND_ASSIGN(DownloadManagerTest); | 181 DISALLOW_COPY_AND_ASSIGN(DownloadManagerTest); |
| 159 }; | 182 }; |
| 160 | 183 |
| 161 const char* DownloadManagerTest::kTestData = "a;sdlfalsdfjalsdkfjad"; | 184 const char* DownloadManagerTest::kTestData = "a;sdlfalsdfjalsdkfjad"; |
| 162 const size_t DownloadManagerTest::kTestDataLen = | 185 const size_t DownloadManagerTest::kTestDataLen = |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); | 891 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); |
| 869 EXPECT_TRUE(observer->was_updated()); | 892 EXPECT_TRUE(observer->was_updated()); |
| 870 EXPECT_FALSE(observer->was_opened()); | 893 EXPECT_FALSE(observer->was_opened()); |
| 871 EXPECT_TRUE(download->GetFileExternallyRemoved()); | 894 EXPECT_TRUE(download->GetFileExternallyRemoved()); |
| 872 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); | 895 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); |
| 873 EXPECT_EQ(download_item_model->GetStatusText(), | 896 EXPECT_EQ(download_item_model->GetStatusText(), |
| 874 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED)); | 897 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED)); |
| 875 | 898 |
| 876 EXPECT_FALSE(file_util::PathExists(new_path)); | 899 EXPECT_FALSE(file_util::PathExists(new_path)); |
| 877 } | 900 } |
| OLD | NEW |