| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/platform_thread.h" | 7 #include "base/platform_thread.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
| 10 #include "chrome/browser/automation/url_request_mock_http_job.h" | 10 #include "chrome/browser/automation/url_request_mock_http_job.h" |
| 11 #include "chrome/browser/download/save_package.h" | 11 #include "chrome/browser/download/save_package.h" |
| 12 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
| 13 #include "chrome/test/automation/browser_proxy.h" | 13 #include "chrome/test/automation/browser_proxy.h" |
| 14 #include "chrome/test/automation/tab_proxy.h" | 14 #include "chrome/test/automation/tab_proxy.h" |
| 15 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
| 16 #include "net/url_request/url_request_unittest.h" | 16 #include "net/url_request/url_request_unittest.h" |
| 17 | 17 |
| 18 #if defined(OS_LINUX) |
| 19 #define MAYBE_SaveCompleteHTML DISABLED_SaveCompleteHTML |
| 20 #define MAYBE_SaveHTMLOnly DISABLED_SaveHTMLOnly |
| 21 #else |
| 22 #define MAYBE_SaveCompleteHTML SaveCompleteHTML |
| 23 #define MAYBE_SaveHTMLOnly SaveHTMLOnly |
| 24 #endif |
| 25 |
| 18 const char* const kTestDir = "save_page"; | 26 const char* const kTestDir = "save_page"; |
| 19 | 27 |
| 20 const char* const kAppendedExtension = ".htm"; | 28 const char* const kAppendedExtension = ".htm"; |
| 21 | 29 |
| 22 class SavePageTest : public UITest { | 30 class SavePageTest : public UITest { |
| 23 protected: | 31 protected: |
| 24 SavePageTest() : UITest() {} | 32 SavePageTest() : UITest() {} |
| 25 | 33 |
| 26 void CheckFile(const FilePath& client_file, | 34 void CheckFile(const FilePath& client_file, |
| 27 const FilePath& server_file, | 35 const FilePath& server_file, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 79 |
| 72 virtual void TearDown() { | 80 virtual void TearDown() { |
| 73 UITest::TearDown(); | 81 UITest::TearDown(); |
| 74 DieFileDie(save_dir_, true); | 82 DieFileDie(save_dir_, true); |
| 75 } | 83 } |
| 76 | 84 |
| 77 FilePath save_dir_; | 85 FilePath save_dir_; |
| 78 FilePath download_dir_; | 86 FilePath download_dir_; |
| 79 }; | 87 }; |
| 80 | 88 |
| 81 TEST_F(SavePageTest, SaveHTMLOnly) { | 89 // Flaky on Linux: http://code.google.com/p/chromium/issues/detail?id=14746 |
| 90 TEST_F(SavePageTest, MAYBE_SaveHTMLOnly) { |
| 82 std::string file_name("a.htm"); | 91 std::string file_name("a.htm"); |
| 83 FilePath full_file_name = save_dir_.AppendASCII(file_name); | 92 FilePath full_file_name = save_dir_.AppendASCII(file_name); |
| 84 FilePath dir = save_dir_.AppendASCII("a_files"); | 93 FilePath dir = save_dir_.AppendASCII("a_files"); |
| 85 | 94 |
| 86 GURL url = URLRequestMockHTTPJob::GetMockUrl( | 95 GURL url = URLRequestMockHTTPJob::GetMockUrl( |
| 87 UTF8ToWide(std::string(kTestDir) + "/" + file_name)); | 96 UTF8ToWide(std::string(kTestDir) + "/" + file_name)); |
| 88 scoped_refptr<TabProxy> tab(GetActiveTab()); | 97 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 89 ASSERT_TRUE(tab->NavigateToURL(url)); | 98 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 90 WaitUntilTabCount(1); | 99 WaitUntilTabCount(1); |
| 91 | 100 |
| 92 EXPECT_TRUE(tab->SavePage(full_file_name.ToWStringHack(), dir.ToWStringHack(), | 101 EXPECT_TRUE(tab->SavePage(full_file_name.ToWStringHack(), dir.ToWStringHack(), |
| 93 SavePackage::SAVE_AS_ONLY_HTML)); | 102 SavePackage::SAVE_AS_ONLY_HTML)); |
| 94 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 103 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 95 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); | 104 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); |
| 96 | 105 |
| 97 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)), | 106 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)), |
| 98 true); | 107 true); |
| 99 EXPECT_FALSE(file_util::PathExists(dir)); | 108 EXPECT_FALSE(file_util::PathExists(dir)); |
| 100 } | 109 } |
| 101 | 110 |
| 102 TEST_F(SavePageTest, SaveCompleteHTML) { | 111 // Flaky on Linux: http://code.google.com/p/chromium/issues/detail?id=14746 |
| 112 TEST_F(SavePageTest, MAYBE_SaveCompleteHTML) { |
| 103 std::string file_name = "b.htm"; | 113 std::string file_name = "b.htm"; |
| 104 FilePath full_file_name = save_dir_.AppendASCII(file_name); | 114 FilePath full_file_name = save_dir_.AppendASCII(file_name); |
| 105 FilePath dir = save_dir_.AppendASCII("b_files"); | 115 FilePath dir = save_dir_.AppendASCII("b_files"); |
| 106 | 116 |
| 107 GURL url = URLRequestMockHTTPJob::GetMockUrl( | 117 GURL url = URLRequestMockHTTPJob::GetMockUrl( |
| 108 UTF8ToWide(std::string(kTestDir) + "/" + file_name)); | 118 UTF8ToWide(std::string(kTestDir) + "/" + file_name)); |
| 109 scoped_refptr<TabProxy> tab(GetActiveTab()); | 119 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 110 ASSERT_TRUE(tab->NavigateToURL(url)); | 120 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 111 WaitUntilTabCount(1); | 121 WaitUntilTabCount(1); |
| 112 | 122 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 EXPECT_TRUE(browser->RunCommandAsync(IDC_SAVE_PAGE)); | 201 EXPECT_TRUE(browser->RunCommandAsync(IDC_SAVE_PAGE)); |
| 192 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); | 202 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); |
| 193 automation()->SavePackageShouldPromptUser(true); | 203 automation()->SavePackageShouldPromptUser(true); |
| 194 | 204 |
| 195 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)), | 205 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)), |
| 196 false); | 206 false); |
| 197 EXPECT_TRUE(DieFileDie(full_file_name, false)); | 207 EXPECT_TRUE(DieFileDie(full_file_name, false)); |
| 198 EXPECT_TRUE(DieFileDie(dir, true)); | 208 EXPECT_TRUE(DieFileDie(dir, true)); |
| 199 } | 209 } |
| 200 #endif | 210 #endif |
| OLD | NEW |