OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 #include "chrome/browser/download/download_shelf.h" | 37 #include "chrome/browser/download/download_shelf.h" |
38 #include "chrome/browser/download/download_target_determiner.h" | 38 #include "chrome/browser/download/download_target_determiner.h" |
39 #include "chrome/browser/download/download_test_file_activity_observer.h" | 39 #include "chrome/browser/download/download_test_file_activity_observer.h" |
40 #include "chrome/browser/extensions/extension_install_prompt.h" | 40 #include "chrome/browser/extensions/extension_install_prompt.h" |
41 #include "chrome/browser/extensions/extension_service.h" | 41 #include "chrome/browser/extensions/extension_service.h" |
42 #include "chrome/browser/history/download_row.h" | 42 #include "chrome/browser/history/download_row.h" |
43 #include "chrome/browser/history/history_service.h" | 43 #include "chrome/browser/history/history_service.h" |
44 #include "chrome/browser/history/history_service_factory.h" | 44 #include "chrome/browser/history/history_service_factory.h" |
45 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 45 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
46 #include "chrome/browser/infobars/infobar.h" | 46 #include "chrome/browser/infobars/infobar.h" |
47 #include "chrome/browser/infobars/infobar_manager.h" | |
48 #include "chrome/browser/infobars/infobar_service.h" | 47 #include "chrome/browser/infobars/infobar_service.h" |
49 #include "chrome/browser/net/url_request_mock_util.h" | 48 #include "chrome/browser/net/url_request_mock_util.h" |
50 #include "chrome/browser/profiles/profile.h" | 49 #include "chrome/browser/profiles/profile.h" |
51 #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" |
52 #include "chrome/browser/ui/browser.h" | 51 #include "chrome/browser/ui/browser.h" |
53 #include "chrome/browser/ui/browser_commands.h" | 52 #include "chrome/browser/ui/browser_commands.h" |
54 #include "chrome/browser/ui/browser_finder.h" | 53 #include "chrome/browser/ui/browser_finder.h" |
55 #include "chrome/browser/ui/browser_list.h" | 54 #include "chrome/browser/ui/browser_list.h" |
56 #include "chrome/browser/ui/browser_tabstrip.h" | 55 #include "chrome/browser/ui/browser_tabstrip.h" |
57 #include "chrome/browser/ui/browser_window.h" | 56 #include "chrome/browser/ui/browser_window.h" |
(...skipping 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2786 content::WindowedNotificationObserver infobar_added_1( | 2785 content::WindowedNotificationObserver infobar_added_1( |
2787 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 2786 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
2788 content::NotificationService::AllSources()); | 2787 content::NotificationService::AllSources()); |
2789 ui_test_utils::NavigateToURL( | 2788 ui_test_utils::NavigateToURL( |
2790 browser(), | 2789 browser(), |
2791 test_server()->GetURL("files/downloads/download-a_zip_file.html")); | 2790 test_server()->GetURL("files/downloads/download-a_zip_file.html")); |
2792 infobar_added_1.Wait(); | 2791 infobar_added_1.Wait(); |
2793 | 2792 |
2794 InfoBarService* infobar_service = InfoBarService::FromWebContents( | 2793 InfoBarService* infobar_service = InfoBarService::FromWebContents( |
2795 browser()->tab_strip_model()->GetActiveWebContents()); | 2794 browser()->tab_strip_model()->GetActiveWebContents()); |
2796 InfoBarManager* infobar_manager = infobar_service->infobar_manager(); | |
2797 // Verify that there is only one infobar. | 2795 // Verify that there is only one infobar. |
2798 ASSERT_EQ(1u, infobar_manager->infobar_count()); | 2796 ASSERT_EQ(1u, infobar_service->infobar_count()); |
2799 | 2797 |
2800 // Get the infobar at index 0. | 2798 // Get the infobar at index 0. |
2801 InfoBar* infobar = infobar_manager->infobar_at(0); | 2799 InfoBar* infobar = infobar_service->infobar_at(0); |
2802 ConfirmInfoBarDelegate* confirm_infobar = | 2800 ConfirmInfoBarDelegate* confirm_infobar = |
2803 infobar->delegate()->AsConfirmInfoBarDelegate(); | 2801 infobar->delegate()->AsConfirmInfoBarDelegate(); |
2804 ASSERT_TRUE(confirm_infobar != NULL); | 2802 ASSERT_TRUE(confirm_infobar != NULL); |
2805 | 2803 |
2806 // Verify multi download warning infobar message. | 2804 // Verify multi download warning infobar message. |
2807 EXPECT_EQ(confirm_infobar->GetMessageText(), | 2805 EXPECT_EQ(confirm_infobar->GetMessageText(), |
2808 l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING)); | 2806 l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING)); |
2809 | 2807 |
2810 // Click on the "Allow" button to allow multiple downloads. | 2808 // Click on the "Allow" button to allow multiple downloads. |
2811 if (confirm_infobar->Accept()) | 2809 if (confirm_infobar->Accept()) |
2812 infobar_manager->RemoveInfoBar(infobar); | 2810 infobar_service->RemoveInfoBar(infobar); |
2813 // Verify that there are no more infobars. | 2811 // Verify that there are no more infobars. |
2814 EXPECT_EQ(0u, infobar_manager->infobar_count()); | 2812 EXPECT_EQ(0u, infobar_service->infobar_count()); |
2815 | 2813 |
2816 // Waits for the download to complete. | 2814 // Waits for the download to complete. |
2817 downloads_observer->WaitForFinished(); | 2815 downloads_observer->WaitForFinished(); |
2818 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState( | 2816 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState( |
2819 DownloadItem::COMPLETE)); | 2817 DownloadItem::COMPLETE)); |
2820 } | 2818 } |
2821 | 2819 |
2822 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) { | 2820 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) { |
2823 ASSERT_TRUE(test_server()->Start()); | 2821 ASSERT_TRUE(test_server()->Start()); |
2824 GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip")); | 2822 GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip")); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3207 | 3205 |
3208 // No errors this time. The download should complete successfully. | 3206 // No errors this time. The download should complete successfully. |
3209 EXPECT_FALSE(completion_observer->IsFinished()); | 3207 EXPECT_FALSE(completion_observer->IsFinished()); |
3210 completion_observer->StartObserving(); | 3208 completion_observer->StartObserving(); |
3211 download->Resume(); | 3209 download->Resume(); |
3212 completion_observer->WaitForFinished(); | 3210 completion_observer->WaitForFinished(); |
3213 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); | 3211 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); |
3214 | 3212 |
3215 EXPECT_FALSE(DidShowFileChooser()); | 3213 EXPECT_FALSE(DidShowFileChooser()); |
3216 } | 3214 } |
OLD | NEW |