Commit 3d63f87a authored by felt's avatar felt Committed by Commit bot

Add new test: DownloadTest.TestMultipleDownloadsBubble

This ensures that both infobars and bubbles are tested by creating both
DownloadTest.TestMultipleDownloadsInfobar and DownloadTest.
TestMultipleDownloadsBubble. The correct UI (infobar or bubble) is
forced with a switch.

BUG=438758

Committed: https://crrev.com/ff5eb76821e76cb6c90b940249caf3d748e6fbc0
Cr-Commit-Position: refs/heads/master@{#318987}

Review URL: https://codereview.chromium.org/976823002

Cr-Commit-Position: refs/heads/master@{#319164}
parent d1401a5e
......@@ -56,7 +56,10 @@
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/website_settings/mock_permission_bubble_view.h"
#include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/safe_browsing/csd.pb.h"
#include "chrome/common/url_constants.h"
......@@ -1090,6 +1093,12 @@ class DownloadTest : public InProcessBrowserTest {
return download;
}
void WaitForBubble(MockPermissionBubbleView* mock_bubble) {
if (mock_bubble->IsVisible())
return;
content::RunMessageLoop();
}
private:
static void EnsureNoPendingDownloadJobsOnIO(bool* result) {
if (net::URLRequestSlowDownloadJob::NumberOutstandingRequests())
......@@ -2892,6 +2901,10 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsInfobar) {
ASSERT_TRUE(test_server()->Start());
// Ensure that infobars are being used instead of bubbles.
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisablePermissionsBubbles);
// Create a downloads observer.
scoped_ptr<content::DownloadTestObserver> downloads_observer(
CreateWaiter(browser(), 2));
......@@ -2932,6 +2945,53 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsInfobar) {
DownloadItem::COMPLETE));
}
IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsBubble) {
#if defined(OS_WIN) && defined(USE_ASH)
// Disable this test in Metro+Ash for now (http://crbug.com/262796).
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshBrowserTests))
return;
#endif
#if defined(OS_ANDROID) || defined(OS_IOS)
// Permission bubbles are not supported on mobile.
return;
#endif
ASSERT_TRUE(test_server()->Start());
// Enable permision bubbles.
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnablePermissionsBubbles);
// Create a downloads observer.
scoped_ptr<content::DownloadTestObserver> downloads_observer(
CreateWaiter(browser(), 2));
MockPermissionBubbleView* mock_bubble_view = new MockPermissionBubbleView();
PermissionBubbleManager::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents())->
SetView(mock_bubble_view);
mock_bubble_view->SetBrowserTest(true);
ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
browser(),
test_server()->GetURL("files/downloads/download-a_zip_file.html"), 1);
WaitForBubble(mock_bubble_view);
ASSERT_TRUE(mock_bubble_view->IsVisible());
mock_bubble_view->Accept();
ASSERT_FALSE(mock_bubble_view->IsVisible());
// Waits for the download to complete.
downloads_observer->WaitForFinished();
EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState(
DownloadItem::COMPLETE));
browser()->tab_strip_model()->GetActiveWebContents()->Close();
delete mock_bubble_view;
}
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) {
ASSERT_TRUE(test_server()->Start());
GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment