OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_path.h" | 5 #include "base/file_path.h" |
6 #include "base/scoped_temp_dir.h" | 6 #include "base/scoped_temp_dir.h" |
7 #include "chrome/app/chrome_dll_resource.h" | 7 #include "chrome/app/chrome_dll_resource.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_window.h" | 9 #include "chrome/browser/browser_window.h" |
10 #include "chrome/browser/net/url_request_mock_http_job.h" | 10 #include "chrome/browser/net/url_request_mock_http_job.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 FilePath file_name(FILE_PATH_LITERAL("a.htm")); | 81 FilePath file_name(FILE_PATH_LITERAL("a.htm")); |
82 GURL url = URLRequestMockHTTPJob::GetMockUrl( | 82 GURL url = URLRequestMockHTTPJob::GetMockUrl( |
83 FilePath(kTestDir).Append(file_name).ToWStringHack()); | 83 FilePath(kTestDir).Append(file_name).ToWStringHack()); |
84 ui_test_utils::NavigateToURL(browser(), url); | 84 ui_test_utils::NavigateToURL(browser(), url); |
85 | 85 |
86 TabContents* current_tab = browser()->GetSelectedTabContents(); | 86 TabContents* current_tab = browser()->GetSelectedTabContents(); |
87 ASSERT_TRUE(current_tab); | 87 ASSERT_TRUE(current_tab); |
88 | 88 |
89 FilePath full_file_name = save_dir_.path().Append(file_name); | 89 FilePath full_file_name = save_dir_.path().Append(file_name); |
90 FilePath dir = save_dir_.path().AppendASCII("a_files"); | 90 FilePath dir = save_dir_.path().AppendASCII("a_files"); |
91 ASSERT_TRUE(current_tab->SavePage(full_file_name.ToWStringHack(), | 91 ASSERT_TRUE(current_tab->SavePage(full_file_name, dir, |
92 dir.ToWStringHack(), | |
93 SavePackage::SAVE_AS_ONLY_HTML)); | 92 SavePackage::SAVE_AS_ONLY_HTML)); |
94 | 93 |
95 SavePageFinishedObserver observer; | 94 SavePageFinishedObserver observer; |
96 | 95 |
97 EXPECT_EQ(url, observer.page_url()); | 96 EXPECT_EQ(url, observer.page_url()); |
98 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 97 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
99 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 98 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
100 EXPECT_FALSE(file_util::PathExists(dir)); | 99 EXPECT_FALSE(file_util::PathExists(dir)); |
101 EXPECT_TRUE(file_util::ContentsEqual( | 100 EXPECT_TRUE(file_util::ContentsEqual( |
102 test_dir_.Append(FilePath(kTestDir)).Append(file_name), | 101 test_dir_.Append(FilePath(kTestDir)).Append(file_name), |
103 full_file_name)); | 102 full_file_name)); |
104 } | 103 } |
105 | 104 |
106 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveCompleteHTML) { | 105 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveCompleteHTML) { |
107 FilePath file_name(FILE_PATH_LITERAL("b.htm")); | 106 FilePath file_name(FILE_PATH_LITERAL("b.htm")); |
108 GURL url = URLRequestMockHTTPJob::GetMockUrl( | 107 GURL url = URLRequestMockHTTPJob::GetMockUrl( |
109 FilePath(kTestDir).Append(file_name).ToWStringHack()); | 108 FilePath(kTestDir).Append(file_name).ToWStringHack()); |
110 ui_test_utils::NavigateToURL(browser(), url); | 109 ui_test_utils::NavigateToURL(browser(), url); |
111 | 110 |
112 TabContents* current_tab = browser()->GetSelectedTabContents(); | 111 TabContents* current_tab = browser()->GetSelectedTabContents(); |
113 ASSERT_TRUE(current_tab); | 112 ASSERT_TRUE(current_tab); |
114 | 113 |
115 FilePath full_file_name = save_dir_.path().Append(file_name); | 114 FilePath full_file_name = save_dir_.path().Append(file_name); |
116 FilePath dir = save_dir_.path().AppendASCII("b_files"); | 115 FilePath dir = save_dir_.path().AppendASCII("b_files"); |
117 ASSERT_TRUE(current_tab->SavePage(full_file_name.ToWStringHack(), | 116 ASSERT_TRUE(current_tab->SavePage(full_file_name, dir, |
118 dir.ToWStringHack(), | |
119 SavePackage::SAVE_AS_COMPLETE_HTML)); | 117 SavePackage::SAVE_AS_COMPLETE_HTML)); |
120 | 118 |
121 SavePageFinishedObserver observer; | 119 SavePageFinishedObserver observer; |
122 | 120 |
123 EXPECT_EQ(url, observer.page_url()); | 121 EXPECT_EQ(url, observer.page_url()); |
124 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 122 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
125 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 123 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
126 EXPECT_TRUE(file_util::PathExists(dir)); | 124 EXPECT_TRUE(file_util::PathExists(dir)); |
127 EXPECT_TRUE(file_util::TextContentsEqual( | 125 EXPECT_TRUE(file_util::TextContentsEqual( |
128 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved1.htm"), | 126 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved1.htm"), |
(...skipping 23 matching lines...) Expand all Loading... |
152 ui_test_utils::NavigateToURL(browser(), url); | 150 ui_test_utils::NavigateToURL(browser(), url); |
153 | 151 |
154 FilePath full_file_name = save_dir_.path().AppendASCII( | 152 FilePath full_file_name = save_dir_.path().AppendASCII( |
155 std::string("Test page for saving page feature") + kAppendedExtension); | 153 std::string("Test page for saving page feature") + kAppendedExtension); |
156 FilePath dir = save_dir_.path().AppendASCII( | 154 FilePath dir = save_dir_.path().AppendASCII( |
157 "Test page for saving page feature_files"); | 155 "Test page for saving page feature_files"); |
158 | 156 |
159 TabContents* current_tab = browser()->GetSelectedTabContents(); | 157 TabContents* current_tab = browser()->GetSelectedTabContents(); |
160 ASSERT_TRUE(current_tab); | 158 ASSERT_TRUE(current_tab); |
161 | 159 |
162 ASSERT_TRUE(current_tab->SavePage(full_file_name.ToWStringHack(), | 160 ASSERT_TRUE(current_tab->SavePage(full_file_name, dir, |
163 dir.ToWStringHack(), | |
164 SavePackage::SAVE_AS_COMPLETE_HTML)); | 161 SavePackage::SAVE_AS_COMPLETE_HTML)); |
165 SavePageFinishedObserver observer; | 162 SavePageFinishedObserver observer; |
166 | 163 |
167 EXPECT_EQ(url, observer.page_url()); | 164 EXPECT_EQ(url, observer.page_url()); |
168 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 165 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
169 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 166 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
170 EXPECT_TRUE(file_util::PathExists(dir)); | 167 EXPECT_TRUE(file_util::PathExists(dir)); |
171 EXPECT_TRUE(file_util::TextContentsEqual( | 168 EXPECT_TRUE(file_util::TextContentsEqual( |
172 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved2.htm"), | 169 test_dir_.Append(FilePath(kTestDir)).AppendASCII("b.saved2.htm"), |
173 full_file_name)); | 170 full_file_name)); |
174 EXPECT_TRUE(file_util::ContentsEqual( | 171 EXPECT_TRUE(file_util::ContentsEqual( |
175 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"), | 172 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.png"), |
176 dir.AppendASCII("1.png"))); | 173 dir.AppendASCII("1.png"))); |
177 EXPECT_TRUE(file_util::ContentsEqual( | 174 EXPECT_TRUE(file_util::ContentsEqual( |
178 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.css"), | 175 test_dir_.Append(FilePath(kTestDir)).AppendASCII("1.css"), |
179 dir.AppendASCII("1.css"))); | 176 dir.AppendASCII("1.css"))); |
180 } | 177 } |
181 #endif // !defined(OS_MACOSX) | 178 #endif // !defined(OS_MACOSX) |
182 | 179 |
183 } // namespace | 180 } // namespace |
OLD | NEW |