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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 MOCK_METHOD0(CanOpenDownload, bool()); | 90 MOCK_METHOD0(CanOpenDownload, bool()); |
91 MOCK_METHOD0(ShouldOpenFileBasedOnExtension, bool()); | 91 MOCK_METHOD0(ShouldOpenFileBasedOnExtension, bool()); |
92 MOCK_METHOD0(OpenDownload, void()); | 92 MOCK_METHOD0(OpenDownload, void()); |
93 MOCK_METHOD0(ShowDownloadInShell, void()); | 93 MOCK_METHOD0(ShowDownloadInShell, void()); |
94 MOCK_METHOD0(DangerousDownloadValidated, void()); | 94 MOCK_METHOD0(DangerousDownloadValidated, void()); |
95 MOCK_METHOD3(UpdateProgress, void(int64, int64, const std::string&)); | 95 MOCK_METHOD3(UpdateProgress, void(int64, int64, const std::string&)); |
96 MOCK_METHOD1(Cancel, void(bool)); | 96 MOCK_METHOD1(Cancel, void(bool)); |
97 MOCK_METHOD0(MarkAsComplete, void()); | 97 MOCK_METHOD0(MarkAsComplete, void()); |
98 MOCK_METHOD1(OnAllDataSaved, void(const std::string&)); | 98 MOCK_METHOD1(OnAllDataSaved, void(const std::string&)); |
99 MOCK_METHOD0(OnDownloadedFileRemoved, void()); | 99 MOCK_METHOD0(OnDownloadedFileRemoved, void()); |
100 MOCK_METHOD0(MaybeCompleteDownload, void()); | |
101 virtual void Start( | 100 virtual void Start( |
102 scoped_ptr<DownloadFile> download_file) OVERRIDE { | 101 scoped_ptr<DownloadFile> download_file) OVERRIDE { |
103 MockStart(download_file.get()); | 102 MockStart(download_file.get()); |
104 } | 103 } |
105 | 104 |
106 MOCK_METHOD1(MockStart, void(DownloadFile*)); | 105 MOCK_METHOD1(MockStart, void(DownloadFile*)); |
107 | 106 |
108 MOCK_METHOD1(Delete, void(DeleteReason)); | 107 MOCK_METHOD1(Delete, void(DeleteReason)); |
109 MOCK_METHOD0(Remove, void()); | 108 MOCK_METHOD0(Remove, void()); |
110 MOCK_CONST_METHOD1(TimeRemaining, bool(base::TimeDelta*)); | 109 MOCK_CONST_METHOD1(TimeRemaining, bool(base::TimeDelta*)); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 if (DCHECK_IS_ON()) | 553 if (DCHECK_IS_ON()) |
555 // Null out ShowDownloadInBrowser | 554 // Null out ShowDownloadInBrowser |
556 EXPECT_CALL(item, GetWebContents()) | 555 EXPECT_CALL(item, GetWebContents()) |
557 .WillOnce(Return(static_cast<WebContents*>(NULL))); | 556 .WillOnce(Return(static_cast<WebContents*>(NULL))); |
558 EXPECT_CALL(GetMockDownloadManagerDelegate(), | 557 EXPECT_CALL(GetMockDownloadManagerDelegate(), |
559 GetAlternativeWebContentsToNotifyForDownload()) | 558 GetAlternativeWebContentsToNotifyForDownload()) |
560 .WillOnce(Return(static_cast<WebContents*>(NULL))); | 559 .WillOnce(Return(static_cast<WebContents*>(NULL))); |
561 | 560 |
562 EXPECT_CALL(item, IsInProgress()) | 561 EXPECT_CALL(item, IsInProgress()) |
563 .WillOnce(Return(true)); | 562 .WillOnce(Return(true)); |
564 | |
565 // History addition should result in a call into MaybeCompleteDownload(). | |
566 EXPECT_CALL(item, MaybeCompleteDownload()) | |
567 .WillOnce(Return()); | |
568 } | 563 } |
569 | 564 |
570 protected: | 565 protected: |
571 // Key test variable; we'll keep it available to sub-classes. | 566 // Key test variable; we'll keep it available to sub-classes. |
572 scoped_refptr<DownloadManagerImpl> download_manager_; | 567 scoped_refptr<DownloadManagerImpl> download_manager_; |
573 base::WeakPtr<MockDownloadFileFactory> mock_download_file_factory_; | 568 base::WeakPtr<MockDownloadFileFactory> mock_download_file_factory_; |
574 | 569 |
575 // Target detetermined callback. | 570 // Target detetermined callback. |
576 bool callback_called_; | 571 bool callback_called_; |
577 FilePath target_path_; | 572 FilePath target_path_; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 callback_called_ = false; | 644 callback_called_ = false; |
650 DetermineDownloadTarget(&item); | 645 DetermineDownloadTarget(&item); |
651 EXPECT_TRUE(callback_called_); | 646 EXPECT_TRUE(callback_called_); |
652 EXPECT_EQ(path, target_path_); | 647 EXPECT_EQ(path, target_path_); |
653 EXPECT_EQ(DownloadItem::TARGET_DISPOSITION_OVERWRITE, target_disposition_); | 648 EXPECT_EQ(DownloadItem::TARGET_DISPOSITION_OVERWRITE, target_disposition_); |
654 EXPECT_EQ(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, danger_type_); | 649 EXPECT_EQ(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, danger_type_); |
655 EXPECT_EQ(path, intermediate_path_); | 650 EXPECT_EQ(path, intermediate_path_); |
656 } | 651 } |
657 | 652 |
658 } // namespace content | 653 } // namespace content |
OLD | NEW |