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

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

Issue 8569015: Revert 110765 - Fix DownloadTests and change cros/aura to use shelf (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/download/download_util.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 DCHECK(downloads); 572 DCHECK(downloads);
573 DownloadManager* manager = DownloadManagerForBrowser(browser); 573 DownloadManager* manager = DownloadManagerForBrowser(browser);
574 manager->SearchDownloads(string16(), downloads); 574 manager->SearchDownloads(string16(), downloads);
575 } 575 }
576 576
577 // Check that the download UI (shelf on non-chromeos or panel on chromeos) 577 // Check that the download UI (shelf on non-chromeos or panel on chromeos)
578 // is visible or not as expected. Additionally, check that the filename 578 // is visible or not as expected. Additionally, check that the filename
579 // is present in the UI (currently only on chromeos). 579 // is present in the UI (currently only on chromeos).
580 void CheckDownloadUI(Browser* browser, bool expected_non_cros, 580 void CheckDownloadUI(Browser* browser, bool expected_non_cros,
581 bool expected_cros, const FilePath& filename) { 581 bool expected_cros, const FilePath& filename) {
582 #if defined(OS_CHROMEOS) && !defined(USE_AURA) 582 #if defined(OS_CHROMEOS)
583 #if defined(TOUCH_UI) 583 #if defined(TOUCH_UI)
584 TabContents* download_contents = ActiveDownloadsUI::GetPopup(NULL); 584 TabContents* download_contents = ActiveDownloadsUI::GetPopup(NULL);
585 EXPECT_EQ(expected_cros, download_contents != NULL); 585 EXPECT_EQ(expected_cros, download_contents != NULL);
586 if (!download_contents || filename.empty()) 586 if (!download_contents || filename.empty())
587 return; 587 return;
588 588
589 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( 589 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>(
590 download_contents->web_ui()); 590 download_contents->web_ui());
591 #else 591 #else
592 Browser* popup = ActiveDownloadsUI::GetPopup(); 592 Browser* popup = ActiveDownloadsUI::GetPopup();
(...skipping 18 matching lines...) Expand all
611 break; 611 break;
612 } 612 }
613 } 613 }
614 EXPECT_TRUE(exists); 614 EXPECT_TRUE(exists);
615 #else 615 #else
616 EXPECT_EQ(expected_non_cros, browser->window()->IsDownloadShelfVisible()); 616 EXPECT_EQ(expected_non_cros, browser->window()->IsDownloadShelfVisible());
617 // TODO: Check for filename match in download shelf. 617 // TODO: Check for filename match in download shelf.
618 #endif 618 #endif
619 } 619 }
620 static void ExpectWindowCountAfterDownload(size_t expected) { 620 static void ExpectWindowCountAfterDownload(size_t expected) {
621 #if defined(OS_CHROMEOS) && !defined(USE_AURA) 621 #if defined(OS_CHROMEOS)
622 // On ChromeOS, a download panel is created to display 622 // On ChromeOS, a download panel is created to display
623 // download information, and this counts as a window. 623 // download information, and this counts as a window.
624 expected++; 624 expected++;
625 #endif 625 #endif
626 EXPECT_EQ(expected, BrowserList::size()); 626 EXPECT_EQ(expected, BrowserList::size());
627 } 627 }
628 628
629 // Arrange for select file calls on the given browser from the 629 // Arrange for select file calls on the given browser from the
630 // download manager to always choose the suggested file. 630 // download manager to always choose the suggested file.
631 void NullSelectFile(Browser* browser) { 631 void NullSelectFile(Browser* browser) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 // Download a file and wait. 777 // Download a file and wait.
778 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); 778 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG);
779 779
780 CheckDownload(browser(), download_file, file); 780 CheckDownload(browser(), download_file, file);
781 781
782 // Check state. 782 // Check state.
783 EXPECT_EQ(1, browser()->tab_count()); 783 EXPECT_EQ(1, browser()->tab_count());
784 CheckDownloadUI(browser(), true, true, download_file); 784 CheckDownloadUI(browser(), true, true, download_file);
785 } 785 }
786 786
787 #if !defined(OS_CHROMEOS) || defined(USE_AURA) 787 #if !defined(OS_CHROMEOS) // Download shelf is not per-window on ChromeOS.
788 // Download shelf is not per-window on ChromeOS.
789 // Test that the download shelf is per-window by starting a download in one 788 // Test that the download shelf is per-window by starting a download in one
790 // tab, opening a second tab, closing the shelf, going back to the first tab, 789 // tab, opening a second tab, closing the shelf, going back to the first tab,
791 // and checking that the shelf is closed. 790 // and checking that the shelf is closed.
792 IN_PROC_BROWSER_TEST_F(DownloadTest, PerWindowShelf) { 791 IN_PROC_BROWSER_TEST_F(DownloadTest, PerWindowShelf) {
793 ASSERT_TRUE(InitialSetup(false)); 792 ASSERT_TRUE(InitialSetup(false));
794 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); 793 FilePath file(FILE_PATH_LITERAL("download-test3.gif"));
795 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 794 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
796 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); 795 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif"));
797 796
798 // Download a file and wait. 797 // Download a file and wait.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 ASSERT_TRUE(RunSizeTest(browser(), SIZE_TEST_TYPE_KNOWN, 844 ASSERT_TRUE(RunSizeTest(browser(), SIZE_TEST_TYPE_KNOWN,
846 "71% - ", "100% - ")); 845 "71% - ", "100% - "));
847 } 846 }
848 847
849 // Test that when downloading an item in Incognito mode, we don't crash when 848 // Test that when downloading an item in Incognito mode, we don't crash when
850 // closing the last Incognito window (http://crbug.com/13983). 849 // closing the last Incognito window (http://crbug.com/13983).
851 // Also check that the download shelf is not visible after closing the 850 // Also check that the download shelf is not visible after closing the
852 // Incognito window. 851 // Incognito window.
853 IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) { 852 IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) {
854 ASSERT_TRUE(InitialSetup(false)); 853 ASSERT_TRUE(InitialSetup(false));
854
855 // Open an Incognito window. 855 // Open an Incognito window.
856 Browser* incognito = CreateIncognitoBrowser(); // Waits. 856 Browser* incognito = CreateIncognitoBrowser(); // Waits.
857 ASSERT_TRUE(incognito); 857 ASSERT_TRUE(incognito);
858 int window_count = BrowserList::size(); 858 int window_count = BrowserList::size();
859 EXPECT_EQ(2, window_count); 859 EXPECT_EQ(2, window_count);
860 860
861 // Download a file in the Incognito window and wait. 861 // Download a file in the Incognito window and wait.
862 CreateAndSetDownloadsDirectory(incognito); 862 CreateAndSetDownloadsDirectory(incognito);
863 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 863 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
864 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 864 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 search_results.clear(); 1675 search_results.clear();
1676 1676
1677 manager->SearchDownloads(UTF8ToUTF16("another_file"), &search_results); 1677 manager->SearchDownloads(UTF8ToUTF16("another_file"), &search_results);
1678 ASSERT_EQ(2u, search_results.size()); 1678 ASSERT_EQ(2u, search_results.size());
1679 std::sort(search_results.begin(), search_results.end(), 1679 std::sort(search_results.begin(), search_results.end(),
1680 DownloadItemSorter); 1680 DownloadItemSorter);
1681 EXPECT_EQ(2, search_results[0]->db_handle()); 1681 EXPECT_EQ(2, search_results[0]->db_handle());
1682 EXPECT_EQ(3, search_results[1]->db_handle()); 1682 EXPECT_EQ(3, search_results[1]->db_handle());
1683 search_results.clear(); 1683 search_results.clear();
1684 } 1684 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698