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/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 MessageLoopForUI::current()->Quit(); | 117 MessageLoopForUI::current()->Quit(); |
118 } | 118 } |
119 | 119 |
120 bool waiting_; | 120 bool waiting_; |
121 DownloadManager* manager_; | 121 DownloadManager* manager_; |
122 DownloadItem* created_item_; | 122 DownloadItem* created_item_; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(DownloadItemCreatedObserver); | 124 DISALLOW_COPY_AND_ASSIGN(DownloadItemCreatedObserver); |
125 }; | 125 }; |
126 | 126 |
| 127 class DownloadPersistedObserver : public DownloadItem::Observer { |
| 128 public: |
| 129 explicit DownloadPersistedObserver(DownloadItem* item) |
| 130 : waiting_(false), item_(item) { |
| 131 item->AddObserver(this); |
| 132 } |
| 133 |
| 134 ~DownloadPersistedObserver() { |
| 135 if (item_) |
| 136 item_->RemoveObserver(this); |
| 137 } |
| 138 |
| 139 // Wait for download item to get the persisted bit set. |
| 140 // Note that this class provides no protection against the download |
| 141 // being destroyed between creation and return of WaitForPersisted(); |
| 142 // the caller must guarantee that in some other fashion. |
| 143 void WaitForPersisted() { |
| 144 // In combination with OnDownloadDestroyed() below, verify the |
| 145 // above interface contract. |
| 146 DCHECK(item_); |
| 147 |
| 148 if (item_->IsPersisted()) |
| 149 return; |
| 150 |
| 151 waiting_ = true; |
| 152 content::RunMessageLoop(); |
| 153 waiting_ = false; |
| 154 |
| 155 return; |
| 156 } |
| 157 |
| 158 private: |
| 159 // DownloadItem::Observer |
| 160 void OnDownloadUpdated(DownloadItem* item) { |
| 161 DCHECK_EQ(item, item_); |
| 162 |
| 163 if (waiting_ && item->IsPersisted()) |
| 164 MessageLoopForUI::current()->Quit(); |
| 165 } |
| 166 |
| 167 void OnDownloadDestroyed(DownloadItem* item) { |
| 168 if (item != item_) |
| 169 return; |
| 170 |
| 171 item_->RemoveObserver(this); |
| 172 item_ = NULL; |
| 173 } |
| 174 |
| 175 bool waiting_; |
| 176 DownloadItem* item_; |
| 177 |
| 178 DISALLOW_COPY_AND_ASSIGN(DownloadPersistedObserver); |
| 179 }; |
| 180 |
127 class SavePageBrowserTest : public InProcessBrowserTest { | 181 class SavePageBrowserTest : public InProcessBrowserTest { |
128 public: | 182 public: |
129 SavePageBrowserTest() {} | 183 SavePageBrowserTest() {} |
130 virtual ~SavePageBrowserTest(); | 184 virtual ~SavePageBrowserTest(); |
131 | 185 |
132 protected: | 186 protected: |
133 void SetUp() OVERRIDE { | 187 void SetUp() OVERRIDE { |
134 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); | 188 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); |
135 ASSERT_TRUE(save_dir_.CreateUniqueTempDir()); | 189 ASSERT_TRUE(save_dir_.CreateUniqueTempDir()); |
136 InProcessBrowserTest::SetUp(); | 190 InProcessBrowserTest::SetUp(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 256 |
203 // Indicate thet we have received the history and can continue. | 257 // Indicate thet we have received the history and can continue. |
204 MessageLoopForUI::current()->Quit(); | 258 MessageLoopForUI::current()->Quit(); |
205 } | 259 } |
206 | 260 |
207 struct DownloadPersistentStoreInfoMatch | 261 struct DownloadPersistentStoreInfoMatch |
208 : public std::unary_function<DownloadPersistentStoreInfo, bool> { | 262 : public std::unary_function<DownloadPersistentStoreInfo, bool> { |
209 | 263 |
210 DownloadPersistentStoreInfoMatch(const GURL& url, | 264 DownloadPersistentStoreInfoMatch(const GURL& url, |
211 const FilePath& path, | 265 const FilePath& path, |
212 int64 num_files) | 266 int64 num_files, |
| 267 DownloadItem::DownloadState state) |
213 : url_(url), | 268 : url_(url), |
214 path_(path), | 269 path_(path), |
215 num_files_(num_files) { | 270 num_files_(num_files), |
216 } | 271 state_(state) {} |
217 | 272 |
218 bool operator() (const DownloadPersistentStoreInfo& info) const { | 273 bool operator() (const DownloadPersistentStoreInfo& info) const { |
219 return info.url == url_ && | 274 return info.url == url_ && |
220 info.path == path_ && | 275 info.path == path_ && |
221 // For non-MHTML save packages, received_bytes is actually the | 276 // For non-MHTML save packages, received_bytes is actually the |
222 // number of files. | 277 // number of files. |
223 ((num_files_ < 0) || | 278 ((num_files_ < 0) || |
224 (info.received_bytes == num_files_)) && | 279 (info.received_bytes == num_files_)) && |
225 info.total_bytes == 0 && | 280 info.total_bytes == 0 && |
226 info.state == DownloadItem::COMPLETE; | 281 info.state == state_; |
227 } | 282 } |
228 | 283 |
229 GURL url_; | 284 GURL url_; |
230 FilePath path_; | 285 FilePath path_; |
231 int64 num_files_; | 286 int64 num_files_; |
| 287 DownloadItem::DownloadState state_; |
232 }; | 288 }; |
233 | 289 |
234 void CheckDownloadHistory(const GURL& url, | 290 void CheckDownloadHistory(const GURL& url, |
235 const FilePath& path, | 291 const FilePath& path, |
236 int64 num_files) { | 292 int64 num_files, |
| 293 DownloadItem::DownloadState state) { |
237 QueryDownloadHistory(); | 294 QueryDownloadHistory(); |
238 | 295 |
239 std::vector<DownloadPersistentStoreInfo>::iterator found = | 296 std::vector<DownloadPersistentStoreInfo>::iterator found = |
240 std::find_if(history_entries_.begin(), history_entries_.end(), | 297 std::find_if(history_entries_.begin(), history_entries_.end(), |
241 DownloadPersistentStoreInfoMatch(url, path, num_files)); | 298 DownloadPersistentStoreInfoMatch(url, path, num_files, |
| 299 state)); |
242 | 300 |
243 if (found == history_entries_.end()) { | 301 if (found == history_entries_.end()) { |
244 LOG(ERROR) << "Missing url=" << url.spec() | 302 LOG(ERROR) << "Missing url=" << url.spec() |
245 << " path=" << path.value() | 303 << " path=" << path.value() |
246 << " received=" << num_files; | 304 << " received=" << num_files; |
247 for (size_t index = 0; index < history_entries_.size(); ++index) { | 305 for (size_t index = 0; index < history_entries_.size(); ++index) { |
248 LOG(ERROR) << "History@" << index << ": url=" | 306 LOG(ERROR) << "History@" << index << ": url=" |
249 << history_entries_[index].url.spec() | 307 << history_entries_[index].url.spec() |
250 << " path=" << history_entries_[index].path.value() | 308 << " path=" << history_entries_[index].path.value() |
251 << " received=" << history_entries_[index].received_bytes | 309 << " received=" << history_entries_[index].received_bytes |
(...skipping 23 matching lines...) Expand all Loading... |
275 GURL url = NavigateToMockURL("a"); | 333 GURL url = NavigateToMockURL("a"); |
276 | 334 |
277 FilePath full_file_name, dir; | 335 FilePath full_file_name, dir; |
278 GetDestinationPaths("a", &full_file_name, &dir); | 336 GetDestinationPaths("a", &full_file_name, &dir); |
279 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, | 337 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, |
280 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); | 338 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); |
281 | 339 |
282 EXPECT_EQ(url, WaitForSavePackageToFinish()); | 340 EXPECT_EQ(url, WaitForSavePackageToFinish()); |
283 | 341 |
284 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 342 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
285 CheckDownloadHistory(url, full_file_name, 1); // a.htm is 1 file. | 343 // a.htm is 1 file. |
| 344 CheckDownloadHistory(url, full_file_name, 1, DownloadItem::COMPLETE); |
286 | 345 |
287 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 346 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
288 EXPECT_FALSE(file_util::PathExists(dir)); | 347 EXPECT_FALSE(file_util::PathExists(dir)); |
289 EXPECT_TRUE(file_util::ContentsEqual( | 348 EXPECT_TRUE(file_util::ContentsEqual( |
290 test_dir_.Append(FilePath(kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), | 349 test_dir_.Append(FilePath(kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), |
291 full_file_name)); | 350 full_file_name)); |
292 } | 351 } |
293 | 352 |
294 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveHTMLOnlyCancel) { | 353 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveHTMLOnlyCancel) { |
295 GURL url = NavigateToMockURL("a"); | 354 GURL url = NavigateToMockURL("a"); |
296 DownloadManager* manager(GetDownloadManager()); | 355 DownloadManager* manager(GetDownloadManager()); |
297 std::vector<DownloadItem*> downloads; | 356 std::vector<DownloadItem*> downloads; |
298 manager->SearchDownloads(string16(), &downloads); | 357 manager->SearchDownloads(string16(), &downloads); |
299 ASSERT_EQ(0u, downloads.size()); | 358 ASSERT_EQ(0u, downloads.size()); |
300 | 359 |
301 FilePath full_file_name, dir; | 360 FilePath full_file_name, dir; |
302 GetDestinationPaths("a", &full_file_name, &dir); | 361 GetDestinationPaths("a", &full_file_name, &dir); |
303 DownloadItemCreatedObserver creation_observer(manager); | 362 DownloadItemCreatedObserver creation_observer(manager); |
304 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, | 363 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, |
305 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); | 364 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); |
306 DownloadItem* item = creation_observer.WaitForNewDownloadItem(); | 365 DownloadItem* item = creation_observer.WaitForNewDownloadItem(); |
307 item->Cancel(true); | 366 item->Cancel(true); |
308 | 367 |
309 // TODO(rdsmith): Fix DII::Cancel() to actually cancel the save package. | 368 // TODO(rdsmith): Fix DII::Cancel() to actually cancel the save package. |
310 // Currently it's ignored. | 369 // Currently it's ignored. |
311 EXPECT_EQ(url, WaitForSavePackageToFinish()); | 370 EXPECT_EQ(url, WaitForSavePackageToFinish()); |
| 371 DownloadPersistedObserver(item).WaitForPersisted(); |
| 372 // -1 to disable number of files check; we don't update after cancel, and |
| 373 // we don't know when the single file completed in relationship to |
| 374 // the cancel. |
| 375 CheckDownloadHistory(url, full_file_name, -1, DownloadItem::CANCELLED); |
312 | 376 |
313 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 377 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
314 CheckDownloadHistory(url, full_file_name, 1); // a.htm is 1 file. | |
315 | 378 |
316 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 379 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
317 EXPECT_FALSE(file_util::PathExists(dir)); | 380 EXPECT_FALSE(file_util::PathExists(dir)); |
318 EXPECT_TRUE(file_util::ContentsEqual( | 381 EXPECT_TRUE(file_util::ContentsEqual( |
319 test_dir_.Append(FilePath(kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), | 382 test_dir_.Append(FilePath(kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), |
320 full_file_name)); | 383 full_file_name)); |
321 } | 384 } |
322 | 385 |
323 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveHTMLOnlyTabDestroy) { | 386 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveHTMLOnlyTabDestroy) { |
324 GURL url = NavigateToMockURL("a"); | 387 GURL url = NavigateToMockURL("a"); |
(...skipping 26 matching lines...) Expand all Loading... |
351 ui_test_utils::NavigateToURL(browser(), view_source_url); | 414 ui_test_utils::NavigateToURL(browser(), view_source_url); |
352 | 415 |
353 FilePath full_file_name, dir; | 416 FilePath full_file_name, dir; |
354 GetDestinationPaths("a", &full_file_name, &dir); | 417 GetDestinationPaths("a", &full_file_name, &dir); |
355 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, | 418 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, |
356 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); | 419 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); |
357 | 420 |
358 EXPECT_EQ(actual_page_url, WaitForSavePackageToFinish()); | 421 EXPECT_EQ(actual_page_url, WaitForSavePackageToFinish()); |
359 | 422 |
360 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 423 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
361 CheckDownloadHistory(actual_page_url, full_file_name, 1); // a.htm is 1 file. | 424 // a.htm is 1 file. |
| 425 CheckDownloadHistory(actual_page_url, full_file_name, 1, |
| 426 DownloadItem::COMPLETE); |
362 | 427 |
363 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 428 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
364 EXPECT_FALSE(file_util::PathExists(dir)); | 429 EXPECT_FALSE(file_util::PathExists(dir)); |
365 EXPECT_TRUE(file_util::ContentsEqual( | 430 EXPECT_TRUE(file_util::ContentsEqual( |
366 test_dir_.Append(FilePath(kTestDir)).Append(file_name), | 431 test_dir_.Append(FilePath(kTestDir)).Append(file_name), |
367 full_file_name)); | 432 full_file_name)); |
368 } | 433 } |
369 | 434 |
370 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveCompleteHTML) { | 435 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveCompleteHTML) { |
371 GURL url = NavigateToMockURL("b"); | 436 GURL url = NavigateToMockURL("b"); |
372 | 437 |
373 FilePath full_file_name, dir; | 438 FilePath full_file_name, dir; |
374 GetDestinationPaths("b", &full_file_name, &dir); | 439 GetDestinationPaths("b", &full_file_name, &dir); |
375 ASSERT_TRUE(GetCurrentTab()->SavePage( | 440 ASSERT_TRUE(GetCurrentTab()->SavePage( |
376 full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); | 441 full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); |
377 | 442 |
378 EXPECT_EQ(url, WaitForSavePackageToFinish()); | 443 EXPECT_EQ(url, WaitForSavePackageToFinish()); |
379 | 444 |
380 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 445 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
381 CheckDownloadHistory(url, full_file_name, 3); // b.htm is 3 files. | 446 // b.htm is 3 files. |
| 447 CheckDownloadHistory(url, full_file_name, 3, DownloadItem::COMPLETE); |
382 | 448 |
383 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 449 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
384 EXPECT_TRUE(file_util::PathExists(dir)); | 450 EXPECT_TRUE(file_util::PathExists(dir)); |
385 EXPECT_TRUE(file_util::TextContentsEqual( | 451 EXPECT_TRUE(file_util::TextContentsEqual( |
386 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved1.htm"), | 452 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved1.htm"), |
387 full_file_name)); | 453 full_file_name)); |
388 EXPECT_TRUE(file_util::ContentsEqual( | 454 EXPECT_TRUE(file_util::ContentsEqual( |
389 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"), | 455 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"), |
390 dir.AppendASCII("1.png"))); | 456 dir.AppendASCII("1.png"))); |
391 EXPECT_TRUE(file_util::ContentsEqual( | 457 EXPECT_TRUE(file_util::ContentsEqual( |
(...skipping 12 matching lines...) Expand all Loading... |
404 FilePath full_file_name = save_dir_.path().AppendASCII( | 470 FilePath full_file_name = save_dir_.path().AppendASCII( |
405 std::string("Test page for saving page feature") + kAppendedExtension); | 471 std::string("Test page for saving page feature") + kAppendedExtension); |
406 FilePath dir = save_dir_.path().AppendASCII( | 472 FilePath dir = save_dir_.path().AppendASCII( |
407 "Test page for saving page feature_files"); | 473 "Test page for saving page feature_files"); |
408 ASSERT_TRUE(GetCurrentTab()->SavePage( | 474 ASSERT_TRUE(GetCurrentTab()->SavePage( |
409 full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); | 475 full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); |
410 | 476 |
411 EXPECT_EQ(url, WaitForSavePackageToFinish()); | 477 EXPECT_EQ(url, WaitForSavePackageToFinish()); |
412 | 478 |
413 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 479 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
414 CheckDownloadHistory(url, full_file_name, 3); // b.htm is 3 files. | 480 // b.htm is 3 files. |
| 481 CheckDownloadHistory(url, full_file_name, 3, DownloadItem::COMPLETE); |
415 | 482 |
416 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 483 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
417 EXPECT_TRUE(file_util::PathExists(dir)); | 484 EXPECT_TRUE(file_util::PathExists(dir)); |
418 EXPECT_TRUE(file_util::TextContentsEqual( | 485 EXPECT_TRUE(file_util::TextContentsEqual( |
419 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved2.htm"), | 486 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved2.htm"), |
420 full_file_name)); | 487 full_file_name)); |
421 EXPECT_TRUE(file_util::ContentsEqual( | 488 EXPECT_TRUE(file_util::ContentsEqual( |
422 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"), | 489 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"), |
423 dir.AppendASCII("1.png"))); | 490 dir.AppendASCII("1.png"))); |
424 EXPECT_TRUE(file_util::ContentsEqual( | 491 EXPECT_TRUE(file_util::ContentsEqual( |
425 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.css"), | 492 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.css"), |
426 dir.AppendASCII("1.css"))); | 493 dir.AppendASCII("1.css"))); |
427 } | 494 } |
428 | 495 |
429 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, RemoveFromList) { | 496 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, RemoveFromList) { |
430 GURL url = NavigateToMockURL("a"); | 497 GURL url = NavigateToMockURL("a"); |
431 | 498 |
432 FilePath full_file_name, dir; | 499 FilePath full_file_name, dir; |
433 GetDestinationPaths("a", &full_file_name, &dir); | 500 GetDestinationPaths("a", &full_file_name, &dir); |
434 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, | 501 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, |
435 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); | 502 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); |
436 | 503 |
437 EXPECT_EQ(url, WaitForSavePackageToFinish()); | 504 EXPECT_EQ(url, WaitForSavePackageToFinish()); |
438 | 505 |
439 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 506 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
440 CheckDownloadHistory(url, full_file_name, 1); // a.htm is 1 file. | 507 // a.htm is 1 file. |
| 508 CheckDownloadHistory(url, full_file_name, 1, DownloadItem::COMPLETE); |
441 | 509 |
442 EXPECT_EQ(GetDownloadManager()->RemoveAllDownloads(), 1); | 510 EXPECT_EQ(GetDownloadManager()->RemoveAllDownloads(), 1); |
443 | 511 |
444 // Should not be in history. | 512 // Should not be in history. |
445 QueryDownloadHistory(); | 513 QueryDownloadHistory(); |
446 EXPECT_EQ(std::find_if(history_entries_.begin(), history_entries_.end(), | 514 EXPECT_EQ(std::find_if(history_entries_.begin(), history_entries_.end(), |
447 DownloadPersistentStoreInfoMatch(url, full_file_name, 1)), | 515 DownloadPersistentStoreInfoMatch( |
| 516 url, full_file_name, 1, DownloadItem::COMPLETE)), |
448 history_entries_.end()); | 517 history_entries_.end()); |
449 | 518 |
450 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 519 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
451 EXPECT_FALSE(file_util::PathExists(dir)); | 520 EXPECT_FALSE(file_util::PathExists(dir)); |
452 EXPECT_TRUE(file_util::ContentsEqual( | 521 EXPECT_TRUE(file_util::ContentsEqual( |
453 test_dir_.Append(FilePath(kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), | 522 test_dir_.Append(FilePath(kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), |
454 full_file_name)); | 523 full_file_name)); |
455 } | 524 } |
456 | 525 |
457 // This tests that a webpage with the title "test.exe" is saved as | 526 // This tests that a webpage with the title "test.exe" is saved as |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 #if defined(OS_CHROMEOS) | 580 #if defined(OS_CHROMEOS) |
512 SavePackageFilePickerChromeOS::SetShouldPromptUser(false); | 581 SavePackageFilePickerChromeOS::SetShouldPromptUser(false); |
513 #else | 582 #else |
514 SavePackageFilePicker::SetShouldPromptUser(false); | 583 SavePackageFilePicker::SetShouldPromptUser(false); |
515 #endif | 584 #endif |
516 content::WindowedNotificationObserver observer( | 585 content::WindowedNotificationObserver observer( |
517 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, | 586 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
518 content::NotificationService::AllSources()); | 587 content::NotificationService::AllSources()); |
519 chrome::SavePage(browser()); | 588 chrome::SavePage(browser()); |
520 observer.Wait(); | 589 observer.Wait(); |
521 CheckDownloadHistory(url, full_file_name, -1); | 590 CheckDownloadHistory(url, full_file_name, -1, DownloadItem::COMPLETE); |
522 | 591 |
523 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 592 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
524 int64 actual_file_size = -1; | 593 int64 actual_file_size = -1; |
525 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); | 594 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); |
526 EXPECT_LE(kFileSizeMin, actual_file_size); | 595 EXPECT_LE(kFileSizeMin, actual_file_size); |
527 } | 596 } |
OLD | NEW |