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

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

Issue 10392111: Use ByteStream in downloads system to decouple source and sink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR. 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "base/threading/thread.h" 7 #include "base/threading/thread.h"
8 #include "content/browser/download/byte_stream.h"
8 #include "content/browser/download/download_create_info.h" 9 #include "content/browser/download/download_create_info.h"
9 #include "content/browser/download/download_file_manager.h" 10 #include "content/browser/download/download_file_manager.h"
10 #include "content/browser/download/download_item_impl.h" 11 #include "content/browser/download/download_item_impl.h"
11 #include "content/browser/download/download_request_handle.h" 12 #include "content/browser/download/download_request_handle.h"
12 #include "content/public/browser/download_id.h" 13 #include "content/public/browser/download_id.h"
13 #include "content/public/browser/download_interrupt_reasons.h" 14 #include "content/public/browser/download_interrupt_reasons.h"
14 #include "content/public/test/mock_download_item.h" 15 #include "content/public/test/mock_download_item.h"
15 #include "content/public/test/test_browser_thread.h" 16 #include "content/public/test/test_browser_thread.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 MOCK_CONST_METHOD0(GetDownloadManager, DownloadManager*()); 52 MOCK_CONST_METHOD0(GetDownloadManager, DownloadManager*());
52 MOCK_CONST_METHOD0(PauseRequest, void()); 53 MOCK_CONST_METHOD0(PauseRequest, void());
53 MOCK_CONST_METHOD0(ResumeRequest, void()); 54 MOCK_CONST_METHOD0(ResumeRequest, void());
54 MOCK_CONST_METHOD0(CancelRequest, void()); 55 MOCK_CONST_METHOD0(CancelRequest, void());
55 MOCK_CONST_METHOD0(DebugString, std::string()); 56 MOCK_CONST_METHOD0(DebugString, std::string());
56 }; 57 };
57 58
58 class MockDownloadFileFactory 59 class MockDownloadFileFactory
59 : public DownloadFileManager::DownloadFileFactory { 60 : public DownloadFileManager::DownloadFileFactory {
60 public: 61 public:
61 MOCK_METHOD5(CreateFile, 62 content::DownloadFile* CreateFile(
63 DownloadCreateInfo* info,
64 scoped_ptr<content::ByteStreamReader> stream_reader,
65 const DownloadRequestHandle& request_handle,
66 DownloadManager* mgr,
67 bool calculate_hash,
68 const net::BoundNetLog& bound_net_log) {
69 return MockCreateFile(
70 info, stream_reader.get(), request_handle, mgr, calculate_hash,
71 bound_net_log);
72 }
73
74 MOCK_METHOD6(MockCreateFile,
62 content::DownloadFile*(DownloadCreateInfo*, 75 content::DownloadFile*(DownloadCreateInfo*,
76 content::ByteStreamReader*,
63 const DownloadRequestHandle&, 77 const DownloadRequestHandle&,
64 DownloadManager*, 78 DownloadManager*,
65 bool, 79 bool,
66 const net::BoundNetLog&)); 80 const net::BoundNetLog&));
67 }; 81 };
68 82
69 class MockDownloadFileManager : public DownloadFileManager { 83 class MockDownloadFileManager : public DownloadFileManager {
70 public: 84 public:
71 MockDownloadFileManager(); 85 MockDownloadFileManager();
72 MOCK_METHOD0(Shutdown, void()); 86 MOCK_METHOD0(Shutdown, void());
73 MOCK_METHOD2(StartDownload, 87 MOCK_METHOD3(MockStartDownload,
74 void(DownloadCreateInfo*, const DownloadRequestHandle&)); 88 void(DownloadCreateInfo*, content::ByteStreamReader*,
75 MOCK_METHOD2(UpdateDownload, void(DownloadId, content::DownloadBuffer*)); 89 const DownloadRequestHandle&));
76 MOCK_METHOD3(OnResponseCompleted, 90 virtual void StartDownload(scoped_ptr<DownloadCreateInfo> info,
77 void(DownloadId, content::DownloadInterruptReason, 91 scoped_ptr<content::ByteStreamReader> stream,
78 const std::string&)); 92 const DownloadRequestHandle& request_handle) {
93 MockStartDownload(info.release(), stream.release(), request_handle);
94 }
95
79 MOCK_METHOD1(CancelDownload, void(DownloadId)); 96 MOCK_METHOD1(CancelDownload, void(DownloadId));
80 MOCK_METHOD1(CompleteDownload, void(DownloadId)); 97 MOCK_METHOD1(CompleteDownload, void(DownloadId));
81 MOCK_METHOD1(OnDownloadManagerShutdown, void(DownloadManager*)); 98 MOCK_METHOD1(OnDownloadManagerShutdown, void(DownloadManager*));
82 MOCK_METHOD4(RenameInProgressDownloadFile, 99 MOCK_METHOD4(RenameInProgressDownloadFile,
83 void(DownloadId, const FilePath&, bool, 100 void(DownloadId, const FilePath&, bool,
84 const RenameCompletionCallback&)); 101 const RenameCompletionCallback&));
85 MOCK_METHOD4(RenameCompletingDownloadFile, 102 MOCK_METHOD4(RenameCompletingDownloadFile,
86 void(DownloadId, const FilePath&, bool, 103 void(DownloadId, const FilePath&, bool,
87 const RenameCompletionCallback&)); 104 const RenameCompletionCallback&));
88 MOCK_CONST_METHOD0(NumberOfActiveDownloads, int()); 105 MOCK_CONST_METHOD0(NumberOfActiveDownloads, int());
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 final_path)))); 546 final_path))));
530 item->OnDownloadCompleting(file_manager.get()); 547 item->OnDownloadCompleting(file_manager.get());
531 RunAllPendingInMessageLoops(); 548 RunAllPendingInMessageLoops();
532 ::testing::Mock::VerifyAndClearExpectations(file_manager.get()); 549 ::testing::Mock::VerifyAndClearExpectations(file_manager.get());
533 ::testing::Mock::VerifyAndClearExpectations(mock_delegate()); 550 ::testing::Mock::VerifyAndClearExpectations(mock_delegate());
534 } 551 }
535 552
536 TEST(MockDownloadItem, Compiles) { 553 TEST(MockDownloadItem, Compiles) {
537 MockDownloadItem mock_item; 554 MockDownloadItem mock_item;
538 } 555 }
OLDNEW
« no previous file with comments | « content/browser/download/download_file_unittest.cc ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698