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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 16 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
17 #include "chrome/browser/download/download_item_model.h" | 17 #include "chrome/browser/download/download_item_model.h" |
18 #include "chrome/browser/download/download_prefs.h" | 18 #include "chrome/browser/download/download_prefs.h" |
19 #include "chrome/browser/download/download_target_info.h" | 19 #include "chrome/browser/download/download_target_info.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 21 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
22 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
23 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
24 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 24 #include "components/sync_preferences/testing_pref_service_syncable.h" |
25 #include "content/public/browser/download_interrupt_reasons.h" | 25 #include "content/public/browser/download_interrupt_reasons.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_contents_delegate.h" | 27 #include "content/public/browser/web_contents_delegate.h" |
28 #include "content/public/test/mock_download_item.h" | 28 #include "content/public/test/mock_download_item.h" |
29 #include "content/public/test/mock_download_manager.h" | 29 #include "content/public/test/mock_download_manager.h" |
30 #include "content/public/test/test_renderer_host.h" | 30 #include "content/public/test/test_renderer_host.h" |
31 #include "content/public/test/web_contents_tester.h" | 31 #include "content/public/test/web_contents_tester.h" |
32 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
34 | 34 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // content::CheckForFileExistenceCallback is the return value from this | 181 // content::CheckForFileExistenceCallback is the return value from this |
182 // method. | 182 // method. |
183 bool CheckForFileExistence(DownloadItem* download); | 183 bool CheckForFileExistence(DownloadItem* download); |
184 | 184 |
185 const base::FilePath& default_download_path() const; | 185 const base::FilePath& default_download_path() const; |
186 TestChromeDownloadManagerDelegate* delegate(); | 186 TestChromeDownloadManagerDelegate* delegate(); |
187 content::MockDownloadManager* download_manager(); | 187 content::MockDownloadManager* download_manager(); |
188 DownloadPrefs* download_prefs(); | 188 DownloadPrefs* download_prefs(); |
189 | 189 |
190 private: | 190 private: |
191 syncable_prefs::TestingPrefServiceSyncable* pref_service_; | 191 sync_preferences::TestingPrefServiceSyncable* pref_service_; |
192 base::ScopedTempDir test_download_dir_; | 192 base::ScopedTempDir test_download_dir_; |
193 std::unique_ptr<content::MockDownloadManager> download_manager_; | 193 std::unique_ptr<content::MockDownloadManager> download_manager_; |
194 std::unique_ptr<TestChromeDownloadManagerDelegate> delegate_; | 194 std::unique_ptr<TestChromeDownloadManagerDelegate> delegate_; |
195 MockWebContentsDelegate web_contents_delegate_; | 195 MockWebContentsDelegate web_contents_delegate_; |
196 }; | 196 }; |
197 | 197 |
198 ChromeDownloadManagerDelegateTest::ChromeDownloadManagerDelegateTest() | 198 ChromeDownloadManagerDelegateTest::ChromeDownloadManagerDelegateTest() |
199 : download_manager_(new ::testing::NiceMock<content::MockDownloadManager>) { | 199 : download_manager_(new ::testing::NiceMock<content::MockDownloadManager>) { |
200 } | 200 } |
201 | 201 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 EXPECT_CALL(*download_item, OnContentCheckCompleted(_)).Times(0); | 678 EXPECT_CALL(*download_item, OnContentCheckCompleted(_)).Times(0); |
679 } | 679 } |
680 | 680 |
681 base::RunLoop run_loop; | 681 base::RunLoop run_loop; |
682 ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(), | 682 ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(), |
683 run_loop.QuitClosure())); | 683 run_loop.QuitClosure())); |
684 run_loop.Run(); | 684 run_loop.Run(); |
685 } | 685 } |
686 | 686 |
687 #endif // FULL_SAFE_BROWSING | 687 #endif // FULL_SAFE_BROWSING |
OLD | NEW |