| 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 25 matching lines...) Expand all Loading... |
| 36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 37 #include "content/test/net/url_request_mock_http_job.h" | 37 #include "content/test/net/url_request_mock_http_job.h" |
| 38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 39 | 39 |
| 40 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
| 41 #include "chrome/browser/download/save_package_file_picker_chromeos.h" | 41 #include "chrome/browser/download/save_package_file_picker_chromeos.h" |
| 42 #else | 42 #else |
| 43 #include "chrome/browser/download/save_package_file_picker.h" | 43 #include "chrome/browser/download/save_package_file_picker.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 using content::BrowserContext; |
| 46 using content::BrowserThread; | 47 using content::BrowserThread; |
| 47 using content::DownloadItem; | 48 using content::DownloadItem; |
| 48 using content::DownloadManager; | 49 using content::DownloadManager; |
| 49 using content::DownloadPersistentStoreInfo; | 50 using content::DownloadPersistentStoreInfo; |
| 50 using content::WebContents; | 51 using content::WebContents; |
| 51 | 52 |
| 52 namespace { | 53 namespace { |
| 53 | 54 |
| 54 static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("save_page"); | 55 static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("save_page"); |
| 55 | 56 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 ui_test_utils::WindowedNotificationObserver observer( | 109 ui_test_utils::WindowedNotificationObserver observer( |
| 109 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, | 110 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
| 110 content::NotificationService::AllSources()); | 111 content::NotificationService::AllSources()); |
| 111 observer.Wait(); | 112 observer.Wait(); |
| 112 return content::Details<DownloadItem>(observer.details()).ptr()-> | 113 return content::Details<DownloadItem>(observer.details()).ptr()-> |
| 113 GetOriginalUrl(); | 114 GetOriginalUrl(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 DownloadManager* GetDownloadManager() const { | 117 DownloadManager* GetDownloadManager() const { |
| 117 DownloadManager* download_manager = | 118 DownloadManager* download_manager = |
| 118 DownloadServiceFactory::GetForProfile( | 119 BrowserContext::GetDownloadManager(browser()->profile()); |
| 119 browser()->profile())->GetDownloadManager(); | |
| 120 EXPECT_TRUE(download_manager); | 120 EXPECT_TRUE(download_manager); |
| 121 return download_manager; | 121 return download_manager; |
| 122 } | 122 } |
| 123 | 123 |
| 124 void QueryDownloadHistory() { | 124 void QueryDownloadHistory() { |
| 125 // Query the history system. | 125 // Query the history system. |
| 126 ChromeDownloadManagerDelegate* delegate = | 126 ChromeDownloadManagerDelegate* delegate = |
| 127 static_cast<ChromeDownloadManagerDelegate*>( | 127 static_cast<ChromeDownloadManagerDelegate*>( |
| 128 GetDownloadManager()->delegate()); | 128 GetDownloadManager()->delegate()); |
| 129 delegate->download_history()->Load( | 129 delegate->download_history()->Load( |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 content::NotificationService::AllSources()); | 407 content::NotificationService::AllSources()); |
| 408 browser()->SavePage(); | 408 browser()->SavePage(); |
| 409 observer.Wait(); | 409 observer.Wait(); |
| 410 CheckDownloadHistory(url, full_file_name, -1); | 410 CheckDownloadHistory(url, full_file_name, -1); |
| 411 | 411 |
| 412 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 412 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
| 413 int64 actual_file_size = -1; | 413 int64 actual_file_size = -1; |
| 414 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); | 414 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); |
| 415 EXPECT_LE(kFileSizeMin, actual_file_size); | 415 EXPECT_LE(kFileSizeMin, actual_file_size); |
| 416 } | 416 } |
| OLD | NEW |