| Index: chrome/browser/download/save_page_browsertest.cc
|
| diff --git a/chrome/browser/download/save_page_browsertest.cc b/chrome/browser/download/save_page_browsertest.cc
|
| index 49e351a3ad1fe1fab596178000feb47caacbe169..e37f0cae8860cb772c3e8a62bae0523503faaca1 100644
|
| --- a/chrome/browser/download/save_page_browsertest.cc
|
| +++ b/chrome/browser/download/save_page_browsertest.cc
|
| @@ -17,11 +17,14 @@
|
| #include "chrome/browser/download/download_service_factory.h"
|
| #include "chrome/browser/download/save_package_file_picker.h"
|
| #include "chrome/browser/net/url_request_mock_util.h"
|
| +#include "chrome/browser/prefs/pref_member.h"
|
| +#include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_window.h"
|
| #include "chrome/browser/ui/webui/chromeos/active_downloads_ui.h"
|
| #include "chrome/common/chrome_paths.h"
|
| +#include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "chrome/test/base/ui_test_utils.h"
|
| @@ -62,6 +65,8 @@ class SavePageBrowserTest : public InProcessBrowserTest {
|
| }
|
|
|
| void SetUpOnMainThread() OVERRIDE {
|
| + browser()->profile()->GetPrefs()->SetFilePath(
|
| + prefs::kDownloadDefaultDirectory, save_dir_.path());
|
| BrowserThread::PostTask(
|
| BrowserThread::IO, FROM_HERE,
|
| base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
|
| @@ -184,12 +189,27 @@ class SavePageBrowserTest : public InProcessBrowserTest {
|
|
|
| void CheckDownloadHistory(const GURL& url,
|
| const FilePath& path,
|
| - int64 num_files_) {
|
| + int64 num_files) {
|
| QueryDownloadHistory();
|
|
|
| - EXPECT_NE(std::find_if(history_entries_.begin(), history_entries_.end(),
|
| - DownloadPersistentStoreInfoMatch(url, path, num_files_)),
|
| - history_entries_.end());
|
| + std::vector<DownloadPersistentStoreInfo>::iterator found =
|
| + std::find_if(history_entries_.begin(), history_entries_.end(),
|
| + DownloadPersistentStoreInfoMatch(url, path, num_files));
|
| +
|
| + if (found == history_entries_.end()) {
|
| + LOG(ERROR) << "Missing url=" << url.spec()
|
| + << " path=" << path.value()
|
| + << " received=" << num_files;
|
| + for (size_t index = 0; index < history_entries_.size(); ++index) {
|
| + LOG(ERROR) << "History@" << index << ": url="
|
| + << history_entries_[index].url.spec()
|
| + << " path=" << history_entries_[index].path.value()
|
| + << " received=" << history_entries_[index].received_bytes
|
| + << " total=" << history_entries_[index].total_bytes
|
| + << " state=" << history_entries_[index].state;
|
| + }
|
| + EXPECT_TRUE(false);
|
| + }
|
| }
|
|
|
| std::vector<DownloadPersistentStoreInfo> history_entries_;
|
| @@ -369,3 +389,26 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, CleanFilenameFromPageTitle) {
|
| EXPECT_TRUE(file_util::DieFileDie(dir, true));
|
| }
|
| #endif
|
| +
|
| +IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SavePageAsMHTML) {
|
| + GURL url = NavigateToMockURL("b");
|
| + FilePath download_dir = DownloadPrefs::FromDownloadManager(
|
| + GetDownloadManager())->download_path();
|
| + FilePath full_file_name = download_dir.AppendASCII(std::string(
|
| + "Test page for saving page feature.mht"));
|
| + SavePackageFilePicker::SetShouldPromptUser(false);
|
| + browser()->profile()->GetPrefs()->SetInteger(
|
| + prefs::kSaveFileType, content::SAVE_PAGE_TYPE_AS_MHTML);
|
| + ui_test_utils::WindowedNotificationObserver observer(
|
| + content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
|
| + content::NotificationService::AllSources());
|
| + browser()->SavePage();
|
| + observer.Wait();
|
| + CheckDownloadUI(full_file_name);
|
| + CheckDownloadHistory(url, full_file_name, 1);
|
| +
|
| + EXPECT_TRUE(file_util::PathExists(full_file_name));
|
| + int64 actual_file_size = -1;
|
| + EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size));
|
| + EXPECT_EQ(2760, actual_file_size);
|
| +}
|
|
|