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" | |
10 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
14 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
15 #include "base/string16.h" | 14 #include "base/string16.h" |
16 #include "base/string_util.h" | 15 #include "base/string_util.h" |
17 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
18 #include "build/build_config.h" | 17 #include "build/build_config.h" |
19 #include "content/browser/byte_stream.h" | 18 #include "content/browser/byte_stream.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // Matches a DownloadCreateInfo* that points to the same object as |info| and | 56 // Matches a DownloadCreateInfo* that points to the same object as |info| and |
58 // has a |default_download_directory| that matches |download_directory|. | 57 // has a |default_download_directory| that matches |download_directory|. |
59 MATCHER_P2(DownloadCreateInfoWithDefaultPath, info, download_directory, "") { | 58 MATCHER_P2(DownloadCreateInfoWithDefaultPath, info, download_directory, "") { |
60 return arg == info && | 59 return arg == info && |
61 arg->default_download_directory == download_directory; | 60 arg->default_download_directory == download_directory; |
62 } | 61 } |
63 | 62 |
64 class MockDownloadItemImpl : public DownloadItemImpl { | 63 class MockDownloadItemImpl : public DownloadItemImpl { |
65 public: | 64 public: |
66 // Use history constructor for minimal base object. | 65 // Use history constructor for minimal base object. |
67 MockDownloadItemImpl(DownloadItemImplDelegate* delegate) | 66 explicit MockDownloadItemImpl(DownloadItemImplDelegate* delegate) |
68 : DownloadItemImpl( | 67 : DownloadItemImpl( |
69 delegate, | 68 delegate, |
70 content::DownloadId(), | 69 content::DownloadId(), |
71 base::FilePath(), | 70 base::FilePath(), |
72 base::FilePath(), | 71 base::FilePath(), |
73 std::vector<GURL>(), | 72 std::vector<GURL>(), |
74 GURL(), | 73 GURL(), |
75 base::Time(), | 74 base::Time(), |
76 base::Time(), | 75 base::Time(), |
77 0, | 76 0, |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 public: | 418 public: |
420 MockDownloadManagerObserver() {} | 419 MockDownloadManagerObserver() {} |
421 ~MockDownloadManagerObserver() {} | 420 ~MockDownloadManagerObserver() {} |
422 MOCK_METHOD2(OnDownloadCreated, void( | 421 MOCK_METHOD2(OnDownloadCreated, void( |
423 DownloadManager*, DownloadItem*)); | 422 DownloadManager*, DownloadItem*)); |
424 MOCK_METHOD1(ManagerGoingDown, void(DownloadManager*)); | 423 MOCK_METHOD1(ManagerGoingDown, void(DownloadManager*)); |
425 MOCK_METHOD2(SelectFileDialogDisplayed, void( | 424 MOCK_METHOD2(SelectFileDialogDisplayed, void( |
426 DownloadManager*, int32)); | 425 DownloadManager*, int32)); |
427 }; | 426 }; |
428 | 427 |
429 } // namespace | 428 } // namespace |
430 | 429 |
431 class DownloadManagerTest : public testing::Test { | 430 class DownloadManagerTest : public testing::Test { |
432 public: | 431 public: |
433 static const char* kTestData; | 432 static const char* kTestData; |
434 static const size_t kTestDataLen; | 433 static const size_t kTestDataLen; |
435 | 434 |
436 DownloadManagerTest() | 435 DownloadManagerTest() |
437 : ui_thread_(BrowserThread::UI, &message_loop_), | 436 : ui_thread_(BrowserThread::UI, &message_loop_), |
438 file_thread_(BrowserThread::FILE, &message_loop_), | 437 file_thread_(BrowserThread::FILE, &message_loop_), |
439 next_download_id_(0) { | 438 next_download_id_(0) { |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 .WillOnce(Return()); | 681 .WillOnce(Return()); |
683 EXPECT_CALL(GetMockDownloadItem(3), Remove()) | 682 EXPECT_CALL(GetMockDownloadItem(3), Remove()) |
684 .Times(0); | 683 .Times(0); |
685 | 684 |
686 download_manager_->RemoveAllDownloads(); | 685 download_manager_->RemoveAllDownloads(); |
687 // Because we're mocking the download item, the Remove call doesn't | 686 // Because we're mocking the download item, the Remove call doesn't |
688 // result in them being removed from the DownloadManager list. | 687 // result in them being removed from the DownloadManager list. |
689 } | 688 } |
690 | 689 |
691 } // namespace content | 690 } // namespace content |
OLD | NEW |