| 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 2706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2717 | 2717 |
| 2718 // Download the same url several times and expect that all downloaded files | 2718 // Download the same url several times and expect that all downloaded files |
| 2719 // after the zero-th contain a deduplication counter. | 2719 // after the zero-th contain a deduplication counter. |
| 2720 for (int index = 0; index < 5; ++index) { | 2720 for (int index = 0; index < 5; ++index) { |
| 2721 DownloadAndWait(browser(), url); | 2721 DownloadAndWait(browser(), url); |
| 2722 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 2722 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
| 2723 content::DownloadItem* item = manager->GetDownload(index); | 2723 content::DownloadItem* item = manager->GetDownload(index); |
| 2724 ASSERT_TRUE(item); | 2724 ASSERT_TRUE(item); |
| 2725 ASSERT_TRUE(item->IsComplete()); | 2725 ASSERT_TRUE(item->IsComplete()); |
| 2726 base::FilePath full_path(item->GetFullPath()); | 2726 base::FilePath full_path(item->GetFullPath()); |
| 2727 EXPECT_EQ(std::string("a_zip_file") + (index == 0 ? std::string(".zip") : | 2727 EXPECT_EQ(std::string("a_zip_file") + |
| 2728 StringPrintf(" (%d).zip", index)), | 2728 (index == 0 ? std::string(".zip") : |
| 2729 base::StringPrintf(" (%d).zip", index)), |
| 2729 full_path.BaseName().AsUTF8Unsafe()); | 2730 full_path.BaseName().AsUTF8Unsafe()); |
| 2730 ASSERT_TRUE(file_util::PathExists(full_path)); | 2731 ASSERT_TRUE(file_util::PathExists(full_path)); |
| 2731 ASSERT_TRUE(VerifyFile(full_path, origin_contents, origin_contents.size())); | 2732 ASSERT_TRUE(VerifyFile(full_path, origin_contents, origin_contents.size())); |
| 2732 } | 2733 } |
| 2733 } | 2734 } |
| 2734 | 2735 |
| 2735 // Test that the entire download pipeline handles unicode correctly. | 2736 // Test that the entire download pipeline handles unicode correctly. |
| 2736 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_CrazyFilenames) { | 2737 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_CrazyFilenames) { |
| 2737 const wchar_t* kCrazyFilenames[] = { | 2738 const wchar_t* kCrazyFilenames[] = { |
| 2738 L"a_file_name.zip", | 2739 L"a_file_name.zip", |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 scoped_ptr<content::DownloadTestObserver> observer( | 2923 scoped_ptr<content::DownloadTestObserver> observer( |
| 2923 DangerousDownloadWaiter( | 2924 DangerousDownloadWaiter( |
| 2924 browser(), 1, | 2925 browser(), 1, |
| 2925 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 2926 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
| 2926 ui_test_utils::NavigateToURL(browser(), url); | 2927 ui_test_utils::NavigateToURL(browser(), url); |
| 2927 observer->WaitForFinished(); | 2928 observer->WaitForFinished(); |
| 2928 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); | 2929 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); |
| 2929 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 2930 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
| 2930 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2931 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 2931 } | 2932 } |
| OLD | NEW |