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

Unified Diff: chrome/browser/download/download_browsertest.cc

Issue 10073017: Remove Active Downloads UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_browsertest.cc
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index 3ea81230f4727427534d6d4148731a9a19fdd8f6..6f8e860def006acac787137065c34157687d0d7f 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -39,7 +39,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/webui/chromeos/active_downloads_ui.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
@@ -250,6 +249,12 @@ class DownloadTest : public InProcessBrowserTest {
DOWNLOAD_DIRECT
};
+ // State of download shelf.
+ enum DownloadShelfVisibility {
+ SHELF_HIDDEN,
+ SHELF_VISIBLE
+ };
+
// Information passed in to |DownloadFileCheckErrors()|.
struct DownloadInfo {
const char* url_name; // URL for the download.
@@ -551,7 +556,7 @@ class DownloadTest : public InProcessBrowserTest {
FilePath basefilename(filename.BaseName());
net::FileURLToFilePath(url, &filename);
FilePath download_path = downloads_directory_.path().Append(basefilename);
- CheckDownloadUI(browser, true, true, basefilename);
+ CheckDownloadShelfVisibility(browser, SHELF_VISIBLE);
bool downloaded_path_exists = file_util::PathExists(download_path);
EXPECT_TRUE(downloaded_path_exists);
@@ -577,45 +582,14 @@ class DownloadTest : public InProcessBrowserTest {
manager->SearchDownloads(string16(), downloads);
}
- // Check that the download UI (shelf on non-chromeos or panel on chromeos)
- // is visible or not as expected. Additionally, check that the filename
- // is present in the UI (currently only on chromeos).
- void CheckDownloadUI(Browser* browser, bool expected_non_cros,
- bool expected_cros, const FilePath& filename) {
-#if defined(OS_CHROMEOS) && !defined(USE_AURA)
- Browser* popup = ActiveDownloadsUI::GetPopup();
- EXPECT_EQ(expected_cros, popup != NULL);
- if (!popup || filename.empty())
- return;
-
- ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>(
- popup->GetSelectedWebContents()->GetWebUI()->GetController());
-
- ASSERT_TRUE(downloads_ui);
- const ActiveDownloadsUI::DownloadList& downloads =
- downloads_ui->GetDownloads();
- EXPECT_EQ(downloads.size(), 1U);
-
- FilePath full_path(DestinationFile(browser, filename));
- bool exists = false;
- for (size_t i = 0; i < downloads.size(); ++i) {
- if (downloads[i]->GetFullPath() == full_path) {
- exists = true;
- break;
- }
- }
- EXPECT_TRUE(exists);
-#else
- EXPECT_EQ(expected_non_cros, browser->window()->IsDownloadShelfVisible());
+ // Check that the download shelf is visible or not as expected.
+ void CheckDownloadShelfVisibility(Browser* browser,
achuithb 2012/04/16 14:27:05 Not sure if this function and the enum is worth it
asanka 2012/04/17 20:02:25 Done.
+ DownloadShelfVisibility expected) {
+ EXPECT_EQ((expected == SHELF_VISIBLE),
+ browser->window()->IsDownloadShelfVisible());
// TODO: Check for filename match in download shelf.
-#endif
}
static void ExpectWindowCountAfterDownload(size_t expected) {
-#if defined(OS_CHROMEOS) && !defined(USE_AURA)
- // On ChromeOS, a download panel is created to display
- // download information, and this counts as a window.
- expected++;
-#endif
EXPECT_EQ(expected, BrowserList::size());
}
@@ -915,7 +889,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeType) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
CheckDownload(browser(), file, file);
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
}
#if defined(OS_WIN)
@@ -936,7 +910,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CheckInternetZone) {
if (file_util::VolumeSupportsADS(downloaded_file))
EXPECT_TRUE(file_util::HasInternetZoneIdentifier(downloaded_file));
CheckDownload(browser(), file, file);
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
}
#endif
@@ -968,7 +942,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
CheckDownload(browser(), file, file);
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
}
// Access a file with a viewable mime-type, verify that a download
@@ -987,7 +961,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, NoDownload) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
- CheckDownloadUI(browser(), false, false, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
}
// Verify that when the DownloadResourceThrottle cancels a download, the
@@ -1042,7 +1016,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadResourceThrottleCancels) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
- CheckDownloadUI(browser(), false, false, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
// Verify that there's no pending download.
EXPECT_TRUE(EnsureNoPendingDownloads());
@@ -1065,11 +1039,9 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, ContentDisposition) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
- CheckDownloadUI(browser(), true, true, download_file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
}
-#if !defined(OS_CHROMEOS) || defined(USE_AURA)
-// Download shelf is not per-window on ChromeOS.
// Test that the download shelf is per-window by starting a download in one
// tab, opening a second tab, closing the shelf, going back to the first tab,
// and checking that the shelf is closed.
@@ -1086,29 +1058,27 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, PerWindowShelf) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
- CheckDownloadUI(browser(), true, true, download_file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
// Open a second tab and wait.
EXPECT_NE(static_cast<TabContentsWrapper*>(NULL),
browser()->AddSelectedTabWithURL(
GURL(), content::PAGE_TRANSITION_TYPED));
EXPECT_EQ(2, browser()->tab_count());
- CheckDownloadUI(browser(), true, true, download_file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
// Hide the download shelf.
browser()->window()->GetDownloadShelf()->Close();
- CheckDownloadUI(browser(), false, false, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
// Go to the first tab.
browser()->ActivateTabAt(0, true);
EXPECT_EQ(2, browser()->tab_count());
// The download shelf should not be visible.
- CheckDownloadUI(browser(), false, false, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
}
-#endif // !OS_CHROMEOS
-#if !defined(OS_CHROMEOS) || defined(USE_AURA)
// Check whether the downloads shelf is closed when the downloads tab is
// invoked.
IN_PROC_BROWSER_TEST_F(DownloadTest, CloseShelfOnDownloadsTab) {
@@ -1121,14 +1091,13 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CloseShelfOnDownloadsTab) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
// Open the downloads tab.
browser()->ShowDownloadsTab();
// The shelf should now be closed.
- CheckDownloadUI(browser(), false, false, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
}
-#endif
// UnknownSize and KnownSize are tests which depend on
// URLRequestSlowDownloadJob to serve content in a certain way. Data will be
@@ -1173,7 +1142,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) {
ExpectWindowCountAfterDownload(2);
// Verify that the download shelf is showing for the Incognito window.
- CheckDownloadUI(incognito, true, true, file);
+ CheckDownloadShelfVisibility(incognito, SHELF_VISIBLE);
#if !defined(OS_MACOSX)
// On Mac OS X, the UI window close is delayed until the outermost
@@ -1195,7 +1164,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) {
// Verify that the regular window does not have a download shelf.
// On ChromeOS, the download panel is common to both profiles, so
// it is still visible.
- CheckDownloadUI(browser(), false, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
CheckDownload(browser(), file, file);
}
@@ -1218,7 +1187,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DontCloseNewTab1) {
// We should have two tabs now.
EXPECT_EQ(2, browser()->tab_count());
- CheckDownloadUI(browser(), false, false, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
}
// Download a file in a background tab. Verify that the tab is closed
@@ -1238,7 +1207,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab1) {
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
// When the download finishes, we should still have one tab.
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
EXPECT_EQ(1, browser()->tab_count());
CheckDownload(browser(), file, file);
@@ -1270,7 +1239,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DontCloseNewTab2) {
ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
// When the download finishes, we should have two tabs.
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
EXPECT_EQ(2, browser()->tab_count());
CheckDownload(browser(), file, file);
@@ -1312,7 +1281,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DontCloseNewTab3) {
ui_test_utils::BROWSER_TEST_NONE);
// When the download finishes, we should have two tabs.
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
EXPECT_EQ(2, browser()->tab_count());
CheckDownload(browser(), file, file);
@@ -1345,7 +1314,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab2) {
ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
// When the download finishes, we should still have one tab.
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
EXPECT_EQ(1, browser()->tab_count());
CheckDownload(browser(), file, file);
@@ -1380,7 +1349,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab3) {
ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
// When the download finishes, we should still have one tab.
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
EXPECT_EQ(1, browser()->tab_count());
CheckDownload(browser(), file, file);
@@ -1414,7 +1383,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, NewWindow) {
ExpectWindowCountAfterDownload(2);
EXPECT_EQ(1, browser()->tab_count());
// Download shelf should close. Download panel stays open on ChromeOS.
- CheckDownloadUI(browser(), false, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
// The download shelf SHOULD be visible in the second window.
std::set<Browser*> original_browsers;
@@ -1424,7 +1393,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, NewWindow) {
ASSERT_TRUE(download_browser != NULL);
EXPECT_NE(download_browser, browser());
EXPECT_EQ(1, download_browser->tab_count());
- CheckDownloadUI(download_browser, true, true, file);
+ CheckDownloadShelfVisibility(download_browser, SHELF_VISIBLE);
#if !defined(OS_MACOSX)
// On Mac OS X, the UI window close is delayed until the outermost
@@ -1446,7 +1415,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, NewWindow) {
EXPECT_EQ(1, browser()->tab_count());
// Download shelf should close. Download panel stays open on ChromeOS.
- CheckDownloadUI(browser(), false, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
CheckDownload(browser(), file, file);
}
@@ -1470,7 +1439,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, MultiDownload) {
string16(), &downloads);
ASSERT_EQ(1u, downloads.size());
ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState());
- CheckDownloadUI(browser(), true, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
DownloadItem* download1 = downloads[0]; // The only download.
// Start the second download and wait until it's done.
@@ -1490,7 +1459,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, MultiDownload) {
ASSERT_EQ(DownloadItem::IN_PROGRESS, download1->GetState());
ASSERT_EQ(DownloadItem::COMPLETE, download2->GetState());
// The download shelf should be open.
- CheckDownloadUI(browser(), true, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
// Allow the first request to finish. We do this by loading a third URL
// in a separate tab.
@@ -1507,7 +1476,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, MultiDownload) {
// Get the important info from other threads and check it.
EXPECT_TRUE(EnsureNoPendingDownloads());
- CheckDownloadUI(browser(), true, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
// The |DownloadItem|s should now be done and have the final file names.
// Verify that the files have the expected data and size.
@@ -1556,7 +1525,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCancelled) {
string16(), &downloads);
ASSERT_EQ(1u, downloads.size());
ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState());
- CheckDownloadUI(browser(), true, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
// Cancel the download and wait for download system quiesce.
downloads[0]->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
@@ -1571,7 +1540,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCancelled) {
// Using "DownloadItem::Remove" follows the discard dangerous download path,
// which completely removes the browser from the shelf and closes the shelf
// if it was there. Download panel stays open on ChromeOS.
- CheckDownloadUI(browser(), false, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
}
// Confirm a download makes it into the history properly.
@@ -1595,7 +1564,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
CheckDownload(browser(), file, file);
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
// Check history results.
DownloadsHistoryDataCollector history_collector(
@@ -1718,7 +1687,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_AutoOpen) {
EXPECT_EQ(1, browser()->tab_count());
CheckDownload(browser(), file, file);
// Download shelf should close. Download panel stays open on ChromeOS.
- CheckDownloadUI(browser(), false, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
}
// Download an extension. Expect a dangerous download warning.
@@ -1738,7 +1707,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) {
EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen());
// Download shelf should close. Download panel stays open on ChromeOS.
- CheckDownloadUI(browser(), false, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
// Check that the CRX is not installed.
ExtensionService* extension_service =
@@ -1769,7 +1738,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) {
EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen());
// Download shelf should close. Download panel stays open on ChromeOS.
- CheckDownloadUI(browser(), false, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
// Check that the extension was not installed.
ExtensionService* extension_service =
@@ -1800,7 +1769,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) {
EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen());
// Download shelf should close. Download panel stays open on ChromeOS.
- CheckDownloadUI(browser(), false, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
// Check that the extension was installed.
ExtensionService* extension_service =
@@ -1858,7 +1827,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxLargeTheme) {
EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen());
// Download shelf should close. Download panel stays open on ChromeOS.
- CheckDownloadUI(browser(), false, true, FilePath());
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
// Check that the extension was installed.
ExtensionService* extension_service =
@@ -2028,7 +1997,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrl) {
// Check state.
EXPECT_EQ(1, browser()->tab_count());
ASSERT_TRUE(CheckDownload(browser(), file, file));
- CheckDownloadUI(browser(), true, true, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE);
}
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) {
@@ -2060,7 +2029,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) {
OriginFile(file)));
// Temporary downloads won't be visible.
- CheckDownloadUI(browser(), false, false, file);
+ CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN);
}
IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaGet) {

Powered by Google App Engine
This is Rietveld 408576698