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

Unified Diff: content/browser/download/download_manager_impl_unittest.cc

Issue 148133007: [Downloads] Always call DM::StartDownload() for explicit downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
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 70a392fd4753085881211c1ddf428b77c90368b1..2993dbbbddaaecded52152d427486bf6666aa886 100644
--- a/content/browser/download/download_manager_impl_unittest.cc
+++ b/content/browser/download/download_manager_impl_unittest.cc
@@ -107,9 +107,9 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_METHOD0(MarkAsComplete, void());
MOCK_METHOD1(OnAllDataSaved, void(const std::string&));
MOCK_METHOD0(OnDownloadedFileRemoved, void());
- virtual void Start(
- scoped_ptr<DownloadFile> download_file,
- scoped_ptr<DownloadRequestHandleInterface> req_handle) OVERRIDE {
+ virtual void Start(scoped_ptr<DownloadFile> download_file,
+ scoped_ptr<DownloadRequestHandleInterface> req_handle,
+ const DownloadCreateInfo& create_info) OVERRIDE {
MockStart(download_file.get(), req_handle.get());
}
@@ -364,26 +364,22 @@ class MockDownloadFileFactory
virtual ~MockDownloadFileFactory() {}
// Overridden method from DownloadFileFactory
- MOCK_METHOD8(MockCreateFile, MockDownloadFile*(
- const DownloadSaveInfo&,
- const base::FilePath&,
- const GURL&, const GURL&, bool,
- ByteStreamReader*,
- const net::BoundNetLog&,
- base::WeakPtr<DownloadDestinationObserver>));
+ MOCK_METHOD3(MockCreateFile,
+ MockDownloadFile*(const DownloadSaveInfo&,
+ bool,
+ ByteStreamReader*));
virtual DownloadFile* CreateFile(
- scoped_ptr<DownloadSaveInfo> save_info,
+ const DownloadSaveInfo& save_info,
const base::FilePath& default_download_directory,
const GURL& url,
const GURL& referrer_url,
bool calculate_hash,
- scoped_ptr<ByteStreamReader> stream,
+ scoped_ptr<net::FileStream> file_stream,
+ scoped_ptr<ByteStreamReader> byte_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);
+ return MockCreateFile(save_info, calculate_hash, byte_stream.get());
}
};
@@ -443,6 +439,14 @@ class MockDownloadManagerObserver : public DownloadManager::Observer {
DownloadManager*, int32));
};
+class MockByteStreamReader : public ByteStreamReader {
+ public:
+ virtual ~MockByteStreamReader() {}
+ MOCK_METHOD2(Read, StreamState(scoped_refptr<net::IOBuffer>*, size_t*));
+ MOCK_CONST_METHOD0(GetStatus, int());
+ MOCK_METHOD1(RegisterCallback, void(const base::Closure&));
+};
+
} // namespace
class DownloadManagerTest : public testing::Test {
@@ -524,7 +528,7 @@ class DownloadManagerTest : public testing::Test {
// we call Start on it immediately, so we need to set that expectation
// in the factory.
scoped_ptr<DownloadRequestHandleInterface> req_handle;
- item.Start(scoped_ptr<DownloadFile>(), req_handle.Pass());
+ item.Start(scoped_ptr<DownloadFile>(), req_handle.Pass(), info);
return item;
}
@@ -596,7 +600,7 @@ class DownloadManagerTest : public testing::Test {
// Confirm the appropriate invocations occur when you start a download.
TEST_F(DownloadManagerTest, StartDownload) {
scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo);
- scoped_ptr<ByteStreamReader> stream;
+ scoped_ptr<ByteStreamReader> stream(new MockByteStreamReader);
uint32 local_id(5); // Random value
base::FilePath download_path(FILE_PATH_LITERAL("download/path"));
@@ -617,8 +621,7 @@ TEST_F(DownloadManagerTest, StartDownload) {
MockDownloadFile* mock_file = new MockDownloadFile;
EXPECT_CALL(*mock_file, SetClientGuid("client-id"));
EXPECT_CALL(*mock_download_file_factory_.get(),
- MockCreateFile(Ref(*info->save_info.get()), _, _, _, true,
- stream.get(), _, _))
+ MockCreateFile(Ref(*info->save_info.get()), true, stream.get()))
.WillOnce(Return(mock_file));
download_manager_->StartDownload(

Powered by Google App Engine
This is Rietveld 408576698