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

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 1322033003: Stop compiling dead download infobar code on desktop Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gn Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/download/OWNERS ('k') | chrome/browser/download/download_request_limiter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 GetDownloads(browser(), &download_items); 2746 GetDownloads(browser(), &download_items);
2747 EXPECT_TRUE(DidShowFileChooser()); 2747 EXPECT_TRUE(DidShowFileChooser());
2748 ASSERT_EQ(1u, download_items.size()); 2748 ASSERT_EQ(1u, download_items.size());
2749 ASSERT_EQ(img_url, download_items[0]->GetOriginalUrl()); 2749 ASSERT_EQ(img_url, download_items[0]->GetOriginalUrl());
2750 base::FilePath file = download_items[0]->GetTargetFilePath(); 2750 base::FilePath file = download_items[0]->GetTargetFilePath();
2751 // The contents of the file is the value of the Referer header if there was 2751 // The contents of the file is the value of the Referer header if there was
2752 // one. 2752 // one.
2753 EXPECT_TRUE(VerifyFile(file, "", 0)); 2753 EXPECT_TRUE(VerifyFile(file, "", 0));
2754 } 2754 }
2755 2755
2756 // Verify the multiple downloads infobar. 2756 // On mobile, the multiple downloads UI is an infobar. On desktop, it's a
2757 // bubble. Test each as appropriate.
2758 #if defined(OS_ANDROID) || defined(OS_IOS)
2757 IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsInfobar) { 2759 IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsInfobar) {
2758 #if defined(OS_WIN) && defined(USE_ASH)
2759 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
2760 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2761 switches::kAshBrowserTests))
2762 return;
2763 #endif
2764
2765 // Ensure that infobars are being used instead of bubbles. 2760 // Ensure that infobars are being used instead of bubbles.
2766 base::CommandLine::ForCurrentProcess()->AppendSwitch( 2761 base::CommandLine::ForCurrentProcess()->AppendSwitch(
2767 switches::kDisablePermissionsBubbles); 2762 switches::kDisablePermissionsBubbles);
2768 2763
2769 // Create a downloads observer. 2764 // Create a downloads observer.
2770 scoped_ptr<content::DownloadTestObserver> downloads_observer( 2765 scoped_ptr<content::DownloadTestObserver> downloads_observer(
2771 CreateWaiter(browser(), 2)); 2766 CreateWaiter(browser(), 2));
2772 2767
2773 // Create an infobar observer. 2768 // Create an infobar observer.
2774 content::WindowedNotificationObserver infobar_added_1( 2769 content::WindowedNotificationObserver infobar_added_1(
(...skipping 23 matching lines...) Expand all
2798 if (confirm_infobar->Accept()) 2793 if (confirm_infobar->Accept())
2799 infobar_service->RemoveInfoBar(infobar); 2794 infobar_service->RemoveInfoBar(infobar);
2800 // Verify that there are no more infobars. 2795 // Verify that there are no more infobars.
2801 EXPECT_EQ(0u, infobar_service->infobar_count()); 2796 EXPECT_EQ(0u, infobar_service->infobar_count());
2802 2797
2803 // Waits for the download to complete. 2798 // Waits for the download to complete.
2804 downloads_observer->WaitForFinished(); 2799 downloads_observer->WaitForFinished();
2805 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState( 2800 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState(
2806 DownloadItem::COMPLETE)); 2801 DownloadItem::COMPLETE));
2807 } 2802 }
2808 2803 #else
2809 IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsBubble) { 2804 IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsBubble) {
2810 #if defined(OS_WIN) && defined(USE_ASH) 2805 #if defined(OS_WIN) && defined(USE_ASH)
2811 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 2806 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
2812 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2807 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2813 switches::kAshBrowserTests)) 2808 switches::kAshBrowserTests))
2814 return; 2809 return;
2815 #endif 2810 #endif
2816 2811
2817 #if defined(OS_ANDROID) || defined(OS_IOS)
2818 // Permission bubbles are not supported on mobile.
2819 return;
2820 #endif
2821
2822 // Enable permision bubbles. 2812 // Enable permision bubbles.
2823 base::CommandLine::ForCurrentProcess()->AppendSwitch( 2813 base::CommandLine::ForCurrentProcess()->AppendSwitch(
2824 switches::kEnablePermissionsBubbles); 2814 switches::kEnablePermissionsBubbles);
2825 2815
2826 // Create a downloads observer. 2816 // Create a downloads observer.
2827 scoped_ptr<content::DownloadTestObserver> downloads_observer( 2817 scoped_ptr<content::DownloadTestObserver> downloads_observer(
2828 CreateWaiter(browser(), 2)); 2818 CreateWaiter(browser(), 2));
2829 2819
2830 PermissionBubbleManager* permission_bubble_manager = 2820 PermissionBubbleManager* permission_bubble_manager =
2831 PermissionBubbleManager::FromWebContents( 2821 PermissionBubbleManager::FromWebContents(
2832 browser()->tab_strip_model()->GetActiveWebContents()); 2822 browser()->tab_strip_model()->GetActiveWebContents());
2833 permission_bubble_manager->DisplayPendingRequests(browser()); 2823 permission_bubble_manager->DisplayPendingRequests(browser());
2834 permission_bubble_manager->set_auto_response_for_test( 2824 permission_bubble_manager->set_auto_response_for_test(
2835 PermissionBubbleManager::ACCEPT_ALL); 2825 PermissionBubbleManager::ACCEPT_ALL);
2836 2826
2837 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 2827 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
2838 browser(), net::URLRequestMockHTTPJob::GetMockUrl( 2828 browser(), net::URLRequestMockHTTPJob::GetMockUrl(
2839 "downloads/download-a_zip_file.html"), 2829 "downloads/download-a_zip_file.html"),
2840 1); 2830 1);
2841 2831
2842 // Waits for the download to complete. 2832 // Waits for the download to complete.
2843 downloads_observer->WaitForFinished(); 2833 downloads_observer->WaitForFinished();
2844 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState( 2834 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState(
2845 DownloadItem::COMPLETE)); 2835 DownloadItem::COMPLETE));
2846 2836
2847 browser()->tab_strip_model()->GetActiveWebContents()->Close(); 2837 browser()->tab_strip_model()->GetActiveWebContents()->Close();
2848 } 2838 }
2839 #endif
2849 2840
2850 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) { 2841 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) {
2851 GURL url = net::URLRequestMockHTTPJob::GetMockUrl("downloads/a_zip_file.zip"); 2842 GURL url = net::URLRequestMockHTTPJob::GetMockUrl("downloads/a_zip_file.zip");
2852 content::DownloadManager* manager = DownloadManagerForBrowser(browser()); 2843 content::DownloadManager* manager = DownloadManagerForBrowser(browser());
2853 base::FilePath origin_file(OriginFile(base::FilePath(FILE_PATH_LITERAL( 2844 base::FilePath origin_file(OriginFile(base::FilePath(FILE_PATH_LITERAL(
2854 "downloads/a_zip_file.zip")))); 2845 "downloads/a_zip_file.zip"))));
2855 ASSERT_TRUE(base::PathExists(origin_file)); 2846 ASSERT_TRUE(base::PathExists(origin_file));
2856 std::string origin_contents; 2847 std::string origin_contents;
2857 ASSERT_TRUE(base::ReadFileToString(origin_file, &origin_contents)); 2848 ASSERT_TRUE(base::ReadFileToString(origin_file, &origin_contents));
2858 2849
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
3655 3646
3656 scoped_ptr<content::DownloadTestObserver> observer(DangerousDownloadWaiter( 3647 scoped_ptr<content::DownloadTestObserver> observer(DangerousDownloadWaiter(
3657 browser(), 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 3648 browser(), 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
3658 ui_test_utils::NavigateToURL(browser(), extension_url); 3649 ui_test_utils::NavigateToURL(browser(), extension_url);
3659 3650
3660 observer->WaitForFinished(); 3651 observer->WaitForFinished();
3661 3652
3662 // Download shelf should close. 3653 // Download shelf should close.
3663 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3654 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3664 } 3655 }
OLDNEW
« no previous file with comments | « chrome/browser/download/OWNERS ('k') | chrome/browser/download/download_request_limiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698