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

Side by Side Diff: content/browser/download/download_manager_impl_unittest.cc

Issue 21355004: [Downloads] Move client guid for AV scanning of downloaded files to chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 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 <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/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 MOCK_METHOD2(ShouldCompleteDownload, 188 MOCK_METHOD2(ShouldCompleteDownload,
189 bool(DownloadItem*, const base::Closure&)); 189 bool(DownloadItem*, const base::Closure&));
190 MOCK_METHOD2(ShouldOpenDownload, 190 MOCK_METHOD2(ShouldOpenDownload,
191 bool(DownloadItem*, const DownloadOpenDelayedCallback&)); 191 bool(DownloadItem*, const DownloadOpenDelayedCallback&));
192 MOCK_METHOD0(GenerateFileHash, bool()); 192 MOCK_METHOD0(GenerateFileHash, bool());
193 MOCK_METHOD4(GetSaveDir, void(BrowserContext*, 193 MOCK_METHOD4(GetSaveDir, void(BrowserContext*,
194 base::FilePath*, base::FilePath*, bool*)); 194 base::FilePath*, base::FilePath*, bool*));
195 MOCK_METHOD5(ChooseSavePath, void( 195 MOCK_METHOD5(ChooseSavePath, void(
196 WebContents*, const base::FilePath&, const base::FilePath::StringType&, 196 WebContents*, const base::FilePath&, const base::FilePath::StringType&,
197 bool, const SavePackagePathPickedCallback&)); 197 bool, const SavePackagePathPickedCallback&));
198 MOCK_CONST_METHOD0(ApplicationClientIdForFileScanning, std::string());
198 }; 199 };
199 200
200 MockDownloadManagerDelegate::MockDownloadManagerDelegate() {} 201 MockDownloadManagerDelegate::MockDownloadManagerDelegate() {}
201 202
202 MockDownloadManagerDelegate::~MockDownloadManagerDelegate() {} 203 MockDownloadManagerDelegate::~MockDownloadManagerDelegate() {}
203 204
204 class MockDownloadItemFactory 205 class MockDownloadItemFactory
205 : public DownloadItemFactory, 206 : public DownloadItemFactory,
206 public base::SupportsWeakPtr<MockDownloadItemFactory> { 207 public base::SupportsWeakPtr<MockDownloadItemFactory> {
207 public: 208 public:
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 357 }
357 358
358 class MockDownloadFileFactory 359 class MockDownloadFileFactory
359 : public DownloadFileFactory, 360 : public DownloadFileFactory,
360 public base::SupportsWeakPtr<MockDownloadFileFactory> { 361 public base::SupportsWeakPtr<MockDownloadFileFactory> {
361 public: 362 public:
362 MockDownloadFileFactory() {} 363 MockDownloadFileFactory() {}
363 virtual ~MockDownloadFileFactory() {} 364 virtual ~MockDownloadFileFactory() {}
364 365
365 // Overridden method from DownloadFileFactory 366 // Overridden method from DownloadFileFactory
366 MOCK_METHOD8(MockCreateFile, DownloadFile*( 367 MOCK_METHOD8(MockCreateFile, MockDownloadFile*(
367 const DownloadSaveInfo&, 368 const DownloadSaveInfo&,
368 const base::FilePath&, 369 const base::FilePath&,
369 const GURL&, const GURL&, bool, 370 const GURL&, const GURL&, bool,
370 ByteStreamReader*, 371 ByteStreamReader*,
371 const net::BoundNetLog&, 372 const net::BoundNetLog&,
372 base::WeakPtr<DownloadDestinationObserver>)); 373 base::WeakPtr<DownloadDestinationObserver>));
373 374
374 virtual DownloadFile* CreateFile( 375 virtual DownloadFile* CreateFile(
375 scoped_ptr<DownloadSaveInfo> save_info, 376 scoped_ptr<DownloadSaveInfo> save_info,
376 const base::FilePath& default_download_directory, 377 const base::FilePath& default_download_directory,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 587
587 EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _)) 588 EXPECT_CALL(GetMockObserver(), OnDownloadCreated(download_manager_.get(), _))
588 .WillOnce(Return()); 589 .WillOnce(Return());
589 EXPECT_CALL(GetMockDownloadManagerDelegate(), GetNextId(_)) 590 EXPECT_CALL(GetMockDownloadManagerDelegate(), GetNextId(_))
590 .WillOnce(RunCallback<0>(local_id)); 591 .WillOnce(RunCallback<0>(local_id));
591 592
592 // Doing nothing will set the default download directory to null. 593 // Doing nothing will set the default download directory to null.
593 EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _, _)); 594 EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _, _));
594 EXPECT_CALL(GetMockDownloadManagerDelegate(), GenerateFileHash()) 595 EXPECT_CALL(GetMockDownloadManagerDelegate(), GenerateFileHash())
595 .WillOnce(Return(true)); 596 .WillOnce(Return(true));
597 EXPECT_CALL(GetMockDownloadManagerDelegate(),
598 ApplicationClientIdForFileScanning())
599 .WillRepeatedly(Return("client-id"));
600 MockDownloadFile* mock_file = new MockDownloadFile;
601 EXPECT_CALL(*mock_file, SetClientGuid("client-id"));
596 EXPECT_CALL(*mock_download_file_factory_.get(), 602 EXPECT_CALL(*mock_download_file_factory_.get(),
597 MockCreateFile(Ref(*info->save_info.get()), _, _, _, true, 603 MockCreateFile(Ref(*info->save_info.get()), _, _, _, true,
598 stream.get(), _, _)); 604 stream.get(), _, _))
605 .WillOnce(Return(mock_file));
599 606
600 download_manager_->StartDownload( 607 download_manager_->StartDownload(
601 info.Pass(), stream.Pass(), DownloadUrlParameters::OnStartedCallback()); 608 info.Pass(), stream.Pass(), DownloadUrlParameters::OnStartedCallback());
602 EXPECT_TRUE(download_manager_->GetDownload(local_id)); 609 EXPECT_TRUE(download_manager_->GetDownload(local_id));
603 } 610 }
604 611
605 // Confirm that calling DetermineDownloadTarget behaves properly if the delegate 612 // Confirm that calling DetermineDownloadTarget behaves properly if the delegate
606 // blocks starting. 613 // blocks starting.
607 TEST_F(DownloadManagerTest, DetermineDownloadTarget_True) { 614 TEST_F(DownloadManagerTest, DetermineDownloadTarget_True) {
608 // Put a mock we have a handle to on the download manager. 615 // Put a mock we have a handle to on the download manager.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 .WillOnce(Return()); 675 .WillOnce(Return());
669 EXPECT_CALL(GetMockDownloadItem(3), Remove()) 676 EXPECT_CALL(GetMockDownloadItem(3), Remove())
670 .Times(0); 677 .Times(0);
671 678
672 download_manager_->RemoveAllDownloads(); 679 download_manager_->RemoveAllDownloads();
673 // Because we're mocking the download item, the Remove call doesn't 680 // Because we're mocking the download item, the Remove call doesn't
674 // result in them being removed from the DownloadManager list. 681 // result in them being removed from the DownloadManager list.
675 } 682 }
676 683
677 } // namespace content 684 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/browser/download/mock_download_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698