| 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 "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "content/browser/download/download_item_factory.h" | 31 #include "content/browser/download/download_item_factory.h" |
| 32 #include "content/browser/download/download_item_impl.h" | 32 #include "content/browser/download/download_item_impl.h" |
| 33 #include "content/browser/download/download_item_impl_delegate.h" | 33 #include "content/browser/download/download_item_impl_delegate.h" |
| 34 #include "content/browser/download/download_request_handle.h" | 34 #include "content/browser/download/download_request_handle.h" |
| 35 #include "content/browser/download/mock_download_file.h" | 35 #include "content/browser/download/mock_download_file.h" |
| 36 #include "content/browser/download/mock_download_item_impl.h" | 36 #include "content/browser/download/mock_download_item_impl.h" |
| 37 #include "content/public/browser/browser_context.h" | 37 #include "content/public/browser/browser_context.h" |
| 38 #include "content/public/browser/download_interrupt_reasons.h" | 38 #include "content/public/browser/download_interrupt_reasons.h" |
| 39 #include "content/public/browser/download_item.h" | 39 #include "content/public/browser/download_item.h" |
| 40 #include "content/public/browser/download_manager_delegate.h" | 40 #include "content/public/browser/download_manager_delegate.h" |
| 41 #include "content/public/browser/zoom_level_delegate.h" | |
| 42 #include "content/public/test/mock_download_item.h" | 41 #include "content/public/test/mock_download_item.h" |
| 43 #include "content/public/test/test_browser_context.h" | 42 #include "content/public/test/test_browser_context.h" |
| 44 #include "content/public/test/test_browser_thread.h" | 43 #include "content/public/test/test_browser_thread.h" |
| 45 #include "net/log/net_log_with_source.h" | 44 #include "net/log/net_log_with_source.h" |
| 46 #include "testing/gmock/include/gmock/gmock.h" | 45 #include "testing/gmock/include/gmock/gmock.h" |
| 47 #include "testing/gmock_mutant.h" | 46 #include "testing/gmock_mutant.h" |
| 48 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
| 49 #include "url/origin.h" | 48 #include "url/origin.h" |
| 50 | 49 |
| 50 #if !defined(OS_ANDROID) |
| 51 #include "content/public/browser/zoom_level_delegate.h" |
| 52 #endif // !defined(OS_ANDROID) |
| 53 |
| 51 using ::testing::AllOf; | 54 using ::testing::AllOf; |
| 52 using ::testing::DoAll; | 55 using ::testing::DoAll; |
| 53 using ::testing::Eq; | 56 using ::testing::Eq; |
| 54 using ::testing::Ref; | 57 using ::testing::Ref; |
| 55 using ::testing::Return; | 58 using ::testing::Return; |
| 56 using ::testing::ReturnRef; | 59 using ::testing::ReturnRef; |
| 57 using ::testing::ReturnRefOfCopy; | 60 using ::testing::ReturnRefOfCopy; |
| 58 using ::testing::SetArgPointee; | 61 using ::testing::SetArgPointee; |
| 59 using ::testing::StrictMock; | 62 using ::testing::StrictMock; |
| 60 using ::testing::_; | 63 using ::testing::_; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 }; | 300 }; |
| 298 | 301 |
| 299 class MockBrowserContext : public BrowserContext { | 302 class MockBrowserContext : public BrowserContext { |
| 300 public: | 303 public: |
| 301 MockBrowserContext() { | 304 MockBrowserContext() { |
| 302 content::BrowserContext::Initialize(this, base::FilePath()); | 305 content::BrowserContext::Initialize(this, base::FilePath()); |
| 303 } | 306 } |
| 304 ~MockBrowserContext() {} | 307 ~MockBrowserContext() {} |
| 305 | 308 |
| 306 MOCK_CONST_METHOD0(GetPath, base::FilePath()); | 309 MOCK_CONST_METHOD0(GetPath, base::FilePath()); |
| 310 #if !defined(OS_ANDROID) |
| 307 MOCK_METHOD1(CreateZoomLevelDelegateMock, | 311 MOCK_METHOD1(CreateZoomLevelDelegateMock, |
| 308 ZoomLevelDelegate*(const base::FilePath&)); | 312 ZoomLevelDelegate*(const base::FilePath&)); |
| 313 #endif // !defined(OS_ANDROID) |
| 309 MOCK_CONST_METHOD0(IsOffTheRecord, bool()); | 314 MOCK_CONST_METHOD0(IsOffTheRecord, bool()); |
| 310 MOCK_METHOD0(GetResourceContext, ResourceContext*()); | 315 MOCK_METHOD0(GetResourceContext, ResourceContext*()); |
| 311 MOCK_METHOD0(GetDownloadManagerDelegate, DownloadManagerDelegate*()); | 316 MOCK_METHOD0(GetDownloadManagerDelegate, DownloadManagerDelegate*()); |
| 312 MOCK_METHOD0(GetGuestManager, BrowserPluginGuestManager* ()); | 317 MOCK_METHOD0(GetGuestManager, BrowserPluginGuestManager* ()); |
| 313 MOCK_METHOD0(GetSpecialStoragePolicy, storage::SpecialStoragePolicy*()); | 318 MOCK_METHOD0(GetSpecialStoragePolicy, storage::SpecialStoragePolicy*()); |
| 314 MOCK_METHOD0(GetPushMessagingService, PushMessagingService*()); | 319 MOCK_METHOD0(GetPushMessagingService, PushMessagingService*()); |
| 315 MOCK_METHOD0(GetSSLHostStateDelegate, SSLHostStateDelegate*()); | 320 MOCK_METHOD0(GetSSLHostStateDelegate, SSLHostStateDelegate*()); |
| 316 MOCK_METHOD0(GetPermissionManager, PermissionManager*()); | 321 MOCK_METHOD0(GetPermissionManager, PermissionManager*()); |
| 317 MOCK_METHOD0(GetBackgroundSyncController, BackgroundSyncController*()); | 322 MOCK_METHOD0(GetBackgroundSyncController, BackgroundSyncController*()); |
| 318 MOCK_METHOD0(CreateMediaRequestContext, | 323 MOCK_METHOD0(CreateMediaRequestContext, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 331 return nullptr; | 336 return nullptr; |
| 332 } | 337 } |
| 333 | 338 |
| 334 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( | 339 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
| 335 const base::FilePath& partition_path, | 340 const base::FilePath& partition_path, |
| 336 bool in_memory, | 341 bool in_memory, |
| 337 ProtocolHandlerMap* protocol_handlers, | 342 ProtocolHandlerMap* protocol_handlers, |
| 338 URLRequestInterceptorScopedVector request_interceptors) override { | 343 URLRequestInterceptorScopedVector request_interceptors) override { |
| 339 return nullptr; | 344 return nullptr; |
| 340 } | 345 } |
| 341 | 346 #if !defined(OS_ANDROID) |
| 342 std::unique_ptr<ZoomLevelDelegate> CreateZoomLevelDelegate( | 347 std::unique_ptr<ZoomLevelDelegate> CreateZoomLevelDelegate( |
| 343 const base::FilePath& path) override { | 348 const base::FilePath& path) override { |
| 344 return std::unique_ptr<ZoomLevelDelegate>( | 349 return std::unique_ptr<ZoomLevelDelegate>( |
| 345 CreateZoomLevelDelegateMock(path)); | 350 CreateZoomLevelDelegateMock(path)); |
| 346 } | 351 } |
| 352 #endif // !defined(OS_ANDROID) |
| 347 }; | 353 }; |
| 348 | 354 |
| 349 class MockDownloadManagerObserver : public DownloadManager::Observer { | 355 class MockDownloadManagerObserver : public DownloadManager::Observer { |
| 350 public: | 356 public: |
| 351 MockDownloadManagerObserver() {} | 357 MockDownloadManagerObserver() {} |
| 352 ~MockDownloadManagerObserver() {} | 358 ~MockDownloadManagerObserver() {} |
| 353 MOCK_METHOD2(OnDownloadCreated, void( | 359 MOCK_METHOD2(OnDownloadCreated, void( |
| 354 DownloadManager*, DownloadItem*)); | 360 DownloadManager*, DownloadItem*)); |
| 355 MOCK_METHOD1(ManagerGoingDown, void(DownloadManager*)); | 361 MOCK_METHOD1(ManagerGoingDown, void(DownloadManager*)); |
| 356 MOCK_METHOD2(SelectFileDialogDisplayed, void(DownloadManager*, int32_t)); | 362 MOCK_METHOD2(SelectFileDialogDisplayed, void(DownloadManager*, int32_t)); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); | 647 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); |
| 642 | 648 |
| 643 base::Callback<bool(const GURL&)> url_filter = | 649 base::Callback<bool(const GURL&)> url_filter = |
| 644 GetSingleURLFilter(download_urls_[0]); | 650 GetSingleURLFilter(download_urls_[0]); |
| 645 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( | 651 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( |
| 646 url_filter, base::Time(), base::Time::Max()); | 652 url_filter, base::Time(), base::Time::Max()); |
| 647 EXPECT_EQ(remove_count, 1); | 653 EXPECT_EQ(remove_count, 1); |
| 648 } | 654 } |
| 649 | 655 |
| 650 } // namespace content | 656 } // namespace content |
| OLD | NEW |