diff options
Diffstat (limited to 'chrome/browser/download/save_page_uitest.cc')
-rw-r--r-- | chrome/browser/download/save_page_uitest.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/browser/download/save_page_uitest.cc b/chrome/browser/download/save_page_uitest.cc index 0c75c21..be422f8 100644 --- a/chrome/browser/download/save_page_uitest.cc +++ b/chrome/browser/download/save_page_uitest.cc @@ -5,9 +5,11 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/string_util.h" +#include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/automation/url_request_mock_http_job.h" #include "chrome/browser/download/save_package.h" #include "chrome/common/chrome_paths.h" +#include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" #include "net/url_request/url_request_unittest.h" @@ -53,9 +55,18 @@ class SavePageTest : public UITest { UITest::SetUp(); EXPECT_TRUE(file_util::CreateNewTempDirectory(L"", &save_dir_)); save_dir_ += FilePath::kSeparators[0]; + + download_dir_ = GetDownloadDirectory(); + download_dir_ += FilePath::kSeparators[0]; + } + + virtual void TearDown() { + UITest::TearDown(); + DieFileDie(save_dir_, true); } std::wstring save_dir_; + std::wstring download_dir_; }; TEST_F(SavePageTest, SaveHTMLOnly) { @@ -110,3 +121,48 @@ TEST_F(SavePageTest, NoSave) { EXPECT_FALSE(WaitForDownloadShelfVisible(tab.get())); } +TEST_F(SavePageTest, FilenameFromPageTitle) { + std::wstring file_name = L"b.htm"; + std::wstring full_file_name = download_dir_ + + L"Test page for saving page feature.htm"; + std::wstring dir = download_dir_ + + L"Test page for saving page feature_files"; + + GURL url = URLRequestMockHTTPJob::GetMockUrl(kTestDir + L"/" + file_name); + scoped_ptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab->NavigateToURL(url)); + WaitUntilTabCount(1); + + scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + automation()->SavePackageShouldPromptUser(false); + EXPECT_TRUE(browser->RunCommand(IDC_SAVE_PAGE)); + EXPECT_TRUE(WaitForDownloadShelfVisible(tab.get())); + automation()->SavePackageShouldPromptUser(true); + + CheckFile(dir + L"\\1.png", L"1.png", true); + CheckFile(dir + L"\\1.css", L"1.css", true); + CheckFile(full_file_name, file_name, false); + EXPECT_TRUE(DieFileDie(full_file_name, false)); + EXPECT_TRUE(DieFileDie(dir, true)); +} + +TEST_F(SavePageTest, CleanFilenameFromPageTitle) { + std::wstring file_name = L"c.htm"; + std::wstring full_file_name = download_dir_ + L"test.htm"; + std::wstring dir = download_dir_ + L"test_files"; + + GURL url = URLRequestMockHTTPJob::GetMockUrl(kTestDir + L"/" + file_name); + scoped_ptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab->NavigateToURL(url)); + WaitUntilTabCount(1); + + scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + automation()->SavePackageShouldPromptUser(false); + EXPECT_TRUE(browser->RunCommand(IDC_SAVE_PAGE)); + EXPECT_TRUE(WaitForDownloadShelfVisible(tab.get())); + automation()->SavePackageShouldPromptUser(true); + + CheckFile(full_file_name, file_name, false); + EXPECT_TRUE(DieFileDie(full_file_name, false)); + EXPECT_TRUE(DieFileDie(dir, true)); +} |