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_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 base::FilePath png(base_path.Append(verification_name + L".png")); | 125 base::FilePath png(base_path.Append(verification_name + L".png")); |
126 | 126 |
127 base::FilePath cleartype( | 127 base::FilePath cleartype( |
128 base_path.Append(verification_name + L"_cleartype.png")); | 128 base_path.Append(verification_name + L"_cleartype.png")); |
129 // Looks for Cleartype override. | 129 // Looks for Cleartype override. |
130 if (file_util::PathExists(cleartype) && IsClearTypeEnabled()) | 130 if (file_util::PathExists(cleartype) && IsClearTypeEnabled()) |
131 png = cleartype; | 131 png = cleartype; |
132 | 132 |
133 if (GenerateFiles()) { | 133 if (GenerateFiles()) { |
134 // Copy the .emf and generate an .png. | 134 // Copy the .emf and generate an .png. |
135 file_util::CopyFile(test_result, emf); | 135 base::CopyFile(test_result, emf); |
136 Image emf_content(emf); | 136 Image emf_content(emf); |
137 emf_content.SaveToPng(png); | 137 emf_content.SaveToPng(png); |
138 // Saving is always fine. | 138 // Saving is always fine. |
139 return 0; | 139 return 0; |
140 } else { | 140 } else { |
141 // File compare between test and result. | 141 // File compare between test and result. |
142 Image emf_content(emf); | 142 Image emf_content(emf); |
143 Image test_content(test_result); | 143 Image test_content(test_result); |
144 Image png_content(png); | 144 Image png_content(png); |
145 double diff_emf = emf_content.PercentageDifferent(test_content); | 145 double diff_emf = emf_content.PercentageDifferent(test_content); |
146 | 146 |
147 EXPECT_EQ(0., diff_emf) << WideToUTF8(verification_name) << | 147 EXPECT_EQ(0., diff_emf) << WideToUTF8(verification_name) << |
148 " original size:" << emf_content.size().ToString() << | 148 " original size:" << emf_content.size().ToString() << |
149 " result size:" << test_content.size().ToString(); | 149 " result size:" << test_content.size().ToString(); |
150 if (diff_emf) { | 150 if (diff_emf) { |
151 // Backup the result emf file. | 151 // Backup the result emf file. |
152 base::FilePath failed( | 152 base::FilePath failed( |
153 base_path.Append(verification_name + L"_failed.emf")); | 153 base_path.Append(verification_name + L"_failed.emf")); |
154 file_util::CopyFile(test_result, failed); | 154 base::CopyFile(test_result, failed); |
155 } | 155 } |
156 | 156 |
157 // This verification is only to know that the EMF rendering stays | 157 // This verification is only to know that the EMF rendering stays |
158 // immutable. | 158 // immutable. |
159 double diff_png = emf_content.PercentageDifferent(png_content); | 159 double diff_png = emf_content.PercentageDifferent(png_content); |
160 EXPECT_EQ(0., diff_png) << WideToUTF8(verification_name) << | 160 EXPECT_EQ(0., diff_png) << WideToUTF8(verification_name) << |
161 " original size:" << emf_content.size().ToString() << | 161 " original size:" << emf_content.size().ToString() << |
162 " result size:" << test_content.size().ToString(); | 162 " result size:" << test_content.size().ToString(); |
163 if (diff_png) { | 163 if (diff_png) { |
164 // Backup the rendered emf file to detect the rendering difference. | 164 // Backup the rendered emf file to detect the rendering difference. |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 460 |
461 // Force a navigation elsewhere to verify that it's fine with it. | 461 // Force a navigation elsewhere to verify that it's fine with it. |
462 url = test_server()->GetURL("files/printing/test1.html"); | 462 url = test_server()->GetURL("files/printing/test1.html"); |
463 ui_test_utils::NavigateToURL(browser(), url); | 463 ui_test_utils::NavigateToURL(browser(), url); |
464 } | 464 } |
465 chrome::CloseWindow(browser()); | 465 chrome::CloseWindow(browser()); |
466 content::RunAllPendingInMessageLoop(); | 466 content::RunAllPendingInMessageLoop(); |
467 | 467 |
468 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; | 468 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; |
469 } | 469 } |
OLD | NEW |