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

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

Issue 976823002: Add new test: DownloadTest.TestMultipleDownloadsBubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wait until bubble is shown Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_browsertest.cc
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index a8094005950ed44ead25bfb0061782d6102a8bca..ca8338af30a0bf81ab5fe02cb93340c8511f6068 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -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"));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698