Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/browser/printing/printing_layout_uitest.cc

Issue 9585001: Cleanup: Remove deprecated version of file_util::AppendToPath(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/test/test_file_util_win.cc ('k') | chrome/test/mini_installer_test/installer_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/test/test_file_util.h" 9 #include "base/test/test_file_util.h"
10 #include "base/threading/simple_thread.h" 10 #include "base/threading/simple_thread.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // |verification_name|. Compares the saved printed job pixels with the test 52 // |verification_name|. Compares the saved printed job pixels with the test
53 // data pixels and returns the percentage of different pixels; 0 for success, 53 // data pixels and returns the percentage of different pixels; 0 for success,
54 // [0, 100] for failure. 54 // [0, 100] for failure.
55 double CompareWithResult(const std::wstring& verification_name) { 55 double CompareWithResult(const std::wstring& verification_name) {
56 FilePath test_result(ScanFiles(verification_name)); 56 FilePath test_result(ScanFiles(verification_name));
57 if (test_result.value().empty()) { 57 if (test_result.value().empty()) {
58 // 100% different, the print job buffer is not there. 58 // 100% different, the print job buffer is not there.
59 return 100.; 59 return 100.;
60 } 60 }
61 61
62 std::wstring verification_file(test_data_directory_.value()); 62 FilePath base_path(test_data_directory_.AppendASCII("printing"));
63 file_util::AppendToPath(&verification_file, L"printing"); 63 FilePath emf(base_path.Append(verification_name + L".emf"));
64 file_util::AppendToPath(&verification_file, verification_name); 64 FilePath png(base_path.Append(verification_name + L".png"));
65 FilePath emf(verification_file + L".emf");
66 FilePath png(verification_file + L".png");
67 65
66 FilePath cleartype(base_path.Append(verification_name + L"_cleartype.png"));
68 // Looks for Cleartype override. 67 // Looks for Cleartype override.
69 if (file_util::PathExists( 68 if (file_util::PathExists(cleartype) && IsClearTypeEnabled())
70 FilePath::FromWStringHack(verification_file + L"_cleartype.png")) && 69 png = cleartype;
71 IsClearTypeEnabled()) {
72 png = FilePath(verification_file + L"_cleartype.png");
73 }
74 70
75 if (GenerateFiles()) { 71 if (GenerateFiles()) {
76 // Copy the .emf and generate an .png. 72 // Copy the .emf and generate an .png.
77 file_util::CopyFile(test_result, emf); 73 file_util::CopyFile(test_result, emf);
78 Image emf_content(emf); 74 Image emf_content(emf);
79 emf_content.SaveToPng(png); 75 emf_content.SaveToPng(png);
80 // Saving is always fine. 76 // Saving is always fine.
81 return 0; 77 return 0;
82 } else { 78 } else {
83 // File compare between test and result. 79 // File compare between test and result.
84 Image emf_content(emf); 80 Image emf_content(emf);
85 Image test_content(test_result); 81 Image test_content(test_result);
86 Image png_content(png); 82 Image png_content(png);
87 double diff_emf = emf_content.PercentageDifferent(test_content); 83 double diff_emf = emf_content.PercentageDifferent(test_content);
88 84
89 EXPECT_EQ(0., diff_emf) << WideToUTF8(verification_name) << 85 EXPECT_EQ(0., diff_emf) << WideToUTF8(verification_name) <<
90 " original size:" << emf_content.size().ToString() << 86 " original size:" << emf_content.size().ToString() <<
91 " result size:" << test_content.size().ToString(); 87 " result size:" << test_content.size().ToString();
92 if (diff_emf) { 88 if (diff_emf) {
93 // Backup the result emf file. 89 // Backup the result emf file.
94 file_util::CopyFile(test_result, FilePath( 90 FilePath failed(base_path.Append(verification_name + L"_failed.emf"));
95 verification_file + L"_failed.emf")); 91 file_util::CopyFile(test_result, failed);
96 } 92 }
97 93
98 // This verification is only to know that the EMF rendering stays 94 // This verification is only to know that the EMF rendering stays
99 // immutable. 95 // immutable.
100 double diff_png = emf_content.PercentageDifferent(png_content); 96 double diff_png = emf_content.PercentageDifferent(png_content);
101 EXPECT_EQ(0., diff_png) << WideToUTF8(verification_name) << 97 EXPECT_EQ(0., diff_png) << WideToUTF8(verification_name) <<
102 " original size:" << emf_content.size().ToString() << 98 " original size:" << emf_content.size().ToString() <<
103 " result size:" << test_content.size().ToString(); 99 " result size:" << test_content.size().ToString();
104 if (diff_png) { 100 if (diff_png) {
105 // Backup the rendered emf file to detect the rendering difference. 101 // Backup the rendered emf file to detect the rendering difference.
106 emf_content.SaveToPng(FilePath(verification_file + L"_rendering.png")); 102 FilePath rendering(
103 base_path.Append(verification_name + L"_rendering.png"));
104 emf_content.SaveToPng(rendering);
107 } 105 }
108 return std::max(diff_png, diff_emf); 106 return std::max(diff_png, diff_emf);
109 } 107 }
110 } 108 }
111 109
112 // Makes sure the directory exists and is empty. 110 // Makes sure the directory exists and is empty.
113 void CleanupDumpDirectory() { 111 void CleanupDumpDirectory() {
114 EXPECT_TRUE(file_util::DieFileDie(emf_path(), true)); 112 EXPECT_TRUE(file_util::DieFileDie(emf_path(), true));
115 EXPECT_TRUE(file_util::CreateDirectory(emf_path())); 113 EXPECT_TRUE(file_util::CreateDirectory(emf_path()));
116 } 114 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 423
426 // Force a navigation elsewhere to verify that it's fine with it. 424 // Force a navigation elsewhere to verify that it's fine with it.
427 url = test_server.GetURL("files/printing/test1.html"); 425 url = test_server.GetURL("files/printing/test1.html");
428 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 426 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
429 tab_proxy->NavigateToURL(url)); 427 tab_proxy->NavigateToURL(url));
430 } 428 }
431 CloseBrowserAndServer(); 429 CloseBrowserAndServer();
432 430
433 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; 431 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe";
434 } 432 }
OLDNEW
« no previous file with comments | « base/test/test_file_util_win.cc ('k') | chrome/test/mini_installer_test/installer_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698