| 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/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 base::ScopedTempDir save_dir_; | 370 base::ScopedTempDir save_dir_; |
| 371 | 371 |
| 372 private: | 372 private: |
| 373 DISALLOW_COPY_AND_ASSIGN(SavePageBrowserTest); | 373 DISALLOW_COPY_AND_ASSIGN(SavePageBrowserTest); |
| 374 }; | 374 }; |
| 375 | 375 |
| 376 SavePageBrowserTest::~SavePageBrowserTest() { | 376 SavePageBrowserTest::~SavePageBrowserTest() { |
| 377 } | 377 } |
| 378 | 378 |
| 379 // Disabled on Windows due to flakiness. http://crbug.com/162323 | 379 // Disabled on Windows due to flakiness. http://crbug.com/162323 |
| 380 #if defined(OS_WIN) | 380 // TODO(linux_aura) http://crbug.com/163931 |
| 381 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(US
E_AURA)) |
| 381 #define MAYBE_SaveHTMLOnly DISABLED_SaveHTMLOnly | 382 #define MAYBE_SaveHTMLOnly DISABLED_SaveHTMLOnly |
| 382 #else | 383 #else |
| 383 #define MAYBE_SaveHTMLOnly SaveHTMLOnly | 384 #define MAYBE_SaveHTMLOnly SaveHTMLOnly |
| 384 #endif | 385 #endif |
| 385 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveHTMLOnly) { | 386 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveHTMLOnly) { |
| 386 GURL url = NavigateToMockURL("a"); | 387 GURL url = NavigateToMockURL("a"); |
| 387 | 388 |
| 388 base::FilePath full_file_name, dir; | 389 base::FilePath full_file_name, dir; |
| 389 GetDestinationPaths("a", &full_file_name, &dir); | 390 GetDestinationPaths("a", &full_file_name, &dir); |
| 390 DownloadPersistedObserver persisted(browser()->profile(), base::Bind( | 391 DownloadPersistedObserver persisted(browser()->profile(), base::Bind( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 401 ASSERT_TRUE(VerifySavePackageExpectations(browser(), url)); | 402 ASSERT_TRUE(VerifySavePackageExpectations(browser(), url)); |
| 402 persisted.WaitForPersisted(); | 403 persisted.WaitForPersisted(); |
| 403 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 404 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
| 404 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 405 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
| 405 EXPECT_FALSE(file_util::PathExists(dir)); | 406 EXPECT_FALSE(file_util::PathExists(dir)); |
| 406 EXPECT_TRUE(file_util::ContentsEqual(test_dir_.Append(base::FilePath( | 407 EXPECT_TRUE(file_util::ContentsEqual(test_dir_.Append(base::FilePath( |
| 407 kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), full_file_name)); | 408 kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), full_file_name)); |
| 408 } | 409 } |
| 409 | 410 |
| 410 // Disabled on Windows due to flakiness. http://crbug.com/162323 | 411 // Disabled on Windows due to flakiness. http://crbug.com/162323 |
| 411 #if defined(OS_WIN) | 412 // TODO(linux_aura) http://crbug.com/163931 |
| 413 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(US
E_AURA)) |
| 412 #define MAYBE_SaveHTMLOnlyCancel DISABLED_SaveHTMLOnlyCancel | 414 #define MAYBE_SaveHTMLOnlyCancel DISABLED_SaveHTMLOnlyCancel |
| 413 #else | 415 #else |
| 414 #define MAYBE_SaveHTMLOnlyCancel SaveHTMLOnlyCancel | 416 #define MAYBE_SaveHTMLOnlyCancel SaveHTMLOnlyCancel |
| 415 #endif | 417 #endif |
| 416 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveHTMLOnlyCancel) { | 418 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveHTMLOnlyCancel) { |
| 417 GURL url = NavigateToMockURL("a"); | 419 GURL url = NavigateToMockURL("a"); |
| 418 DownloadManager* manager(GetDownloadManager()); | 420 DownloadManager* manager(GetDownloadManager()); |
| 419 std::vector<DownloadItem*> downloads; | 421 std::vector<DownloadItem*> downloads; |
| 420 manager->GetAllDownloads(&downloads); | 422 manager->GetAllDownloads(&downloads); |
| 421 ASSERT_EQ(0u, downloads.size()); | 423 ASSERT_EQ(0u, downloads.size()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 468 |
| 467 // Close the tab; does this cancel the download? | 469 // Close the tab; does this cancel the download? |
| 468 GetCurrentTab(browser())->Close(); | 470 GetCurrentTab(browser())->Close(); |
| 469 EXPECT_TRUE(items[0]->IsCancelled()); | 471 EXPECT_TRUE(items[0]->IsCancelled()); |
| 470 | 472 |
| 471 EXPECT_FALSE(file_util::PathExists(full_file_name)); | 473 EXPECT_FALSE(file_util::PathExists(full_file_name)); |
| 472 EXPECT_FALSE(file_util::PathExists(dir)); | 474 EXPECT_FALSE(file_util::PathExists(dir)); |
| 473 } | 475 } |
| 474 | 476 |
| 475 // Disabled on Windows due to flakiness. http://crbug.com/162323 | 477 // Disabled on Windows due to flakiness. http://crbug.com/162323 |
| 476 #if defined(OS_WIN) | 478 // TODO(linux_aura) http://crbug.com/163931 |
| 479 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(US
E_AURA)) |
| 477 #define MAYBE_SaveViewSourceHTMLOnly DISABLED_SaveViewSourceHTMLOnly | 480 #define MAYBE_SaveViewSourceHTMLOnly DISABLED_SaveViewSourceHTMLOnly |
| 478 #else | 481 #else |
| 479 #define MAYBE_SaveViewSourceHTMLOnly SaveViewSourceHTMLOnly | 482 #define MAYBE_SaveViewSourceHTMLOnly SaveViewSourceHTMLOnly |
| 480 #endif | 483 #endif |
| 481 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveViewSourceHTMLOnly) { | 484 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveViewSourceHTMLOnly) { |
| 482 base::FilePath file_name(FILE_PATH_LITERAL("a.htm")); | 485 base::FilePath file_name(FILE_PATH_LITERAL("a.htm")); |
| 483 GURL view_source_url = URLRequestMockHTTPJob::GetMockViewSourceUrl( | 486 GURL view_source_url = URLRequestMockHTTPJob::GetMockViewSourceUrl( |
| 484 base::FilePath(kTestDir).Append(file_name)); | 487 base::FilePath(kTestDir).Append(file_name)); |
| 485 GURL actual_page_url = URLRequestMockHTTPJob::GetMockUrl( | 488 GURL actual_page_url = URLRequestMockHTTPJob::GetMockUrl( |
| 486 base::FilePath(kTestDir).Append(file_name)); | 489 base::FilePath(kTestDir).Append(file_name)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 505 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 508 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
| 506 | 509 |
| 507 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 510 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
| 508 EXPECT_FALSE(file_util::PathExists(dir)); | 511 EXPECT_FALSE(file_util::PathExists(dir)); |
| 509 EXPECT_TRUE(file_util::ContentsEqual( | 512 EXPECT_TRUE(file_util::ContentsEqual( |
| 510 test_dir_.Append(base::FilePath(kTestDir)).Append(file_name), | 513 test_dir_.Append(base::FilePath(kTestDir)).Append(file_name), |
| 511 full_file_name)); | 514 full_file_name)); |
| 512 } | 515 } |
| 513 | 516 |
| 514 // Disabled on Windows due to flakiness. http://crbug.com/162323 | 517 // Disabled on Windows due to flakiness. http://crbug.com/162323 |
| 515 #if defined(OS_WIN) | 518 // TODO(linux_aura) http://crbug.com/163931 |
| 519 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(US
E_AURA)) |
| 516 #define MAYBE_SaveCompleteHTML DISABLED_SaveCompleteHTML | 520 #define MAYBE_SaveCompleteHTML DISABLED_SaveCompleteHTML |
| 517 #else | 521 #else |
| 518 #define MAYBE_SaveCompleteHTML SaveCompleteHTML | 522 #define MAYBE_SaveCompleteHTML SaveCompleteHTML |
| 519 #endif | 523 #endif |
| 520 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveCompleteHTML) { | 524 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveCompleteHTML) { |
| 521 GURL url = NavigateToMockURL("b"); | 525 GURL url = NavigateToMockURL("b"); |
| 522 | 526 |
| 523 base::FilePath full_file_name, dir; | 527 base::FilePath full_file_name, dir; |
| 524 GetDestinationPaths("b", &full_file_name, &dir); | 528 GetDestinationPaths("b", &full_file_name, &dir); |
| 525 DownloadPersistedObserver persisted(browser()->profile(), base::Bind( | 529 DownloadPersistedObserver persisted(browser()->profile(), base::Bind( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 // SavePackage will cancel because there aren't any resources to | 603 // SavePackage will cancel because there aren't any resources to |
| 600 // save. | 604 // save. |
| 601 } | 605 } |
| 602 | 606 |
| 603 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, NoSave) { | 607 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, NoSave) { |
| 604 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); | 608 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); |
| 605 EXPECT_FALSE(chrome::CanSavePage(browser())); | 609 EXPECT_FALSE(chrome::CanSavePage(browser())); |
| 606 } | 610 } |
| 607 | 611 |
| 608 // Disabled on Windows due to flakiness. http://crbug.com/162323 | 612 // Disabled on Windows due to flakiness. http://crbug.com/162323 |
| 609 #if defined(OS_WIN) | 613 // TODO(linux_aura) http://crbug.com/163931 |
| 614 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(US
E_AURA)) |
| 610 #define MAYBE_FileNameFromPageTitle DISABLED_FileNameFromPageTitle | 615 #define MAYBE_FileNameFromPageTitle DISABLED_FileNameFromPageTitle |
| 611 #else | 616 #else |
| 612 #define MAYBE_FileNameFromPageTitle FileNameFromPageTitle | 617 #define MAYBE_FileNameFromPageTitle FileNameFromPageTitle |
| 613 #endif | 618 #endif |
| 614 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_FileNameFromPageTitle) { | 619 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_FileNameFromPageTitle) { |
| 615 GURL url = NavigateToMockURL("b"); | 620 GURL url = NavigateToMockURL("b"); |
| 616 | 621 |
| 617 base::FilePath full_file_name = save_dir_.path().AppendASCII( | 622 base::FilePath full_file_name = save_dir_.path().AppendASCII( |
| 618 std::string("Test page for saving page feature") + kAppendedExtension); | 623 std::string("Test page for saving page feature") + kAppendedExtension); |
| 619 base::FilePath dir = save_dir_.path().AppendASCII( | 624 base::FilePath dir = save_dir_.path().AppendASCII( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 642 full_file_name)); | 647 full_file_name)); |
| 643 EXPECT_TRUE(file_util::ContentsEqual( | 648 EXPECT_TRUE(file_util::ContentsEqual( |
| 644 test_dir_.Append(base::FilePath(kTestDir)).AppendASCII("1.png"), | 649 test_dir_.Append(base::FilePath(kTestDir)).AppendASCII("1.png"), |
| 645 dir.AppendASCII("1.png"))); | 650 dir.AppendASCII("1.png"))); |
| 646 EXPECT_TRUE(file_util::ContentsEqual( | 651 EXPECT_TRUE(file_util::ContentsEqual( |
| 647 test_dir_.Append(base::FilePath(kTestDir)).AppendASCII("1.css"), | 652 test_dir_.Append(base::FilePath(kTestDir)).AppendASCII("1.css"), |
| 648 dir.AppendASCII("1.css"))); | 653 dir.AppendASCII("1.css"))); |
| 649 } | 654 } |
| 650 | 655 |
| 651 // Disabled on Windows due to flakiness. http://crbug.com/162323 | 656 // Disabled on Windows due to flakiness. http://crbug.com/162323 |
| 652 #if defined(OS_WIN) | 657 // TODO(linux_aura) http://crbug.com/163931 |
| 658 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(US
E_AURA)) |
| 653 #define MAYBE_RemoveFromList DISABLED_RemoveFromList | 659 #define MAYBE_RemoveFromList DISABLED_RemoveFromList |
| 654 #else | 660 #else |
| 655 #define MAYBE_RemoveFromList RemoveFromList | 661 #define MAYBE_RemoveFromList RemoveFromList |
| 656 #endif | 662 #endif |
| 657 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_RemoveFromList) { | 663 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_RemoveFromList) { |
| 658 GURL url = NavigateToMockURL("a"); | 664 GURL url = NavigateToMockURL("a"); |
| 659 | 665 |
| 660 base::FilePath full_file_name, dir; | 666 base::FilePath full_file_name, dir; |
| 661 GetDestinationPaths("a", &full_file_name, &dir); | 667 GetDestinationPaths("a", &full_file_name, &dir); |
| 662 DownloadPersistedObserver persisted(browser()->profile(), base::Bind( | 668 DownloadPersistedObserver persisted(browser()->profile(), base::Bind( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 persisted.WaitForPersisted(); | 773 persisted.WaitForPersisted(); |
| 768 | 774 |
| 769 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 775 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
| 770 int64 actual_file_size = -1; | 776 int64 actual_file_size = -1; |
| 771 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); | 777 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); |
| 772 EXPECT_LE(kFileSizeMin, actual_file_size); | 778 EXPECT_LE(kFileSizeMin, actual_file_size); |
| 773 } | 779 } |
| 774 | 780 |
| 775 } // namespace | 781 } // namespace |
| 776 | 782 |
| OLD | NEW |