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

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

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 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
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/file_util.h" 10 #include "base/file_util.h"
(...skipping 25 matching lines...) Expand all
36 #include "chrome/browser/download/download_shelf.h" 36 #include "chrome/browser/download/download_shelf.h"
37 #include "chrome/browser/download/download_target_determiner.h" 37 #include "chrome/browser/download/download_target_determiner.h"
38 #include "chrome/browser/download/download_test_file_activity_observer.h" 38 #include "chrome/browser/download/download_test_file_activity_observer.h"
39 #include "chrome/browser/extensions/extension_install_prompt.h" 39 #include "chrome/browser/extensions/extension_install_prompt.h"
40 #include "chrome/browser/extensions/extension_service.h" 40 #include "chrome/browser/extensions/extension_service.h"
41 #include "chrome/browser/history/download_row.h" 41 #include "chrome/browser/history/download_row.h"
42 #include "chrome/browser/history/history_service.h" 42 #include "chrome/browser/history/history_service.h"
43 #include "chrome/browser/history/history_service_factory.h" 43 #include "chrome/browser/history/history_service_factory.h"
44 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 44 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
45 #include "chrome/browser/infobars/infobar.h" 45 #include "chrome/browser/infobars/infobar.h"
46 #include "chrome/browser/infobars/infobar_manager.h"
46 #include "chrome/browser/infobars/infobar_service.h" 47 #include "chrome/browser/infobars/infobar_service.h"
47 #include "chrome/browser/net/url_request_mock_util.h" 48 #include "chrome/browser/net/url_request_mock_util.h"
48 #include "chrome/browser/profiles/profile.h" 49 #include "chrome/browser/profiles/profile.h"
49 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h" 50 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h"
50 #include "chrome/browser/ui/browser.h" 51 #include "chrome/browser/ui/browser.h"
51 #include "chrome/browser/ui/browser_commands.h" 52 #include "chrome/browser/ui/browser_commands.h"
52 #include "chrome/browser/ui/browser_finder.h" 53 #include "chrome/browser/ui/browser_finder.h"
53 #include "chrome/browser/ui/browser_list.h" 54 #include "chrome/browser/ui/browser_list.h"
54 #include "chrome/browser/ui/browser_tabstrip.h" 55 #include "chrome/browser/ui/browser_tabstrip.h"
55 #include "chrome/browser/ui/browser_window.h" 56 #include "chrome/browser/ui/browser_window.h"
(...skipping 2727 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 2784
2784 // Create an infobar observer. 2785 // Create an infobar observer.
2785 content::WindowedNotificationObserver infobar_added_1( 2786 content::WindowedNotificationObserver infobar_added_1(
2786 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 2787 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
2787 content::NotificationService::AllSources()); 2788 content::NotificationService::AllSources());
2788 ui_test_utils::NavigateToURL( 2789 ui_test_utils::NavigateToURL(
2789 browser(), 2790 browser(),
2790 test_server()->GetURL("files/downloads/download-a_zip_file.html")); 2791 test_server()->GetURL("files/downloads/download-a_zip_file.html"));
2791 infobar_added_1.Wait(); 2792 infobar_added_1.Wait();
2792 2793
2793 InfoBarService* infobar_service = InfoBarService::FromWebContents( 2794 InfoBarManager& infobar_manager =
2794 browser()->tab_strip_model()->GetActiveWebContents()); 2795 InfoBarService::FromWebContents(
2796 browser()->tab_strip_model()->GetActiveWebContents())
2797 ->infobar_manager();
2795 // Verify that there is only one infobar. 2798 // Verify that there is only one infobar.
2796 ASSERT_EQ(1u, infobar_service->infobar_count()); 2799 ASSERT_EQ(1u, infobar_manager.infobar_count());
2797 2800
2798 // Get the infobar at index 0. 2801 // Get the infobar at index 0.
2799 InfoBar* infobar = infobar_service->infobar_at(0); 2802 InfoBar* infobar = infobar_manager.infobar_at(0);
2800 ConfirmInfoBarDelegate* confirm_infobar = 2803 ConfirmInfoBarDelegate* confirm_infobar =
2801 infobar->delegate()->AsConfirmInfoBarDelegate(); 2804 infobar->delegate()->AsConfirmInfoBarDelegate();
2802 ASSERT_TRUE(confirm_infobar != NULL); 2805 ASSERT_TRUE(confirm_infobar != NULL);
2803 2806
2804 // Verify multi download warning infobar message. 2807 // Verify multi download warning infobar message.
2805 EXPECT_EQ(confirm_infobar->GetMessageText(), 2808 EXPECT_EQ(confirm_infobar->GetMessageText(),
2806 l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING)); 2809 l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING));
2807 2810
2808 // Click on the "Allow" button to allow multiple downloads. 2811 // Click on the "Allow" button to allow multiple downloads.
2809 if (confirm_infobar->Accept()) 2812 if (confirm_infobar->Accept())
2810 infobar_service->RemoveInfoBar(infobar); 2813 infobar_manager.RemoveInfoBar(infobar);
2811 // Verify that there are no more infobars. 2814 // Verify that there are no more infobars.
2812 EXPECT_EQ(0u, infobar_service->infobar_count()); 2815 EXPECT_EQ(0u, infobar_manager.infobar_count());
2813 2816
2814 // Waits for the download to complete. 2817 // Waits for the download to complete.
2815 downloads_observer->WaitForFinished(); 2818 downloads_observer->WaitForFinished();
2816 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState( 2819 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState(
2817 DownloadItem::COMPLETE)); 2820 DownloadItem::COMPLETE));
2818 } 2821 }
2819 2822
2820 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) { 2823 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) {
2821 ASSERT_TRUE(test_server()->Start()); 2824 ASSERT_TRUE(test_server()->Start());
2822 GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip")); 2825 GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip"));
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
3225 3228
3226 // No errors this time. The download should complete successfully. 3229 // No errors this time. The download should complete successfully.
3227 EXPECT_FALSE(completion_observer->IsFinished()); 3230 EXPECT_FALSE(completion_observer->IsFinished());
3228 completion_observer->StartObserving(); 3231 completion_observer->StartObserving();
3229 download->Resume(); 3232 download->Resume();
3230 completion_observer->WaitForFinished(); 3233 completion_observer->WaitForFinished();
3231 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); 3234 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState());
3232 3235
3233 EXPECT_FALSE(DidShowFileChooser()); 3236 EXPECT_FALSE(DidShowFileChooser());
3234 } 3237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698