OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 archiver->CreateArchive(GetTestFilePath(), kTestArcihveId, callback()); | 226 archiver->CreateArchive(GetTestFilePath(), kTestArcihveId, callback()); |
227 PumpLoop(); | 227 PumpLoop(); |
228 | 228 |
229 EXPECT_EQ(archiver.get(), last_archiver()); | 229 EXPECT_EQ(archiver.get(), last_archiver()); |
230 EXPECT_EQ(OfflinePageArchiver::ArchiverResult::SUCCESSFULLY_CREATED, | 230 EXPECT_EQ(OfflinePageArchiver::ArchiverResult::SUCCESSFULLY_CREATED, |
231 last_result()); | 231 last_result()); |
232 EXPECT_EQ(GetTestFilePath(), last_file_path()); | 232 EXPECT_EQ(GetTestFilePath(), last_file_path()); |
233 EXPECT_EQ(kTestFileSize, last_file_size()); | 233 EXPECT_EQ(kTestFileSize, last_file_size()); |
234 } | 234 } |
235 | 235 |
236 TEST_F(OfflinePageMHTMLArchiverTest, GenerateFileName) { | |
237 GURL url_1("http://news.google.com/page1"); | |
238 std::string title_1("Google News Page"); | |
239 base::FilePath expected_1(FILE_PATH_LITERAL( | |
240 "news.google.com-Google_News_Page-1234.mhtml")); | |
241 base::FilePath actual_1( | |
242 OfflinePageMHTMLArchiver::GenerateFileName(url_1, title_1, 1234LL)); | |
243 EXPECT_EQ(expected_1, actual_1); | |
244 | |
245 GURL url_2("https://en.m.wikipedia.org/Sample_page_about_stuff"); | |
246 std::string title_2("Some Wiki Page"); | |
247 base::FilePath expected_2(FILE_PATH_LITERAL( | |
248 "en.m.wikipedia.org-Some_Wiki_Page-56789.mhtml")); | |
249 base::FilePath actual_2( | |
250 OfflinePageMHTMLArchiver::GenerateFileName(url_2, title_2, 56789LL)); | |
251 EXPECT_EQ(expected_2, actual_2); | |
252 | |
253 GURL url_3("https://www.google.com/search"); | |
254 std::string title_3 = | |
255 "A really really really really really long title " | |
256 "that is over 80 chars long here^ - TRUNCATE THIS PART"; | |
257 std::string expected_title_3_part = | |
258 "A_really_really_really_really_really_long_title_" | |
259 "that_is_over_80_chars_long_here^"; | |
260 base::FilePath expected_3( | |
261 FILE_PATH_LITERAL("www.google.com-" + | |
262 expected_title_3_part + | |
263 "-123456789.mhtml")); | |
264 base::FilePath actual_3( | |
265 OfflinePageMHTMLArchiver::GenerateFileName(url_3, title_3, 123456789LL)); | |
266 EXPECT_EQ(expected_3, actual_3); | |
267 } | |
268 | |
269 } // namespace offline_pages | 236 } // namespace offline_pages |
OLD | NEW |