| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
| 8 #include "chrome/browser/character_encoding.h" | 8 #include "chrome/browser/character_encoding.h" |
| 9 #include "chrome/browser/net/url_request_mock_util.h" | 9 #include "chrome/browser/net/url_request_mock_util.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // Saves the current page and verifies that the output matches the expected | 35 // Saves the current page and verifies that the output matches the expected |
| 36 // result. | 36 // result. |
| 37 void SaveAndCompare(const char* filename_to_write, const FilePath& expected) { | 37 void SaveAndCompare(const char* filename_to_write, const FilePath& expected) { |
| 38 // Dump the page, the content of dump page should be identical to the | 38 // Dump the page, the content of dump page should be identical to the |
| 39 // expected result file. | 39 // expected result file. |
| 40 FilePath full_file_name = save_dir_.AppendASCII(filename_to_write); | 40 FilePath full_file_name = save_dir_.AppendASCII(filename_to_write); |
| 41 // We save the page as way of complete HTML file, which requires a directory | 41 // We save the page as way of complete HTML file, which requires a directory |
| 42 // name to save sub resources in it. Although this test file does not have | 42 // name to save sub resources in it. Although this test file does not have |
| 43 // sub resources, but the directory name is still required. | 43 // sub resources, but the directory name is still required. |
| 44 ui_test_utils::WindowedNotificationObserver observer( | 44 content::WindowedNotificationObserver observer( |
| 45 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, | 45 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
| 46 content::NotificationService::AllSources()); | 46 content::NotificationService::AllSources()); |
| 47 chrome::GetActiveWebContents(browser())->SavePage( | 47 chrome::GetActiveWebContents(browser())->SavePage( |
| 48 full_file_name, temp_sub_resource_dir_, | 48 full_file_name, temp_sub_resource_dir_, |
| 49 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML); | 49 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML); |
| 50 observer.Wait(); | 50 observer.Wait(); |
| 51 | 51 |
| 52 FilePath expected_file_name = ui_test_utils::GetTestFilePath( | 52 FilePath expected_file_name = ui_test_utils::GetTestFilePath( |
| 53 FilePath(kTestDir), expected); | 53 FilePath(kTestDir), expected); |
| 54 | 54 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 EXPECT_EQ(kTestDatas[i].expected_encoding, web_contents->GetEncoding()); | 289 EXPECT_EQ(kTestDatas[i].expected_encoding, web_contents->GetEncoding()); |
| 290 | 290 |
| 291 // Dump the page, the content of dump page should be equal with our expect | 291 // Dump the page, the content of dump page should be equal with our expect |
| 292 // result file. | 292 // result file. |
| 293 FilePath expected_result_file_name = | 293 FilePath expected_result_file_name = |
| 294 FilePath().AppendASCII(kAutoDetectDir).AppendASCII(kExpectedResultDir). | 294 FilePath().AppendASCII(kAutoDetectDir).AppendASCII(kExpectedResultDir). |
| 295 AppendASCII(kTestDatas[i].expected_result); | 295 AppendASCII(kTestDatas[i].expected_result); |
| 296 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); | 296 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); |
| 297 } | 297 } |
| 298 } | 298 } |
| OLD | NEW |