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

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

Issue 10861002: Revert 152213 - Replace the DownloadFileManager with direct ownership of DownloadFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 "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/byte_stream.h"
9 #include "content/browser/download/download_create_info.h" 9 #include "content/browser/download/download_create_info.h"
10 #include "content/browser/download/download_file_factory.h" 10 #include "content/browser/download/download_file_manager.h"
11 #include "content/browser/download/download_item_impl.h" 11 #include "content/browser/download/download_item_impl.h"
12 #include "content/browser/download/download_item_impl_delegate.h" 12 #include "content/browser/download/download_item_impl_delegate.h"
13 #include "content/browser/download/download_request_handle.h" 13 #include "content/browser/download/download_request_handle.h"
14 #include "content/browser/download/mock_download_file.h"
15 #include "content/public/browser/download_id.h" 14 #include "content/public/browser/download_id.h"
16 #include "content/public/browser/download_destination_observer.h"
17 #include "content/public/browser/download_interrupt_reasons.h" 15 #include "content/public/browser/download_interrupt_reasons.h"
18 #include "content/public/test/mock_download_item.h" 16 #include "content/public/test/mock_download_item.h"
19 #include "content/public/test/test_browser_thread.h" 17 #include "content/public/test/test_browser_thread.h"
20 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
22 20
23 using content::BrowserThread; 21 using content::BrowserThread;
24 using content::DownloadId; 22 using content::DownloadId;
25 using content::DownloadItem; 23 using content::DownloadItem;
26 using content::DownloadManager; 24 using content::DownloadManager;
27 using content::MockDownloadItem; 25 using content::MockDownloadItem;
28 using content::WebContents; 26 using content::WebContents;
29 using ::testing::_; 27 using ::testing::_;
30 using ::testing::AllOf; 28 using ::testing::AllOf;
31 using ::testing::Property; 29 using ::testing::Property;
32 using ::testing::Return; 30 using ::testing::Return;
33 using ::testing::StrictMock;
34 31
35 DownloadId::Domain kValidDownloadItemIdDomain = "valid DownloadId::Domain"; 32 DownloadId::Domain kValidDownloadItemIdDomain = "valid DownloadId::Domain";
36 33
37 namespace { 34 namespace {
38 class MockDelegate : public DownloadItemImplDelegate { 35 class MockDelegate : public DownloadItemImplDelegate {
39 public: 36 public:
40 MOCK_METHOD1(DelegateStart, void(DownloadItemImpl* download)); 37 MockDelegate(DownloadFileManager* file_manager)
38 : file_manager_(file_manager) {
39 }
40 MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const FilePath& path));
41 MOCK_METHOD1(ShouldOpenDownload, bool(DownloadItemImpl* download)); 41 MOCK_METHOD1(ShouldOpenDownload, bool(DownloadItemImpl* download));
42 MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const FilePath& path));
43 MOCK_METHOD1(CheckForFileRemoval, void(DownloadItemImpl* download)); 42 MOCK_METHOD1(CheckForFileRemoval, void(DownloadItemImpl* download));
44 MOCK_METHOD1(MaybeCompleteDownload, void(DownloadItemImpl* download)); 43 MOCK_METHOD1(MaybeCompleteDownload, void(DownloadItemImpl* download));
45 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*()); 44 MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*());
46 MOCK_METHOD1(DownloadStopped, void(DownloadItemImpl* download)); 45 MOCK_METHOD1(DownloadStopped, void(DownloadItemImpl* download));
47 MOCK_METHOD1(DownloadCompleted, void(DownloadItemImpl* download)); 46 MOCK_METHOD1(DownloadCompleted, void(DownloadItemImpl* download));
48 MOCK_METHOD1(DownloadOpened, void(DownloadItemImpl* download)); 47 MOCK_METHOD1(DownloadOpened, void(DownloadItemImpl* download));
49 MOCK_METHOD1(DownloadRemoved, void(DownloadItemImpl* download)); 48 MOCK_METHOD1(DownloadRemoved, void(DownloadItemImpl* download));
50 MOCK_METHOD1(DownloadRenamedToIntermediateName, 49 MOCK_METHOD1(DownloadRenamedToIntermediateName,
51 void(DownloadItemImpl* download)); 50 void(DownloadItemImpl* download));
52 MOCK_METHOD1(DownloadRenamedToFinalName, void(DownloadItemImpl* download)); 51 MOCK_METHOD1(DownloadRenamedToFinalName, void(DownloadItemImpl* download));
53 MOCK_CONST_METHOD1(AssertStateConsistent, void(DownloadItemImpl* download)); 52 MOCK_CONST_METHOD1(AssertStateConsistent, void(DownloadItemImpl* download));
54 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE { 53 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE {
55 return file_manager_; 54 return file_manager_;
56 } 55 }
57 private: 56 private:
58 DownloadFileManager* file_manager_; 57 DownloadFileManager* file_manager_;
59 }; 58 };
60 59
61 class MockRequestHandle : public DownloadRequestHandleInterface { 60 class MockRequestHandle : public DownloadRequestHandleInterface {
62 public: 61 public:
63 MOCK_CONST_METHOD0(GetWebContents, WebContents*()); 62 MOCK_CONST_METHOD0(GetWebContents, WebContents*());
64 MOCK_CONST_METHOD0(GetDownloadManager, DownloadManager*()); 63 MOCK_CONST_METHOD0(GetDownloadManager, DownloadManager*());
65 MOCK_CONST_METHOD0(PauseRequest, void()); 64 MOCK_CONST_METHOD0(PauseRequest, void());
66 MOCK_CONST_METHOD0(ResumeRequest, void()); 65 MOCK_CONST_METHOD0(ResumeRequest, void());
67 MOCK_CONST_METHOD0(CancelRequest, void()); 66 MOCK_CONST_METHOD0(CancelRequest, void());
68 MOCK_CONST_METHOD0(DebugString, std::string()); 67 MOCK_CONST_METHOD0(DebugString, std::string());
69 }; 68 };
70 69
70 class MockDownloadFileFactory
71 : public DownloadFileManager::DownloadFileFactory {
72 public:
73 content::DownloadFile* CreateFile(
74 DownloadCreateInfo* info,
75 scoped_ptr<content::ByteStreamReader> stream_reader,
76 DownloadManager* mgr,
77 bool calculate_hash,
78 const net::BoundNetLog& bound_net_log) {
79 return MockCreateFile(
80 info, stream_reader.get(), info->request_handle, mgr, calculate_hash,
81 bound_net_log);
82 }
83
84 MOCK_METHOD6(MockCreateFile,
85 content::DownloadFile*(DownloadCreateInfo*,
86 content::ByteStreamReader*,
87 const DownloadRequestHandle&,
88 DownloadManager*,
89 bool,
90 const net::BoundNetLog&));
91 };
92
93 class MockDownloadFileManager : public DownloadFileManager {
94 public:
95 MockDownloadFileManager();
96 MOCK_METHOD0(Shutdown, void());
97 MOCK_METHOD1(CancelDownload, void(DownloadId));
98 MOCK_METHOD2(CompleteDownload, void(DownloadId, const base::Closure&));
99 MOCK_METHOD1(OnDownloadManagerShutdown, void(DownloadManager*));
100 MOCK_METHOD4(RenameDownloadFile, void(DownloadId, const FilePath&, bool,
101 const RenameCompletionCallback&));
102 MOCK_CONST_METHOD0(NumberOfActiveDownloads, int());
103 private:
104 ~MockDownloadFileManager() {}
105 };
106
71 // Schedules a task to invoke the RenameCompletionCallback with |new_path| on 107 // Schedules a task to invoke the RenameCompletionCallback with |new_path| on
72 // the UI thread. Should only be used as the action for 108 // the UI thread. Should only be used as the action for
73 // MockDownloadFile::Rename as follows: 109 // MockDownloadFileManager::Rename*DownloadFile as follows:
74 // EXPECT_CALL(download_file, Rename(_,_,_)) 110 // EXPECT_CALL(mock_download_file_manager,
111 // RenameDownloadFile(_,_,_,_))
75 // .WillOnce(ScheduleRenameCallback(new_path)); 112 // .WillOnce(ScheduleRenameCallback(new_path));
76 ACTION_P(ScheduleRenameCallback, new_path) { 113 ACTION_P(ScheduleRenameCallback, new_path) {
77 BrowserThread::PostTask( 114 BrowserThread::PostTask(
78 BrowserThread::UI, FROM_HERE, 115 BrowserThread::UI, FROM_HERE,
79 base::Bind(arg2, content::DOWNLOAD_INTERRUPT_REASON_NONE, new_path)); 116 base::Bind(arg3, content::DOWNLOAD_INTERRUPT_REASON_NONE, new_path));
80 } 117 }
81 118
82 // Similarly for scheduling a completion callback. 119 // Similarly for scheduling a completion callback.
83 ACTION(ScheduleCompleteCallback) { 120 ACTION(ScheduleCompleteCallback) {
84 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(arg1)); 121 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(arg1));
85 } 122 }
86 123
124 MockDownloadFileManager::MockDownloadFileManager()
125 : DownloadFileManager(new MockDownloadFileFactory) {
126 }
127
87 } // namespace 128 } // namespace
88 129
89 class DownloadItemTest : public testing::Test { 130 class DownloadItemTest : public testing::Test {
90 public: 131 public:
91 class MockObserver : public DownloadItem::Observer { 132 class MockObserver : public DownloadItem::Observer {
92 public: 133 public:
93 explicit MockObserver(DownloadItem* item) 134 explicit MockObserver(DownloadItem* item)
94 : item_(item), 135 : item_(item),
95 removed_(false), 136 removed_(false),
96 destroyed_(false), 137 destroyed_(false),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 private: 177 private:
137 DownloadItem* item_; 178 DownloadItem* item_;
138 bool removed_; 179 bool removed_;
139 bool destroyed_; 180 bool destroyed_;
140 bool updated_; 181 bool updated_;
141 }; 182 };
142 183
143 DownloadItemTest() 184 DownloadItemTest()
144 : ui_thread_(BrowserThread::UI, &loop_), 185 : ui_thread_(BrowserThread::UI, &loop_),
145 file_thread_(BrowserThread::FILE, &loop_), 186 file_thread_(BrowserThread::FILE, &loop_),
146 delegate_() { 187 file_manager_(new MockDownloadFileManager),
188 delegate_(file_manager_.get()) {
147 } 189 }
148 190
149 ~DownloadItemTest() { 191 ~DownloadItemTest() {
150 } 192 }
151 193
152 virtual void SetUp() { 194 virtual void SetUp() {
153 } 195 }
154 196
155 virtual void TearDown() { 197 virtual void TearDown() {
156 ui_thread_.DeprecatedGetThreadObject()->message_loop()->RunAllPending(); 198 ui_thread_.DeprecatedGetThreadObject()->message_loop()->RunAllPending();
(...skipping 20 matching lines...) Expand all
177 219
178 scoped_ptr<DownloadRequestHandleInterface> request_handle( 220 scoped_ptr<DownloadRequestHandleInterface> request_handle(
179 new testing::NiceMock<MockRequestHandle>); 221 new testing::NiceMock<MockRequestHandle>);
180 DownloadItemImpl* download = 222 DownloadItemImpl* download =
181 new DownloadItemImpl(&delegate_, *(info_.get()), 223 new DownloadItemImpl(&delegate_, *(info_.get()),
182 request_handle.Pass(), net::BoundNetLog()); 224 request_handle.Pass(), net::BoundNetLog());
183 allocated_downloads_.insert(download); 225 allocated_downloads_.insert(download);
184 return download; 226 return download;
185 } 227 }
186 228
187 // Add DownloadFile to DownloadItem
188 MockDownloadFile* AddDownloadFileToDownloadItem(DownloadItemImpl* item) {
189 MockDownloadFile* mock_download_file(new StrictMock<MockDownloadFile>);
190 scoped_ptr<content::DownloadFile> download_file(mock_download_file);
191 EXPECT_CALL(*mock_download_file, Initialize(_));
192 item->Start(download_file.Pass());
193 loop_.RunAllPending();
194 return mock_download_file;
195 }
196
197 // Cleanup a download item (specifically get rid of the DownloadFile on it).
198 // The item must be in the IN_PROGRESS state.
199 void CleanupItem(DownloadItemImpl* item, MockDownloadFile* download_file) {
200 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
201
202 EXPECT_CALL(*download_file, Cancel());
203 EXPECT_CALL(delegate_, DownloadStopped(item));
204 item->Cancel(true);
205 loop_.RunAllPending();
206 }
207
208 // Destroy a previously created download item. 229 // Destroy a previously created download item.
209 void DestroyDownloadItem(DownloadItem* item) { 230 void DestroyDownloadItem(DownloadItem* item) {
210 allocated_downloads_.erase(item); 231 allocated_downloads_.erase(item);
211 delete item; 232 delete item;
212 } 233 }
213 234
214 void RunAllPendingInMessageLoops() { 235 void RunAllPendingInMessageLoops() {
215 loop_.RunAllPending(); 236 loop_.RunAllPending();
216 } 237 }
217 238
218 MockDelegate* mock_delegate() { 239 MockDelegate* mock_delegate() {
219 return &delegate_; 240 return &delegate_;
220 } 241 }
221 242
243 MockDownloadFileManager* mock_file_manager() {
244 return file_manager_.get();
245 }
246
222 private: 247 private:
223 MessageLoopForUI loop_; 248 MessageLoopForUI loop_;
224 content::TestBrowserThread ui_thread_; // UI thread 249 content::TestBrowserThread ui_thread_; // UI thread
225 content::TestBrowserThread file_thread_; // FILE thread 250 content::TestBrowserThread file_thread_; // FILE thread
251 scoped_refptr<MockDownloadFileManager> file_manager_;
226 testing::NiceMock<MockDelegate> delegate_; 252 testing::NiceMock<MockDelegate> delegate_;
227 std::set<DownloadItem*> allocated_downloads_; 253 std::set<DownloadItem*> allocated_downloads_;
228 }; 254 };
229 255
230 namespace { 256 namespace {
231 257
232 const int kDownloadChunkSize = 1000; 258 const int kDownloadChunkSize = 1000;
233 const int kDownloadSpeed = 1000; 259 const int kDownloadSpeed = 1000;
234 const int kDummyDBHandle = 10; 260 const int kDummyDBHandle = 10;
235 const FilePath::CharType kDummyPath[] = FILE_PATH_LITERAL("/testpath"); 261 const FilePath::CharType kDummyPath[] = FILE_PATH_LITERAL("/testpath");
(...skipping 13 matching lines...) Expand all
249 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 275 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
250 MockObserver observer(item); 276 MockObserver observer(item);
251 277
252 item->UpdateProgress(kDownloadChunkSize, kDownloadSpeed, ""); 278 item->UpdateProgress(kDownloadChunkSize, kDownloadSpeed, "");
253 ASSERT_TRUE(observer.CheckUpdated()); 279 ASSERT_TRUE(observer.CheckUpdated());
254 EXPECT_EQ(kDownloadSpeed, item->CurrentSpeed()); 280 EXPECT_EQ(kDownloadSpeed, item->CurrentSpeed());
255 } 281 }
256 282
257 TEST_F(DownloadItemTest, NotificationAfterCancel) { 283 TEST_F(DownloadItemTest, NotificationAfterCancel) {
258 DownloadItemImpl* user_cancel = CreateDownloadItem(DownloadItem::IN_PROGRESS); 284 DownloadItemImpl* user_cancel = CreateDownloadItem(DownloadItem::IN_PROGRESS);
259 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(user_cancel);
260 EXPECT_CALL(*download_file, Cancel());
261 MockObserver observer1(user_cancel); 285 MockObserver observer1(user_cancel);
262 286
263 user_cancel->Cancel(true); 287 user_cancel->Cancel(true);
264 ASSERT_TRUE(observer1.CheckUpdated()); 288 ASSERT_TRUE(observer1.CheckUpdated());
265 RunAllPendingInMessageLoops();
266 289
267 DownloadItemImpl* system_cancel = 290 DownloadItemImpl* system_cancel =
268 CreateDownloadItem(DownloadItem::IN_PROGRESS); 291 CreateDownloadItem(DownloadItem::IN_PROGRESS);
269 download_file = AddDownloadFileToDownloadItem(system_cancel);
270 EXPECT_CALL(*download_file, Cancel());
271 MockObserver observer2(system_cancel); 292 MockObserver observer2(system_cancel);
272 293
273 system_cancel->Cancel(false); 294 system_cancel->Cancel(false);
274 ASSERT_TRUE(observer2.CheckUpdated()); 295 ASSERT_TRUE(observer2.CheckUpdated());
275 RunAllPendingInMessageLoops();
276 } 296 }
277 297
278 TEST_F(DownloadItemTest, NotificationAfterComplete) { 298 TEST_F(DownloadItemTest, NotificationAfterComplete) {
279 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 299 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
280 MockObserver observer(item); 300 MockObserver observer(item);
281 301
282 item->OnAllDataSaved(DownloadItem::kEmptyFileHash); 302 item->OnAllDataSaved(kDownloadChunkSize, DownloadItem::kEmptyFileHash);
283 ASSERT_TRUE(observer.CheckUpdated()); 303 ASSERT_TRUE(observer.CheckUpdated());
284 304
285 item->MarkAsComplete(); 305 item->MarkAsComplete();
286 ASSERT_TRUE(observer.CheckUpdated()); 306 ASSERT_TRUE(observer.CheckUpdated());
287 } 307 }
288 308
289 TEST_F(DownloadItemTest, NotificationAfterDownloadedFileRemoved) { 309 TEST_F(DownloadItemTest, NotificationAfterDownloadedFileRemoved) {
290 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 310 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
291 MockObserver observer(item); 311 MockObserver observer(item);
292 312
293 item->OnDownloadedFileRemoved(); 313 item->OnDownloadedFileRemoved();
294 ASSERT_TRUE(observer.CheckUpdated()); 314 ASSERT_TRUE(observer.CheckUpdated());
295 } 315 }
296 316
297 TEST_F(DownloadItemTest, NotificationAfterInterrupted) { 317 TEST_F(DownloadItemTest, NotificationAfterInterrupted) {
298 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 318 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
299 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
300 EXPECT_CALL(*download_file, Cancel());
301 MockObserver observer(item); 319 MockObserver observer(item);
302 320
303 item->Interrupt(content::DOWNLOAD_INTERRUPT_REASON_NONE); 321 item->Interrupt(content::DOWNLOAD_INTERRUPT_REASON_NONE);
304 ASSERT_TRUE(observer.CheckUpdated()); 322 ASSERT_TRUE(observer.CheckUpdated());
305 RunAllPendingInMessageLoops();
306 } 323 }
307 324
308 TEST_F(DownloadItemTest, NotificationAfterDelete) { 325 TEST_F(DownloadItemTest, NotificationAfterDelete) {
309 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 326 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
310 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
311 EXPECT_CALL(*download_file, Cancel());
312 MockObserver observer(item); 327 MockObserver observer(item);
313 328
314 item->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN); 329 item->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN);
315 ASSERT_TRUE(observer.CheckUpdated()); 330 ASSERT_TRUE(observer.CheckUpdated());
316 RunAllPendingInMessageLoops();
317 } 331 }
318 332
319 TEST_F(DownloadItemTest, NotificationAfterDestroyed) { 333 TEST_F(DownloadItemTest, NotificationAfterDestroyed) {
320 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 334 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
321 MockObserver observer(item); 335 MockObserver observer(item);
322 336
323 DestroyDownloadItem(item); 337 DestroyDownloadItem(item);
324 ASSERT_TRUE(observer.CheckDestroyed()); 338 ASSERT_TRUE(observer.CheckDestroyed());
325 } 339 }
326 340
327 TEST_F(DownloadItemTest, NotificationAfterRemove) { 341 TEST_F(DownloadItemTest, NotificationAfterRemove) {
328 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 342 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
329 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
330 EXPECT_CALL(*download_file, Cancel());
331 MockObserver observer(item); 343 MockObserver observer(item);
332 344
333 item->Remove(); 345 item->Remove();
334 ASSERT_TRUE(observer.CheckUpdated()); 346 ASSERT_TRUE(observer.CheckUpdated());
335 ASSERT_TRUE(observer.CheckRemoved()); 347 ASSERT_TRUE(observer.CheckRemoved());
336 } 348 }
337 349
338 TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) { 350 TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) {
339 // Setting to NOT_DANGEROUS does not trigger a notification. 351 // Setting to NOT_DANGEROUS does not trigger a notification.
340 DownloadItemImpl* safe_item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 352 DownloadItemImpl* safe_item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
341 MockObserver safe_observer(safe_item); 353 MockObserver safe_observer(safe_item);
342 354
343 safe_item->OnAllDataSaved(""); 355 safe_item->OnAllDataSaved(1, "");
344 EXPECT_TRUE(safe_observer.CheckUpdated()); 356 EXPECT_TRUE(safe_observer.CheckUpdated());
345 safe_item->OnContentCheckCompleted( 357 safe_item->OnContentCheckCompleted(
346 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); 358 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
347 EXPECT_TRUE(safe_observer.CheckUpdated()); 359 EXPECT_TRUE(safe_observer.CheckUpdated());
348 360
349 // Setting to unsafe url or unsafe file should trigger a notification. 361 // Setting to unsafe url or unsafe file should trigger a notification.
350 DownloadItemImpl* unsafeurl_item = 362 DownloadItemImpl* unsafeurl_item =
351 CreateDownloadItem(DownloadItem::IN_PROGRESS); 363 CreateDownloadItem(DownloadItem::IN_PROGRESS);
352 MockObserver unsafeurl_observer(unsafeurl_item); 364 MockObserver unsafeurl_observer(unsafeurl_item);
353 365
354 unsafeurl_item->OnAllDataSaved(""); 366 unsafeurl_item->OnAllDataSaved(1, "");
355 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); 367 EXPECT_TRUE(unsafeurl_observer.CheckUpdated());
356 unsafeurl_item->OnContentCheckCompleted( 368 unsafeurl_item->OnContentCheckCompleted(
357 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL); 369 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
358 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); 370 EXPECT_TRUE(unsafeurl_observer.CheckUpdated());
359 371
360 unsafeurl_item->DangerousDownloadValidated(); 372 unsafeurl_item->DangerousDownloadValidated();
361 EXPECT_TRUE(unsafeurl_observer.CheckUpdated()); 373 EXPECT_TRUE(unsafeurl_observer.CheckUpdated());
362 374
363 DownloadItemImpl* unsafefile_item = 375 DownloadItemImpl* unsafefile_item =
364 CreateDownloadItem(DownloadItem::IN_PROGRESS); 376 CreateDownloadItem(DownloadItem::IN_PROGRESS);
365 MockObserver unsafefile_observer(unsafefile_item); 377 MockObserver unsafefile_observer(unsafefile_item);
366 378
367 unsafefile_item->OnAllDataSaved(""); 379 unsafefile_item->OnAllDataSaved(1, "");
368 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); 380 EXPECT_TRUE(unsafefile_observer.CheckUpdated());
369 unsafefile_item->OnContentCheckCompleted( 381 unsafefile_item->OnContentCheckCompleted(
370 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); 382 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE);
371 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); 383 EXPECT_TRUE(unsafefile_observer.CheckUpdated());
372 384
373 unsafefile_item->DangerousDownloadValidated(); 385 unsafefile_item->DangerousDownloadValidated();
374 EXPECT_TRUE(unsafefile_observer.CheckUpdated()); 386 EXPECT_TRUE(unsafefile_observer.CheckUpdated());
375 } 387 }
376 388
377 // DownloadItemImpl::OnDownloadTargetDetermined will schedule a task to run 389 // DownloadItemImpl::OnDownloadTargetDetermined will schedule a task to run
378 // DownloadFile::Rename(). Once the rename 390 // DownloadFileManager::RenameDownloadFile(). Once the rename
379 // completes, DownloadItemImpl receives a notification with the new file 391 // completes, DownloadItemImpl receives a notification with the new file
380 // name. Check that observers are updated when the new filename is available and 392 // name. Check that observers are updated when the new filename is available and
381 // not before. 393 // not before.
382 TEST_F(DownloadItemTest, NotificationAfterOnDownloadTargetDetermined) { 394 TEST_F(DownloadItemTest, NotificationAfterOnDownloadTargetDetermined) {
383 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 395 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
384 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
385 MockObserver observer(item); 396 MockObserver observer(item);
386 FilePath target_path(kDummyPath); 397 FilePath target_path(kDummyPath);
387 FilePath intermediate_path(target_path.InsertBeforeExtensionASCII("x")); 398 FilePath intermediate_path(target_path.InsertBeforeExtensionASCII("x"));
388 FilePath new_intermediate_path(target_path.InsertBeforeExtensionASCII("y")); 399 FilePath new_intermediate_path(target_path.InsertBeforeExtensionASCII("y"));
389 EXPECT_CALL(*download_file, Rename(intermediate_path, false, _)) 400 EXPECT_CALL(*mock_file_manager(),
401 RenameDownloadFile(_,intermediate_path,false,_))
390 .WillOnce(ScheduleRenameCallback(new_intermediate_path)); 402 .WillOnce(ScheduleRenameCallback(new_intermediate_path));
391 403
392 // Currently, a notification would be generated if the danger type is anything 404 // Currently, a notification would be generated if the danger type is anything
393 // other than NOT_DANGEROUS. 405 // other than NOT_DANGEROUS.
394 item->OnDownloadTargetDetermined(target_path, 406 item->OnDownloadTargetDetermined(target_path,
395 DownloadItem::TARGET_DISPOSITION_OVERWRITE, 407 DownloadItem::TARGET_DISPOSITION_OVERWRITE,
396 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 408 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
397 intermediate_path); 409 intermediate_path);
398 EXPECT_FALSE(observer.CheckUpdated()); 410 EXPECT_FALSE(observer.CheckUpdated());
399 RunAllPendingInMessageLoops(); 411 RunAllPendingInMessageLoops();
400 EXPECT_TRUE(observer.CheckUpdated()); 412 EXPECT_TRUE(observer.CheckUpdated());
401 EXPECT_EQ(new_intermediate_path, item->GetFullPath()); 413 EXPECT_EQ(new_intermediate_path, item->GetFullPath());
402
403 CleanupItem(item, download_file);
404 } 414 }
405 415
406 TEST_F(DownloadItemTest, NotificationAfterTogglePause) { 416 TEST_F(DownloadItemTest, NotificationAfterTogglePause) {
407 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 417 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
408 MockObserver observer(item); 418 MockObserver observer(item);
409 419
410 item->TogglePause(); 420 item->TogglePause();
411 ASSERT_TRUE(observer.CheckUpdated()); 421 ASSERT_TRUE(observer.CheckUpdated());
412 422
413 item->TogglePause(); 423 item->TogglePause();
414 ASSERT_TRUE(observer.CheckUpdated()); 424 ASSERT_TRUE(observer.CheckUpdated());
415 } 425 }
416 426
417 TEST_F(DownloadItemTest, DisplayName) { 427 TEST_F(DownloadItemTest, DisplayName) {
418 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 428 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
419 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
420 FilePath target_path(FilePath(kDummyPath).AppendASCII("foo.bar")); 429 FilePath target_path(FilePath(kDummyPath).AppendASCII("foo.bar"));
421 FilePath intermediate_path(target_path.InsertBeforeExtensionASCII("x")); 430 FilePath intermediate_path(target_path.InsertBeforeExtensionASCII("x"));
422 EXPECT_EQ(FILE_PATH_LITERAL(""), 431 EXPECT_EQ(FILE_PATH_LITERAL(""),
423 item->GetFileNameToReportUser().value()); 432 item->GetFileNameToReportUser().value());
424 EXPECT_CALL(*download_file, Rename(_, false, _)) 433 EXPECT_CALL(*mock_file_manager(),
434 RenameDownloadFile(_,_,false,_))
425 .WillOnce(ScheduleRenameCallback(intermediate_path)); 435 .WillOnce(ScheduleRenameCallback(intermediate_path));
426 item->OnDownloadTargetDetermined(target_path, 436 item->OnDownloadTargetDetermined(target_path,
427 DownloadItem::TARGET_DISPOSITION_OVERWRITE, 437 DownloadItem::TARGET_DISPOSITION_OVERWRITE,
428 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 438 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
429 intermediate_path); 439 intermediate_path);
430 RunAllPendingInMessageLoops(); 440 RunAllPendingInMessageLoops();
431 EXPECT_EQ(FILE_PATH_LITERAL("foo.bar"), 441 EXPECT_EQ(FILE_PATH_LITERAL("foo.bar"),
432 item->GetFileNameToReportUser().value()); 442 item->GetFileNameToReportUser().value());
433 item->SetDisplayName(FilePath(FILE_PATH_LITERAL("new.name"))); 443 item->SetDisplayName(FilePath(FILE_PATH_LITERAL("new.name")));
434 EXPECT_EQ(FILE_PATH_LITERAL("new.name"), 444 EXPECT_EQ(FILE_PATH_LITERAL("new.name"),
435 item->GetFileNameToReportUser().value()); 445 item->GetFileNameToReportUser().value());
436 CleanupItem(item, download_file);
437 }
438
439 // Test to make sure that Start method calls DF initialize properly.
440 TEST_F(DownloadItemTest, Start) {
441 MockDownloadFile* mock_download_file(new MockDownloadFile);
442 scoped_ptr<content::DownloadFile> download_file(mock_download_file);
443 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
444 EXPECT_CALL(*mock_download_file, Initialize(_));
445 item->Start(download_file.Pass());
446
447 CleanupItem(item, mock_download_file);
448 } 446 }
449 447
450 // Test that the delegate is invoked after the download file is renamed. 448 // Test that the delegate is invoked after the download file is renamed.
451 // Delegate::DownloadRenamedToIntermediateName() should be invoked when the 449 // Delegate::DownloadRenamedToIntermediateName() should be invoked when the
452 // download is renamed to the intermediate name. 450 // download is renamed to the intermediate name.
453 // Delegate::DownloadRenamedToFinalName() should be invoked after the final 451 // Delegate::DownloadRenamedToFinalName() should be invoked after the final
454 // rename. 452 // rename.
455 TEST_F(DownloadItemTest, CallbackAfterRename) { 453 TEST_F(DownloadItemTest, CallbackAfterRename) {
456 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 454 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
457 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
458 FilePath final_path(FilePath(kDummyPath).AppendASCII("foo.bar")); 455 FilePath final_path(FilePath(kDummyPath).AppendASCII("foo.bar"));
459 FilePath intermediate_path(final_path.InsertBeforeExtensionASCII("x")); 456 FilePath intermediate_path(final_path.InsertBeforeExtensionASCII("x"));
460 FilePath new_intermediate_path(final_path.InsertBeforeExtensionASCII("y")); 457 FilePath new_intermediate_path(final_path.InsertBeforeExtensionASCII("y"));
461 EXPECT_CALL(*download_file, Rename(intermediate_path, false, _)) 458 EXPECT_CALL(*mock_file_manager(),
459 RenameDownloadFile(item->GetGlobalId(),
460 intermediate_path, false, _))
462 .WillOnce(ScheduleRenameCallback(new_intermediate_path)); 461 .WillOnce(ScheduleRenameCallback(new_intermediate_path));
463
464 // DownloadItemImpl should invoke this callback on the delegate once the 462 // DownloadItemImpl should invoke this callback on the delegate once the
465 // download is renamed to the intermediate name. Also check that GetFullPath() 463 // download is renamed to the intermediate name. Also check that GetFullPath()
466 // returns the intermediate path at the time of the call. 464 // returns the intermediate path at the time of the call.
467 EXPECT_CALL(*mock_delegate(), 465 EXPECT_CALL(*mock_delegate(),
468 DownloadRenamedToIntermediateName( 466 DownloadRenamedToIntermediateName(
469 AllOf(item, 467 AllOf(item,
470 Property(&DownloadItem::GetFullPath, 468 Property(&DownloadItem::GetFullPath,
471 new_intermediate_path)))); 469 new_intermediate_path))));
472 item->OnDownloadTargetDetermined(final_path, 470 item->OnDownloadTargetDetermined(final_path,
473 DownloadItem::TARGET_DISPOSITION_OVERWRITE, 471 DownloadItem::TARGET_DISPOSITION_OVERWRITE,
474 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 472 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
475 intermediate_path); 473 intermediate_path);
476 RunAllPendingInMessageLoops(); 474 RunAllPendingInMessageLoops();
477 // All the callbacks should have happened by now. 475 // All the callbacks should have happened by now.
478 ::testing::Mock::VerifyAndClearExpectations(download_file); 476 ::testing::Mock::VerifyAndClearExpectations(mock_file_manager());
479 ::testing::Mock::VerifyAndClearExpectations(mock_delegate()); 477 ::testing::Mock::VerifyAndClearExpectations(mock_delegate());
480 478
481 item->OnAllDataSaved(""); 479 item->OnAllDataSaved(10, "");
482 EXPECT_CALL(*download_file, Rename(final_path, true, _)) 480 EXPECT_CALL(*mock_file_manager(),
481 RenameDownloadFile(item->GetGlobalId(),
482 final_path, true, _))
483 .WillOnce(ScheduleRenameCallback(final_path)); 483 .WillOnce(ScheduleRenameCallback(final_path));
484 EXPECT_CALL(*mock_file_manager(),
485 CompleteDownload(item->GetGlobalId(), _))
486 .WillOnce(ScheduleCompleteCallback());
484 // DownloadItemImpl should invoke this callback on the delegate after the 487 // DownloadItemImpl should invoke this callback on the delegate after the
485 // final rename has completed. Also check that GetFullPath() and 488 // final rename has completed. Also check that GetFullPath() and
486 // GetTargetFilePath() return the final path at the time of the call. 489 // GetTargetFilePath() return the final path at the time of the call.
487 EXPECT_CALL(*mock_delegate(), 490 EXPECT_CALL(*mock_delegate(),
488 DownloadRenamedToFinalName( 491 DownloadRenamedToFinalName(
489 AllOf(item, 492 AllOf(item,
490 Property(&DownloadItem::GetFullPath, final_path), 493 Property(&DownloadItem::GetFullPath, final_path),
491 Property(&DownloadItem::GetTargetFilePath, 494 Property(&DownloadItem::GetTargetFilePath,
492 final_path)))); 495 final_path))));
493 EXPECT_CALL(*mock_delegate(), DownloadCompleted(item)); 496 EXPECT_CALL(*mock_delegate(), DownloadCompleted(item));
494 EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item)) 497 EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item))
495 .WillOnce(Return(true)); 498 .WillOnce(Return(true));
496 EXPECT_CALL(*download_file, Detach());
497 item->OnDownloadCompleting(); 499 item->OnDownloadCompleting();
498 RunAllPendingInMessageLoops(); 500 RunAllPendingInMessageLoops();
499 ::testing::Mock::VerifyAndClearExpectations(download_file); 501 ::testing::Mock::VerifyAndClearExpectations(mock_file_manager());
500 ::testing::Mock::VerifyAndClearExpectations(mock_delegate()); 502 ::testing::Mock::VerifyAndClearExpectations(mock_delegate());
501 } 503 }
502 504
503 TEST_F(DownloadItemTest, Interrupted) { 505 TEST_F(DownloadItemTest, Interrupted) {
504 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 506 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
505 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
506 507
507 const content::DownloadInterruptReason reason( 508 const content::DownloadInterruptReason reason(
508 content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED); 509 content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
509 510
510 // Confirm interrupt sets state properly. 511 // Confirm interrupt sets state properly.
511 EXPECT_CALL(*download_file, Cancel());
512 item->Interrupt(reason); 512 item->Interrupt(reason);
513 RunAllPendingInMessageLoops();
514 EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState()); 513 EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState());
515 EXPECT_EQ(reason, item->GetLastReason()); 514 EXPECT_EQ(reason, item->GetLastReason());
516 515
517 // Cancel should result in no change. 516 // Cancel should result in no change.
518 item->Cancel(true); 517 item->Cancel(true);
519 EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState()); 518 EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState());
520 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, 519 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED,
521 item->GetLastReason()); 520 item->GetLastReason());
522 } 521 }
523 522
524 TEST_F(DownloadItemTest, Canceled) { 523 TEST_F(DownloadItemTest, Canceled) {
525 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 524 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
526 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
527 525
528 // Confirm cancel sets state properly. 526 // Confirm cancel sets state properly.
529 EXPECT_CALL(*mock_delegate(), DownloadStopped(item)); 527 EXPECT_CALL(*mock_delegate(), DownloadStopped(item));
530 EXPECT_CALL(*download_file, Cancel());
531 item->Cancel(true); 528 item->Cancel(true);
532 EXPECT_EQ(DownloadItem::CANCELLED, item->GetState()); 529 EXPECT_EQ(DownloadItem::CANCELLED, item->GetState());
533 RunAllPendingInMessageLoops();
534 } 530 }
535 531
536 TEST_F(DownloadItemTest, FileRemoved) { 532 TEST_F(DownloadItemTest, FileRemoved) {
537 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 533 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
538 534
539 EXPECT_FALSE(item->GetFileExternallyRemoved()); 535 EXPECT_FALSE(item->GetFileExternallyRemoved());
540 item->OnDownloadedFileRemoved(); 536 item->OnDownloadedFileRemoved();
541 EXPECT_TRUE(item->GetFileExternallyRemoved()); 537 EXPECT_TRUE(item->GetFileExternallyRemoved());
542 } 538 }
543 539
544 TEST_F(DownloadItemTest, DestinationUpdate) {
545 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
546 base::WeakPtr<content::DownloadDestinationObserver> as_observer(
547 item->DestinationObserverAsWeakPtr());
548 MockObserver observer(item);
549
550 EXPECT_EQ(0l, item->CurrentSpeed());
551 EXPECT_EQ("", item->GetHashState());
552 EXPECT_EQ(0l, item->GetReceivedBytes());
553 EXPECT_EQ(0l, item->GetTotalBytes());
554 EXPECT_FALSE(observer.CheckUpdated());
555 item->SetTotalBytes(100l);
556 EXPECT_EQ(100l, item->GetTotalBytes());
557
558 as_observer->DestinationUpdate(10, 20, "deadbeef");
559 EXPECT_EQ(20l, item->CurrentSpeed());
560 EXPECT_EQ("deadbeef", item->GetHashState());
561 EXPECT_EQ(10l, item->GetReceivedBytes());
562 EXPECT_EQ(100l, item->GetTotalBytes());
563 EXPECT_TRUE(observer.CheckUpdated());
564
565 as_observer->DestinationUpdate(200, 20, "livebeef");
566 EXPECT_EQ(20l, item->CurrentSpeed());
567 EXPECT_EQ("livebeef", item->GetHashState());
568 EXPECT_EQ(200l, item->GetReceivedBytes());
569 EXPECT_EQ(0l, item->GetTotalBytes());
570 EXPECT_TRUE(observer.CheckUpdated());
571 }
572
573 TEST_F(DownloadItemTest, DestinationError) {
574 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
575 MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item);
576 base::WeakPtr<content::DownloadDestinationObserver> as_observer(
577 item->DestinationObserverAsWeakPtr());
578 MockObserver observer(item);
579
580 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
581 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, item->GetLastReason());
582 EXPECT_FALSE(observer.CheckUpdated());
583
584 EXPECT_CALL(*mock_delegate(), DownloadStopped(item));
585 EXPECT_CALL(*download_file, Cancel());
586 as_observer->DestinationError(
587 content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
588 ::testing::Mock::VerifyAndClearExpectations(mock_delegate());
589 EXPECT_TRUE(observer.CheckUpdated());
590 EXPECT_EQ(content::DownloadItem::INTERRUPTED, item->GetState());
591 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
592 item->GetLastReason());
593 RunAllPendingInMessageLoops();
594 }
595
596 TEST_F(DownloadItemTest, DestinationCompleted) {
597 DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
598 base::WeakPtr<content::DownloadDestinationObserver> as_observer(
599 item->DestinationObserverAsWeakPtr());
600 MockObserver observer(item);
601
602 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
603 EXPECT_EQ("", item->GetHash());
604 EXPECT_EQ("", item->GetHashState());
605 EXPECT_FALSE(item->AllDataSaved());
606 EXPECT_FALSE(observer.CheckUpdated());
607
608 as_observer->DestinationUpdate(10, 20, "deadbeef");
609 EXPECT_TRUE(observer.CheckUpdated());
610 EXPECT_FALSE(observer.CheckUpdated()); // Confirm reset.
611 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
612 EXPECT_EQ("", item->GetHash());
613 EXPECT_EQ("deadbeef", item->GetHashState());
614 EXPECT_FALSE(item->AllDataSaved());
615
616 EXPECT_CALL(*mock_delegate(), MaybeCompleteDownload(item));
617 as_observer->DestinationCompleted("livebeef");
618 ::testing::Mock::VerifyAndClearExpectations(mock_delegate());
619 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, item->GetState());
620 EXPECT_TRUE(observer.CheckUpdated());
621 EXPECT_EQ("livebeef", item->GetHash());
622 EXPECT_EQ("", item->GetHashState());
623 EXPECT_TRUE(item->AllDataSaved());
624 }
625
626 TEST(MockDownloadItem, Compiles) { 540 TEST(MockDownloadItem, Compiles) {
627 MockDownloadItem mock_item; 541 MockDownloadItem mock_item;
628 } 542 }
629
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl_delegate.cc ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698