| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 WebContents* GetCurrentTab() const { | 103 WebContents* GetCurrentTab() const { |
| 104 WebContents* current_tab = chrome::GetActiveWebContents(browser()); | 104 WebContents* current_tab = chrome::GetActiveWebContents(browser()); |
| 105 EXPECT_TRUE(current_tab); | 105 EXPECT_TRUE(current_tab); |
| 106 return current_tab; | 106 return current_tab; |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 GURL WaitForSavePackageToFinish() const { | 110 GURL WaitForSavePackageToFinish() const { |
| 111 ui_test_utils::WindowedNotificationObserver observer( | 111 content::WindowedNotificationObserver observer( |
| 112 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, | 112 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
| 113 content::NotificationService::AllSources()); | 113 content::NotificationService::AllSources()); |
| 114 observer.Wait(); | 114 observer.Wait(); |
| 115 return content::Details<DownloadItem>(observer.details()).ptr()-> | 115 return content::Details<DownloadItem>(observer.details()).ptr()-> |
| 116 GetOriginalUrl(); | 116 GetOriginalUrl(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 DownloadManager* GetDownloadManager() const { | 119 DownloadManager* GetDownloadManager() const { |
| 120 DownloadManager* download_manager = | 120 DownloadManager* download_manager = |
| 121 BrowserContext::GetDownloadManager(browser()->profile()); | 121 BrowserContext::GetDownloadManager(browser()->profile()); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 FilePath full_file_name = | 356 FilePath full_file_name = |
| 357 download_dir.AppendASCII(std::string("test.exe") + kAppendedExtension); | 357 download_dir.AppendASCII(std::string("test.exe") + kAppendedExtension); |
| 358 FilePath dir = download_dir.AppendASCII("test.exe_files"); | 358 FilePath dir = download_dir.AppendASCII("test.exe_files"); |
| 359 | 359 |
| 360 EXPECT_FALSE(file_util::PathExists(full_file_name)); | 360 EXPECT_FALSE(file_util::PathExists(full_file_name)); |
| 361 GURL url = URLRequestMockHTTPJob::GetMockUrl( | 361 GURL url = URLRequestMockHTTPJob::GetMockUrl( |
| 362 FilePath(kTestDir).Append(file_name)); | 362 FilePath(kTestDir).Append(file_name)); |
| 363 ui_test_utils::NavigateToURL(browser(), url); | 363 ui_test_utils::NavigateToURL(browser(), url); |
| 364 | 364 |
| 365 SavePackageFilePicker::SetShouldPromptUser(false); | 365 SavePackageFilePicker::SetShouldPromptUser(false); |
| 366 ui_test_utils::WindowedNotificationObserver observer( | 366 content::WindowedNotificationObserver observer( |
| 367 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, | 367 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
| 368 content::NotificationService::AllSources()); | 368 content::NotificationService::AllSources()); |
| 369 chrome::SavePage(browser()); | 369 chrome::SavePage(browser()); |
| 370 observer.Wait(); | 370 observer.Wait(); |
| 371 | 371 |
| 372 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 372 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
| 373 | 373 |
| 374 EXPECT_TRUE(file_util::DieFileDie(full_file_name, false)); | 374 EXPECT_TRUE(file_util::DieFileDie(full_file_name, false)); |
| 375 EXPECT_TRUE(file_util::DieFileDie(dir, true)); | 375 EXPECT_TRUE(file_util::DieFileDie(dir, true)); |
| 376 } | 376 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 396 GURL url = NavigateToMockURL("b"); | 396 GURL url = NavigateToMockURL("b"); |
| 397 FilePath download_dir = DownloadPrefs::FromDownloadManager( | 397 FilePath download_dir = DownloadPrefs::FromDownloadManager( |
| 398 GetDownloadManager())->download_path(); | 398 GetDownloadManager())->download_path(); |
| 399 FilePath full_file_name = download_dir.AppendASCII(std::string( | 399 FilePath full_file_name = download_dir.AppendASCII(std::string( |
| 400 "Test page for saving page feature.mhtml")); | 400 "Test page for saving page feature.mhtml")); |
| 401 #if defined(OS_CHROMEOS) | 401 #if defined(OS_CHROMEOS) |
| 402 SavePackageFilePickerChromeOS::SetShouldPromptUser(false); | 402 SavePackageFilePickerChromeOS::SetShouldPromptUser(false); |
| 403 #else | 403 #else |
| 404 SavePackageFilePicker::SetShouldPromptUser(false); | 404 SavePackageFilePicker::SetShouldPromptUser(false); |
| 405 #endif | 405 #endif |
| 406 ui_test_utils::WindowedNotificationObserver observer( | 406 content::WindowedNotificationObserver observer( |
| 407 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, | 407 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
| 408 content::NotificationService::AllSources()); | 408 content::NotificationService::AllSources()); |
| 409 chrome::SavePage(browser()); | 409 chrome::SavePage(browser()); |
| 410 observer.Wait(); | 410 observer.Wait(); |
| 411 CheckDownloadHistory(url, full_file_name, -1); | 411 CheckDownloadHistory(url, full_file_name, -1); |
| 412 | 412 |
| 413 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 413 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
| 414 int64 actual_file_size = -1; | 414 int64 actual_file_size = -1; |
| 415 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); | 415 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); |
| 416 EXPECT_LE(kFileSizeMin, actual_file_size); | 416 EXPECT_LE(kFileSizeMin, actual_file_size); |
| 417 } | 417 } |
| OLD | NEW |