| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 emf_content.SaveToPng(png); | 134 emf_content.SaveToPng(png); |
| 135 // Saving is always fine. | 135 // Saving is always fine. |
| 136 return 0; | 136 return 0; |
| 137 } else { | 137 } else { |
| 138 // File compare between test and result. | 138 // File compare between test and result. |
| 139 Image emf_content(emf); | 139 Image emf_content(emf); |
| 140 Image test_content(test_result); | 140 Image test_content(test_result); |
| 141 Image png_content(png); | 141 Image png_content(png); |
| 142 double diff_emf = emf_content.PercentageDifferent(test_content); | 142 double diff_emf = emf_content.PercentageDifferent(test_content); |
| 143 | 143 |
| 144 EXPECT_EQ(0., diff_emf) << WideToUTF8(verification_name) << | 144 EXPECT_EQ(0., diff_emf) << base::WideToUTF8(verification_name) << |
| 145 " original size:" << emf_content.size().ToString() << | 145 " original size:" << emf_content.size().ToString() << |
| 146 " result size:" << test_content.size().ToString(); | 146 " result size:" << test_content.size().ToString(); |
| 147 if (diff_emf) { | 147 if (diff_emf) { |
| 148 // Backup the result emf file. | 148 // Backup the result emf file. |
| 149 base::FilePath failed( | 149 base::FilePath failed( |
| 150 base_path.Append(verification_name + L"_failed.emf")); | 150 base_path.Append(verification_name + L"_failed.emf")); |
| 151 file_util::CopyFile(test_result, failed); | 151 file_util::CopyFile(test_result, failed); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // This verification is only to know that the EMF rendering stays | 154 // This verification is only to know that the EMF rendering stays |
| 155 // immutable. | 155 // immutable. |
| 156 double diff_png = emf_content.PercentageDifferent(png_content); | 156 double diff_png = emf_content.PercentageDifferent(png_content); |
| 157 EXPECT_EQ(0., diff_png) << WideToUTF8(verification_name) << | 157 EXPECT_EQ(0., diff_png) << base::WideToUTF8(verification_name) << |
| 158 " original size:" << emf_content.size().ToString() << | 158 " original size:" << emf_content.size().ToString() << |
| 159 " result size:" << test_content.size().ToString(); | 159 " result size:" << test_content.size().ToString(); |
| 160 if (diff_png) { | 160 if (diff_png) { |
| 161 // Backup the rendered emf file to detect the rendering difference. | 161 // Backup the rendered emf file to detect the rendering difference. |
| 162 base::FilePath rendering( | 162 base::FilePath rendering( |
| 163 base_path.Append(verification_name + L"_rendering.png")); | 163 base_path.Append(verification_name + L"_rendering.png")); |
| 164 emf_content.SaveToPng(rendering); | 164 emf_content.SaveToPng(rendering); |
| 165 } | 165 } |
| 166 return std::max(diff_png, diff_emf); | 166 return std::max(diff_png, diff_emf); |
| 167 } | 167 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 197 for (int i = 0; i < 100; ++i) { | 197 for (int i = 0; i < 100; ++i) { |
| 198 file_util::FileEnumerator enumerator(emf_path_, false, | 198 file_util::FileEnumerator enumerator(emf_path_, false, |
| 199 file_util::FileEnumerator::FILES); | 199 file_util::FileEnumerator::FILES); |
| 200 emf_file.clear(); | 200 emf_file.clear(); |
| 201 prn_file.clear(); | 201 prn_file.clear(); |
| 202 found_emf = false; | 202 found_emf = false; |
| 203 found_prn = false; | 203 found_prn = false; |
| 204 base::FilePath file; | 204 base::FilePath file; |
| 205 while (!(file = enumerator.Next()).empty()) { | 205 while (!(file = enumerator.Next()).empty()) { |
| 206 std::wstring ext = file.Extension(); | 206 std::wstring ext = file.Extension(); |
| 207 if (base::strcasecmp(WideToUTF8(ext).c_str(), ".emf") == 0) { | 207 if (base::strcasecmp(base::WideToUTF8(ext).c_str(), ".emf") == 0) { |
| 208 EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" << | 208 EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" << |
| 209 emf_file << "\" and \"" << file.value() << | 209 emf_file << "\" and \"" << file.value() << |
| 210 "\" when looking for \"" << verification_name << "\""; | 210 "\" when looking for \"" << verification_name << "\""; |
| 211 found_emf = true; | 211 found_emf = true; |
| 212 emf_file = file.value(); | 212 emf_file = file.value(); |
| 213 continue; | 213 continue; |
| 214 } | 214 } |
| 215 if (base::strcasecmp(WideToUTF8(ext).c_str(), ".prn") == 0) { | 215 if (base::strcasecmp(base::WideToUTF8(ext).c_str(), ".prn") == 0) { |
| 216 EXPECT_FALSE(found_prn) << "Found a leftover .PRN file: \"" << | 216 EXPECT_FALSE(found_prn) << "Found a leftover .PRN file: \"" << |
| 217 prn_file << "\" and \"" << file.value() << | 217 prn_file << "\" and \"" << file.value() << |
| 218 "\" when looking for \"" << verification_name << "\""; | 218 "\" when looking for \"" << verification_name << "\""; |
| 219 prn_file = file.value(); | 219 prn_file = file.value(); |
| 220 found_prn = true; | 220 found_prn = true; |
| 221 file_util::Delete(file, false); | 221 file_util::Delete(file, false); |
| 222 continue; | 222 continue; |
| 223 } | 223 } |
| 224 EXPECT_TRUE(false); | 224 EXPECT_TRUE(false); |
| 225 } | 225 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 457 |
| 458 // Force a navigation elsewhere to verify that it's fine with it. | 458 // Force a navigation elsewhere to verify that it's fine with it. |
| 459 url = test_server()->GetURL("files/printing/test1.html"); | 459 url = test_server()->GetURL("files/printing/test1.html"); |
| 460 ui_test_utils::NavigateToURL(browser(), url); | 460 ui_test_utils::NavigateToURL(browser(), url); |
| 461 } | 461 } |
| 462 chrome::CloseWindow(browser()); | 462 chrome::CloseWindow(browser()); |
| 463 content::RunAllPendingInMessageLoop(); | 463 content::RunAllPendingInMessageLoop(); |
| 464 | 464 |
| 465 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; | 465 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; |
| 466 } | 466 } |
| OLD | NEW |