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

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

Issue 10073017: Remove Active Downloads UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 8 months 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) 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 "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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 GURL WaitForSavePackageToFinish() const { 91 GURL WaitForSavePackageToFinish() const {
92 ui_test_utils::TestNotificationObserver observer; 92 ui_test_utils::TestNotificationObserver observer;
93 ui_test_utils::RegisterAndWait(&observer, 93 ui_test_utils::RegisterAndWait(&observer,
94 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, 94 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
95 content::NotificationService::AllSources()); 95 content::NotificationService::AllSources());
96 return content::Details<DownloadItem>(observer.details()).ptr()-> 96 return content::Details<DownloadItem>(observer.details()).ptr()->
97 GetOriginalUrl(); 97 GetOriginalUrl();
98 } 98 }
99 99
100 void CheckDownloadUI(const FilePath& download_path) const {
101 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
102 }
103
104 DownloadManager* GetDownloadManager() const { 100 DownloadManager* GetDownloadManager() const {
105 DownloadManager* download_manager = 101 DownloadManager* download_manager =
106 DownloadServiceFactory::GetForProfile( 102 DownloadServiceFactory::GetForProfile(
107 browser()->profile())->GetDownloadManager(); 103 browser()->profile())->GetDownloadManager();
108 EXPECT_TRUE(download_manager); 104 EXPECT_TRUE(download_manager);
109 return download_manager; 105 return download_manager;
110 } 106 }
111 107
112 void QueryDownloadHistory() { 108 void QueryDownloadHistory() {
113 // Query the history system. 109 // Query the history system.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveHTMLOnly) { 174 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveHTMLOnly) {
179 GURL url = NavigateToMockURL("a"); 175 GURL url = NavigateToMockURL("a");
180 176
181 FilePath full_file_name, dir; 177 FilePath full_file_name, dir;
182 GetDestinationPaths("a", &full_file_name, &dir); 178 GetDestinationPaths("a", &full_file_name, &dir);
183 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, 179 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir,
184 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); 180 content::SAVE_PAGE_TYPE_AS_ONLY_HTML));
185 181
186 EXPECT_EQ(url, WaitForSavePackageToFinish()); 182 EXPECT_EQ(url, WaitForSavePackageToFinish());
187 183
188 CheckDownloadUI(full_file_name); 184 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
189 CheckDownloadHistory(url, full_file_name, 1); // a.htm is 1 file. 185 CheckDownloadHistory(url, full_file_name, 1); // a.htm is 1 file.
190 186
191 EXPECT_TRUE(file_util::PathExists(full_file_name)); 187 EXPECT_TRUE(file_util::PathExists(full_file_name));
192 EXPECT_FALSE(file_util::PathExists(dir)); 188 EXPECT_FALSE(file_util::PathExists(dir));
193 EXPECT_TRUE(file_util::ContentsEqual( 189 EXPECT_TRUE(file_util::ContentsEqual(
194 test_dir_.Append(FilePath(kTestDir)).Append(FILE_PATH_LITERAL("a.htm")), 190 test_dir_.Append(FilePath(kTestDir)).Append(FILE_PATH_LITERAL("a.htm")),
195 full_file_name)); 191 full_file_name));
196 } 192 }
197 193
198 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveViewSourceHTMLOnly) { 194 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveViewSourceHTMLOnly) {
199 FilePath file_name(FILE_PATH_LITERAL("a.htm")); 195 FilePath file_name(FILE_PATH_LITERAL("a.htm"));
200 GURL view_source_url = URLRequestMockHTTPJob::GetMockViewSourceUrl( 196 GURL view_source_url = URLRequestMockHTTPJob::GetMockViewSourceUrl(
201 FilePath(kTestDir).Append(file_name)); 197 FilePath(kTestDir).Append(file_name));
202 GURL actual_page_url = URLRequestMockHTTPJob::GetMockUrl( 198 GURL actual_page_url = URLRequestMockHTTPJob::GetMockUrl(
203 FilePath(kTestDir).Append(file_name)); 199 FilePath(kTestDir).Append(file_name));
204 ui_test_utils::NavigateToURL(browser(), view_source_url); 200 ui_test_utils::NavigateToURL(browser(), view_source_url);
205 201
206 FilePath full_file_name, dir; 202 FilePath full_file_name, dir;
207 GetDestinationPaths("a", &full_file_name, &dir); 203 GetDestinationPaths("a", &full_file_name, &dir);
208 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, 204 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir,
209 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); 205 content::SAVE_PAGE_TYPE_AS_ONLY_HTML));
210 206
211 EXPECT_EQ(actual_page_url, WaitForSavePackageToFinish()); 207 EXPECT_EQ(actual_page_url, WaitForSavePackageToFinish());
212 208
213 CheckDownloadUI(full_file_name); 209 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
214 CheckDownloadHistory(actual_page_url, full_file_name, 1); // a.htm is 1 file. 210 CheckDownloadHistory(actual_page_url, full_file_name, 1); // a.htm is 1 file.
215 211
216 EXPECT_TRUE(file_util::PathExists(full_file_name)); 212 EXPECT_TRUE(file_util::PathExists(full_file_name));
217 EXPECT_FALSE(file_util::PathExists(dir)); 213 EXPECT_FALSE(file_util::PathExists(dir));
218 EXPECT_TRUE(file_util::ContentsEqual( 214 EXPECT_TRUE(file_util::ContentsEqual(
219 test_dir_.Append(FilePath(kTestDir)).Append(file_name), 215 test_dir_.Append(FilePath(kTestDir)).Append(file_name),
220 full_file_name)); 216 full_file_name));
221 } 217 }
222 218
223 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveCompleteHTML) { 219 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveCompleteHTML) {
224 GURL url = NavigateToMockURL("b"); 220 GURL url = NavigateToMockURL("b");
225 221
226 FilePath full_file_name, dir; 222 FilePath full_file_name, dir;
227 GetDestinationPaths("b", &full_file_name, &dir); 223 GetDestinationPaths("b", &full_file_name, &dir);
228 ASSERT_TRUE(GetCurrentTab()->SavePage( 224 ASSERT_TRUE(GetCurrentTab()->SavePage(
229 full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); 225 full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML));
230 226
231 EXPECT_EQ(url, WaitForSavePackageToFinish()); 227 EXPECT_EQ(url, WaitForSavePackageToFinish());
232 228
233 CheckDownloadUI(full_file_name); 229 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
234 CheckDownloadHistory(url, full_file_name, 3); // b.htm is 3 files. 230 CheckDownloadHistory(url, full_file_name, 3); // b.htm is 3 files.
235 231
236 EXPECT_TRUE(file_util::PathExists(full_file_name)); 232 EXPECT_TRUE(file_util::PathExists(full_file_name));
237 EXPECT_TRUE(file_util::PathExists(dir)); 233 EXPECT_TRUE(file_util::PathExists(dir));
238 EXPECT_TRUE(file_util::TextContentsEqual( 234 EXPECT_TRUE(file_util::TextContentsEqual(
239 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved1.htm"), 235 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved1.htm"),
240 full_file_name)); 236 full_file_name));
241 EXPECT_TRUE(file_util::ContentsEqual( 237 EXPECT_TRUE(file_util::ContentsEqual(
242 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"), 238 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"),
243 dir.AppendASCII("1.png"))); 239 dir.AppendASCII("1.png")));
(...skipping 13 matching lines...) Expand all
257 253
258 FilePath full_file_name = save_dir_.path().AppendASCII( 254 FilePath full_file_name = save_dir_.path().AppendASCII(
259 std::string("Test page for saving page feature") + kAppendedExtension); 255 std::string("Test page for saving page feature") + kAppendedExtension);
260 FilePath dir = save_dir_.path().AppendASCII( 256 FilePath dir = save_dir_.path().AppendASCII(
261 "Test page for saving page feature_files"); 257 "Test page for saving page feature_files");
262 ASSERT_TRUE(GetCurrentTab()->SavePage( 258 ASSERT_TRUE(GetCurrentTab()->SavePage(
263 full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); 259 full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML));
264 260
265 EXPECT_EQ(url, WaitForSavePackageToFinish()); 261 EXPECT_EQ(url, WaitForSavePackageToFinish());
266 262
267 CheckDownloadUI(full_file_name); 263 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
268 CheckDownloadHistory(url, full_file_name, 3); // b.htm is 3 files. 264 CheckDownloadHistory(url, full_file_name, 3); // b.htm is 3 files.
269 265
270 EXPECT_TRUE(file_util::PathExists(full_file_name)); 266 EXPECT_TRUE(file_util::PathExists(full_file_name));
271 EXPECT_TRUE(file_util::PathExists(dir)); 267 EXPECT_TRUE(file_util::PathExists(dir));
272 EXPECT_TRUE(file_util::TextContentsEqual( 268 EXPECT_TRUE(file_util::TextContentsEqual(
273 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved2.htm"), 269 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved2.htm"),
274 full_file_name)); 270 full_file_name));
275 EXPECT_TRUE(file_util::ContentsEqual( 271 EXPECT_TRUE(file_util::ContentsEqual(
276 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"), 272 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"),
277 dir.AppendASCII("1.png"))); 273 dir.AppendASCII("1.png")));
278 EXPECT_TRUE(file_util::ContentsEqual( 274 EXPECT_TRUE(file_util::ContentsEqual(
279 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.css"), 275 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.css"),
280 dir.AppendASCII("1.css"))); 276 dir.AppendASCII("1.css")));
281 } 277 }
282 278
283 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, RemoveFromList) { 279 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, RemoveFromList) {
284 GURL url = NavigateToMockURL("a"); 280 GURL url = NavigateToMockURL("a");
285 281
286 FilePath full_file_name, dir; 282 FilePath full_file_name, dir;
287 GetDestinationPaths("a", &full_file_name, &dir); 283 GetDestinationPaths("a", &full_file_name, &dir);
288 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, 284 ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir,
289 content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); 285 content::SAVE_PAGE_TYPE_AS_ONLY_HTML));
290 286
291 EXPECT_EQ(url, WaitForSavePackageToFinish()); 287 EXPECT_EQ(url, WaitForSavePackageToFinish());
292 288
293 CheckDownloadUI(full_file_name); 289 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
294 CheckDownloadHistory(url, full_file_name, 1); // a.htm is 1 file. 290 CheckDownloadHistory(url, full_file_name, 1); // a.htm is 1 file.
295 291
296 EXPECT_EQ(GetDownloadManager()->RemoveAllDownloads(), 1); 292 EXPECT_EQ(GetDownloadManager()->RemoveAllDownloads(), 1);
297 293
298 // Should not be in history. 294 // Should not be in history.
299 QueryDownloadHistory(); 295 QueryDownloadHistory();
300 EXPECT_EQ(std::find_if(history_entries_.begin(), history_entries_.end(), 296 EXPECT_EQ(std::find_if(history_entries_.begin(), history_entries_.end(),
301 DownloadPersistentStoreInfoMatch(url, full_file_name, 1)), 297 DownloadPersistentStoreInfoMatch(url, full_file_name, 1)),
302 history_entries_.end()); 298 history_entries_.end());
303 299
(...skipping 28 matching lines...) Expand all
332 content::NotificationService::AllSources()); 328 content::NotificationService::AllSources());
333 browser()->SavePage(); 329 browser()->SavePage();
334 observer.Wait(); 330 observer.Wait();
335 331
336 EXPECT_TRUE(file_util::PathExists(full_file_name)); 332 EXPECT_TRUE(file_util::PathExists(full_file_name));
337 333
338 EXPECT_TRUE(file_util::DieFileDie(full_file_name, false)); 334 EXPECT_TRUE(file_util::DieFileDie(full_file_name, false));
339 EXPECT_TRUE(file_util::DieFileDie(dir, true)); 335 EXPECT_TRUE(file_util::DieFileDie(dir, true));
340 } 336 }
341 #endif 337 #endif
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/resources/chromeos/active_downloads.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698