OLD | NEW |
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/callback.h" | 5 #include "base/callback.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "content/browser/byte_stream.h" | 10 #include "content/browser/byte_stream.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 MOCK_METHOD2(DetermineDownloadTarget, void( | 47 MOCK_METHOD2(DetermineDownloadTarget, void( |
48 DownloadItemImpl*, const DownloadTargetCallback&)); | 48 DownloadItemImpl*, const DownloadTargetCallback&)); |
49 MOCK_METHOD2(ShouldCompleteDownload, | 49 MOCK_METHOD2(ShouldCompleteDownload, |
50 bool(DownloadItemImpl*, const base::Closure&)); | 50 bool(DownloadItemImpl*, const base::Closure&)); |
51 MOCK_METHOD2(ShouldOpenDownload, | 51 MOCK_METHOD2(ShouldOpenDownload, |
52 bool(DownloadItemImpl*, const ShouldOpenDownloadCallback&)); | 52 bool(DownloadItemImpl*, const ShouldOpenDownloadCallback&)); |
53 MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const base::FilePath&)); | 53 MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const base::FilePath&)); |
54 MOCK_METHOD1(CheckForFileRemoval, void(DownloadItemImpl*)); | 54 MOCK_METHOD1(CheckForFileRemoval, void(DownloadItemImpl*)); |
55 | 55 |
56 virtual void ResumeInterruptedDownload( | 56 void ResumeInterruptedDownload( |
57 scoped_ptr<DownloadUrlParameters> params, uint32 id) override { | 57 scoped_ptr<DownloadUrlParameters> params, uint32 id) override { |
58 MockResumeInterruptedDownload(params.get(), id); | 58 MockResumeInterruptedDownload(params.get(), id); |
59 } | 59 } |
60 MOCK_METHOD2(MockResumeInterruptedDownload, | 60 MOCK_METHOD2(MockResumeInterruptedDownload, |
61 void(DownloadUrlParameters* params, uint32 id)); | 61 void(DownloadUrlParameters* params, uint32 id)); |
62 | 62 |
63 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); | 63 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); |
64 MOCK_METHOD1(UpdatePersistence, void(DownloadItemImpl*)); | 64 MOCK_METHOD1(UpdatePersistence, void(DownloadItemImpl*)); |
65 MOCK_METHOD1(DownloadOpened, void(DownloadItemImpl*)); | 65 MOCK_METHOD1(DownloadOpened, void(DownloadItemImpl*)); |
66 MOCK_METHOD1(DownloadRemoved, void(DownloadItemImpl*)); | 66 MOCK_METHOD1(DownloadRemoved, void(DownloadItemImpl*)); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 ~DownloadItemTest() { | 201 ~DownloadItemTest() { |
202 } | 202 } |
203 | 203 |
204 virtual void SetUp() { | 204 virtual void SetUp() { |
205 } | 205 } |
206 | 206 |
207 virtual void TearDown() { | 207 virtual void TearDown() { |
208 ui_thread_.DeprecatedGetThreadObject()->message_loop()->RunUntilIdle(); | 208 ui_thread_.DeprecatedGetThreadObject()->message_loop()->RunUntilIdle(); |
209 STLDeleteElements(&allocated_downloads_); | 209 STLDeleteElements(&allocated_downloads_); |
210 allocated_downloads_.clear(); | |
211 } | 210 } |
212 | 211 |
213 // This class keeps ownership of the created download item; it will | 212 // This class keeps ownership of the created download item; it will |
214 // be torn down at the end of the test unless DestroyDownloadItem is | 213 // be torn down at the end of the test unless DestroyDownloadItem is |
215 // called. | 214 // called. |
216 DownloadItemImpl* CreateDownloadItem() { | 215 DownloadItemImpl* CreateDownloadItem() { |
217 // Normally, the download system takes ownership of info, and is | 216 // Normally, the download system takes ownership of info, and is |
218 // responsible for deleting it. In these unit tests, however, we | 217 // responsible for deleting it. In these unit tests, however, we |
219 // don't call the function that deletes it, so we do so ourselves. | 218 // don't call the function that deletes it, so we do so ourselves. |
220 scoped_ptr<DownloadCreateInfo> info_; | 219 scoped_ptr<DownloadCreateInfo> info_; |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 base::Unretained(&returned_path))); | 1292 base::Unretained(&returned_path))); |
1294 RunAllPendingInMessageLoops(); | 1293 RunAllPendingInMessageLoops(); |
1295 EXPECT_TRUE(returned_path.empty()); | 1294 EXPECT_TRUE(returned_path.empty()); |
1296 } | 1295 } |
1297 | 1296 |
1298 TEST(MockDownloadItem, Compiles) { | 1297 TEST(MockDownloadItem, Compiles) { |
1299 MockDownloadItem mock_item; | 1298 MockDownloadItem mock_item; |
1300 } | 1299 } |
1301 | 1300 |
1302 } // namespace content | 1301 } // namespace content |
OLD | NEW |