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

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

Issue 8503018: Split DownloadItem into an ABC, an Impl, and a Mock. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge 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
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/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return current_tab; 79 return current_tab;
80 } 80 }
81 81
82 82
83 GURL WaitForSavePackageToFinish() const { 83 GURL WaitForSavePackageToFinish() const {
84 ui_test_utils::TestNotificationObserver observer; 84 ui_test_utils::TestNotificationObserver observer;
85 ui_test_utils::RegisterAndWait(&observer, 85 ui_test_utils::RegisterAndWait(&observer,
86 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, 86 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
87 content::NotificationService::AllSources()); 87 content::NotificationService::AllSources());
88 return content::Details<DownloadItem>(observer.details()).ptr()-> 88 return content::Details<DownloadItem>(observer.details()).ptr()->
89 original_url(); 89 GetOriginalUrl();
90 } 90 }
91 91
92 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) 92 #if defined(OS_CHROMEOS) && defined(TOUCH_UI)
93 const ActiveDownloadsUI::DownloadList& GetDownloads() const { 93 const ActiveDownloadsUI::DownloadList& GetDownloads() const {
94 TabContents* download_contents = ActiveDownloadsUI::GetPopup(NULL); 94 TabContents* download_contents = ActiveDownloadsUI::GetPopup(NULL);
95 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( 95 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>(
96 download_contents->web_ui()); 96 download_contents->web_ui());
97 EXPECT_TRUE(downloads_ui); 97 EXPECT_TRUE(downloads_ui);
98 return downloads_ui->GetDownloads(); 98 return downloads_ui->GetDownloads();
99 } 99 }
100 #elif defined(OS_CHROMEOS) 100 #elif defined(OS_CHROMEOS)
101 const ActiveDownloadsUI::DownloadList& GetDownloads() const { 101 const ActiveDownloadsUI::DownloadList& GetDownloads() const {
102 Browser* popup = ActiveDownloadsUI::GetPopup(); 102 Browser* popup = ActiveDownloadsUI::GetPopup();
103 EXPECT_TRUE(popup); 103 EXPECT_TRUE(popup);
104 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( 104 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>(
105 popup->GetSelectedTabContents()->web_ui()); 105 popup->GetSelectedTabContents()->web_ui());
106 EXPECT_TRUE(downloads_ui); 106 EXPECT_TRUE(downloads_ui);
107 return downloads_ui->GetDownloads(); 107 return downloads_ui->GetDownloads();
108 } 108 }
109 #endif 109 #endif
110 110
111 void CheckDownloadUI(const FilePath& download_path) const { 111 void CheckDownloadUI(const FilePath& download_path) const {
112 #if defined(OS_CHROMEOS) && !defined(USE_AURA) 112 #if defined(OS_CHROMEOS) && !defined(USE_AURA)
113 const ActiveDownloadsUI::DownloadList& downloads = GetDownloads(); 113 const ActiveDownloadsUI::DownloadList& downloads = GetDownloads();
114 EXPECT_EQ(downloads.size(), 1U); 114 EXPECT_EQ(downloads.size(), 1U);
115 115
116 bool found = false; 116 bool found = false;
117 for (size_t i = 0; i < downloads.size(); ++i) { 117 for (size_t i = 0; i < downloads.size(); ++i) {
118 if (downloads[i]->full_path() == download_path) { 118 if (downloads[i]->GetFullPath() == download_path) {
119 found = true; 119 found = true;
120 break; 120 break;
121 } 121 }
122 } 122 }
123 EXPECT_TRUE(found); 123 EXPECT_TRUE(found);
124 #else 124 #else
125 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); 125 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
126 #endif 126 #endif
127 } 127 }
128 128
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, ExplicitCancel) { 352 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, ExplicitCancel) {
353 GURL url = NavigateToMockURL("a"); 353 GURL url = NavigateToMockURL("a");
354 FilePath full_file_name, dir; 354 FilePath full_file_name, dir;
355 GetDestinationPaths("a", &full_file_name, &dir); 355 GetDestinationPaths("a", &full_file_name, &dir);
356 scoped_refptr<SavePackage> save_package(new SavePackage(GetCurrentTab(), 356 scoped_refptr<SavePackage> save_package(new SavePackage(GetCurrentTab(),
357 SavePackage::SAVE_AS_ONLY_HTML, full_file_name, dir)); 357 SavePackage::SAVE_AS_ONLY_HTML, full_file_name, dir));
358 save_package->Cancel(true); 358 save_package->Cancel(true);
359 } 359 }
360 360
361 } // namespace 361 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/download/download_util.cc ('k') | chrome/browser/safe_browsing/download_protection_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698