Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 8503018: Split DownloadItem into an ABC, an Impl, and a Mock. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 #endif // defined(TOUCH_UI) 599 #endif // defined(TOUCH_UI)
600 600
601 ASSERT_TRUE(downloads_ui); 601 ASSERT_TRUE(downloads_ui);
602 const ActiveDownloadsUI::DownloadList& downloads = 602 const ActiveDownloadsUI::DownloadList& downloads =
603 downloads_ui->GetDownloads(); 603 downloads_ui->GetDownloads();
604 EXPECT_EQ(downloads.size(), 1U); 604 EXPECT_EQ(downloads.size(), 1U);
605 605
606 FilePath full_path(DestinationFile(browser, filename)); 606 FilePath full_path(DestinationFile(browser, filename));
607 bool exists = false; 607 bool exists = false;
608 for (size_t i = 0; i < downloads.size(); ++i) { 608 for (size_t i = 0; i < downloads.size(); ++i) {
609 if (downloads[i]->full_path() == full_path) { 609 if (downloads[i]->GetFullPath() == full_path) {
610 exists = true; 610 exists = true;
611 break; 611 break;
612 } 612 }
613 } 613 }
614 EXPECT_TRUE(exists); 614 EXPECT_TRUE(exists);
615 #else 615 #else
616 EXPECT_EQ(expected_non_cros, browser->window()->IsDownloadShelfVisible()); 616 EXPECT_EQ(expected_non_cros, browser->window()->IsDownloadShelfVisible());
617 // TODO: Check for filename match in download shelf. 617 // TODO: Check for filename match in download shelf.
618 #endif 618 #endif
619 } 619 }
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 scoped_ptr<DownloadTestObserver> observer1( 1160 scoped_ptr<DownloadTestObserver> observer1(
1161 CreateInProgressWaiter(browser(), 1)); 1161 CreateInProgressWaiter(browser(), 1));
1162 ui_test_utils::NavigateToURL( 1162 ui_test_utils::NavigateToURL(
1163 browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl)); 1163 browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl));
1164 observer1->WaitForFinished(); 1164 observer1->WaitForFinished();
1165 1165
1166 std::vector<DownloadItem*> downloads; 1166 std::vector<DownloadItem*> downloads;
1167 browser()->profile()->GetDownloadManager()->SearchDownloads( 1167 browser()->profile()->GetDownloadManager()->SearchDownloads(
1168 string16(), &downloads); 1168 string16(), &downloads);
1169 ASSERT_EQ(1u, downloads.size()); 1169 ASSERT_EQ(1u, downloads.size());
1170 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->state()); 1170 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState());
1171 CheckDownloadUI(browser(), true, true, FilePath()); 1171 CheckDownloadUI(browser(), true, true, FilePath());
1172 DownloadItem* download1 = downloads[0]; // The only download. 1172 DownloadItem* download1 = downloads[0]; // The only download.
1173 1173
1174 // Start the second download and wait until it's done. 1174 // Start the second download and wait until it's done.
1175 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1175 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1176 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 1176 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
1177 // Download the file and wait. We do not expect the Select File dialog. 1177 // Download the file and wait. We do not expect the Select File dialog.
1178 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); 1178 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG);
1179 1179
1180 // Should now have 2 items on the download shelf. 1180 // Should now have 2 items on the download shelf.
1181 downloads.clear(); 1181 downloads.clear();
1182 browser()->profile()->GetDownloadManager()->SearchDownloads( 1182 browser()->profile()->GetDownloadManager()->SearchDownloads(
1183 string16(), &downloads); 1183 string16(), &downloads);
1184 ASSERT_EQ(2u, downloads.size()); 1184 ASSERT_EQ(2u, downloads.size());
1185 // We don't know the order of the downloads. 1185 // We don't know the order of the downloads.
1186 DownloadItem* download2 = downloads[(download1 == downloads[0]) ? 1 : 0]; 1186 DownloadItem* download2 = downloads[(download1 == downloads[0]) ? 1 : 0];
1187 1187
1188 ASSERT_EQ(DownloadItem::IN_PROGRESS, download1->state()); 1188 ASSERT_EQ(DownloadItem::IN_PROGRESS, download1->GetState());
1189 ASSERT_EQ(DownloadItem::COMPLETE, download2->state()); 1189 ASSERT_EQ(DownloadItem::COMPLETE, download2->GetState());
1190 // The download shelf should be open. 1190 // The download shelf should be open.
1191 CheckDownloadUI(browser(), true, true, FilePath()); 1191 CheckDownloadUI(browser(), true, true, FilePath());
1192 1192
1193 // Allow the first request to finish. We do this by loading a third URL 1193 // Allow the first request to finish. We do this by loading a third URL
1194 // in a separate tab. 1194 // in a separate tab.
1195 scoped_ptr<DownloadTestObserver> observer2(CreateWaiter(browser(), 1)); 1195 scoped_ptr<DownloadTestObserver> observer2(CreateWaiter(browser(), 1));
1196 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl); 1196 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl);
1197 ui_test_utils::NavigateToURLWithDisposition( 1197 ui_test_utils::NavigateToURLWithDisposition(
1198 browser(), 1198 browser(),
1199 finish_url, 1199 finish_url,
1200 NEW_FOREGROUND_TAB, 1200 NEW_FOREGROUND_TAB,
1201 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1201 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1202 observer2->WaitForFinished(); // Wait for the third request. 1202 observer2->WaitForFinished(); // Wait for the third request.
1203 1203
1204 // Get the important info from other threads and check it. 1204 // Get the important info from other threads and check it.
1205 scoped_refptr<CancelTestDataCollector> info(new CancelTestDataCollector()); 1205 scoped_refptr<CancelTestDataCollector> info(new CancelTestDataCollector());
1206 info->WaitForDataCollected(); 1206 info->WaitForDataCollected();
1207 EXPECT_EQ(0, info->dfm_pending_downloads()); 1207 EXPECT_EQ(0, info->dfm_pending_downloads());
1208 1208
1209 CheckDownloadUI(browser(), true, true, FilePath()); 1209 CheckDownloadUI(browser(), true, true, FilePath());
1210 1210
1211 // The |DownloadItem|s should now be done and have the final file names. 1211 // The |DownloadItem|s should now be done and have the final file names.
1212 // Verify that the files have the expected data and size. 1212 // Verify that the files have the expected data and size.
1213 // |file1| should be full of '*'s, and |file2| should be the same as the 1213 // |file1| should be full of '*'s, and |file2| should be the same as the
1214 // source file. 1214 // source file.
1215 FilePath file1(download1->full_path()); 1215 FilePath file1(download1->GetFullPath());
1216 size_t file_size1 = URLRequestSlowDownloadJob::kFirstDownloadSize + 1216 size_t file_size1 = URLRequestSlowDownloadJob::kFirstDownloadSize +
1217 URLRequestSlowDownloadJob::kSecondDownloadSize; 1217 URLRequestSlowDownloadJob::kSecondDownloadSize;
1218 std::string expected_contents(file_size1, '*'); 1218 std::string expected_contents(file_size1, '*');
1219 ASSERT_TRUE(VerifyFile(file1, expected_contents, file_size1)); 1219 ASSERT_TRUE(VerifyFile(file1, expected_contents, file_size1));
1220 1220
1221 FilePath file2(download2->full_path()); 1221 FilePath file2(download2->GetFullPath());
1222 ASSERT_TRUE(file_util::ContentsEqual(OriginFile(file), file2)); 1222 ASSERT_TRUE(file_util::ContentsEqual(OriginFile(file), file2));
1223 } 1223 }
1224 1224
1225 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCancelled) { 1225 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCancelled) {
1226 ASSERT_TRUE(InitialSetup(false)); 1226 ASSERT_TRUE(InitialSetup(false));
1227 EXPECT_EQ(1, browser()->tab_count()); 1227 EXPECT_EQ(1, browser()->tab_count());
1228 1228
1229 // TODO(rdsmith): Fragile code warning! The code below relies on the 1229 // TODO(rdsmith): Fragile code warning! The code below relies on the
1230 // DownloadTestObserver only finishing when the new download has reached 1230 // DownloadTestObserver only finishing when the new download has reached
1231 // the state of being entered into the history and being user-visible 1231 // the state of being entered into the history and being user-visible
(...skipping 15 matching lines...) Expand all
1247 scoped_ptr<DownloadTestObserver> observer( 1247 scoped_ptr<DownloadTestObserver> observer(
1248 CreateInProgressWaiter(browser(), 1)); 1248 CreateInProgressWaiter(browser(), 1));
1249 ui_test_utils::NavigateToURL( 1249 ui_test_utils::NavigateToURL(
1250 browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl)); 1250 browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl));
1251 observer->WaitForFinished(); 1251 observer->WaitForFinished();
1252 1252
1253 std::vector<DownloadItem*> downloads; 1253 std::vector<DownloadItem*> downloads;
1254 DownloadManagerForBrowser(browser())->SearchDownloads( 1254 DownloadManagerForBrowser(browser())->SearchDownloads(
1255 string16(), &downloads); 1255 string16(), &downloads);
1256 ASSERT_EQ(1u, downloads.size()); 1256 ASSERT_EQ(1u, downloads.size());
1257 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->state()); 1257 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState());
1258 CheckDownloadUI(browser(), true, true, FilePath()); 1258 CheckDownloadUI(browser(), true, true, FilePath());
1259 1259
1260 // Cancel the download and wait for download system quiesce. 1260 // Cancel the download and wait for download system quiesce.
1261 downloads[0]->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 1261 downloads[0]->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
1262 scoped_refptr<DownloadTestFlushObserver> flush_observer( 1262 scoped_refptr<DownloadTestFlushObserver> flush_observer(
1263 new DownloadTestFlushObserver( 1263 new DownloadTestFlushObserver(
1264 DownloadManagerForBrowser(browser()))); 1264 DownloadManagerForBrowser(browser())));
1265 flush_observer->WaitForFlush(); 1265 flush_observer->WaitForFlush();
1266 1266
1267 // Get the important info from other threads and check it. 1267 // Get the important info from other threads and check it.
(...skipping 17 matching lines...) Expand all
1285 int64 origin_size; 1285 int64 origin_size;
1286 file_util::GetFileSize(origin_file, &origin_size); 1286 file_util::GetFileSize(origin_file, &origin_size);
1287 1287
1288 // Download the file and wait. We do not expect the Select File dialog. 1288 // Download the file and wait. We do not expect the Select File dialog.
1289 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); 1289 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG);
1290 1290
1291 // Get details of what downloads have just happened. 1291 // Get details of what downloads have just happened.
1292 std::vector<DownloadItem*> downloads; 1292 std::vector<DownloadItem*> downloads;
1293 GetDownloads(browser(), &downloads); 1293 GetDownloads(browser(), &downloads);
1294 ASSERT_EQ(1u, downloads.size()); 1294 ASSERT_EQ(1u, downloads.size());
1295 int64 db_handle = downloads[0]->db_handle(); 1295 int64 db_handle = downloads[0]->GetDbHandle();
1296 1296
1297 // Check state. 1297 // Check state.
1298 EXPECT_EQ(1, browser()->tab_count()); 1298 EXPECT_EQ(1, browser()->tab_count());
1299 CheckDownload(browser(), file, file); 1299 CheckDownload(browser(), file, file);
1300 CheckDownloadUI(browser(), true, true, file); 1300 CheckDownloadUI(browser(), true, true, file);
1301 1301
1302 // Check history results. 1302 // Check history results.
1303 DownloadsHistoryDataCollector history_collector( 1303 DownloadsHistoryDataCollector history_collector(
1304 db_handle, 1304 db_handle,
1305 DownloadManagerForBrowser(browser())); 1305 DownloadManagerForBrowser(browser()));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 MockDownloadOpeningObserver observer( 1398 MockDownloadOpeningObserver observer(
1399 DownloadManagerForBrowser(browser())); 1399 DownloadManagerForBrowser(browser()));
1400 1400
1401 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); 1401 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG);
1402 1402
1403 // Find the download and confirm it was opened. 1403 // Find the download and confirm it was opened.
1404 std::vector<DownloadItem*> downloads; 1404 std::vector<DownloadItem*> downloads;
1405 DownloadManagerForBrowser(browser())->SearchDownloads( 1405 DownloadManagerForBrowser(browser())->SearchDownloads(
1406 string16(), &downloads); 1406 string16(), &downloads);
1407 ASSERT_EQ(1u, downloads.size()); 1407 ASSERT_EQ(1u, downloads.size());
1408 EXPECT_EQ(DownloadItem::COMPLETE, downloads[0]->state()); 1408 EXPECT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState());
1409 EXPECT_TRUE(downloads[0]->opened()); 1409 EXPECT_TRUE(downloads[0]->GetOpened());
1410 1410
1411 // As long as we're here, confirmed everything else is good. 1411 // As long as we're here, confirmed everything else is good.
1412 EXPECT_EQ(1, browser()->tab_count()); 1412 EXPECT_EQ(1, browser()->tab_count());
1413 CheckDownload(browser(), file, file); 1413 CheckDownload(browser(), file, file);
1414 // Download shelf should close. Download panel stays open on ChromeOS. 1414 // Download shelf should close. Download panel stays open on ChromeOS.
1415 CheckDownloadUI(browser(), false, true, FilePath()); 1415 CheckDownloadUI(browser(), false, true, FilePath());
1416 } 1416 }
1417 1417
1418 // Download an extension. Expect a dangerous download warning. 1418 // Download an extension. Expect a dangerous download warning.
1419 // Deny the download. 1419 // Deny the download.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 CheckDownloadUI(browser(), false, true, FilePath()); 1546 CheckDownloadUI(browser(), false, true, FilePath());
1547 1547
1548 // Check that the extension was installed. 1548 // Check that the extension was installed.
1549 ExtensionService* extension_service = 1549 ExtensionService* extension_service =
1550 browser()->profile()->GetExtensionService(); 1550 browser()->profile()->GetExtensionService();
1551 ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false)); 1551 ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false));
1552 } 1552 }
1553 1553
1554 // Sort download items by db_handle. 1554 // Sort download items by db_handle.
1555 static bool DownloadItemSorter(DownloadItem* d1, DownloadItem* d2) { 1555 static bool DownloadItemSorter(DownloadItem* d1, DownloadItem* d2) {
1556 return d1->db_handle() < d2->db_handle(); 1556 return d1->GetDbHandle() < d2->GetDbHandle();
1557 } 1557 }
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(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 manager->SearchDownloads(string16(), &search_results); 1610 manager->SearchDownloads(string16(), &search_results);
1611 ASSERT_EQ(3u, search_results.size()); 1611 ASSERT_EQ(3u, search_results.size());
1612 std::sort(search_results.begin(), search_results.end(), 1612 std::sort(search_results.begin(), search_results.end(),
1613 DownloadItemSorter); 1613 DownloadItemSorter);
1614 // We do a full check only once to protect against the data 1614 // We do a full check only once to protect against the data
1615 // somehow getting scrambled on its way into the DownloadItems. 1615 // somehow getting scrambled on its way into the DownloadItems.
1616 { 1616 {
1617 DownloadItem* d1 = search_results[0]; 1617 DownloadItem* d1 = search_results[0];
1618 DownloadItem* d2 = search_results[1]; 1618 DownloadItem* d2 = search_results[1];
1619 DownloadItem* d3 = search_results[2]; 1619 DownloadItem* d3 = search_results[2];
1620 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("/path/to/file")), d1->full_path()); 1620 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("/path/to/file")), d1->GetFullPath());
1621 EXPECT_EQ(GURL("http://www.google.com/fantasy_download"), 1621 EXPECT_EQ(GURL("http://www.google.com/fantasy_download"),
1622 d1->original_url()); 1622 d1->GetOriginalUrl());
1623 EXPECT_EQ(current - base::TimeDelta::FromMinutes(5), 1623 EXPECT_EQ(current - base::TimeDelta::FromMinutes(5),
1624 d1->start_time()); 1624 d1->GetStartTime());
1625 EXPECT_EQ(current, d1->end_time()); 1625 EXPECT_EQ(current, d1->GetEndTime());
1626 EXPECT_EQ(128, d1->received_bytes()); 1626 EXPECT_EQ(128, d1->GetReceivedBytes());
1627 EXPECT_EQ(128, d1->total_bytes()); 1627 EXPECT_EQ(128, d1->GetTotalBytes());
1628 EXPECT_EQ(DownloadItem::COMPLETE, d1->state()); 1628 EXPECT_EQ(DownloadItem::COMPLETE, d1->GetState());
1629 EXPECT_EQ(1, d1->db_handle()); 1629 EXPECT_EQ(1, d1->GetDbHandle());
1630 EXPECT_FALSE(d1->opened()); 1630 EXPECT_FALSE(d1->GetOpened());
1631 1631
1632 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("/path/to/another_file")), 1632 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("/path/to/another_file")),
1633 d2->full_path()); 1633 d2->GetFullPath());
1634 EXPECT_EQ(GURL("http://www.google.com/reality_download"), 1634 EXPECT_EQ(GURL("http://www.google.com/reality_download"),
1635 d2->original_url()); 1635 d2->GetOriginalUrl());
1636 EXPECT_EQ(current - base::TimeDelta::FromMinutes(10), 1636 EXPECT_EQ(current - base::TimeDelta::FromMinutes(10),
1637 d2->start_time()); 1637 d2->GetStartTime());
1638 EXPECT_EQ(current, d2->end_time()); 1638 EXPECT_EQ(current, d2->GetEndTime());
1639 EXPECT_EQ(256, d2->received_bytes()); 1639 EXPECT_EQ(256, d2->GetReceivedBytes());
1640 EXPECT_EQ(256, d2->total_bytes()); 1640 EXPECT_EQ(256, d2->GetTotalBytes());
1641 EXPECT_EQ(DownloadItem::COMPLETE, d2->state()); 1641 EXPECT_EQ(DownloadItem::COMPLETE, d2->GetState());
1642 EXPECT_EQ(2, d2->db_handle()); 1642 EXPECT_EQ(2, d2->GetDbHandle());
1643 EXPECT_FALSE(d2->opened()); 1643 EXPECT_FALSE(d2->GetOpened());
1644 1644
1645 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("/different_path/to/another_file")), 1645 EXPECT_EQ(FilePath(FILE_PATH_LITERAL("/different_path/to/another_file")),
1646 d3->full_path()); 1646 d3->GetFullPath());
1647 EXPECT_EQ(GURL("http://www.izzle.com/not_really_a_download"), 1647 EXPECT_EQ(GURL("http://www.izzle.com/not_really_a_download"),
1648 d3->original_url()); 1648 d3->GetOriginalUrl());
1649 EXPECT_EQ(current - base::TimeDelta::FromMinutes(15), 1649 EXPECT_EQ(current - base::TimeDelta::FromMinutes(15),
1650 d3->start_time()); 1650 d3->GetStartTime());
1651 EXPECT_EQ(current, d3->end_time()); 1651 EXPECT_EQ(current, d3->GetEndTime());
1652 EXPECT_EQ(512, d3->received_bytes()); 1652 EXPECT_EQ(512, d3->GetReceivedBytes());
1653 EXPECT_EQ(512, d3->total_bytes()); 1653 EXPECT_EQ(512, d3->GetTotalBytes());
1654 EXPECT_EQ(DownloadItem::COMPLETE, d3->state()); 1654 EXPECT_EQ(DownloadItem::COMPLETE, d3->GetState());
1655 EXPECT_EQ(3, d3->db_handle()); 1655 EXPECT_EQ(3, d3->GetDbHandle());
1656 EXPECT_TRUE(d3->opened()); 1656 EXPECT_TRUE(d3->GetOpened());
1657 } 1657 }
1658 search_results.clear(); 1658 search_results.clear();
1659 1659
1660 string16 search_input; 1660 string16 search_input;
1661 manager->SearchDownloads(UTF8ToUTF16("www.google.com"), &search_results); 1661 manager->SearchDownloads(UTF8ToUTF16("www.google.com"), &search_results);
1662 ASSERT_EQ(2u, search_results.size()); 1662 ASSERT_EQ(2u, search_results.size());
1663 std::sort(search_results.begin(), search_results.end(), 1663 std::sort(search_results.begin(), search_results.end(),
1664 DownloadItemSorter); 1664 DownloadItemSorter);
1665 EXPECT_EQ(1, search_results[0]->db_handle()); 1665 EXPECT_EQ(1, search_results[0]->GetDbHandle());
1666 EXPECT_EQ(2, search_results[1]->db_handle()); 1666 EXPECT_EQ(2, search_results[1]->GetDbHandle());
1667 search_results.clear(); 1667 search_results.clear();
1668 1668
1669 manager->SearchDownloads(UTF8ToUTF16("real"), &search_results); 1669 manager->SearchDownloads(UTF8ToUTF16("real"), &search_results);
1670 ASSERT_EQ(2u, search_results.size()); 1670 ASSERT_EQ(2u, search_results.size());
1671 std::sort(search_results.begin(), search_results.end(), 1671 std::sort(search_results.begin(), search_results.end(),
1672 DownloadItemSorter); 1672 DownloadItemSorter);
1673 EXPECT_EQ(2, search_results[0]->db_handle()); 1673 EXPECT_EQ(2, search_results[0]->GetDbHandle());
1674 EXPECT_EQ(3, search_results[1]->db_handle()); 1674 EXPECT_EQ(3, search_results[1]->GetDbHandle());
1675 search_results.clear(); 1675 search_results.clear();
1676 1676
1677 manager->SearchDownloads(UTF8ToUTF16("another_file"), &search_results); 1677 manager->SearchDownloads(UTF8ToUTF16("another_file"), &search_results);
1678 ASSERT_EQ(2u, search_results.size()); 1678 ASSERT_EQ(2u, search_results.size());
1679 std::sort(search_results.begin(), search_results.end(), 1679 std::sort(search_results.begin(), search_results.end(),
1680 DownloadItemSorter); 1680 DownloadItemSorter);
1681 EXPECT_EQ(2, search_results[0]->db_handle()); 1681 EXPECT_EQ(2, search_results[0]->GetDbHandle());
1682 EXPECT_EQ(3, search_results[1]->db_handle()); 1682 EXPECT_EQ(3, search_results[1]->GetDbHandle());
1683 search_results.clear(); 1683 search_results.clear();
1684 } 1684 }
OLDNEW
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate.cc ('k') | chrome/browser/download/download_crx_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698