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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 ASSERT_TRUE(observer.CheckUpdated()); | 374 ASSERT_TRUE(observer.CheckUpdated()); |
375 | 375 |
376 item->MarkAsComplete(); | 376 item->MarkAsComplete(); |
377 ASSERT_TRUE(observer.CheckUpdated()); | 377 ASSERT_TRUE(observer.CheckUpdated()); |
378 } | 378 } |
379 | 379 |
380 TEST_F(DownloadItemTest, NotificationAfterDownloadedFileRemoved) { | 380 TEST_F(DownloadItemTest, NotificationAfterDownloadedFileRemoved) { |
381 DownloadItemImpl* item = CreateDownloadItem(); | 381 DownloadItemImpl* item = CreateDownloadItem(); |
382 MockObserver observer(item); | 382 MockObserver observer(item); |
383 | 383 |
384 item->OnDownloadedFileRemoved(true); | 384 item->OnDownloadedFileRemoved(); |
385 ASSERT_TRUE(observer.CheckUpdated()); | 385 ASSERT_TRUE(observer.CheckUpdated()); |
386 } | 386 } |
387 | 387 |
388 TEST_F(DownloadItemTest, NoNotificationAfterDownloadedFileNotRemoved) { | |
389 DownloadItemImpl* item = CreateDownloadItem(); | |
390 MockObserver observer(item); | |
391 | |
392 item->OnDownloadedFileRemoved(false); | |
393 ASSERT_FALSE(observer.CheckUpdated()); | |
394 } | |
395 | |
396 TEST_F(DownloadItemTest, NotificationAfterInterrupted) { | 388 TEST_F(DownloadItemTest, NotificationAfterInterrupted) { |
397 DownloadItemImpl* item = CreateDownloadItem(); | 389 DownloadItemImpl* item = CreateDownloadItem(); |
398 MockDownloadFile* download_file = | 390 MockDownloadFile* download_file = |
399 DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); | 391 DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); |
400 EXPECT_CALL(*download_file, Cancel()); | 392 EXPECT_CALL(*download_file, Cancel()); |
401 MockObserver observer(item); | 393 MockObserver observer(item); |
402 | 394 |
403 EXPECT_CALL(*mock_delegate(), MockResumeInterruptedDownload(_,_)) | 395 EXPECT_CALL(*mock_delegate(), MockResumeInterruptedDownload(_,_)) |
404 .Times(0); | 396 .Times(0); |
405 | 397 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 // Confirm cancel sets state properly. | 856 // Confirm cancel sets state properly. |
865 EXPECT_CALL(*download_file, Cancel()); | 857 EXPECT_CALL(*download_file, Cancel()); |
866 item->Cancel(true); | 858 item->Cancel(true); |
867 EXPECT_EQ(DownloadItem::CANCELLED, item->GetState()); | 859 EXPECT_EQ(DownloadItem::CANCELLED, item->GetState()); |
868 } | 860 } |
869 | 861 |
870 TEST_F(DownloadItemTest, FileRemoved) { | 862 TEST_F(DownloadItemTest, FileRemoved) { |
871 DownloadItemImpl* item = CreateDownloadItem(); | 863 DownloadItemImpl* item = CreateDownloadItem(); |
872 | 864 |
873 EXPECT_FALSE(item->GetFileExternallyRemoved()); | 865 EXPECT_FALSE(item->GetFileExternallyRemoved()); |
874 item->OnDownloadedFileRemoved(true); | 866 item->OnDownloadedFileRemoved(); |
875 EXPECT_TRUE(item->GetFileExternallyRemoved()); | 867 EXPECT_TRUE(item->GetFileExternallyRemoved()); |
876 } | 868 } |
877 | 869 |
878 TEST_F(DownloadItemTest, DestinationUpdate) { | 870 TEST_F(DownloadItemTest, DestinationUpdate) { |
879 DownloadItemImpl* item = CreateDownloadItem(); | 871 DownloadItemImpl* item = CreateDownloadItem(); |
880 base::WeakPtr<DownloadDestinationObserver> as_observer( | 872 base::WeakPtr<DownloadDestinationObserver> as_observer( |
881 item->DestinationObserverAsWeakPtr()); | 873 item->DestinationObserverAsWeakPtr()); |
882 MockObserver observer(item); | 874 MockObserver observer(item); |
883 | 875 |
884 EXPECT_EQ(0l, item->CurrentSpeed()); | 876 EXPECT_EQ(0l, item->CurrentSpeed()); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 base::Unretained(&returned_path))); | 1262 base::Unretained(&returned_path))); |
1271 RunAllPendingInMessageLoops(); | 1263 RunAllPendingInMessageLoops(); |
1272 EXPECT_TRUE(returned_path.empty()); | 1264 EXPECT_TRUE(returned_path.empty()); |
1273 } | 1265 } |
1274 | 1266 |
1275 TEST(MockDownloadItem, Compiles) { | 1267 TEST(MockDownloadItem, Compiles) { |
1276 MockDownloadItem mock_item; | 1268 MockDownloadItem mock_item; |
1277 } | 1269 } |
1278 | 1270 |
1279 } // namespace content | 1271 } // namespace content |
OLD | NEW |