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 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 // Check that the file contains the expected referrer. | 2635 // Check that the file contains the expected referrer. |
2636 base::FilePath file(download_items[0]->GetTargetFilePath()); | 2636 base::FilePath file(download_items[0]->GetTargetFilePath()); |
2637 std::string expected_contents = test_server()->GetURL(std::string()).spec(); | 2637 std::string expected_contents = test_server()->GetURL(std::string()).spec(); |
2638 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); | 2638 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
2639 } | 2639 } |
2640 | 2640 |
2641 IN_PROC_BROWSER_TEST_F(DownloadTest, HiddenDownload) { | 2641 IN_PROC_BROWSER_TEST_F(DownloadTest, HiddenDownload) { |
2642 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 2642 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
2643 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 2643 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
2644 | 2644 |
2645 scoped_refptr<DownloadManager> download_manager = | 2645 DownloadManager* download_manager = DownloadManagerForBrowser(browser()); |
2646 DownloadManagerForBrowser(browser()); | |
2647 scoped_ptr<content::DownloadTestObserver> observer( | 2646 scoped_ptr<content::DownloadTestObserver> observer( |
2648 new content::DownloadTestObserverTerminal( | 2647 new content::DownloadTestObserverTerminal( |
2649 download_manager, | 2648 download_manager, |
2650 1, | 2649 1, |
2651 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); | 2650 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
2652 | 2651 |
2653 // Download and set IsHiddenDownload to true. | 2652 // Download and set IsHiddenDownload to true. |
2654 WebContents* web_contents = | 2653 WebContents* web_contents = |
2655 browser()->tab_strip_model()->GetActiveWebContents(); | 2654 browser()->tab_strip_model()->GetActiveWebContents(); |
2656 scoped_ptr<DownloadUrlParameters> params( | 2655 scoped_ptr<DownloadUrlParameters> params( |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2936 scoped_ptr<content::DownloadTestObserver> observer( | 2935 scoped_ptr<content::DownloadTestObserver> observer( |
2937 DangerousDownloadWaiter( | 2936 DangerousDownloadWaiter( |
2938 browser(), 1, | 2937 browser(), 1, |
2939 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 2938 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
2940 ui_test_utils::NavigateToURL(browser(), url); | 2939 ui_test_utils::NavigateToURL(browser(), url); |
2941 observer->WaitForFinished(); | 2940 observer->WaitForFinished(); |
2942 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); | 2941 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); |
2943 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 2942 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
2944 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2943 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
2945 } | 2944 } |
OLD | NEW |