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_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 #include "chrome/browser/extensions/extension_install_ui.h" | 32 #include "chrome/browser/extensions/extension_install_ui.h" |
33 #include "chrome/browser/extensions/extension_service.h" | 33 #include "chrome/browser/extensions/extension_service.h" |
34 #include "chrome/browser/history/history.h" | 34 #include "chrome/browser/history/history.h" |
35 #include "chrome/browser/net/url_request_mock_util.h" | 35 #include "chrome/browser/net/url_request_mock_util.h" |
36 #include "chrome/browser/prefs/pref_service.h" | 36 #include "chrome/browser/prefs/pref_service.h" |
37 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
38 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 38 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
39 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
40 #include "chrome/browser/ui/browser_list.h" | 40 #include "chrome/browser/ui/browser_list.h" |
41 #include "chrome/browser/ui/browser_window.h" | 41 #include "chrome/browser/ui/browser_window.h" |
42 #include "chrome/browser/ui/webui/chromeos/active_downloads_ui.h" | |
43 #include "chrome/common/chrome_notification_types.h" | 42 #include "chrome/common/chrome_notification_types.h" |
44 #include "chrome/common/chrome_paths.h" | 43 #include "chrome/common/chrome_paths.h" |
45 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
46 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
47 #include "chrome/test/base/in_process_browser_test.h" | 46 #include "chrome/test/base/in_process_browser_test.h" |
48 #include "chrome/test/base/ui_test_utils.h" | 47 #include "chrome/test/base/ui_test_utils.h" |
49 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
50 #include "content/public/browser/download_item.h" | 49 #include "content/public/browser/download_item.h" |
51 #include "content/public/browser/download_manager.h" | 50 #include "content/public/browser/download_manager.h" |
52 #include "content/public/browser/download_persistent_store_info.h" | 51 #include "content/public/browser/download_persistent_store_info.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 EXPECT_NOTHING, | 242 EXPECT_NOTHING, |
244 EXPECT_SELECT_DIALOG | 243 EXPECT_SELECT_DIALOG |
245 }; | 244 }; |
246 | 245 |
247 // Choice of navigation or direct fetch. Used by |DownloadFileCheckErrors()|. | 246 // Choice of navigation or direct fetch. Used by |DownloadFileCheckErrors()|. |
248 enum DownloadMethod { | 247 enum DownloadMethod { |
249 DOWNLOAD_NAVIGATE, | 248 DOWNLOAD_NAVIGATE, |
250 DOWNLOAD_DIRECT | 249 DOWNLOAD_DIRECT |
251 }; | 250 }; |
252 | 251 |
252 // State of download shelf. | |
253 enum DownloadShelfVisibility { | |
254 SHELF_HIDDEN, | |
255 SHELF_VISIBLE | |
256 }; | |
257 | |
253 // Information passed in to |DownloadFileCheckErrors()|. | 258 // Information passed in to |DownloadFileCheckErrors()|. |
254 struct DownloadInfo { | 259 struct DownloadInfo { |
255 const char* url_name; // URL for the download. | 260 const char* url_name; // URL for the download. |
256 DownloadMethod download_method; // Navigation or Direct. | 261 DownloadMethod download_method; // Navigation or Direct. |
257 // Download interrupt reason (NONE is OK). | 262 // Download interrupt reason (NONE is OK). |
258 content::DownloadInterruptReason reason; | 263 content::DownloadInterruptReason reason; |
259 bool show_download_item; // True if the download item appears on the shelf. | 264 bool show_download_item; // True if the download item appears on the shelf. |
260 bool should_redirect_to_documents; // True if we save it in "My Documents". | 265 bool should_redirect_to_documents; // True if we save it in "My Documents". |
261 }; | 266 }; |
262 | 267 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 549 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
545 CheckDownloadStatesForBrowser(browser, 1, DownloadItem::COMPLETE); | 550 CheckDownloadStatesForBrowser(browser, 1, DownloadItem::COMPLETE); |
546 | 551 |
547 EXPECT_EQ(2, browser->tab_count()); | 552 EXPECT_EQ(2, browser->tab_count()); |
548 | 553 |
549 // TODO(ahendrickson): check download status text after downloading. | 554 // TODO(ahendrickson): check download status text after downloading. |
550 | 555 |
551 FilePath basefilename(filename.BaseName()); | 556 FilePath basefilename(filename.BaseName()); |
552 net::FileURLToFilePath(url, &filename); | 557 net::FileURLToFilePath(url, &filename); |
553 FilePath download_path = downloads_directory_.path().Append(basefilename); | 558 FilePath download_path = downloads_directory_.path().Append(basefilename); |
554 CheckDownloadUI(browser, true, true, basefilename); | 559 CheckDownloadShelfVisibility(browser, SHELF_VISIBLE); |
555 | 560 |
556 bool downloaded_path_exists = file_util::PathExists(download_path); | 561 bool downloaded_path_exists = file_util::PathExists(download_path); |
557 EXPECT_TRUE(downloaded_path_exists); | 562 EXPECT_TRUE(downloaded_path_exists); |
558 if (!downloaded_path_exists) | 563 if (!downloaded_path_exists) |
559 return false; | 564 return false; |
560 | 565 |
561 // Check the file contents. | 566 // Check the file contents. |
562 size_t file_size = URLRequestSlowDownloadJob::kFirstDownloadSize + | 567 size_t file_size = URLRequestSlowDownloadJob::kFirstDownloadSize + |
563 URLRequestSlowDownloadJob::kSecondDownloadSize; | 568 URLRequestSlowDownloadJob::kSecondDownloadSize; |
564 std::string expected_contents(file_size, '*'); | 569 std::string expected_contents(file_size, '*'); |
565 EXPECT_TRUE(VerifyFile(download_path, expected_contents, file_size)); | 570 EXPECT_TRUE(VerifyFile(download_path, expected_contents, file_size)); |
566 | 571 |
567 // Delete the file we just downloaded. | 572 // Delete the file we just downloaded. |
568 EXPECT_TRUE(file_util::DieFileDie(download_path, true)); | 573 EXPECT_TRUE(file_util::DieFileDie(download_path, true)); |
569 EXPECT_FALSE(file_util::PathExists(download_path)); | 574 EXPECT_FALSE(file_util::PathExists(download_path)); |
570 | 575 |
571 return true; | 576 return true; |
572 } | 577 } |
573 | 578 |
574 void GetDownloads(Browser* browser, std::vector<DownloadItem*>* downloads) { | 579 void GetDownloads(Browser* browser, std::vector<DownloadItem*>* downloads) { |
575 DCHECK(downloads); | 580 DCHECK(downloads); |
576 DownloadManager* manager = DownloadManagerForBrowser(browser); | 581 DownloadManager* manager = DownloadManagerForBrowser(browser); |
577 manager->SearchDownloads(string16(), downloads); | 582 manager->SearchDownloads(string16(), downloads); |
578 } | 583 } |
579 | 584 |
580 // Check that the download UI (shelf on non-chromeos or panel on chromeos) | 585 // Check that the download shelf is visible or not as expected. |
581 // is visible or not as expected. Additionally, check that the filename | 586 void CheckDownloadShelfVisibility(Browser* browser, |
achuithb
2012/04/16 14:27:05
Not sure if this function and the enum is worth it
asanka
2012/04/17 20:02:25
Done.
| |
582 // is present in the UI (currently only on chromeos). | 587 DownloadShelfVisibility expected) { |
583 void CheckDownloadUI(Browser* browser, bool expected_non_cros, | 588 EXPECT_EQ((expected == SHELF_VISIBLE), |
584 bool expected_cros, const FilePath& filename) { | 589 browser->window()->IsDownloadShelfVisible()); |
585 #if defined(OS_CHROMEOS) && !defined(USE_AURA) | |
586 Browser* popup = ActiveDownloadsUI::GetPopup(); | |
587 EXPECT_EQ(expected_cros, popup != NULL); | |
588 if (!popup || filename.empty()) | |
589 return; | |
590 | |
591 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( | |
592 popup->GetSelectedWebContents()->GetWebUI()->GetController()); | |
593 | |
594 ASSERT_TRUE(downloads_ui); | |
595 const ActiveDownloadsUI::DownloadList& downloads = | |
596 downloads_ui->GetDownloads(); | |
597 EXPECT_EQ(downloads.size(), 1U); | |
598 | |
599 FilePath full_path(DestinationFile(browser, filename)); | |
600 bool exists = false; | |
601 for (size_t i = 0; i < downloads.size(); ++i) { | |
602 if (downloads[i]->GetFullPath() == full_path) { | |
603 exists = true; | |
604 break; | |
605 } | |
606 } | |
607 EXPECT_TRUE(exists); | |
608 #else | |
609 EXPECT_EQ(expected_non_cros, browser->window()->IsDownloadShelfVisible()); | |
610 // TODO: Check for filename match in download shelf. | 590 // TODO: Check for filename match in download shelf. |
611 #endif | |
612 } | 591 } |
613 static void ExpectWindowCountAfterDownload(size_t expected) { | 592 static void ExpectWindowCountAfterDownload(size_t expected) { |
614 #if defined(OS_CHROMEOS) && !defined(USE_AURA) | |
615 // On ChromeOS, a download panel is created to display | |
616 // download information, and this counts as a window. | |
617 expected++; | |
618 #endif | |
619 EXPECT_EQ(expected, BrowserList::size()); | 593 EXPECT_EQ(expected, BrowserList::size()); |
620 } | 594 } |
621 | 595 |
622 // Arrange for select file calls on the given browser from the | 596 // Arrange for select file calls on the given browser from the |
623 // download manager to always choose the suggested file. | 597 // download manager to always choose the suggested file. |
624 void NullSelectFile(Browser* browser) { | 598 void NullSelectFile(Browser* browser) { |
625 PickSuggestedFileDelegate* new_delegate = | 599 PickSuggestedFileDelegate* new_delegate = |
626 new PickSuggestedFileDelegate(browser->profile()); | 600 new PickSuggestedFileDelegate(browser->profile()); |
627 | 601 |
628 // Gives ownership to DownloadService. | 602 // Gives ownership to DownloadService. |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 ASSERT_TRUE(InitialSetup(false)); | 882 ASSERT_TRUE(InitialSetup(false)); |
909 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 883 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
910 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 884 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
911 | 885 |
912 // Download the file and wait. We do not expect the Select File dialog. | 886 // Download the file and wait. We do not expect the Select File dialog. |
913 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 887 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); |
914 | 888 |
915 // Check state. | 889 // Check state. |
916 EXPECT_EQ(1, browser()->tab_count()); | 890 EXPECT_EQ(1, browser()->tab_count()); |
917 CheckDownload(browser(), file, file); | 891 CheckDownload(browser(), file, file); |
918 CheckDownloadUI(browser(), true, true, file); | 892 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
919 } | 893 } |
920 | 894 |
921 #if defined(OS_WIN) | 895 #if defined(OS_WIN) |
922 // Download a file and confirm that the zone identifier (on windows) | 896 // Download a file and confirm that the zone identifier (on windows) |
923 // is set to internet. | 897 // is set to internet. |
924 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckInternetZone) { | 898 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckInternetZone) { |
925 ASSERT_TRUE(InitialSetup(false)); | 899 ASSERT_TRUE(InitialSetup(false)); |
926 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 900 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
927 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 901 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
928 | 902 |
929 // Download the file and wait. We do not expect the Select File dialog. | 903 // Download the file and wait. We do not expect the Select File dialog. |
930 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 904 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); |
931 | 905 |
932 // Check state. Special file state must be checked before CheckDownload, | 906 // Check state. Special file state must be checked before CheckDownload, |
933 // as CheckDownload will delete the output file. | 907 // as CheckDownload will delete the output file. |
934 EXPECT_EQ(1, browser()->tab_count()); | 908 EXPECT_EQ(1, browser()->tab_count()); |
935 FilePath downloaded_file(DestinationFile(browser(), file)); | 909 FilePath downloaded_file(DestinationFile(browser(), file)); |
936 if (file_util::VolumeSupportsADS(downloaded_file)) | 910 if (file_util::VolumeSupportsADS(downloaded_file)) |
937 EXPECT_TRUE(file_util::HasInternetZoneIdentifier(downloaded_file)); | 911 EXPECT_TRUE(file_util::HasInternetZoneIdentifier(downloaded_file)); |
938 CheckDownload(browser(), file, file); | 912 CheckDownload(browser(), file, file); |
939 CheckDownloadUI(browser(), true, true, file); | 913 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
940 } | 914 } |
941 #endif | 915 #endif |
942 | 916 |
943 // Put up a Select File dialog when the file is downloaded, due to | 917 // Put up a Select File dialog when the file is downloaded, due to |
944 // downloads preferences settings. | 918 // downloads preferences settings. |
945 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) { | 919 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) { |
946 ASSERT_TRUE(InitialSetup(true)); | 920 ASSERT_TRUE(InitialSetup(true)); |
947 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 921 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
948 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 922 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
949 | 923 |
(...skipping 11 matching lines...) Expand all Loading... | |
961 browser(), url, CURRENT_TAB, | 935 browser(), url, CURRENT_TAB, |
962 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 936 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
963 observer->WaitForFinished(); | 937 observer->WaitForFinished(); |
964 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 938 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
965 CheckDownloadStates(1, DownloadItem::COMPLETE); | 939 CheckDownloadStates(1, DownloadItem::COMPLETE); |
966 EXPECT_TRUE(observer->select_file_dialog_seen()); | 940 EXPECT_TRUE(observer->select_file_dialog_seen()); |
967 | 941 |
968 // Check state. | 942 // Check state. |
969 EXPECT_EQ(1, browser()->tab_count()); | 943 EXPECT_EQ(1, browser()->tab_count()); |
970 CheckDownload(browser(), file, file); | 944 CheckDownload(browser(), file, file); |
971 CheckDownloadUI(browser(), true, true, file); | 945 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
972 } | 946 } |
973 | 947 |
974 // Access a file with a viewable mime-type, verify that a download | 948 // Access a file with a viewable mime-type, verify that a download |
975 // did not initiate. | 949 // did not initiate. |
976 IN_PROC_BROWSER_TEST_F(DownloadTest, NoDownload) { | 950 IN_PROC_BROWSER_TEST_F(DownloadTest, NoDownload) { |
977 ASSERT_TRUE(InitialSetup(false)); | 951 ASSERT_TRUE(InitialSetup(false)); |
978 FilePath file(FILE_PATH_LITERAL("download-test2.html")); | 952 FilePath file(FILE_PATH_LITERAL("download-test2.html")); |
979 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 953 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
980 FilePath file_path(DestinationFile(browser(), file)); | 954 FilePath file_path(DestinationFile(browser(), file)); |
981 | 955 |
982 // Open a web page and wait. | 956 // Open a web page and wait. |
983 ui_test_utils::NavigateToURL(browser(), url); | 957 ui_test_utils::NavigateToURL(browser(), url); |
984 | 958 |
985 // Check that we did not download the web page. | 959 // Check that we did not download the web page. |
986 EXPECT_FALSE(file_util::PathExists(file_path)); | 960 EXPECT_FALSE(file_util::PathExists(file_path)); |
987 | 961 |
988 // Check state. | 962 // Check state. |
989 EXPECT_EQ(1, browser()->tab_count()); | 963 EXPECT_EQ(1, browser()->tab_count()); |
990 CheckDownloadUI(browser(), false, false, FilePath()); | 964 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
991 } | 965 } |
992 | 966 |
993 // Verify that when the DownloadResourceThrottle cancels a download, the | 967 // Verify that when the DownloadResourceThrottle cancels a download, the |
994 // download never makes it to the downloads system. | 968 // download never makes it to the downloads system. |
995 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadResourceThrottleCancels) { | 969 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadResourceThrottleCancels) { |
996 ASSERT_TRUE(InitialSetup(false)); | 970 ASSERT_TRUE(InitialSetup(false)); |
997 | 971 |
998 // Navigate to a page with the same domain as the file to download. We can't | 972 // Navigate to a page with the same domain as the file to download. We can't |
999 // navigate directly to the file we don't want to download because cross-site | 973 // navigate directly to the file we don't want to download because cross-site |
1000 // navigations reset the TabDownloadState. | 974 // navigations reset the TabDownloadState. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1035 base::Bind(&MessageLoop::Quit, | 1009 base::Bind(&MessageLoop::Quit, |
1036 base::Unretained(MessageLoopForUI::current()))); | 1010 base::Unretained(MessageLoopForUI::current()))); |
1037 | 1011 |
1038 // Check that we did not download the file. | 1012 // Check that we did not download the file. |
1039 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1013 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1040 FilePath file_path(DestinationFile(browser(), file)); | 1014 FilePath file_path(DestinationFile(browser(), file)); |
1041 EXPECT_FALSE(file_util::PathExists(file_path)); | 1015 EXPECT_FALSE(file_util::PathExists(file_path)); |
1042 | 1016 |
1043 // Check state. | 1017 // Check state. |
1044 EXPECT_EQ(1, browser()->tab_count()); | 1018 EXPECT_EQ(1, browser()->tab_count()); |
1045 CheckDownloadUI(browser(), false, false, FilePath()); | 1019 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1046 | 1020 |
1047 // Verify that there's no pending download. | 1021 // Verify that there's no pending download. |
1048 EXPECT_TRUE(EnsureNoPendingDownloads()); | 1022 EXPECT_TRUE(EnsureNoPendingDownloads()); |
1049 } | 1023 } |
1050 | 1024 |
1051 // Download a 0-size file with a content-disposition header, verify that the | 1025 // Download a 0-size file with a content-disposition header, verify that the |
1052 // download tab opened and the file exists as the filename specified in the | 1026 // download tab opened and the file exists as the filename specified in the |
1053 // header. This also ensures we properly handle empty file downloads. | 1027 // header. This also ensures we properly handle empty file downloads. |
1054 // The download shelf should be visible in the current tab. | 1028 // The download shelf should be visible in the current tab. |
1055 IN_PROC_BROWSER_TEST_F(DownloadTest, ContentDisposition) { | 1029 IN_PROC_BROWSER_TEST_F(DownloadTest, ContentDisposition) { |
1056 ASSERT_TRUE(InitialSetup(false)); | 1030 ASSERT_TRUE(InitialSetup(false)); |
1057 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); | 1031 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); |
1058 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1032 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1059 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); | 1033 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); |
1060 | 1034 |
1061 // Download a file and wait. | 1035 // Download a file and wait. |
1062 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1036 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); |
1063 | 1037 |
1064 CheckDownload(browser(), download_file, file); | 1038 CheckDownload(browser(), download_file, file); |
1065 | 1039 |
1066 // Check state. | 1040 // Check state. |
1067 EXPECT_EQ(1, browser()->tab_count()); | 1041 EXPECT_EQ(1, browser()->tab_count()); |
1068 CheckDownloadUI(browser(), true, true, download_file); | 1042 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1069 } | 1043 } |
1070 | 1044 |
1071 #if !defined(OS_CHROMEOS) || defined(USE_AURA) | |
1072 // Download shelf is not per-window on ChromeOS. | |
1073 // Test that the download shelf is per-window by starting a download in one | 1045 // Test that the download shelf is per-window by starting a download in one |
1074 // tab, opening a second tab, closing the shelf, going back to the first tab, | 1046 // tab, opening a second tab, closing the shelf, going back to the first tab, |
1075 // and checking that the shelf is closed. | 1047 // and checking that the shelf is closed. |
1076 IN_PROC_BROWSER_TEST_F(DownloadTest, PerWindowShelf) { | 1048 IN_PROC_BROWSER_TEST_F(DownloadTest, PerWindowShelf) { |
1077 ASSERT_TRUE(InitialSetup(false)); | 1049 ASSERT_TRUE(InitialSetup(false)); |
1078 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); | 1050 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); |
1079 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1051 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1080 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); | 1052 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); |
1081 | 1053 |
1082 // Download a file and wait. | 1054 // Download a file and wait. |
1083 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1055 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); |
1084 | 1056 |
1085 CheckDownload(browser(), download_file, file); | 1057 CheckDownload(browser(), download_file, file); |
1086 | 1058 |
1087 // Check state. | 1059 // Check state. |
1088 EXPECT_EQ(1, browser()->tab_count()); | 1060 EXPECT_EQ(1, browser()->tab_count()); |
1089 CheckDownloadUI(browser(), true, true, download_file); | 1061 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1090 | 1062 |
1091 // Open a second tab and wait. | 1063 // Open a second tab and wait. |
1092 EXPECT_NE(static_cast<TabContentsWrapper*>(NULL), | 1064 EXPECT_NE(static_cast<TabContentsWrapper*>(NULL), |
1093 browser()->AddSelectedTabWithURL( | 1065 browser()->AddSelectedTabWithURL( |
1094 GURL(), content::PAGE_TRANSITION_TYPED)); | 1066 GURL(), content::PAGE_TRANSITION_TYPED)); |
1095 EXPECT_EQ(2, browser()->tab_count()); | 1067 EXPECT_EQ(2, browser()->tab_count()); |
1096 CheckDownloadUI(browser(), true, true, download_file); | 1068 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1097 | 1069 |
1098 // Hide the download shelf. | 1070 // Hide the download shelf. |
1099 browser()->window()->GetDownloadShelf()->Close(); | 1071 browser()->window()->GetDownloadShelf()->Close(); |
1100 CheckDownloadUI(browser(), false, false, FilePath()); | 1072 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1101 | 1073 |
1102 // Go to the first tab. | 1074 // Go to the first tab. |
1103 browser()->ActivateTabAt(0, true); | 1075 browser()->ActivateTabAt(0, true); |
1104 EXPECT_EQ(2, browser()->tab_count()); | 1076 EXPECT_EQ(2, browser()->tab_count()); |
1105 | 1077 |
1106 // The download shelf should not be visible. | 1078 // The download shelf should not be visible. |
1107 CheckDownloadUI(browser(), false, false, FilePath()); | 1079 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1108 } | 1080 } |
1109 #endif // !OS_CHROMEOS | |
1110 | 1081 |
1111 #if !defined(OS_CHROMEOS) || defined(USE_AURA) | |
1112 // Check whether the downloads shelf is closed when the downloads tab is | 1082 // Check whether the downloads shelf is closed when the downloads tab is |
1113 // invoked. | 1083 // invoked. |
1114 IN_PROC_BROWSER_TEST_F(DownloadTest, CloseShelfOnDownloadsTab) { | 1084 IN_PROC_BROWSER_TEST_F(DownloadTest, CloseShelfOnDownloadsTab) { |
1115 ASSERT_TRUE(InitialSetup(false)); | 1085 ASSERT_TRUE(InitialSetup(false)); |
1116 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1086 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1117 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1087 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1118 | 1088 |
1119 // Download the file and wait. We do not expect the Select File dialog. | 1089 // Download the file and wait. We do not expect the Select File dialog. |
1120 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1090 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); |
1121 | 1091 |
1122 // Check state. | 1092 // Check state. |
1123 EXPECT_EQ(1, browser()->tab_count()); | 1093 EXPECT_EQ(1, browser()->tab_count()); |
1124 CheckDownloadUI(browser(), true, true, file); | 1094 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1125 | 1095 |
1126 // Open the downloads tab. | 1096 // Open the downloads tab. |
1127 browser()->ShowDownloadsTab(); | 1097 browser()->ShowDownloadsTab(); |
1128 // The shelf should now be closed. | 1098 // The shelf should now be closed. |
1129 CheckDownloadUI(browser(), false, false, FilePath()); | 1099 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1130 } | 1100 } |
1131 #endif | |
1132 | 1101 |
1133 // UnknownSize and KnownSize are tests which depend on | 1102 // UnknownSize and KnownSize are tests which depend on |
1134 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be | 1103 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be |
1135 // sent in two chunks where the first chunk is 35K and the second chunk is 10K. | 1104 // sent in two chunks where the first chunk is 35K and the second chunk is 10K. |
1136 // The test will first attempt to download a file; but the server will "pause" | 1105 // The test will first attempt to download a file; but the server will "pause" |
1137 // in the middle until the server receives a second request for | 1106 // in the middle until the server receives a second request for |
1138 // "download-finish". At that time, the download will finish. | 1107 // "download-finish". At that time, the download will finish. |
1139 // These tests don't currently test much due to holes in |RunSizeTest()|. See | 1108 // These tests don't currently test much due to holes in |RunSizeTest()|. See |
1140 // comments in that routine for details. | 1109 // comments in that routine for details. |
1141 IN_PROC_BROWSER_TEST_F(DownloadTest, UnknownSize) { | 1110 IN_PROC_BROWSER_TEST_F(DownloadTest, UnknownSize) { |
(...skipping 24 matching lines...) Expand all Loading... | |
1166 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1135 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1167 // Since |incognito| is a separate browser, we have to set it up explicitly. | 1136 // Since |incognito| is a separate browser, we have to set it up explicitly. |
1168 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, | 1137 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, |
1169 false); | 1138 false); |
1170 DownloadAndWait(incognito, url, EXPECT_NO_SELECT_DIALOG); | 1139 DownloadAndWait(incognito, url, EXPECT_NO_SELECT_DIALOG); |
1171 | 1140 |
1172 // We should still have 2 windows. | 1141 // We should still have 2 windows. |
1173 ExpectWindowCountAfterDownload(2); | 1142 ExpectWindowCountAfterDownload(2); |
1174 | 1143 |
1175 // Verify that the download shelf is showing for the Incognito window. | 1144 // Verify that the download shelf is showing for the Incognito window. |
1176 CheckDownloadUI(incognito, true, true, file); | 1145 CheckDownloadShelfVisibility(incognito, SHELF_VISIBLE); |
1177 | 1146 |
1178 #if !defined(OS_MACOSX) | 1147 #if !defined(OS_MACOSX) |
1179 // On Mac OS X, the UI window close is delayed until the outermost | 1148 // On Mac OS X, the UI window close is delayed until the outermost |
1180 // message loop runs. So it isn't possible to get a BROWSER_CLOSED | 1149 // message loop runs. So it isn't possible to get a BROWSER_CLOSED |
1181 // notification inside of a test. | 1150 // notification inside of a test. |
1182 ui_test_utils::WindowedNotificationObserver signal( | 1151 ui_test_utils::WindowedNotificationObserver signal( |
1183 chrome::NOTIFICATION_BROWSER_CLOSED, | 1152 chrome::NOTIFICATION_BROWSER_CLOSED, |
1184 content::Source<Browser>(incognito)); | 1153 content::Source<Browser>(incognito)); |
1185 #endif | 1154 #endif |
1186 | 1155 |
1187 // Close the Incognito window and don't crash. | 1156 // Close the Incognito window and don't crash. |
1188 incognito->CloseWindow(); | 1157 incognito->CloseWindow(); |
1189 | 1158 |
1190 #if !defined(OS_MACOSX) | 1159 #if !defined(OS_MACOSX) |
1191 signal.Wait(); | 1160 signal.Wait(); |
1192 ExpectWindowCountAfterDownload(1); | 1161 ExpectWindowCountAfterDownload(1); |
1193 #endif | 1162 #endif |
1194 | 1163 |
1195 // Verify that the regular window does not have a download shelf. | 1164 // Verify that the regular window does not have a download shelf. |
1196 // On ChromeOS, the download panel is common to both profiles, so | 1165 // On ChromeOS, the download panel is common to both profiles, so |
1197 // it is still visible. | 1166 // it is still visible. |
1198 CheckDownloadUI(browser(), false, true, file); | 1167 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1199 | 1168 |
1200 CheckDownload(browser(), file, file); | 1169 CheckDownload(browser(), file, file); |
1201 } | 1170 } |
1202 | 1171 |
1203 // Navigate to a new background page, but don't download. Confirm that the | 1172 // Navigate to a new background page, but don't download. Confirm that the |
1204 // download shelf is not visible and that we have two tabs. | 1173 // download shelf is not visible and that we have two tabs. |
1205 IN_PROC_BROWSER_TEST_F(DownloadTest, DontCloseNewTab1) { | 1174 IN_PROC_BROWSER_TEST_F(DownloadTest, DontCloseNewTab1) { |
1206 ASSERT_TRUE(InitialSetup(false)); | 1175 ASSERT_TRUE(InitialSetup(false)); |
1207 // Because it's an HTML link, it should open a web page rather than | 1176 // Because it's an HTML link, it should open a web page rather than |
1208 // downloading. | 1177 // downloading. |
1209 FilePath file1(FILE_PATH_LITERAL("download-test2.html")); | 1178 FilePath file1(FILE_PATH_LITERAL("download-test2.html")); |
1210 GURL url(URLRequestMockHTTPJob::GetMockUrl(file1)); | 1179 GURL url(URLRequestMockHTTPJob::GetMockUrl(file1)); |
1211 | 1180 |
1212 // Open a web page and wait. | 1181 // Open a web page and wait. |
1213 ui_test_utils::NavigateToURLWithDisposition( | 1182 ui_test_utils::NavigateToURLWithDisposition( |
1214 browser(), | 1183 browser(), |
1215 url, | 1184 url, |
1216 NEW_BACKGROUND_TAB, | 1185 NEW_BACKGROUND_TAB, |
1217 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1186 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1218 | 1187 |
1219 // We should have two tabs now. | 1188 // We should have two tabs now. |
1220 EXPECT_EQ(2, browser()->tab_count()); | 1189 EXPECT_EQ(2, browser()->tab_count()); |
1221 CheckDownloadUI(browser(), false, false, FilePath()); | 1190 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1222 } | 1191 } |
1223 | 1192 |
1224 // Download a file in a background tab. Verify that the tab is closed | 1193 // Download a file in a background tab. Verify that the tab is closed |
1225 // automatically, and that the download shelf is visible in the current tab. | 1194 // automatically, and that the download shelf is visible in the current tab. |
1226 IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab1) { | 1195 IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab1) { |
1227 ASSERT_TRUE(InitialSetup(false)); | 1196 ASSERT_TRUE(InitialSetup(false)); |
1228 | 1197 |
1229 // Download a file in a new background tab and wait. The tab is automatically | 1198 // Download a file in a new background tab and wait. The tab is automatically |
1230 // closed when the download begins. | 1199 // closed when the download begins. |
1231 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1200 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1232 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1201 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1233 DownloadAndWaitWithDisposition( | 1202 DownloadAndWaitWithDisposition( |
1234 browser(), | 1203 browser(), |
1235 url, | 1204 url, |
1236 NEW_BACKGROUND_TAB, | 1205 NEW_BACKGROUND_TAB, |
1237 EXPECT_NO_SELECT_DIALOG, | 1206 EXPECT_NO_SELECT_DIALOG, |
1238 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1207 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1239 | 1208 |
1240 // When the download finishes, we should still have one tab. | 1209 // When the download finishes, we should still have one tab. |
1241 CheckDownloadUI(browser(), true, true, file); | 1210 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1242 EXPECT_EQ(1, browser()->tab_count()); | 1211 EXPECT_EQ(1, browser()->tab_count()); |
1243 | 1212 |
1244 CheckDownload(browser(), file, file); | 1213 CheckDownload(browser(), file, file); |
1245 } | 1214 } |
1246 | 1215 |
1247 // Open a web page in the current tab, then download a file in another tab via | 1216 // Open a web page in the current tab, then download a file in another tab via |
1248 // a Javascript call. | 1217 // a Javascript call. |
1249 // Verify that we have 2 tabs, and the download shelf is visible in the current | 1218 // Verify that we have 2 tabs, and the download shelf is visible in the current |
1250 // tab. | 1219 // tab. |
1251 // | 1220 // |
(...skipping 11 matching lines...) Expand all Loading... | |
1263 | 1232 |
1264 // Download a file in a new tab and wait (via Javascript). | 1233 // Download a file in a new tab and wait (via Javascript). |
1265 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1234 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1266 DownloadAndWaitWithDisposition(browser(), | 1235 DownloadAndWaitWithDisposition(browser(), |
1267 GURL("javascript:openNew()"), | 1236 GURL("javascript:openNew()"), |
1268 CURRENT_TAB, | 1237 CURRENT_TAB, |
1269 EXPECT_NO_SELECT_DIALOG, | 1238 EXPECT_NO_SELECT_DIALOG, |
1270 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1239 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
1271 | 1240 |
1272 // When the download finishes, we should have two tabs. | 1241 // When the download finishes, we should have two tabs. |
1273 CheckDownloadUI(browser(), true, true, file); | 1242 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1274 EXPECT_EQ(2, browser()->tab_count()); | 1243 EXPECT_EQ(2, browser()->tab_count()); |
1275 | 1244 |
1276 CheckDownload(browser(), file, file); | 1245 CheckDownload(browser(), file, file); |
1277 } | 1246 } |
1278 | 1247 |
1279 // Open a web page in the current tab, open another tab via a Javascript call, | 1248 // Open a web page in the current tab, open another tab via a Javascript call, |
1280 // then download a file in the new tab. | 1249 // then download a file in the new tab. |
1281 // Verify that we have 2 tabs, and the download shelf is visible in the current | 1250 // Verify that we have 2 tabs, and the download shelf is visible in the current |
1282 // tab. | 1251 // tab. |
1283 // | 1252 // |
(...skipping 21 matching lines...) Expand all Loading... | |
1305 // Download a file and wait. | 1274 // Download a file and wait. |
1306 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1275 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1307 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1276 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1308 DownloadAndWaitWithDisposition(browser(), | 1277 DownloadAndWaitWithDisposition(browser(), |
1309 url, | 1278 url, |
1310 CURRENT_TAB, | 1279 CURRENT_TAB, |
1311 EXPECT_NO_SELECT_DIALOG, | 1280 EXPECT_NO_SELECT_DIALOG, |
1312 ui_test_utils::BROWSER_TEST_NONE); | 1281 ui_test_utils::BROWSER_TEST_NONE); |
1313 | 1282 |
1314 // When the download finishes, we should have two tabs. | 1283 // When the download finishes, we should have two tabs. |
1315 CheckDownloadUI(browser(), true, true, file); | 1284 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1316 EXPECT_EQ(2, browser()->tab_count()); | 1285 EXPECT_EQ(2, browser()->tab_count()); |
1317 | 1286 |
1318 CheckDownload(browser(), file, file); | 1287 CheckDownload(browser(), file, file); |
1319 } | 1288 } |
1320 | 1289 |
1321 // Open a web page in the current tab, then download a file via Javascript, | 1290 // Open a web page in the current tab, then download a file via Javascript, |
1322 // which will do so in a temporary tab. | 1291 // which will do so in a temporary tab. |
1323 // Verify that we have 1 tab, and the download shelf is visible. | 1292 // Verify that we have 1 tab, and the download shelf is visible. |
1324 // | 1293 // |
1325 // The download_page3.html page contains an openNew() function that opens a | 1294 // The download_page3.html page contains an openNew() function that opens a |
(...skipping 12 matching lines...) Expand all Loading... | |
1338 // Download a file and wait. | 1307 // Download a file and wait. |
1339 // The file to download is "download-test1.lib". | 1308 // The file to download is "download-test1.lib". |
1340 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1309 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1341 DownloadAndWaitWithDisposition(browser(), | 1310 DownloadAndWaitWithDisposition(browser(), |
1342 GURL("javascript:openNew()"), | 1311 GURL("javascript:openNew()"), |
1343 CURRENT_TAB, | 1312 CURRENT_TAB, |
1344 EXPECT_NO_SELECT_DIALOG, | 1313 EXPECT_NO_SELECT_DIALOG, |
1345 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1314 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
1346 | 1315 |
1347 // When the download finishes, we should still have one tab. | 1316 // When the download finishes, we should still have one tab. |
1348 CheckDownloadUI(browser(), true, true, file); | 1317 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1349 EXPECT_EQ(1, browser()->tab_count()); | 1318 EXPECT_EQ(1, browser()->tab_count()); |
1350 | 1319 |
1351 CheckDownload(browser(), file, file); | 1320 CheckDownload(browser(), file, file); |
1352 } | 1321 } |
1353 | 1322 |
1354 // Open a web page in the current tab, then call Javascript via a button to | 1323 // Open a web page in the current tab, then call Javascript via a button to |
1355 // download a file in a new tab, which is closed automatically when the | 1324 // download a file in a new tab, which is closed automatically when the |
1356 // download begins. | 1325 // download begins. |
1357 // Verify that we have 1 tab, and the download shelf is visible. | 1326 // Verify that we have 1 tab, and the download shelf is visible. |
1358 // | 1327 // |
(...skipping 14 matching lines...) Expand all Loading... | |
1373 // The file to download is "download-test1.lib". | 1342 // The file to download is "download-test1.lib". |
1374 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1343 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1375 DownloadAndWaitWithDisposition( | 1344 DownloadAndWaitWithDisposition( |
1376 browser(), | 1345 browser(), |
1377 GURL("javascript:document.getElementById('form').submit()"), | 1346 GURL("javascript:document.getElementById('form').submit()"), |
1378 CURRENT_TAB, | 1347 CURRENT_TAB, |
1379 EXPECT_NO_SELECT_DIALOG, | 1348 EXPECT_NO_SELECT_DIALOG, |
1380 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1349 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
1381 | 1350 |
1382 // When the download finishes, we should still have one tab. | 1351 // When the download finishes, we should still have one tab. |
1383 CheckDownloadUI(browser(), true, true, file); | 1352 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1384 EXPECT_EQ(1, browser()->tab_count()); | 1353 EXPECT_EQ(1, browser()->tab_count()); |
1385 | 1354 |
1386 CheckDownload(browser(), file, file); | 1355 CheckDownload(browser(), file, file); |
1387 } | 1356 } |
1388 | 1357 |
1389 // Download a file in a new window. | 1358 // Download a file in a new window. |
1390 // Verify that we have 2 windows, and the download shelf is not visible in the | 1359 // Verify that we have 2 windows, and the download shelf is not visible in the |
1391 // first window, but is visible in the second window. | 1360 // first window, but is visible in the second window. |
1392 // Close the new window. | 1361 // Close the new window. |
1393 // Verify that we have 1 window, and the download shelf is not visible. | 1362 // Verify that we have 1 window, and the download shelf is not visible. |
(...skipping 13 matching lines...) Expand all Loading... | |
1407 url, | 1376 url, |
1408 NEW_WINDOW, | 1377 NEW_WINDOW, |
1409 EXPECT_NO_SELECT_DIALOG, | 1378 EXPECT_NO_SELECT_DIALOG, |
1410 ui_test_utils::BROWSER_TEST_NONE); | 1379 ui_test_utils::BROWSER_TEST_NONE); |
1411 | 1380 |
1412 // When the download finishes, the download shelf SHOULD NOT be visible in | 1381 // When the download finishes, the download shelf SHOULD NOT be visible in |
1413 // the first window. | 1382 // the first window. |
1414 ExpectWindowCountAfterDownload(2); | 1383 ExpectWindowCountAfterDownload(2); |
1415 EXPECT_EQ(1, browser()->tab_count()); | 1384 EXPECT_EQ(1, browser()->tab_count()); |
1416 // Download shelf should close. Download panel stays open on ChromeOS. | 1385 // Download shelf should close. Download panel stays open on ChromeOS. |
1417 CheckDownloadUI(browser(), false, true, file); | 1386 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1418 | 1387 |
1419 // The download shelf SHOULD be visible in the second window. | 1388 // The download shelf SHOULD be visible in the second window. |
1420 std::set<Browser*> original_browsers; | 1389 std::set<Browser*> original_browsers; |
1421 original_browsers.insert(browser()); | 1390 original_browsers.insert(browser()); |
1422 Browser* download_browser = | 1391 Browser* download_browser = |
1423 ui_test_utils::GetBrowserNotInSet(original_browsers); | 1392 ui_test_utils::GetBrowserNotInSet(original_browsers); |
1424 ASSERT_TRUE(download_browser != NULL); | 1393 ASSERT_TRUE(download_browser != NULL); |
1425 EXPECT_NE(download_browser, browser()); | 1394 EXPECT_NE(download_browser, browser()); |
1426 EXPECT_EQ(1, download_browser->tab_count()); | 1395 EXPECT_EQ(1, download_browser->tab_count()); |
1427 CheckDownloadUI(download_browser, true, true, file); | 1396 CheckDownloadShelfVisibility(download_browser, SHELF_VISIBLE); |
1428 | 1397 |
1429 #if !defined(OS_MACOSX) | 1398 #if !defined(OS_MACOSX) |
1430 // On Mac OS X, the UI window close is delayed until the outermost | 1399 // On Mac OS X, the UI window close is delayed until the outermost |
1431 // message loop runs. So it isn't possible to get a BROWSER_CLOSED | 1400 // message loop runs. So it isn't possible to get a BROWSER_CLOSED |
1432 // notification inside of a test. | 1401 // notification inside of a test. |
1433 ui_test_utils::WindowedNotificationObserver signal( | 1402 ui_test_utils::WindowedNotificationObserver signal( |
1434 chrome::NOTIFICATION_BROWSER_CLOSED, | 1403 chrome::NOTIFICATION_BROWSER_CLOSED, |
1435 content::Source<Browser>(download_browser)); | 1404 content::Source<Browser>(download_browser)); |
1436 #endif | 1405 #endif |
1437 | 1406 |
1438 // Close the new window. | 1407 // Close the new window. |
1439 download_browser->CloseWindow(); | 1408 download_browser->CloseWindow(); |
1440 | 1409 |
1441 #if !defined(OS_MACOSX) | 1410 #if !defined(OS_MACOSX) |
1442 signal.Wait(); | 1411 signal.Wait(); |
1443 EXPECT_EQ(first_browser, browser()); | 1412 EXPECT_EQ(first_browser, browser()); |
1444 ExpectWindowCountAfterDownload(1); | 1413 ExpectWindowCountAfterDownload(1); |
1445 #endif | 1414 #endif |
1446 | 1415 |
1447 EXPECT_EQ(1, browser()->tab_count()); | 1416 EXPECT_EQ(1, browser()->tab_count()); |
1448 // Download shelf should close. Download panel stays open on ChromeOS. | 1417 // Download shelf should close. Download panel stays open on ChromeOS. |
1449 CheckDownloadUI(browser(), false, true, file); | 1418 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1450 | 1419 |
1451 CheckDownload(browser(), file, file); | 1420 CheckDownload(browser(), file, file); |
1452 } | 1421 } |
1453 | 1422 |
1454 // Check that downloading multiple (in this case, 2) files does not result in | 1423 // Check that downloading multiple (in this case, 2) files does not result in |
1455 // corrupted files. | 1424 // corrupted files. |
1456 IN_PROC_BROWSER_TEST_F(DownloadTest, MultiDownload) { | 1425 IN_PROC_BROWSER_TEST_F(DownloadTest, MultiDownload) { |
1457 ASSERT_TRUE(InitialSetup(false)); | 1426 ASSERT_TRUE(InitialSetup(false)); |
1458 EXPECT_EQ(1, browser()->tab_count()); | 1427 EXPECT_EQ(1, browser()->tab_count()); |
1459 | 1428 |
1460 // Create a download, wait until it's started, and confirm | 1429 // Create a download, wait until it's started, and confirm |
1461 // we're in the expected state. | 1430 // we're in the expected state. |
1462 scoped_ptr<DownloadTestObserver> observer1( | 1431 scoped_ptr<DownloadTestObserver> observer1( |
1463 CreateInProgressWaiter(browser(), 1)); | 1432 CreateInProgressWaiter(browser(), 1)); |
1464 ui_test_utils::NavigateToURL( | 1433 ui_test_utils::NavigateToURL( |
1465 browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl)); | 1434 browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl)); |
1466 observer1->WaitForFinished(); | 1435 observer1->WaitForFinished(); |
1467 | 1436 |
1468 std::vector<DownloadItem*> downloads; | 1437 std::vector<DownloadItem*> downloads; |
1469 browser()->profile()->GetDownloadManager()->SearchDownloads( | 1438 browser()->profile()->GetDownloadManager()->SearchDownloads( |
1470 string16(), &downloads); | 1439 string16(), &downloads); |
1471 ASSERT_EQ(1u, downloads.size()); | 1440 ASSERT_EQ(1u, downloads.size()); |
1472 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState()); | 1441 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState()); |
1473 CheckDownloadUI(browser(), true, true, FilePath()); | 1442 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1474 DownloadItem* download1 = downloads[0]; // The only download. | 1443 DownloadItem* download1 = downloads[0]; // The only download. |
1475 | 1444 |
1476 // Start the second download and wait until it's done. | 1445 // Start the second download and wait until it's done. |
1477 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1446 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1478 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1447 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1479 // Download the file and wait. We do not expect the Select File dialog. | 1448 // Download the file and wait. We do not expect the Select File dialog. |
1480 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1449 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); |
1481 | 1450 |
1482 // Should now have 2 items on the download shelf. | 1451 // Should now have 2 items on the download shelf. |
1483 downloads.clear(); | 1452 downloads.clear(); |
1484 browser()->profile()->GetDownloadManager()->SearchDownloads( | 1453 browser()->profile()->GetDownloadManager()->SearchDownloads( |
1485 string16(), &downloads); | 1454 string16(), &downloads); |
1486 ASSERT_EQ(2u, downloads.size()); | 1455 ASSERT_EQ(2u, downloads.size()); |
1487 // We don't know the order of the downloads. | 1456 // We don't know the order of the downloads. |
1488 DownloadItem* download2 = downloads[(download1 == downloads[0]) ? 1 : 0]; | 1457 DownloadItem* download2 = downloads[(download1 == downloads[0]) ? 1 : 0]; |
1489 | 1458 |
1490 ASSERT_EQ(DownloadItem::IN_PROGRESS, download1->GetState()); | 1459 ASSERT_EQ(DownloadItem::IN_PROGRESS, download1->GetState()); |
1491 ASSERT_EQ(DownloadItem::COMPLETE, download2->GetState()); | 1460 ASSERT_EQ(DownloadItem::COMPLETE, download2->GetState()); |
1492 // The download shelf should be open. | 1461 // The download shelf should be open. |
1493 CheckDownloadUI(browser(), true, true, FilePath()); | 1462 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1494 | 1463 |
1495 // Allow the first request to finish. We do this by loading a third URL | 1464 // Allow the first request to finish. We do this by loading a third URL |
1496 // in a separate tab. | 1465 // in a separate tab. |
1497 scoped_ptr<DownloadTestObserver> observer2(CreateWaiter(browser(), 1)); | 1466 scoped_ptr<DownloadTestObserver> observer2(CreateWaiter(browser(), 1)); |
1498 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl); | 1467 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl); |
1499 ui_test_utils::NavigateToURLWithDisposition( | 1468 ui_test_utils::NavigateToURLWithDisposition( |
1500 browser(), | 1469 browser(), |
1501 finish_url, | 1470 finish_url, |
1502 NEW_FOREGROUND_TAB, | 1471 NEW_FOREGROUND_TAB, |
1503 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1472 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1504 observer2->WaitForFinished(); // Wait for the third request. | 1473 observer2->WaitForFinished(); // Wait for the third request. |
1505 EXPECT_EQ(1u, observer2->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 1474 EXPECT_EQ(1u, observer2->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
1506 | 1475 |
1507 // Get the important info from other threads and check it. | 1476 // Get the important info from other threads and check it. |
1508 EXPECT_TRUE(EnsureNoPendingDownloads()); | 1477 EXPECT_TRUE(EnsureNoPendingDownloads()); |
1509 | 1478 |
1510 CheckDownloadUI(browser(), true, true, FilePath()); | 1479 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1511 | 1480 |
1512 // The |DownloadItem|s should now be done and have the final file names. | 1481 // The |DownloadItem|s should now be done and have the final file names. |
1513 // Verify that the files have the expected data and size. | 1482 // Verify that the files have the expected data and size. |
1514 // |file1| should be full of '*'s, and |file2| should be the same as the | 1483 // |file1| should be full of '*'s, and |file2| should be the same as the |
1515 // source file. | 1484 // source file. |
1516 FilePath file1(download1->GetFullPath()); | 1485 FilePath file1(download1->GetFullPath()); |
1517 size_t file_size1 = URLRequestSlowDownloadJob::kFirstDownloadSize + | 1486 size_t file_size1 = URLRequestSlowDownloadJob::kFirstDownloadSize + |
1518 URLRequestSlowDownloadJob::kSecondDownloadSize; | 1487 URLRequestSlowDownloadJob::kSecondDownloadSize; |
1519 std::string expected_contents(file_size1, '*'); | 1488 std::string expected_contents(file_size1, '*'); |
1520 ASSERT_TRUE(VerifyFile(file1, expected_contents, file_size1)); | 1489 ASSERT_TRUE(VerifyFile(file1, expected_contents, file_size1)); |
(...skipping 28 matching lines...) Expand all Loading... | |
1549 CreateInProgressWaiter(browser(), 1)); | 1518 CreateInProgressWaiter(browser(), 1)); |
1550 ui_test_utils::NavigateToURL( | 1519 ui_test_utils::NavigateToURL( |
1551 browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl)); | 1520 browser(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl)); |
1552 observer->WaitForFinished(); | 1521 observer->WaitForFinished(); |
1553 | 1522 |
1554 std::vector<DownloadItem*> downloads; | 1523 std::vector<DownloadItem*> downloads; |
1555 DownloadManagerForBrowser(browser())->SearchDownloads( | 1524 DownloadManagerForBrowser(browser())->SearchDownloads( |
1556 string16(), &downloads); | 1525 string16(), &downloads); |
1557 ASSERT_EQ(1u, downloads.size()); | 1526 ASSERT_EQ(1u, downloads.size()); |
1558 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState()); | 1527 ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState()); |
1559 CheckDownloadUI(browser(), true, true, FilePath()); | 1528 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1560 | 1529 |
1561 // Cancel the download and wait for download system quiesce. | 1530 // Cancel the download and wait for download system quiesce. |
1562 downloads[0]->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 1531 downloads[0]->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); |
1563 scoped_refptr<DownloadTestFlushObserver> flush_observer( | 1532 scoped_refptr<DownloadTestFlushObserver> flush_observer( |
1564 new DownloadTestFlushObserver( | 1533 new DownloadTestFlushObserver( |
1565 DownloadManagerForBrowser(browser()))); | 1534 DownloadManagerForBrowser(browser()))); |
1566 flush_observer->WaitForFlush(); | 1535 flush_observer->WaitForFlush(); |
1567 | 1536 |
1568 // Get the important info from other threads and check it. | 1537 // Get the important info from other threads and check it. |
1569 EXPECT_TRUE(EnsureNoPendingDownloads()); | 1538 EXPECT_TRUE(EnsureNoPendingDownloads()); |
1570 | 1539 |
1571 // Using "DownloadItem::Remove" follows the discard dangerous download path, | 1540 // Using "DownloadItem::Remove" follows the discard dangerous download path, |
1572 // which completely removes the browser from the shelf and closes the shelf | 1541 // which completely removes the browser from the shelf and closes the shelf |
1573 // if it was there. Download panel stays open on ChromeOS. | 1542 // if it was there. Download panel stays open on ChromeOS. |
1574 CheckDownloadUI(browser(), false, true, FilePath()); | 1543 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1575 } | 1544 } |
1576 | 1545 |
1577 // Confirm a download makes it into the history properly. | 1546 // Confirm a download makes it into the history properly. |
1578 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { | 1547 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { |
1579 ASSERT_TRUE(InitialSetup(false)); | 1548 ASSERT_TRUE(InitialSetup(false)); |
1580 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1549 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1581 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1550 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1582 FilePath origin_file(OriginFile(file)); | 1551 FilePath origin_file(OriginFile(file)); |
1583 int64 origin_size; | 1552 int64 origin_size; |
1584 file_util::GetFileSize(origin_file, &origin_size); | 1553 file_util::GetFileSize(origin_file, &origin_size); |
1585 | 1554 |
1586 // Download the file and wait. We do not expect the Select File dialog. | 1555 // Download the file and wait. We do not expect the Select File dialog. |
1587 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1556 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); |
1588 | 1557 |
1589 // Get details of what downloads have just happened. | 1558 // Get details of what downloads have just happened. |
1590 std::vector<DownloadItem*> downloads; | 1559 std::vector<DownloadItem*> downloads; |
1591 GetDownloads(browser(), &downloads); | 1560 GetDownloads(browser(), &downloads); |
1592 ASSERT_EQ(1u, downloads.size()); | 1561 ASSERT_EQ(1u, downloads.size()); |
1593 int64 db_handle = downloads[0]->GetDbHandle(); | 1562 int64 db_handle = downloads[0]->GetDbHandle(); |
1594 | 1563 |
1595 // Check state. | 1564 // Check state. |
1596 EXPECT_EQ(1, browser()->tab_count()); | 1565 EXPECT_EQ(1, browser()->tab_count()); |
1597 CheckDownload(browser(), file, file); | 1566 CheckDownload(browser(), file, file); |
1598 CheckDownloadUI(browser(), true, true, file); | 1567 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
1599 | 1568 |
1600 // Check history results. | 1569 // Check history results. |
1601 DownloadsHistoryDataCollector history_collector( | 1570 DownloadsHistoryDataCollector history_collector( |
1602 db_handle, | 1571 db_handle, |
1603 DownloadManagerForBrowser(browser())); | 1572 DownloadManagerForBrowser(browser())); |
1604 DownloadPersistentStoreInfo info; | 1573 DownloadPersistentStoreInfo info; |
1605 EXPECT_TRUE(history_collector.GetDownloadsHistoryEntry(&info)) << db_handle; | 1574 EXPECT_TRUE(history_collector.GetDownloadsHistoryEntry(&info)) << db_handle; |
1606 EXPECT_EQ(file, info.path.BaseName()); | 1575 EXPECT_EQ(file, info.path.BaseName()); |
1607 EXPECT_EQ(url, info.url); | 1576 EXPECT_EQ(url, info.url); |
1608 // Ignore start_time. | 1577 // Ignore start_time. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1711 DownloadManagerForBrowser(browser())->SearchDownloads( | 1680 DownloadManagerForBrowser(browser())->SearchDownloads( |
1712 string16(), &downloads); | 1681 string16(), &downloads); |
1713 ASSERT_EQ(1u, downloads.size()); | 1682 ASSERT_EQ(1u, downloads.size()); |
1714 EXPECT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); | 1683 EXPECT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); |
1715 EXPECT_TRUE(downloads[0]->GetOpened()); | 1684 EXPECT_TRUE(downloads[0]->GetOpened()); |
1716 | 1685 |
1717 // As long as we're here, confirmed everything else is good. | 1686 // As long as we're here, confirmed everything else is good. |
1718 EXPECT_EQ(1, browser()->tab_count()); | 1687 EXPECT_EQ(1, browser()->tab_count()); |
1719 CheckDownload(browser(), file, file); | 1688 CheckDownload(browser(), file, file); |
1720 // Download shelf should close. Download panel stays open on ChromeOS. | 1689 // Download shelf should close. Download panel stays open on ChromeOS. |
1721 CheckDownloadUI(browser(), false, true, FilePath()); | 1690 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1722 } | 1691 } |
1723 | 1692 |
1724 // Download an extension. Expect a dangerous download warning. | 1693 // Download an extension. Expect a dangerous download warning. |
1725 // Deny the download. | 1694 // Deny the download. |
1726 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) { | 1695 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) { |
1727 ASSERT_TRUE(InitialSetup(false)); | 1696 ASSERT_TRUE(InitialSetup(false)); |
1728 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); | 1697 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); |
1729 | 1698 |
1730 scoped_ptr<DownloadTestObserver> observer( | 1699 scoped_ptr<DownloadTestObserver> observer( |
1731 DangerousDownloadWaiter( | 1700 DangerousDownloadWaiter( |
1732 browser(), 1, | 1701 browser(), 1, |
1733 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 1702 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
1734 ui_test_utils::NavigateToURL(browser(), extension_url); | 1703 ui_test_utils::NavigateToURL(browser(), extension_url); |
1735 | 1704 |
1736 observer->WaitForFinished(); | 1705 observer->WaitForFinished(); |
1737 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); | 1706 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); |
1738 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 1707 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
1739 | 1708 |
1740 // Download shelf should close. Download panel stays open on ChromeOS. | 1709 // Download shelf should close. Download panel stays open on ChromeOS. |
1741 CheckDownloadUI(browser(), false, true, FilePath()); | 1710 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1742 | 1711 |
1743 // Check that the CRX is not installed. | 1712 // Check that the CRX is not installed. |
1744 ExtensionService* extension_service = | 1713 ExtensionService* extension_service = |
1745 browser()->profile()->GetExtensionService(); | 1714 browser()->profile()->GetExtensionService(); |
1746 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); | 1715 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); |
1747 } | 1716 } |
1748 | 1717 |
1749 // Download an extension. Expect a dangerous download warning. | 1718 // Download an extension. Expect a dangerous download warning. |
1750 // Allow the download, deny the install. | 1719 // Allow the download, deny the install. |
1751 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) { | 1720 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) { |
(...skipping 10 matching lines...) Expand all Loading... | |
1762 browser(), 1, | 1731 browser(), 1, |
1763 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); | 1732 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); |
1764 ui_test_utils::NavigateToURL(browser(), extension_url); | 1733 ui_test_utils::NavigateToURL(browser(), extension_url); |
1765 | 1734 |
1766 observer->WaitForFinished(); | 1735 observer->WaitForFinished(); |
1767 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 1736 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
1768 CheckDownloadStates(1, DownloadItem::COMPLETE); | 1737 CheckDownloadStates(1, DownloadItem::COMPLETE); |
1769 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 1738 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
1770 | 1739 |
1771 // Download shelf should close. Download panel stays open on ChromeOS. | 1740 // Download shelf should close. Download panel stays open on ChromeOS. |
1772 CheckDownloadUI(browser(), false, true, FilePath()); | 1741 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1773 | 1742 |
1774 // Check that the extension was not installed. | 1743 // Check that the extension was not installed. |
1775 ExtensionService* extension_service = | 1744 ExtensionService* extension_service = |
1776 browser()->profile()->GetExtensionService(); | 1745 browser()->profile()->GetExtensionService(); |
1777 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); | 1746 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); |
1778 } | 1747 } |
1779 | 1748 |
1780 // Download an extension. Expect a dangerous download warning. | 1749 // Download an extension. Expect a dangerous download warning. |
1781 // Allow the download, and the install. | 1750 // Allow the download, and the install. |
1782 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) { | 1751 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) { |
(...skipping 10 matching lines...) Expand all Loading... | |
1793 browser(), 1, | 1762 browser(), 1, |
1794 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); | 1763 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); |
1795 ui_test_utils::NavigateToURL(browser(), extension_url); | 1764 ui_test_utils::NavigateToURL(browser(), extension_url); |
1796 | 1765 |
1797 observer->WaitForFinished(); | 1766 observer->WaitForFinished(); |
1798 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 1767 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
1799 CheckDownloadStates(1, DownloadItem::COMPLETE); | 1768 CheckDownloadStates(1, DownloadItem::COMPLETE); |
1800 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 1769 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
1801 | 1770 |
1802 // Download shelf should close. Download panel stays open on ChromeOS. | 1771 // Download shelf should close. Download panel stays open on ChromeOS. |
1803 CheckDownloadUI(browser(), false, true, FilePath()); | 1772 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1804 | 1773 |
1805 // Check that the extension was installed. | 1774 // Check that the extension was installed. |
1806 ExtensionService* extension_service = | 1775 ExtensionService* extension_service = |
1807 browser()->profile()->GetExtensionService(); | 1776 browser()->profile()->GetExtensionService(); |
1808 ASSERT_TRUE(extension_service->GetExtensionById(kGoodCrxId, false)); | 1777 ASSERT_TRUE(extension_service->GetExtensionById(kGoodCrxId, false)); |
1809 } | 1778 } |
1810 | 1779 |
1811 // Test installing a CRX that fails integrity checks. | 1780 // Test installing a CRX that fails integrity checks. |
1812 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInvalid) { | 1781 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInvalid) { |
1813 ASSERT_TRUE(InitialSetup(false)); | 1782 ASSERT_TRUE(InitialSetup(false)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1851 browser(), 1, | 1820 browser(), 1, |
1852 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); | 1821 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); |
1853 ui_test_utils::NavigateToURL(browser(), extension_url); | 1822 ui_test_utils::NavigateToURL(browser(), extension_url); |
1854 | 1823 |
1855 observer->WaitForFinished(); | 1824 observer->WaitForFinished(); |
1856 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 1825 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
1857 CheckDownloadStates(1, DownloadItem::COMPLETE); | 1826 CheckDownloadStates(1, DownloadItem::COMPLETE); |
1858 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 1827 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
1859 | 1828 |
1860 // Download shelf should close. Download panel stays open on ChromeOS. | 1829 // Download shelf should close. Download panel stays open on ChromeOS. |
1861 CheckDownloadUI(browser(), false, true, FilePath()); | 1830 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
1862 | 1831 |
1863 // Check that the extension was installed. | 1832 // Check that the extension was installed. |
1864 ExtensionService* extension_service = | 1833 ExtensionService* extension_service = |
1865 browser()->profile()->GetExtensionService(); | 1834 browser()->profile()->GetExtensionService(); |
1866 ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false)); | 1835 ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false)); |
1867 } | 1836 } |
1868 | 1837 |
1869 // Sort download items by db_handle. | 1838 // Sort download items by db_handle. |
1870 static bool DownloadItemSorter(DownloadItem* d1, DownloadItem* d2) { | 1839 static bool DownloadItemSorter(DownloadItem* d1, DownloadItem* d2) { |
1871 return d1->GetDbHandle() < d2->GetDbHandle(); | 1840 return d1->GetDbHandle() < d2->GetDbHandle(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2021 url, GURL(""), "", false, -1, save_info, web_contents, | 1990 url, GURL(""), "", false, -1, save_info, web_contents, |
2022 DownloadManager::OnStartedCallback()); | 1991 DownloadManager::OnStartedCallback()); |
2023 observer->WaitForFinished(); | 1992 observer->WaitForFinished(); |
2024 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 1993 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
2025 CheckDownloadStates(1, DownloadItem::COMPLETE); | 1994 CheckDownloadStates(1, DownloadItem::COMPLETE); |
2026 EXPECT_TRUE(observer->select_file_dialog_seen()); | 1995 EXPECT_TRUE(observer->select_file_dialog_seen()); |
2027 | 1996 |
2028 // Check state. | 1997 // Check state. |
2029 EXPECT_EQ(1, browser()->tab_count()); | 1998 EXPECT_EQ(1, browser()->tab_count()); |
2030 ASSERT_TRUE(CheckDownload(browser(), file, file)); | 1999 ASSERT_TRUE(CheckDownload(browser(), file, file)); |
2031 CheckDownloadUI(browser(), true, true, file); | 2000 CheckDownloadShelfVisibility(browser(), SHELF_VISIBLE); |
2032 } | 2001 } |
2033 | 2002 |
2034 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) { | 2003 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) { |
2035 ASSERT_TRUE(InitialSetup(false)); | 2004 ASSERT_TRUE(InitialSetup(false)); |
2036 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 2005 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
2037 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 2006 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
2038 | 2007 |
2039 WebContents* web_contents = browser()->GetSelectedWebContents(); | 2008 WebContents* web_contents = browser()->GetSelectedWebContents(); |
2040 ASSERT_TRUE(web_contents); | 2009 ASSERT_TRUE(web_contents); |
2041 | 2010 |
(...skipping 11 matching lines...) Expand all Loading... | |
2053 observer->WaitForFinished(); | 2022 observer->WaitForFinished(); |
2054 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 2023 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
2055 | 2024 |
2056 // Check state. | 2025 // Check state. |
2057 EXPECT_EQ(1, browser()->tab_count()); | 2026 EXPECT_EQ(1, browser()->tab_count()); |
2058 ASSERT_TRUE(CheckDownloadFullPaths(browser(), | 2027 ASSERT_TRUE(CheckDownloadFullPaths(browser(), |
2059 target_file_full_path, | 2028 target_file_full_path, |
2060 OriginFile(file))); | 2029 OriginFile(file))); |
2061 | 2030 |
2062 // Temporary downloads won't be visible. | 2031 // Temporary downloads won't be visible. |
2063 CheckDownloadUI(browser(), false, false, file); | 2032 CheckDownloadShelfVisibility(browser(), SHELF_HIDDEN); |
2064 } | 2033 } |
2065 | 2034 |
2066 IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaGet) { | 2035 IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaGet) { |
2067 // Do initial setup. | 2036 // Do initial setup. |
2068 ASSERT_TRUE(InitialSetup(false)); | 2037 ASSERT_TRUE(InitialSetup(false)); |
2069 ASSERT_TRUE(test_server()->Start()); | 2038 ASSERT_TRUE(test_server()->Start()); |
2070 NullSelectFile(browser()); | 2039 NullSelectFile(browser()); |
2071 std::vector<DownloadItem*> download_items; | 2040 std::vector<DownloadItem*> download_items; |
2072 GetDownloads(browser(), &download_items); | 2041 GetDownloads(browser(), &download_items); |
2073 ASSERT_TRUE(download_items.empty()); | 2042 ASSERT_TRUE(download_items.empty()); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2539 downloads.clear(); | 2508 downloads.clear(); |
2540 GetDownloads(browser(), &downloads); | 2509 GetDownloads(browser(), &downloads); |
2541 EXPECT_EQ(0u, downloads.size()); | 2510 EXPECT_EQ(0u, downloads.size()); |
2542 | 2511 |
2543 if (creation_observer->succeeded()) { | 2512 if (creation_observer->succeeded()) { |
2544 // Wait until the download is done. We don't care how it's finished. | 2513 // Wait until the download is done. We don't care how it's finished. |
2545 backup_observer.WaitForFinished(); | 2514 backup_observer.WaitForFinished(); |
2546 } | 2515 } |
2547 DownloadManagerForBrowser(browser())->RemoveAllDownloads(); | 2516 DownloadManagerForBrowser(browser())->RemoveAllDownloads(); |
2548 } | 2517 } |
OLD | NEW |