| Index: chrome/browser/download/download_browsertest.cc
|
| diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
|
| index 054feae2f4029dc1233e4a41a3cf7169c184bb2b..0432efae0feb0fedbd1b5cd48be7388f7c7122d4 100644
|
| --- a/chrome/browser/download/download_browsertest.cc
|
| +++ b/chrome/browser/download/download_browsertest.cc
|
| @@ -20,6 +20,7 @@
|
| #include "chrome/browser/download/download_service.h"
|
| #include "chrome/browser/download/download_service_factory.h"
|
| #include "chrome/browser/download/download_shelf.h"
|
| +#include "chrome/browser/download/download_test_observer.h"
|
| #include "chrome/browser/download/download_util.h"
|
| #include "chrome/browser/extensions/extension_install_ui.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| @@ -717,39 +718,39 @@ class DownloadTest : public InProcessBrowserTest {
|
| return GetDownloadPrefs(browser)->download_path();
|
| }
|
|
|
| - // Create a DownloadsObserver that will wait for the
|
| + // Create a DownloadTestObserver that will wait for the
|
| // specified number of downloads to finish.
|
| - DownloadsObserver* CreateWaiter(Browser* browser, int num_downloads) {
|
| + DownloadTestObserver* CreateWaiter(Browser* browser, int num_downloads) {
|
| DownloadManager* download_manager = DownloadManagerForBrowser(browser);
|
| - return new DownloadsObserver(
|
| + return new DownloadTestObserver(
|
| download_manager, num_downloads,
|
| DownloadItem::COMPLETE, // Really done
|
| - true, // Bail on select file
|
| - ON_DANGEROUS_DOWNLOAD_FAIL);
|
| + true, // Bail on select file
|
| + DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL);
|
| }
|
|
|
| - // Create a DownloadsObserver that will wait for the
|
| + // Create a DownloadTestObserver that will wait for the
|
| // specified number of downloads to start.
|
| - DownloadsObserver* CreateInProgressWaiter(Browser* browser,
|
| + DownloadTestObserver* CreateInProgressWaiter(Browser* browser,
|
| int num_downloads) {
|
| DownloadManager* download_manager = DownloadManagerForBrowser(browser);
|
| - return new DownloadsObserver(
|
| + return new DownloadTestObserver(
|
| download_manager, num_downloads,
|
| DownloadItem::IN_PROGRESS, // Has started
|
| true, // Bail on select file
|
| - ON_DANGEROUS_DOWNLOAD_FAIL);
|
| + DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL);
|
| }
|
|
|
| - // Create a DownloadsObserver that will wait for the
|
| + // Create a DownloadTestObserver that will wait for the
|
| // specified number of downloads to finish, or for
|
| // a dangerous download warning to be shown.
|
| - DownloadsObserver* DangerousInstallWaiter(
|
| + DownloadTestObserver* DangerousInstallWaiter(
|
| Browser* browser,
|
| int num_downloads,
|
| DownloadItem::DownloadState final_state,
|
| - DangerousDownloadAction dangerous_download_action) {
|
| + DownloadTestObserver::DangerousDownloadAction dangerous_download_action) {
|
| DownloadManager* download_manager = DownloadManagerForBrowser(browser);
|
| - return new DownloadsObserver(
|
| + return new DownloadTestObserver(
|
| download_manager, num_downloads,
|
| final_state,
|
| true, // Bail on select file
|
| @@ -771,7 +772,7 @@ class DownloadTest : public InProcessBrowserTest {
|
| SelectExpectation expectation,
|
| int browser_test_flags) {
|
| // Setup notification, navigate, and block.
|
| - scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser, 1));
|
| + scoped_ptr<DownloadTestObserver> observer(CreateWaiter(browser, 1));
|
| // This call will block until the condition specified by
|
| // |browser_test_flags|, but will not wait for the download to finish.
|
| ui_test_utils::NavigateToURLWithDisposition(browser,
|
| @@ -862,7 +863,7 @@ class DownloadTest : public InProcessBrowserTest {
|
|
|
| // Download a partial web page in a background tab and wait.
|
| // The mock system will not complete until it gets a special URL.
|
| - scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser, 1));
|
| + scoped_ptr<DownloadTestObserver> observer(CreateWaiter(browser, 1));
|
| ui_test_utils::NavigateToURL(browser, url);
|
|
|
| // TODO(ahendrickson): check download status text before downloading.
|
| @@ -1037,13 +1038,13 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) {
|
|
|
| // Download the file and wait. We expect the Select File dialog to appear
|
| // due to the MIME type, but we still wait until the download completes.
|
| - scoped_ptr<DownloadsObserver> observer(
|
| - new DownloadsObserver(
|
| + scoped_ptr<DownloadTestObserver> observer(
|
| + new DownloadTestObserver(
|
| DownloadManagerForBrowser(browser()),
|
| 1,
|
| DownloadItem::COMPLETE, // Really done
|
| false, // Continue on select file.
|
| - ON_DANGEROUS_DOWNLOAD_FAIL));
|
| + DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
|
| ui_test_utils::NavigateToURLWithDisposition(
|
| browser(), url, CURRENT_TAB,
|
| ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
|
| @@ -1461,11 +1462,11 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCancelled) {
|
| EXPECT_EQ(1, browser()->tab_count());
|
|
|
| // TODO(rdsmith): Fragile code warning! The code below relies on the
|
| - // DownloadsObserver only finishing when the new download has reached
|
| + // DownloadTestObserver only finishing when the new download has reached
|
| // the state of being entered into the history and being user-visible
|
| // (that's what's required for the Remove to be valid and for the
|
| // download shelf to be visible). By the pure semantics of
|
| - // DownloadsObserver, that's not guaranteed; DownloadItems are created
|
| + // DownloadTestObserver, that's not guaranteed; DownloadItems are created
|
| // in the IN_PROGRESS state and made known to the DownloadManager
|
| // immediately, so any ModelChanged event on the DownloadManager after
|
| // navigation would allow the observer to return. However, the only
|
| @@ -1478,7 +1479,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCancelled) {
|
|
|
| // Create a download, wait until it's started, and confirm
|
| // we're in the expected state.
|
| - scoped_ptr<DownloadsObserver> observer(
|
| + scoped_ptr<DownloadTestObserver> observer(
|
| CreateInProgressWaiter(browser(), 1));
|
| ui_test_utils::NavigateToURL(
|
| browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl));
|
| @@ -1493,8 +1494,9 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCancelled) {
|
|
|
| // Cancel the download and wait for download system quiesce.
|
| downloads[0]->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
|
| - scoped_refptr<DownloadsFlushObserver> flush_observer(
|
| - new DownloadsFlushObserver(DownloadManagerForBrowser(browser())));
|
| + scoped_refptr<DownloadTestFlushObserver> flush_observer(
|
| + new DownloadTestFlushObserver(
|
| + DownloadManagerForBrowser(browser())));
|
| flush_observer->WaitForFlush();
|
|
|
| // Get the important info from other threads and check it.
|
| @@ -1608,7 +1610,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, AnchorDownloadTag) {
|
|
|
| // Create a download, wait until it's complete, and confirm
|
| // we're in the expected state.
|
| - scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser(), 1));
|
| + scoped_ptr<DownloadTestObserver> observer(CreateWaiter(browser(), 1));
|
| ui_test_utils::NavigateToURL(browser(), url);
|
| observer->WaitForFinished();
|
|
|
| @@ -1654,11 +1656,10 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) {
|
| ASSERT_TRUE(InitialSetup(false));
|
| GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath));
|
|
|
| - scoped_ptr<DownloadsObserver> observer(
|
| - DangerousInstallWaiter(browser(),
|
| - 1,
|
| - DownloadItem::CANCELLED,
|
| - ON_DANGEROUS_DOWNLOAD_DENY));
|
| + scoped_ptr<DownloadTestObserver> observer(
|
| + DangerousInstallWaiter(
|
| + browser(), 1, DownloadItem::CANCELLED,
|
| + DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
|
| ui_test_utils::NavigateToURL(browser(), extension_url);
|
|
|
| observer->WaitForFinished();
|
| @@ -1684,11 +1685,10 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) {
|
| download_crx_util::SetMockInstallUIForTesting(
|
| new MockAbortExtensionInstallUI());
|
|
|
| - scoped_ptr<DownloadsObserver> observer(
|
| - DangerousInstallWaiter(browser(),
|
| - 1,
|
| - DownloadItem::COMPLETE,
|
| - ON_DANGEROUS_DOWNLOAD_ACCEPT));
|
| + scoped_ptr<DownloadTestObserver> observer(
|
| + DangerousInstallWaiter(
|
| + browser(), 1, DownloadItem::COMPLETE,
|
| + DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
|
| ui_test_utils::NavigateToURL(browser(), extension_url);
|
|
|
| observer->WaitForFinished();
|
| @@ -1714,11 +1714,10 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) {
|
| download_crx_util::SetMockInstallUIForTesting(
|
| new MockAutoConfirmExtensionInstallUI(browser()->profile()));
|
|
|
| - scoped_ptr<DownloadsObserver> observer(
|
| - DangerousInstallWaiter(browser(),
|
| - 1,
|
| - DownloadItem::COMPLETE,
|
| - ON_DANGEROUS_DOWNLOAD_ACCEPT));
|
| + scoped_ptr<DownloadTestObserver> observer(
|
| + DangerousInstallWaiter(
|
| + browser(), 1, DownloadItem::COMPLETE,
|
| + DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
|
| ui_test_utils::NavigateToURL(browser(), extension_url);
|
|
|
| observer->WaitForFinished();
|
| @@ -1745,11 +1744,10 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInvalid) {
|
| download_crx_util::SetMockInstallUIForTesting(
|
| new MockAutoConfirmExtensionInstallUI(browser()->profile()));
|
|
|
| - scoped_ptr<DownloadsObserver> observer(
|
| - DangerousInstallWaiter(browser(),
|
| - 1,
|
| - DownloadItem::COMPLETE,
|
| - ON_DANGEROUS_DOWNLOAD_ACCEPT));
|
| + scoped_ptr<DownloadTestObserver> observer(
|
| + DangerousInstallWaiter(
|
| + browser(), 1, DownloadItem::COMPLETE,
|
| + DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
|
| ui_test_utils::NavigateToURL(browser(), extension_url);
|
|
|
| observer->WaitForFinished();
|
| @@ -1770,11 +1768,10 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxLargeTheme) {
|
| download_crx_util::SetMockInstallUIForTesting(
|
| new MockAutoConfirmExtensionInstallUI(browser()->profile()));
|
|
|
| - scoped_ptr<DownloadsObserver> observer(
|
| - DangerousInstallWaiter(browser(),
|
| - 1,
|
| - DownloadItem::COMPLETE,
|
| - ON_DANGEROUS_DOWNLOAD_ACCEPT));
|
| + scoped_ptr<DownloadTestObserver> observer(
|
| + DangerousInstallWaiter(
|
| + browser(), 1, DownloadItem::COMPLETE,
|
| + DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
|
| ui_test_utils::NavigateToURL(browser(), extension_url);
|
|
|
| observer->WaitForFinished();
|
|
|