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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 2674 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
2675 content::NotificationService::AllSources()); | 2675 content::NotificationService::AllSources()); |
2676 ui_test_utils::NavigateToURL( | 2676 ui_test_utils::NavigateToURL( |
2677 browser(), | 2677 browser(), |
2678 test_server()->GetURL("files/downloads/download-a_zip_file.html")); | 2678 test_server()->GetURL("files/downloads/download-a_zip_file.html")); |
2679 infobar_added_1.Wait(); | 2679 infobar_added_1.Wait(); |
2680 | 2680 |
2681 InfoBarService* infobar_service = InfoBarService::FromWebContents( | 2681 InfoBarService* infobar_service = InfoBarService::FromWebContents( |
2682 browser()->tab_strip_model()->GetActiveWebContents()); | 2682 browser()->tab_strip_model()->GetActiveWebContents()); |
2683 // Verify that there is only one infobar. | 2683 // Verify that there is only one infobar. |
2684 EXPECT_EQ(1u, infobar_service->GetInfoBarCount()); | 2684 ASSERT_EQ(1u, infobar_service->infobar_count()); |
2685 | 2685 |
2686 // Get the infobar at index 0. | 2686 // Get the infobar at index 0. |
2687 int infobar_index = 0; | 2687 InfoBarDelegate* infobar = infobar_service->infobar_at(0); |
2688 InfoBarDelegate* infobar = | 2688 ASSERT_TRUE(infobar != NULL); |
2689 infobar_service->GetInfoBarDelegateAt(infobar_index); | |
2690 EXPECT_TRUE(infobar != NULL); | |
2691 | 2689 |
2692 ConfirmInfoBarDelegate* confirm_infobar = | 2690 ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate(); |
2693 infobar->AsConfirmInfoBarDelegate(); | 2691 ASSERT_TRUE(confirm_infobar != NULL); |
2694 EXPECT_TRUE(confirm_infobar != NULL); | |
2695 | 2692 |
2696 // Verify multi download warning infobar message. | 2693 // Verify multi download warning infobar message. |
2697 EXPECT_EQ(confirm_infobar->GetMessageText(), | 2694 EXPECT_EQ(confirm_infobar->GetMessageText(), |
2698 l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING)); | 2695 l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING)); |
2699 | 2696 |
2700 // Click on the "Allow" button to allow multiple downloads. | 2697 // Click on the "Allow" button to allow multiple downloads. |
2701 if (confirm_infobar->Accept()) | 2698 if (confirm_infobar->Accept()) |
2702 infobar_service->RemoveInfoBar(infobar); | 2699 infobar_service->RemoveInfoBar(infobar); |
2703 // Verify that there are no more infobars. | 2700 // Verify that there are no more infobars. |
2704 EXPECT_EQ(0u, infobar_service->GetInfoBarCount()); | 2701 EXPECT_EQ(0u, infobar_service->infobar_count()); |
2705 | 2702 |
2706 // Waits for the download to complete. | 2703 // Waits for the download to complete. |
2707 downloads_observer->WaitForFinished(); | 2704 downloads_observer->WaitForFinished(); |
2708 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState( | 2705 EXPECT_EQ(2u, downloads_observer->NumDownloadsSeenInState( |
2709 DownloadItem::COMPLETE)); | 2706 DownloadItem::COMPLETE)); |
2710 } | 2707 } |
2711 | 2708 |
2712 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) { | 2709 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) { |
2713 ASSERT_TRUE(test_server()->Start()); | 2710 ASSERT_TRUE(test_server()->Start()); |
2714 GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip")); | 2711 GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip")); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2927 scoped_ptr<content::DownloadTestObserver> observer( | 2924 scoped_ptr<content::DownloadTestObserver> observer( |
2928 DangerousDownloadWaiter( | 2925 DangerousDownloadWaiter( |
2929 browser(), 1, | 2926 browser(), 1, |
2930 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 2927 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
2931 ui_test_utils::NavigateToURL(browser(), url); | 2928 ui_test_utils::NavigateToURL(browser(), url); |
2932 observer->WaitForFinished(); | 2929 observer->WaitForFinished(); |
2933 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); | 2930 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); |
2934 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 2931 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
2935 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2932 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
2936 } | 2933 } |
OLD | NEW |