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 "chrome/browser/download/download_browsertest.h" | 5 #include "chrome/browser/download/download_browsertest.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 2201 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
2202 base::ScopedTempDir other_directory; | 2202 base::ScopedTempDir other_directory; |
2203 ASSERT_TRUE(other_directory.CreateUniqueTempDir()); | 2203 ASSERT_TRUE(other_directory.CreateUniqueTempDir()); |
2204 base::FilePath target_file_full_path = | 2204 base::FilePath target_file_full_path = |
2205 other_directory.GetPath().Append(file.BaseName()); | 2205 other_directory.GetPath().Append(file.BaseName()); |
2206 content::DownloadTestObserver* observer(CreateWaiter(browser(), 1)); | 2206 content::DownloadTestObserver* observer(CreateWaiter(browser(), 1)); |
2207 std::unique_ptr<DownloadUrlParameters> params( | 2207 std::unique_ptr<DownloadUrlParameters> params( |
2208 DownloadUrlParameters::CreateForWebContentsMainFrame( | 2208 DownloadUrlParameters::CreateForWebContentsMainFrame( |
2209 web_contents, url)); | 2209 web_contents, url)); |
2210 params->set_file_path(target_file_full_path); | 2210 params->set_file_path(target_file_full_path); |
| 2211 params->set_transient(true); |
2211 DownloadManagerForBrowser(browser())->DownloadUrl(std::move(params)); | 2212 DownloadManagerForBrowser(browser())->DownloadUrl(std::move(params)); |
2212 observer->WaitForFinished(); | 2213 observer->WaitForFinished(); |
2213 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 2214 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
2214 | 2215 |
2215 // Check state. | 2216 // Check state. |
2216 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 2217 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
2217 ASSERT_TRUE(CheckDownloadFullPaths(browser(), | 2218 ASSERT_TRUE(CheckDownloadFullPaths(browser(), |
2218 target_file_full_path, | 2219 target_file_full_path, |
2219 OriginFile(file))); | 2220 OriginFile(file))); |
2220 | 2221 |
2221 // Temporary are treated as auto-opened, and after that open won't be | 2222 // Temporary are treated as auto-opened, and after that open won't be |
2222 // visible; wait for auto-open and confirm not visible. | 2223 // visible; wait for auto-open and confirm not visible. |
2223 std::vector<DownloadItem*> downloads; | 2224 std::vector<DownloadItem*> downloads; |
2224 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads); | 2225 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads); |
2225 ASSERT_EQ(1u, downloads.size()); | 2226 ASSERT_EQ(1u, downloads.size()); |
2226 content::DownloadUpdatedObserver( | 2227 content::DownloadUpdatedObserver( |
2227 downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent(); | 2228 downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent(); |
| 2229 ASSERT_TRUE(downloads[0]->IsTransient()); |
2228 } | 2230 } |
2229 | 2231 |
2230 IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaGet) { | 2232 IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaGet) { |
2231 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory()); | 2233 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory()); |
2232 ASSERT_TRUE(embedded_test_server()->Start()); | 2234 ASSERT_TRUE(embedded_test_server()->Start()); |
2233 EnableFileChooser(true); | 2235 EnableFileChooser(true); |
2234 std::vector<DownloadItem*> download_items; | 2236 std::vector<DownloadItem*> download_items; |
2235 GetDownloads(browser(), &download_items); | 2237 GetDownloads(browser(), &download_items); |
2236 ASSERT_TRUE(download_items.empty()); | 2238 ASSERT_TRUE(download_items.empty()); |
2237 | 2239 |
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3803 browser(), 1, | 3805 browser(), 1, |
3804 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 3806 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
3805 ui_test_utils::NavigateToURL(browser(), extension_url); | 3807 ui_test_utils::NavigateToURL(browser(), extension_url); |
3806 | 3808 |
3807 observer->WaitForFinished(); | 3809 observer->WaitForFinished(); |
3808 | 3810 |
3809 // Download shelf should close. | 3811 // Download shelf should close. |
3810 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 3812 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
3811 } | 3813 } |
3812 #endif // defined(OS_CHROMEOS) | 3814 #endif // defined(OS_CHROMEOS) |
OLD | NEW |