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 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "content/public/browser/download_manager.h" | 10 #include "content/public/browser/download_manager.h" |
11 #include "content/public/browser/download_save_info.h" | 11 #include "content/public/browser/download_save_info.h" |
12 #include "content/public/browser/download_url_parameters.h" | 12 #include "content/public/browser/download_url_parameters.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 class DownloadRequestHandle; | 17 class DownloadRequestHandle; |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 // To avoid leaking download_request_handle.h to embedders. | 21 // To avoid leaking download_request_handle.h to embedders. |
22 void PrintTo(const DownloadRequestHandle& params, std::ostream* os); | 22 void PrintTo(const DownloadRequestHandle& params, std::ostream* os); |
23 | 23 |
24 class MockDownloadManager : public DownloadManager { | 24 class MockDownloadManager : public DownloadManager { |
25 public: | 25 public: |
26 // Structure to make it possible to match more than 10 arguments on | 26 // Structure to make it possible to match more than 10 arguments on |
27 // CreateDownloadItem. | 27 // CreateDownloadItem. |
28 struct CreateDownloadItemAdapter { | 28 struct CreateDownloadItemAdapter { |
29 FilePath current_path; | 29 base::FilePath current_path; |
30 FilePath target_path; | 30 base::FilePath target_path; |
31 std::vector<GURL> url_chain; | 31 std::vector<GURL> url_chain; |
32 GURL referrer_url; | 32 GURL referrer_url; |
33 base::Time start_time; | 33 base::Time start_time; |
34 base::Time end_time; | 34 base::Time end_time; |
35 int64 received_bytes; | 35 int64 received_bytes; |
36 int64 total_bytes; | 36 int64 total_bytes; |
37 DownloadItem::DownloadState state; | 37 DownloadItem::DownloadState state; |
38 DownloadDangerType danger_type; | 38 DownloadDangerType danger_type; |
39 DownloadInterruptReason interrupt_reason; | 39 DownloadInterruptReason interrupt_reason; |
40 bool opened; | 40 bool opened; |
41 | 41 |
42 CreateDownloadItemAdapter( | 42 CreateDownloadItemAdapter( |
43 const FilePath& current_path, | 43 const base::FilePath& current_path, |
44 const FilePath& target_path, | 44 const base::FilePath& target_path, |
45 const std::vector<GURL>& url_chain, | 45 const std::vector<GURL>& url_chain, |
46 const GURL& referrer_url, | 46 const GURL& referrer_url, |
47 const base::Time& start_time, | 47 const base::Time& start_time, |
48 const base::Time& end_time, | 48 const base::Time& end_time, |
49 int64 received_bytes, | 49 int64 received_bytes, |
50 int64 total_bytes, | 50 int64 total_bytes, |
51 DownloadItem::DownloadState state, | 51 DownloadItem::DownloadState state, |
52 DownloadDangerType danger_type, | 52 DownloadDangerType danger_type, |
53 DownloadInterruptReason interrupt_reason, | 53 DownloadInterruptReason interrupt_reason, |
54 bool opened); | 54 bool opened); |
(...skipping 27 matching lines...) Expand all Loading... |
82 MOCK_METHOD0(RemoveAllDownloads, int()); | 82 MOCK_METHOD0(RemoveAllDownloads, int()); |
83 MOCK_METHOD1(DownloadUrlMock, void(DownloadUrlParameters*)); | 83 MOCK_METHOD1(DownloadUrlMock, void(DownloadUrlParameters*)); |
84 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) OVERRIDE { | 84 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) OVERRIDE { |
85 DownloadUrlMock(params.get()); | 85 DownloadUrlMock(params.get()); |
86 } | 86 } |
87 MOCK_METHOD1(AddObserver, void(Observer* observer)); | 87 MOCK_METHOD1(AddObserver, void(Observer* observer)); |
88 MOCK_METHOD1(RemoveObserver, void(Observer* observer)); | 88 MOCK_METHOD1(RemoveObserver, void(Observer* observer)); |
89 | 89 |
90 // Redirects to mock method to get around gmock 10 argument limit. | 90 // Redirects to mock method to get around gmock 10 argument limit. |
91 virtual DownloadItem* CreateDownloadItem( | 91 virtual DownloadItem* CreateDownloadItem( |
92 const FilePath& current_path, | 92 const base::FilePath& current_path, |
93 const FilePath& target_path, | 93 const base::FilePath& target_path, |
94 const std::vector<GURL>& url_chain, | 94 const std::vector<GURL>& url_chain, |
95 const GURL& referrer_url, | 95 const GURL& referrer_url, |
96 const base::Time& start_time, | 96 const base::Time& start_time, |
97 const base::Time& end_time, | 97 const base::Time& end_time, |
98 int64 received_bytes, | 98 int64 received_bytes, |
99 int64 total_bytes, | 99 int64 total_bytes, |
100 DownloadItem::DownloadState state, | 100 DownloadItem::DownloadState state, |
101 DownloadDangerType danger_type, | 101 DownloadDangerType danger_type, |
102 DownloadInterruptReason interrupt_reason, | 102 DownloadInterruptReason interrupt_reason, |
103 bool opened) OVERRIDE; | 103 bool opened) OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
116 MOCK_METHOD1(GetActiveDownloadItem, DownloadItem*(int id)); | 116 MOCK_METHOD1(GetActiveDownloadItem, DownloadItem*(int id)); |
117 MOCK_METHOD1(GetActiveDownload, DownloadItem*(int32 download_id)); | 117 MOCK_METHOD1(GetActiveDownload, DownloadItem*(int32 download_id)); |
118 | 118 |
119 protected: | 119 protected: |
120 virtual ~MockDownloadManager(); | 120 virtual ~MockDownloadManager(); |
121 }; | 121 }; |
122 | 122 |
123 } // namespace content | 123 } // namespace content |
124 | 124 |
125 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ | 125 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ |
OLD | NEW |