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_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 } | 1407 } |
1408 | 1408 |
1409 // Confirm a download makes it into the history properly. | 1409 // Confirm a download makes it into the history properly. |
1410 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { | 1410 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { |
1411 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1411 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1412 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1412 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1413 FilePath origin_file(OriginFile(file)); | 1413 FilePath origin_file(OriginFile(file)); |
1414 int64 origin_size; | 1414 int64 origin_size; |
1415 file_util::GetFileSize(origin_file, &origin_size); | 1415 file_util::GetFileSize(origin_file, &origin_size); |
1416 | 1416 |
| 1417 // We use the server so that we can get a redirect and test url_chain |
| 1418 // persistence. |
| 1419 ASSERT_TRUE(test_server()->Start()); |
| 1420 GURL redirect_url = test_server()->GetURL("server-redirect?" + url.spec()); |
| 1421 |
1417 // Download the file and wait. We do not expect the Select File dialog. | 1422 // Download the file and wait. We do not expect the Select File dialog. |
1418 DownloadAndWait(browser(), url); | 1423 DownloadAndWait(browser(), redirect_url); |
1419 | 1424 |
1420 // Get details of what downloads have just happened. | 1425 // Get details of what downloads have just happened. |
1421 std::vector<DownloadItem*> downloads; | 1426 std::vector<DownloadItem*> downloads; |
1422 GetDownloads(browser(), &downloads); | 1427 GetDownloads(browser(), &downloads); |
1423 ASSERT_EQ(1u, downloads.size()); | 1428 ASSERT_EQ(1u, downloads.size()); |
1424 int64 db_handle = downloads[0]->GetDbHandle(); | 1429 int64 db_handle = downloads[0]->GetDbHandle(); |
1425 | 1430 |
1426 // Check state. | 1431 // Check state. |
1427 EXPECT_EQ(1, browser()->tab_count()); | 1432 EXPECT_EQ(1, browser()->tab_count()); |
1428 CheckDownload(browser(), file, file); | 1433 CheckDownload(browser(), file, file); |
1429 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 1434 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
1430 | 1435 |
1431 // Check history results. | 1436 // Check history results. |
1432 DownloadsHistoryDataCollector history_collector( | 1437 DownloadsHistoryDataCollector history_collector( |
1433 db_handle, | 1438 db_handle, |
1434 DownloadManagerForBrowser(browser())); | 1439 DownloadManagerForBrowser(browser())); |
1435 DownloadPersistentStoreInfo info; | 1440 DownloadPersistentStoreInfo info; |
1436 EXPECT_TRUE(history_collector.GetDownloadsHistoryEntry(&info)) << db_handle; | 1441 EXPECT_TRUE(history_collector.GetDownloadsHistoryEntry(&info)) << db_handle; |
1437 EXPECT_EQ(file, info.path.BaseName()); | 1442 EXPECT_EQ(file, info.target_path.BaseName()); |
1438 EXPECT_EQ(url, info.url); | 1443 ASSERT_EQ(2u, info.url_chain.size()); |
| 1444 EXPECT_EQ(redirect_url, info.url_chain[0]); |
| 1445 EXPECT_EQ(url, info.url_chain[1]); |
1439 // Ignore start_time. | 1446 // Ignore start_time. |
1440 EXPECT_EQ(origin_size, info.received_bytes); | 1447 EXPECT_EQ(origin_size, info.received_bytes); |
1441 EXPECT_EQ(origin_size, info.total_bytes); | 1448 EXPECT_EQ(origin_size, info.total_bytes); |
1442 EXPECT_EQ(DownloadItem::COMPLETE, info.state); | 1449 EXPECT_EQ(DownloadItem::COMPLETE, info.state); |
1443 } | 1450 } |
1444 | 1451 |
1445 // Test for crbug.com/14505. This tests that chrome:// urls are still functional | 1452 // Test for crbug.com/14505. This tests that chrome:// urls are still functional |
1446 // after download of a file while viewing another chrome://. | 1453 // after download of a file while viewing another chrome://. |
1447 IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { | 1454 IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { |
1448 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1455 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2259 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 2266 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
2260 scoped_ptr<DownloadUrlParameters> params( | 2267 scoped_ptr<DownloadUrlParameters> params( |
2261 DownloadUrlParameters::FromWebContents(web_contents, url)); | 2268 DownloadUrlParameters::FromWebContents(web_contents, url)); |
2262 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); | 2269 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); |
2263 download_manager->DownloadUrl(params.Pass()); | 2270 download_manager->DownloadUrl(params.Pass()); |
2264 observer->WaitForFinished(); | 2271 observer->WaitForFinished(); |
2265 | 2272 |
2266 // Verify that download shelf is not shown. | 2273 // Verify that download shelf is not shown. |
2267 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2274 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
2268 } | 2275 } |
OLD | NEW |