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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
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" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 const GURL& expected_url, | 141 const GURL& expected_url, |
142 const base::FilePath& expected_path, | 142 const base::FilePath& expected_path, |
143 int64 num_files, | 143 int64 num_files, |
144 DownloadItem::DownloadState expected_state, | 144 DownloadItem::DownloadState expected_state, |
145 DownloadItem* item, | 145 DownloadItem* item, |
146 const history::DownloadRow& info) { | 146 const history::DownloadRow& info) { |
147 // This function may be called multiple times for a given test. Returning | 147 // This function may be called multiple times for a given test. Returning |
148 // false doesn't necessarily mean that the test has failed or will fail, it | 148 // false doesn't necessarily mean that the test has failed or will fail, it |
149 // might just mean that the test hasn't passed yet. | 149 // might just mean that the test hasn't passed yet. |
150 if (info.target_path != expected_path) { | 150 if (info.target_path != expected_path) { |
151 VLOG(20) << __FUNCTION__ << " " << info.target_path.value() | 151 DVLOG(20) << __FUNCTION__ << " " << info.target_path.value() |
152 << " != " << expected_path.value(); | 152 << " != " << expected_path.value(); |
153 return false; | 153 return false; |
154 } | 154 } |
155 if (info.url_chain.size() != 1u) { | 155 if (info.url_chain.size() != 1u) { |
156 VLOG(20) << __FUNCTION__ << " " << info.url_chain.size() | 156 DVLOG(20) << __FUNCTION__ << " " << info.url_chain.size() |
157 << " != 1"; | 157 << " != 1"; |
158 return false; | 158 return false; |
159 } | 159 } |
160 if (info.url_chain[0] != expected_url) { | 160 if (info.url_chain[0] != expected_url) { |
161 VLOG(20) << __FUNCTION__ << " " << info.url_chain[0].spec() | 161 DVLOG(20) << __FUNCTION__ << " " << info.url_chain[0].spec() |
162 << " != " << expected_url.spec(); | 162 << " != " << expected_url.spec(); |
163 return false; | 163 return false; |
164 } | 164 } |
165 if ((num_files >= 0) && (info.received_bytes != num_files)) { | 165 if ((num_files >= 0) && (info.received_bytes != num_files)) { |
166 VLOG(20) << __FUNCTION__ << " " << num_files | 166 DVLOG(20) << __FUNCTION__ << " " << num_files |
167 << " != " << info.received_bytes; | 167 << " != " << info.received_bytes; |
168 return false; | 168 return false; |
169 } | 169 } |
170 if (info.state != expected_state) { | 170 if (info.state != expected_state) { |
171 VLOG(20) << __FUNCTION__ << " " << info.state | 171 DVLOG(20) << __FUNCTION__ << " " << info.state |
172 << " != " << expected_state; | 172 << " != " << expected_state; |
173 return false; | 173 return false; |
174 } | 174 } |
175 return true; | 175 return true; |
176 } | 176 } |
177 | 177 |
178 const base::FilePath::CharType kTestDir[] = FILE_PATH_LITERAL("save_page"); | 178 const base::FilePath::CharType kTestDir[] = FILE_PATH_LITERAL("save_page"); |
179 | 179 |
180 static const char kAppendedExtension[] = ".html"; | 180 static const char kAppendedExtension[] = ".html"; |
181 | 181 |
182 // Loosely based on logic in DownloadTestObserver. | 182 // Loosely based on logic in DownloadTestObserver. |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( | 801 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( |
802 GetDownloadManager())->DownloadPath(); | 802 GetDownloadManager())->DownloadPath(); |
803 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); | 803 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); |
804 ASSERT_TRUE(base::PathExists(filename)); | 804 ASSERT_TRUE(base::PathExists(filename)); |
805 std::string contents; | 805 std::string contents; |
806 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); | 806 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); |
807 EXPECT_EQ("foo", contents); | 807 EXPECT_EQ("foo", contents); |
808 } | 808 } |
809 | 809 |
810 } // namespace | 810 } // namespace |
OLD | NEW |