| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "base/test/test_file_util.h" | 9 #include "base/test/test_file_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 EXPECT_TRUE(file_util::ContentsEqual(downloaded_file, origin_file)); | 363 EXPECT_TRUE(file_util::ContentsEqual(downloaded_file, origin_file)); |
| 364 | 364 |
| 365 // Delete the downloaded copy of the file. | 365 // Delete the downloaded copy of the file. |
| 366 bool downloaded_file_deleted = | 366 bool downloaded_file_deleted = |
| 367 file_util::DieFileDie(downloaded_file, false); | 367 file_util::DieFileDie(downloaded_file, false); |
| 368 EXPECT_TRUE(downloaded_file_deleted); | 368 EXPECT_TRUE(downloaded_file_deleted); |
| 369 return downloaded_file_deleted; | 369 return downloaded_file_deleted; |
| 370 } | 370 } |
| 371 | 371 |
| 372 // TODO(ahendrickson) -- |expected_title_in_progress| and | 372 // TODO(ahendrickson) -- |expected_title_in_progress| and |
| 373 // |expected_title_in_finished| need to be checked. | 373 // |expected_title_finished| need to be checked. |
| 374 bool RunSizeTest(Browser* browser, | 374 bool RunSizeTest(Browser* browser, |
| 375 const GURL& url, | 375 const GURL& url, |
| 376 const std::wstring& expected_title_in_progress, | 376 const string16& expected_title_in_progress, |
| 377 const std::wstring& expected_title_finished) { | 377 const string16& expected_title_finished) { |
| 378 if (!InitialSetup(false)) | 378 if (!InitialSetup(false)) |
| 379 return false; | 379 return false; |
| 380 | 380 |
| 381 // Download a partial web page in a background tab and wait. | 381 // Download a partial web page in a background tab and wait. |
| 382 // The mock system will not complete until it gets a special URL. | 382 // The mock system will not complete until it gets a special URL. |
| 383 scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser, 1)); | 383 scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser, 1)); |
| 384 ui_test_utils::NavigateToURL(browser, url); | 384 ui_test_utils::NavigateToURL(browser, url); |
| 385 | 385 |
| 386 // TODO(ahendrickson): check download status text before downloading. | 386 // TODO(ahendrickson): check download status text before downloading. |
| 387 // Need to: | 387 // Need to: |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 // Test is believed mostly good (non-flaky) in itself, but it | 606 // Test is believed mostly good (non-flaky) in itself, but it |
| 607 // very occasionally trips over underlying flakiness in the downloads | 607 // very occasionally trips over underlying flakiness in the downloads |
| 608 // subsystem in in http://crbug.com/63237. Until that bug is | 608 // subsystem in in http://crbug.com/63237. Until that bug is |
| 609 // fixed, this test should be considered flaky. It's entered as | 609 // fixed, this test should be considered flaky. It's entered as |
| 610 // DISABLED since if 63237 does cause a failure, it'll be a timeout. | 610 // DISABLED since if 63237 does cause a failure, it'll be a timeout. |
| 611 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_UnknownSize) { | 611 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_UnknownSize) { |
| 612 GURL url(URLRequestSlowDownloadJob::kUnknownSizeUrl); | 612 GURL url(URLRequestSlowDownloadJob::kUnknownSizeUrl); |
| 613 FilePath filename; | 613 FilePath filename; |
| 614 net::FileURLToFilePath(url, &filename); | 614 net::FileURLToFilePath(url, &filename); |
| 615 filename = filename.BaseName(); | 615 filename = filename.BaseName(); |
| 616 ASSERT_TRUE(RunSizeTest(browser(), | 616 ASSERT_TRUE(RunSizeTest( |
| 617 url, | 617 browser(), |
| 618 L"32.0 KB - " + filename.ToWStringHack(), | 618 url, |
| 619 L"100% - " + filename.ToWStringHack())); | 619 ASCIIToUTF16("32.0 KB - ") + filename.LossyDisplayName(), |
| 620 ASCIIToUTF16("100% - ") + filename.LossyDisplayName())); |
| 620 } | 621 } |
| 621 | 622 |
| 622 // Test is believed mostly good (non-flaky) in itself, but it | 623 // Test is believed mostly good (non-flaky) in itself, but it |
| 623 // very occasionally trips over underlying flakiness in the downloads | 624 // very occasionally trips over underlying flakiness in the downloads |
| 624 // subsystem in in http://crbug.com/63237. Until that bug is | 625 // subsystem in in http://crbug.com/63237. Until that bug is |
| 625 // fixed, this test should be considered flaky. It's entered as | 626 // fixed, this test should be considered flaky. It's entered as |
| 626 // DISABLED since if 63237 does cause a failure, it'll be a timeout. | 627 // DISABLED since if 63237 does cause a failure, it'll be a timeout. |
| 627 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_KnownSize) { | 628 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_KnownSize) { |
| 628 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); | 629 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); |
| 629 FilePath filename; | 630 FilePath filename; |
| 630 net::FileURLToFilePath(url, &filename); | 631 net::FileURLToFilePath(url, &filename); |
| 631 filename = filename.BaseName(); | 632 filename = filename.BaseName(); |
| 632 ASSERT_TRUE(RunSizeTest(browser(), | 633 ASSERT_TRUE(RunSizeTest( |
| 633 url, | 634 browser(), |
| 634 L"71% - " + filename.ToWStringHack(), | 635 url, |
| 635 L"100% - " + filename.ToWStringHack())); | 636 ASCIIToUTF16("71% - ") + filename.LossyDisplayName(), |
| 637 ASCIIToUTF16("100% - ") + filename.LossyDisplayName())); |
| 636 } | 638 } |
| 637 | 639 |
| 638 // Test that when downloading an item in Incognito mode, we don't crash when | 640 // Test that when downloading an item in Incognito mode, we don't crash when |
| 639 // closing the last Incognito window (http://crbug.com/13983). | 641 // closing the last Incognito window (http://crbug.com/13983). |
| 640 // Also check that the download shelf is not visible after closing the | 642 // Also check that the download shelf is not visible after closing the |
| 641 // Incognito window. | 643 // Incognito window. |
| 642 // | 644 // |
| 643 // Test is believed mostly good (non-flaky) in itself, but it | 645 // Test is believed mostly good (non-flaky) in itself, but it |
| 644 // sometimes trips over underlying flakiness in the downloads | 646 // sometimes trips over underlying flakiness in the downloads |
| 645 // subsystem in in http://crbug.com/63237. Until that bug is | 647 // subsystem in in http://crbug.com/63237. Until that bug is |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 window_count = BrowserList::size(); | 945 window_count = BrowserList::size(); |
| 944 EXPECT_EQ(1, window_count); | 946 EXPECT_EQ(1, window_count); |
| 945 EXPECT_EQ(1, browser()->tab_count()); | 947 EXPECT_EQ(1, browser()->tab_count()); |
| 946 // The download shelf should not be visible in the remaining window. | 948 // The download shelf should not be visible in the remaining window. |
| 947 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 949 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 948 | 950 |
| 949 CheckDownload(browser(), file, file); | 951 CheckDownload(browser(), file, file); |
| 950 } | 952 } |
| 951 | 953 |
| 952 } // namespace | 954 } // namespace |
| OLD | NEW |