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

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate_unittest.cc

Issue 10535026: Move creation and ownership of DownloadManager from the embedder to content. This matches all the o… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros compile Created 8 years, 6 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) 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 "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/value_conversions.h" 10 #include "base/value_conversions.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 scoped_ptr<TestDownloadProtectionService> download_protection_service_; 194 scoped_ptr<TestDownloadProtectionService> download_protection_service_;
195 #endif 195 #endif
196 }; 196 };
197 197
198 class ChromeDownloadManagerDelegateTest : public ::testing::Test { 198 class ChromeDownloadManagerDelegateTest : public ::testing::Test {
199 public: 199 public:
200 ChromeDownloadManagerDelegateTest(); 200 ChromeDownloadManagerDelegateTest();
201 201
202 // ::testing::Test 202 // ::testing::Test
203 virtual void SetUp() OVERRIDE; 203 virtual void SetUp() OVERRIDE;
204 virtual void TearDown() OVERRIDE;
204 205
205 // Verifies and clears test expectations for |delegate_| and 206 // Verifies and clears test expectations for |delegate_| and
206 // |download_manager_|. 207 // |download_manager_|.
207 void VerifyAndClearExpectations(); 208 void VerifyAndClearExpectations();
208 209
209 // Creates MockDownloadItem and sets up default expectations. 210 // Creates MockDownloadItem and sets up default expectations.
210 content::MockDownloadItem* CreateActiveDownloadItem(int32 id); 211 content::MockDownloadItem* CreateActiveDownloadItem(int32 id);
211 212
212 // Sets the AutoOpenBasedOnExtension user preference for |path|. 213 // Sets the AutoOpenBasedOnExtension user preference for |path|.
213 void EnableAutoOpenBasedOnExtension(const FilePath& path); 214 void EnableAutoOpenBasedOnExtension(const FilePath& path);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 delegate_(new TestChromeDownloadManagerDelegate(&profile_)) { 262 delegate_(new TestChromeDownloadManagerDelegate(&profile_)) {
262 delegate_->SetDownloadManager(download_manager_.get()); 263 delegate_->SetDownloadManager(download_manager_.get());
263 pref_service_ = profile_.GetTestingPrefService(); 264 pref_service_ = profile_.GetTestingPrefService();
264 } 265 }
265 266
266 void ChromeDownloadManagerDelegateTest::SetUp() { 267 void ChromeDownloadManagerDelegateTest::SetUp() {
267 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir()); 268 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir());
268 SetDefaultDownloadPath(test_download_dir_.path()); 269 SetDefaultDownloadPath(test_download_dir_.path());
269 } 270 }
270 271
272 void ChromeDownloadManagerDelegateTest::TearDown() {
273 delegate_->Shutdown();
274 }
275
271 void ChromeDownloadManagerDelegateTest::VerifyAndClearExpectations() { 276 void ChromeDownloadManagerDelegateTest::VerifyAndClearExpectations() {
272 ::testing::Mock::VerifyAndClearExpectations(delegate_); 277 ::testing::Mock::VerifyAndClearExpectations(delegate_);
273 ::testing::Mock::VerifyAndClearExpectations(download_manager_); 278 ::testing::Mock::VerifyAndClearExpectations(download_manager_);
274 } 279 }
275 280
276 content::MockDownloadItem* 281 content::MockDownloadItem*
277 ChromeDownloadManagerDelegateTest::CreateActiveDownloadItem(int32 id) { 282 ChromeDownloadManagerDelegateTest::CreateActiveDownloadItem(int32 id) {
278 content::MockDownloadItem* item = 283 content::MockDownloadItem* item =
279 new ::testing::NiceMock<content::MockDownloadItem>(); 284 new ::testing::NiceMock<content::MockDownloadItem>();
280 ON_CALL(*item, GetFullPath()) 285 ON_CALL(*item, GetFullPath())
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 set_clean_marker_files(false); 1026 set_clean_marker_files(false);
1022 for (unsigned i = 0; i < arraysize(kConflictingDownloadsTestCases); ++i) 1027 for (unsigned i = 0; i < arraysize(kConflictingDownloadsTestCases); ++i)
1023 RunTestCase(kConflictingDownloadsTestCases[i], i); 1028 RunTestCase(kConflictingDownloadsTestCases[i], i);
1024 } 1029 }
1025 1030
1026 // TODO(asanka): Add more tests. 1031 // TODO(asanka): Add more tests.
1027 // * Default download path is not writable. 1032 // * Default download path is not writable.
1028 // * Download path doesn't exist. 1033 // * Download path doesn't exist.
1029 // * IsDangerousFile(). 1034 // * IsDangerousFile().
1030 // * Filename generation. 1035 // * Filename generation.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698