Index: chrome/browser/download/download_browsertest.cc |
=================================================================== |
--- chrome/browser/download/download_browsertest.cc (revision 90234) |
+++ chrome/browser/download/download_browsertest.cc (working copy) |
@@ -608,7 +608,6 @@ |
int num_downloads, |
DownloadItem::DownloadState final_state, |
DangerousDownloadAction dangerous_download_action) { |
- |
achuithb
2011/06/24 00:10:06
Fix lint error.
|
DownloadManager* download_manager = |
browser->profile()->GetDownloadManager(); |
return new DownloadsObserver( |
@@ -757,6 +756,7 @@ |
FilePath basefilename(filename.BaseName()); |
net::FileURLToFilePath(url, &filename); |
FilePath download_path = downloads_directory_.path().Append(basefilename); |
+ CheckDownloadExistsInUI(browser, basefilename); |
bool downloaded_path_exists = file_util::PathExists(download_path); |
EXPECT_TRUE(downloaded_path_exists); |
@@ -776,6 +776,30 @@ |
manager->SearchDownloads(string16(), downloads); |
} |
+ void CheckDownloadExistsInUI(Browser* browser, |
+ const FilePath& file_path) { |
+#if defined(OS_CHROMEOS) |
+ Browser* popup = ActiveDownloadsUI::GetPopup(browser->profile()); |
+ DCHECK(popup); |
Paweł Hajdan Jr.
2011/06/24 08:36:33
No DCHECKs in test code. They crash the entire thi
achuithb
2011/06/24 21:08:53
Done.
|
+ ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( |
+ popup->GetSelectedTabContents()->web_ui()); |
+ DCHECK(downloads_ui); |
+ const ActiveDownloadsUI::DownloadList& downloads = |
+ downloads_ui->GetDownloads(); |
+ EXPECT_EQ(downloads.size(), size_t(1)); |
Paweł Hajdan Jr.
2011/06/24 08:36:33
nit: 1U instead of size_t(1).
achuithb
2011/06/24 21:08:53
Done.
|
+ |
+ FilePath download_path; |
+ FilePath full_path(DestinationFile(browser, file_path)); |
+ for (size_t i = 0; i < downloads.size(); ++i) { |
+ if (downloads[i]->full_path() == full_path) { |
+ download_path = full_path; |
+ break; |
+ } |
+ } |
+ EXPECT_EQ(full_path, download_path); |
+#endif |
Paweł Hajdan Jr.
2011/06/24 08:36:33
nit: // defined(OS_CHROMEOS)
achuithb
2011/06/24 21:08:53
There's now also an else clause for non-chromeos.
|
+ } |
+ |
// Figure out if the appropriate download visibility was done. A |
// utility function to support ChromeOS variations. |
static void CheckDownloadUIVisible(Browser* browser, |
@@ -940,6 +964,7 @@ |
EXPECT_EQ(1, browser()->tab_count()); |
CheckDownload(browser(), file, file); |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), file); |
} |
#if defined(OS_WIN) |
@@ -961,6 +986,7 @@ |
EXPECT_TRUE(file_util::HasInternetZoneIdentifier(downloaded_file)); |
CheckDownload(browser(), file, file); |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), file); |
} |
#endif |
@@ -1024,6 +1050,7 @@ |
// Check state. |
EXPECT_EQ(1, browser()->tab_count()); |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), download_file); |
} |
#if !defined(OS_CHROMEOS) // Download shelf is not per-window on ChromeOS. |
@@ -1044,12 +1071,14 @@ |
// Check state. |
EXPECT_EQ(1, browser()->tab_count()); |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), download_file); |
// Open a second tab and wait. |
EXPECT_NE(static_cast<TabContentsWrapper*>(NULL), |
browser()->AddSelectedTabWithURL(GURL(), PageTransition::TYPED)); |
EXPECT_EQ(2, browser()->tab_count()); |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), download_file); |
// Hide the download shelf. |
browser()->window()->GetDownloadShelf()->Close(); |
@@ -1109,6 +1138,7 @@ |
// Verify that the download shelf is showing for the Incognito window. |
CheckDownloadUIVisible(incognito, true, true); |
+ CheckDownloadExistsInUI(incognito, file); |
#if !defined(OS_MACOSX) |
// On Mac OS X, the UI window close is delayed until the outermost |
@@ -1131,6 +1161,7 @@ |
// On ChromeOS, the download panel is common to both profiles, so |
// it is still visible. |
CheckDownloadUIVisible(browser(), false, true); |
+ CheckDownloadExistsInUI(browser(), file); |
CheckDownload(browser(), file, file); |
} |
@@ -1174,6 +1205,7 @@ |
// When the download finishes, we should still have one tab. |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), file); |
EXPECT_EQ(1, browser()->tab_count()); |
CheckDownload(browser(), file, file); |
@@ -1206,6 +1238,7 @@ |
// When the download finishes, we should have two tabs. |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), file); |
EXPECT_EQ(2, browser()->tab_count()); |
CheckDownload(browser(), file, file); |
@@ -1248,6 +1281,7 @@ |
// When the download finishes, we should have two tabs. |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), file); |
EXPECT_EQ(2, browser()->tab_count()); |
CheckDownload(browser(), file, file); |
@@ -1281,6 +1315,7 @@ |
// When the download finishes, we should still have one tab. |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), file); |
EXPECT_EQ(1, browser()->tab_count()); |
CheckDownload(browser(), file, file); |
@@ -1316,6 +1351,7 @@ |
// When the download finishes, we should still have one tab. |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), file); |
EXPECT_EQ(1, browser()->tab_count()); |
CheckDownload(browser(), file, file); |
@@ -1348,8 +1384,9 @@ |
// the first window. |
ExpectWindowCountAfterDownload(2); |
EXPECT_EQ(1, browser()->tab_count()); |
- // Except on Chrome OS, where the download window sticks around. |
+ // Download shelf should close. Download panel stays open on ChromeOS. |
CheckDownloadUIVisible(browser(), false, true); |
+ CheckDownloadExistsInUI(browser(), file); |
// The download shelf SHOULD be visible in the second window. |
std::set<Browser*> original_browsers; |
@@ -1360,6 +1397,7 @@ |
EXPECT_NE(download_browser, browser()); |
EXPECT_EQ(1, download_browser->tab_count()); |
CheckDownloadUIVisible(download_browser, true, true); |
+ CheckDownloadExistsInUI(download_browser, file); |
#if !defined(OS_MACOSX) |
// On Mac OS X, the UI window close is delayed until the outermost |
@@ -1380,8 +1418,9 @@ |
#endif |
EXPECT_EQ(1, browser()->tab_count()); |
- // On ChromeOS, the popup sticks around. |
+ // Download shelf should close. Download panel stays open on ChromeOS. |
CheckDownloadUIVisible(browser(), false, true); |
+ CheckDownloadExistsInUI(browser(), file); |
CheckDownload(browser(), file, file); |
} |
@@ -1435,8 +1474,7 @@ |
// 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. Chrome OS is an exception to this, where if we |
- // bring up the downloads panel, it stays there. |
+ // if it was there. Download panel stays open on ChromeOS. |
CheckDownloadUIVisible(browser(), false, true); |
} |
@@ -1462,6 +1500,7 @@ |
EXPECT_EQ(1, browser()->tab_count()); |
CheckDownload(browser(), file, file); |
CheckDownloadUIVisible(browser(), true, true); |
+ CheckDownloadExistsInUI(browser(), file); |
// Check history results. |
DownloadsHistoryDataCollector history_collector( |
@@ -1559,9 +1598,9 @@ |
// As long as we're here, confirmed everything else is good. |
EXPECT_EQ(1, browser()->tab_count()); |
CheckDownload(browser(), file, file); |
- // Dissapears on most UIs, but the download panel sticks around for |
- // chrome os. |
+ // Download shelf should close. Download panel stays open on ChromeOS. |
CheckDownloadUIVisible(browser(), false, true); |
+ CheckDownloadExistsInUI(browser(), file); |
} |
// Download an extension. Expect a dangerous download warning. |
@@ -1580,6 +1619,7 @@ |
observer->WaitForFinished(); |
EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
+ // Download shelf should close. Download panel stays open on ChromeOS. |
CheckDownloadUIVisible(browser(), false, true); |
// Check that the CRX is not installed. |
@@ -1609,7 +1649,7 @@ |
observer->WaitForFinished(); |
EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
- // DL Shelf should close. Download panel sticks around on ChromeOS. |
+ // Download shelf should close. Download panel stays open on ChromeOS. |
CheckDownloadUIVisible(browser(), false, true); |
// Check that the extension was not installed. |
@@ -1639,7 +1679,7 @@ |
observer->WaitForFinished(); |
EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
- // DL Shelf should close. Download panel sticks around on ChromeOS. |
+ // Download shelf should close. Download panel stays open on ChromeOS. |
CheckDownloadUIVisible(browser(), false, true); |
// Check that the extension was installed. |
@@ -1695,7 +1735,7 @@ |
observer->WaitForFinished(); |
EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
- // DL Shelf should close. Download panel sticks around on ChromeOS. |
+ // Download shelf should close. Download panel stays open on ChromeOS. |
CheckDownloadUIVisible(browser(), false, true); |
// Check that the extension was installed. |