| 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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 DownloadManager* manager = DownloadManagerForBrowser(browser); | 573 DownloadManager* manager = DownloadManagerForBrowser(browser); |
| 574 manager->SearchDownloads(string16(), downloads); | 574 manager->SearchDownloads(string16(), downloads); |
| 575 } | 575 } |
| 576 | 576 |
| 577 // Check that the download UI (shelf on non-chromeos or panel on chromeos) | 577 // Check that the download UI (shelf on non-chromeos or panel on chromeos) |
| 578 // is visible or not as expected. Additionally, check that the filename | 578 // is visible or not as expected. Additionally, check that the filename |
| 579 // is present in the UI (currently only on chromeos). | 579 // is present in the UI (currently only on chromeos). |
| 580 void CheckDownloadUI(Browser* browser, bool expected_non_cros, | 580 void CheckDownloadUI(Browser* browser, bool expected_non_cros, |
| 581 bool expected_cros, const FilePath& filename) { | 581 bool expected_cros, const FilePath& filename) { |
| 582 #if defined(OS_CHROMEOS) && !defined(USE_AURA) | 582 #if defined(OS_CHROMEOS) && !defined(USE_AURA) |
| 583 #if defined(TOUCH_UI) | |
| 584 TabContents* download_contents = ActiveDownloadsUI::GetPopup(NULL); | |
| 585 EXPECT_EQ(expected_cros, download_contents != NULL); | |
| 586 if (!download_contents || filename.empty()) | |
| 587 return; | |
| 588 | |
| 589 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( | |
| 590 download_contents->web_ui()); | |
| 591 #else | |
| 592 Browser* popup = ActiveDownloadsUI::GetPopup(); | 583 Browser* popup = ActiveDownloadsUI::GetPopup(); |
| 593 EXPECT_EQ(expected_cros, popup != NULL); | 584 EXPECT_EQ(expected_cros, popup != NULL); |
| 594 if (!popup || filename.empty()) | 585 if (!popup || filename.empty()) |
| 595 return; | 586 return; |
| 596 | 587 |
| 597 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( | 588 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( |
| 598 popup->GetSelectedTabContents()->web_ui()); | 589 popup->GetSelectedTabContents()->web_ui()); |
| 599 #endif // defined(TOUCH_UI) | |
| 600 | 590 |
| 601 ASSERT_TRUE(downloads_ui); | 591 ASSERT_TRUE(downloads_ui); |
| 602 const ActiveDownloadsUI::DownloadList& downloads = | 592 const ActiveDownloadsUI::DownloadList& downloads = |
| 603 downloads_ui->GetDownloads(); | 593 downloads_ui->GetDownloads(); |
| 604 EXPECT_EQ(downloads.size(), 1U); | 594 EXPECT_EQ(downloads.size(), 1U); |
| 605 | 595 |
| 606 FilePath full_path(DestinationFile(browser, filename)); | 596 FilePath full_path(DestinationFile(browser, filename)); |
| 607 bool exists = false; | 597 bool exists = false; |
| 608 for (size_t i = 0; i < downloads.size(); ++i) { | 598 for (size_t i = 0; i < downloads.size(); ++i) { |
| 609 if (downloads[i]->GetFullPath() == full_path) { | 599 if (downloads[i]->GetFullPath() == full_path) { |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 search_results.clear(); | 1663 search_results.clear(); |
| 1674 | 1664 |
| 1675 manager->SearchDownloads(UTF8ToUTF16("another_file"), &search_results); | 1665 manager->SearchDownloads(UTF8ToUTF16("another_file"), &search_results); |
| 1676 ASSERT_EQ(2u, search_results.size()); | 1666 ASSERT_EQ(2u, search_results.size()); |
| 1677 std::sort(search_results.begin(), search_results.end(), | 1667 std::sort(search_results.begin(), search_results.end(), |
| 1678 DownloadItemSorter); | 1668 DownloadItemSorter); |
| 1679 EXPECT_EQ(2, search_results[0]->GetDbHandle()); | 1669 EXPECT_EQ(2, search_results[0]->GetDbHandle()); |
| 1680 EXPECT_EQ(3, search_results[1]->GetDbHandle()); | 1670 EXPECT_EQ(3, search_results[1]->GetDbHandle()); |
| 1681 search_results.clear(); | 1671 search_results.clear(); |
| 1682 } | 1672 } |
| OLD | NEW |