Chromium Code Reviews| Index: content/browser/download/download_manager_impl_unittest.cc |
| diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc |
| index 2e9eff427e952d155d92ac84215a3f7ce57815b4..15fc83f35b7d367e1a78c12dbb56662ab32dc739 100644 |
| --- a/content/browser/download/download_manager_impl_unittest.cc |
| +++ b/content/browser/download/download_manager_impl_unittest.cc |
| @@ -109,6 +109,7 @@ class MockDownloadItemImpl : public DownloadItemImpl { |
| scoped_ptr<DownloadFile> download_file, |
| scoped_ptr<DownloadRequestHandleInterface> req_handle) OVERRIDE { |
| MockStart(download_file.get(), req_handle.get()); |
| + last_file_.swap(download_file); |
| } |
| MOCK_METHOD2(MockStart, void(DownloadFile*, DownloadRequestHandleInterface*)); |
| @@ -170,6 +171,9 @@ class MockDownloadItemImpl : public DownloadItemImpl { |
| virtual std::string DebugString(bool verbose) const OVERRIDE { |
| return std::string(); |
| } |
| + |
| + private: |
| + scoped_ptr<DownloadFile> last_file_; |
| }; |
| class MockDownloadManagerDelegate : public DownloadManagerDelegate { |
| @@ -193,6 +197,10 @@ class MockDownloadManagerDelegate : public DownloadManagerDelegate { |
| MOCK_METHOD5(ChooseSavePath, void( |
| WebContents*, const base::FilePath&, const base::FilePath::StringType&, |
| bool, const SavePackagePathPickedCallback&)); |
| + |
| + virtual std::string ApplicationClientIdForFileScanning() const { |
|
asanka
2013/08/08 21:16:01
Use a mock and set expectations so this is consist
Greg Billock
2013/08/08 23:55:46
Done.
|
| + return std::string("client-id"); |
| + } |
| }; |
| MockDownloadManagerDelegate::MockDownloadManagerDelegate() {} |
| @@ -374,10 +382,19 @@ class MockDownloadFileFactory |
| scoped_ptr<ByteStreamReader> stream, |
| const net::BoundNetLog& bound_net_log, |
| base::WeakPtr<DownloadDestinationObserver> observer) { |
| - return MockCreateFile(*save_info.get(), default_download_directory, url, |
| - referrer_url, calculate_hash, |
| - stream.get(), bound_net_log, observer); |
| + MockCreateFile(*save_info.get(), default_download_directory, url, |
| + referrer_url, calculate_hash, |
| + stream.get(), bound_net_log, observer); |
| + mock_file_ = new MockDownloadFile(); |
| + return mock_file_; |
| } |
| + |
| + MockDownloadFile* GetCreatedDownloadFile() { |
| + return mock_file_; |
| + } |
| + |
| + private: |
| + MockDownloadFile* mock_file_; |
| }; |
| class MockBrowserContext : public BrowserContext { |
| @@ -593,7 +610,12 @@ TEST_F(DownloadManagerTest, StartDownload) { |
| download_manager_->StartDownload( |
| info.Pass(), stream.Pass(), DownloadUrlParameters::OnStartedCallback()); |
| - EXPECT_TRUE(download_manager_->GetDownload(local_id)); |
| + EXPECT_TRUE(NULL != download_manager_->GetDownload(local_id)); |
|
asanka
2013/08/08 21:16:01
Is this change necessary?
Greg Billock
2013/08/08 23:55:46
I'll put it back.
|
| + |
| + // Make sure the client app GUID was set in the DownloadItem. |
| + MockDownloadFile* mock_file = |
| + mock_download_file_factory_->GetCreatedDownloadFile(); |
| + EXPECT_EQ("client-id", mock_file->client_guid()); |
| } |
| // Confirm that calling DetermineDownloadTarget behaves properly if the delegate |