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

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

Issue 6246036: FilePath: Remove most of ToWStringHack, adding a LossyDisplayName() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bug link Created 9 years, 10 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 | « chrome/browser/plugin_service.cc ('k') | chrome/browser/process_singleton_win.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_.ToWStringHack()); 62 std::wstring verification_file(test_data_directory_.value());
63 file_util::AppendToPath(&verification_file, L"printing"); 63 file_util::AppendToPath(&verification_file, L"printing");
64 file_util::AppendToPath(&verification_file, verification_name); 64 file_util::AppendToPath(&verification_file, verification_name);
65 FilePath emf(verification_file + L".emf"); 65 FilePath emf(verification_file + L".emf");
66 FilePath png(verification_file + L".png"); 66 FilePath png(verification_file + L".png");
67 67
68 // Looks for Cleartype override. 68 // Looks for Cleartype override.
69 if (file_util::PathExists( 69 if (file_util::PathExists(
70 FilePath::FromWStringHack(verification_file + L"_cleartype.png")) && 70 FilePath::FromWStringHack(verification_file + L"_cleartype.png")) &&
71 IsClearTypeEnabled()) { 71 IsClearTypeEnabled()) {
72 png = FilePath(verification_file + L"_cleartype.png"); 72 png = FilePath(verification_file + L"_cleartype.png");
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 std::wstring prn_file; 136 std::wstring prn_file;
137 bool found_emf = false; 137 bool found_emf = false;
138 bool found_prn = false; 138 bool found_prn = false;
139 for (int i = 0; i < 100; ++i) { 139 for (int i = 0; i < 100; ++i) {
140 file_util::FileEnumerator enumerator(emf_path(), false, 140 file_util::FileEnumerator enumerator(emf_path(), false,
141 file_util::FileEnumerator::FILES); 141 file_util::FileEnumerator::FILES);
142 emf_file.clear(); 142 emf_file.clear();
143 prn_file.clear(); 143 prn_file.clear();
144 found_emf = false; 144 found_emf = false;
145 found_prn = false; 145 found_prn = false;
146 std::wstring file; 146 FilePath file;
147 while (!(file = enumerator.Next().ToWStringHack()).empty()) { 147 while (!(file = enumerator.Next()).empty()) {
148 std::wstring ext = FilePath(file).Extension(); 148 std::wstring ext = file.Extension();
149 if (base::strcasecmp(WideToUTF8(ext).c_str(), ".emf") == 0) { 149 if (base::strcasecmp(WideToUTF8(ext).c_str(), ".emf") == 0) {
150 EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" << 150 EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" <<
151 emf_file << "\" and \"" << file << "\" when looking for \"" << 151 emf_file << "\" and \"" << file.value() <<
152 verification_name << "\""; 152 "\" when looking for \"" << verification_name << "\"";
153 found_emf = true; 153 found_emf = true;
154 emf_file = file; 154 emf_file = file.value();
155 continue; 155 continue;
156 } 156 }
157 if (base::strcasecmp(WideToUTF8(ext).c_str(), ".prn") == 0) { 157 if (base::strcasecmp(WideToUTF8(ext).c_str(), ".prn") == 0) {
158 EXPECT_FALSE(found_prn) << "Found a leftover .PRN file: \"" << 158 EXPECT_FALSE(found_prn) << "Found a leftover .PRN file: \"" <<
159 prn_file << "\" and \"" << file << "\" when looking for \"" << 159 prn_file << "\" and \"" << file.value() <<
160 verification_name << "\""; 160 "\" when looking for \"" << verification_name << "\"";
161 prn_file = file; 161 prn_file = file.value();
162 found_prn = true; 162 found_prn = true;
163 file_util::Delete(file, false); 163 file_util::Delete(file, false);
164 continue; 164 continue;
165 } 165 }
166 EXPECT_TRUE(false); 166 EXPECT_TRUE(false);
167 } 167 }
168 if (found_emf && found_prn) 168 if (found_emf && found_prn)
169 break; 169 break;
170 base::PlatformThread::Sleep(100); 170 base::PlatformThread::Sleep(100);
171 } 171 }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 417
418 // Force a navigation elsewhere to verify that it's fine with it. 418 // Force a navigation elsewhere to verify that it's fine with it.
419 url = test_server.GetURL("files/printing/test1.html"); 419 url = test_server.GetURL("files/printing/test1.html");
420 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 420 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
421 tab_proxy->NavigateToURL(url)); 421 tab_proxy->NavigateToURL(url));
422 } 422 }
423 CloseBrowserAndServer(); 423 CloseBrowserAndServer();
424 424
425 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; 425 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe";
426 } 426 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_service.cc ('k') | chrome/browser/process_singleton_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698