| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 | 1558 |
| 1559 // Confirm that searching through the history works properly | 1559 // Confirm that searching through the history works properly |
| 1560 IN_PROC_BROWSER_TEST_F(DownloadTest, SearchDownloads) { | 1560 IN_PROC_BROWSER_TEST_F(DownloadTest, SearchDownloads) { |
| 1561 ASSERT_TRUE(InitialSetup(false)); | 1561 ASSERT_TRUE(InitialSetup(false)); |
| 1562 | 1562 |
| 1563 // Downloads to populate history with. | 1563 // Downloads to populate history with. |
| 1564 base::Time current(base::Time::Now()); | 1564 base::Time current(base::Time::Now()); |
| 1565 DownloadPersistentStoreInfo population_entries[] = { | 1565 DownloadPersistentStoreInfo population_entries[] = { |
| 1566 DownloadPersistentStoreInfo( | 1566 DownloadPersistentStoreInfo( |
| 1567 FilePath(FILE_PATH_LITERAL("/path/to/file")), | 1567 FilePath(FILE_PATH_LITERAL("/path/to/file")), |
| 1568 FilePath(), |
| 1568 GURL("http://www.google.com/fantasy_download"), | 1569 GURL("http://www.google.com/fantasy_download"), |
| 1569 GURL(""), | 1570 GURL(""), |
| 1570 current - base::TimeDelta::FromMinutes(5), | 1571 current - base::TimeDelta::FromMinutes(5), |
| 1571 current, | 1572 current, |
| 1572 128, | 1573 128, |
| 1573 128, | 1574 128, |
| 1574 DownloadItem::COMPLETE, | 1575 DownloadItem::COMPLETE, |
| 1575 1, | 1576 1, |
| 1576 false), | 1577 false, |
| 1578 "", |
| 1579 "", |
| 1580 "", |
| 1581 DOWNLOAD_INTERRUPT_REASON_NONE), |
| 1577 DownloadPersistentStoreInfo( | 1582 DownloadPersistentStoreInfo( |
| 1578 FilePath(FILE_PATH_LITERAL("/path/to/another_file")), | 1583 FilePath(FILE_PATH_LITERAL("/path/to/another_file")), |
| 1584 FilePath(), |
| 1579 GURL("http://www.google.com/reality_download"), | 1585 GURL("http://www.google.com/reality_download"), |
| 1580 GURL(""), | 1586 GURL(""), |
| 1581 current - base::TimeDelta::FromMinutes(10), | 1587 current - base::TimeDelta::FromMinutes(10), |
| 1582 current, | 1588 current, |
| 1583 256, | 1589 256, |
| 1584 256, | 1590 256, |
| 1585 DownloadItem::COMPLETE, | 1591 DownloadItem::COMPLETE, |
| 1586 2, | 1592 2, |
| 1587 false), | 1593 false, |
| 1594 "", |
| 1595 "", |
| 1596 "", |
| 1597 DOWNLOAD_INTERRUPT_REASON_NONE), |
| 1588 DownloadPersistentStoreInfo( | 1598 DownloadPersistentStoreInfo( |
| 1589 FilePath(FILE_PATH_LITERAL("/different_path/to/another_file")), | 1599 FilePath(FILE_PATH_LITERAL("/different_path/to/another_file")), |
| 1600 FilePath(), |
| 1590 GURL("http://www.izzle.com/not_really_a_download"), | 1601 GURL("http://www.izzle.com/not_really_a_download"), |
| 1591 GURL(""), | 1602 GURL(""), |
| 1592 current - base::TimeDelta::FromMinutes(15), | 1603 current - base::TimeDelta::FromMinutes(15), |
| 1593 current, | 1604 current, |
| 1594 512, | 1605 512, |
| 1595 512, | 1606 512, |
| 1596 DownloadItem::COMPLETE, | 1607 DownloadItem::COMPLETE, |
| 1597 3, | 1608 3, |
| 1598 true) | 1609 true, |
| 1610 "", |
| 1611 "", |
| 1612 "", |
| 1613 DOWNLOAD_INTERRUPT_REASON_NONE) |
| 1599 }; | 1614 }; |
| 1600 std::vector<DownloadPersistentStoreInfo> entries( | 1615 std::vector<DownloadPersistentStoreInfo> entries( |
| 1601 population_entries, population_entries + arraysize(population_entries)); | 1616 population_entries, population_entries + arraysize(population_entries)); |
| 1602 | 1617 |
| 1603 // Populate the manager. | 1618 // Populate the manager. |
| 1604 DownloadManager* manager = DownloadManagerForBrowser(browser()); | 1619 DownloadManager* manager = DownloadManagerForBrowser(browser()); |
| 1605 manager->OnPersistentStoreQueryComplete(&entries); | 1620 manager->OnPersistentStoreQueryComplete(&entries); |
| 1606 | 1621 |
| 1607 // Do some searches and check the results. | 1622 // Do some searches and check the results. |
| 1608 std::vector<DownloadItem*> search_results; | 1623 std::vector<DownloadItem*> search_results; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 search_results.clear(); | 1690 search_results.clear(); |
| 1676 | 1691 |
| 1677 manager->SearchDownloads(UTF8ToUTF16("another_file"), &search_results); | 1692 manager->SearchDownloads(UTF8ToUTF16("another_file"), &search_results); |
| 1678 ASSERT_EQ(2u, search_results.size()); | 1693 ASSERT_EQ(2u, search_results.size()); |
| 1679 std::sort(search_results.begin(), search_results.end(), | 1694 std::sort(search_results.begin(), search_results.end(), |
| 1680 DownloadItemSorter); | 1695 DownloadItemSorter); |
| 1681 EXPECT_EQ(2, search_results[0]->db_handle()); | 1696 EXPECT_EQ(2, search_results[0]->db_handle()); |
| 1682 EXPECT_EQ(3, search_results[1]->db_handle()); | 1697 EXPECT_EQ(3, search_results[1]->db_handle()); |
| 1683 search_results.clear(); | 1698 search_results.clear(); |
| 1684 } | 1699 } |
| OLD | NEW |