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

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

Issue 193101: Fix to use FilePath in more unittests. (Closed)
Patch Set: Created 11 years, 3 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/gfx/gdi_util.h" 7 #include "base/gfx/gdi_util.h"
8 #include "base/simple_thread.h" 8 #include "base/simple_thread.h"
9 #include "base/win_util.h" 9 #include "base/win_util.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
11 #include "chrome/test/automation/browser_proxy.h" 11 #include "chrome/test/automation/browser_proxy.h"
12 #include "chrome/test/automation/tab_proxy.h" 12 #include "chrome/test/automation/tab_proxy.h"
13 #include "chrome/test/automation/window_proxy.h" 13 #include "chrome/test/automation/window_proxy.h"
14 #include "chrome/test/ui/ui_test.h" 14 #include "chrome/test/ui/ui_test.h"
15 #include "net/url_request/url_request_unittest.h" 15 #include "net/url_request/url_request_unittest.h"
16 #include "printing/image.h" 16 #include "printing/image.h"
17 #include "printing/printing_test.h" 17 #include "printing/printing_test.h"
18 #include "printing/native_metafile.h" 18 #include "printing/native_metafile.h"
19 19
20 namespace { 20 namespace {
21 21
22 using printing::Image; 22 using printing::Image;
23 23
24 const wchar_t* const kGenerateSwitch = L"print-layout-generate"; 24 const wchar_t* const kGenerateSwitch = L"print-layout-generate";
25 const wchar_t kDocRoot[] = L"chrome/test/data"; 25 const wchar_t kDocRoot[] = L"chrome/test/data";
26 26
27 class PrintingLayoutTest : public PrintingTest<UITest> { 27 class PrintingLayoutTest : public PrintingTest<UITest> {
28 public: 28 public:
29 PrintingLayoutTest() { 29 PrintingLayoutTest() {
30 emf_path_ = browser_directory_.ToWStringHack(); 30 emf_path_ = browser_directory_;
31 file_util::AppendToPath(&emf_path_, L"metafile_dumps"); 31 emf_path_ = emf_path_.AppendASCII("metafile_dumps");
32 launch_arguments_.AppendSwitchWithValue(L"debug-print", 32 launch_arguments_.AppendSwitchWithValue(L"debug-print",
33 L'"' + emf_path_ + L'"'); 33 L'"' + emf_path_.value() + L'"');
34 show_window_ = true; 34 show_window_ = true;
35 } 35 }
36 36
37 virtual void SetUp() { 37 virtual void SetUp() {
38 // Make sure there is no left overs. 38 // Make sure there is no left overs.
39 CleanupDumpDirectory(); 39 CleanupDumpDirectory();
40 UITest::SetUp(); 40 UITest::SetUp();
41 } 41 }
42 42
43 virtual void TearDown() { 43 virtual void TearDown() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 private: 149 private:
150 // Verifies that there is one .emf and one .prn file in the dump directory. 150 // Verifies that there is one .emf and one .prn file in the dump directory.
151 // Returns the path of the .emf file and deletes the .prn file. 151 // Returns the path of the .emf file and deletes the .prn file.
152 std::wstring ScanFiles(const std::wstring& verification_name) { 152 std::wstring ScanFiles(const std::wstring& verification_name) {
153 // Try to 10 seconds. 153 // Try to 10 seconds.
154 std::wstring emf_file; 154 std::wstring emf_file;
155 std::wstring prn_file; 155 std::wstring prn_file;
156 bool found_emf = false; 156 bool found_emf = false;
157 bool found_prn = false; 157 bool found_prn = false;
158 for (int i = 0; i < 100; ++i) { 158 for (int i = 0; i < 100; ++i) {
159 file_util::FileEnumerator enumerator( 159 file_util::FileEnumerator enumerator(emf_path(), false,
160 FilePath::FromWStringHack(emf_path()), false,
161 file_util::FileEnumerator::FILES); 160 file_util::FileEnumerator::FILES);
162 emf_file.clear(); 161 emf_file.clear();
163 prn_file.clear(); 162 prn_file.clear();
164 found_emf = false; 163 found_emf = false;
165 found_prn = false; 164 found_prn = false;
166 std::wstring file; 165 std::wstring file;
167 while (!(file = enumerator.Next().ToWStringHack()).empty()) { 166 while (!(file = enumerator.Next().ToWStringHack()).empty()) {
168 std::wstring ext = file_util::GetFileExtensionFromPath(file); 167 std::wstring ext = file_util::GetFileExtensionFromPath(file);
169 if (!_wcsicmp(ext.c_str(), L"emf")) { 168 if (!_wcsicmp(ext.c_str(), L"emf")) {
170 EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" << 169 EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" <<
(...skipping 20 matching lines...) Expand all
191 } 190 }
192 EXPECT_TRUE(found_emf) << ".PRN file is: " << prn_file; 191 EXPECT_TRUE(found_emf) << ".PRN file is: " << prn_file;
193 EXPECT_TRUE(found_prn) << ".EMF file is: " << emf_file; 192 EXPECT_TRUE(found_prn) << ".EMF file is: " << emf_file;
194 return emf_file; 193 return emf_file;
195 } 194 }
196 195
197 static bool GenerateFiles() { 196 static bool GenerateFiles() {
198 return CommandLine::ForCurrentProcess()->HasSwitch(kGenerateSwitch); 197 return CommandLine::ForCurrentProcess()->HasSwitch(kGenerateSwitch);
199 } 198 }
200 199
201 const std::wstring& emf_path() const { return emf_path_; } 200 const FilePath& emf_path() const { return emf_path_; }
202 201
203 std::wstring emf_path_; 202 FilePath emf_path_;
204 203
205 DISALLOW_EVIL_CONSTRUCTORS(PrintingLayoutTest); 204 DISALLOW_COPY_AND_ASSIGN(PrintingLayoutTest);
206 }; 205 };
207 206
208 // Tests that don't need UI access. 207 // Tests that don't need UI access.
209 class PrintingLayoutTestHidden : public PrintingLayoutTest { 208 class PrintingLayoutTestHidden : public PrintingLayoutTest {
210 public: 209 public:
211 PrintingLayoutTestHidden() { 210 PrintingLayoutTestHidden() {
212 show_window_ = false; 211 show_window_ = false;
213 } 212 }
214 }; 213 };
215 214
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 443
445 // Force a navigation elsewhere to verify that it's fine with it. 444 // Force a navigation elsewhere to verify that it's fine with it.
446 url = server->TestServerPage("files/printing/test1.html"); 445 url = server->TestServerPage("files/printing/test1.html");
447 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 446 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
448 tab_proxy->NavigateToURL(url)); 447 tab_proxy->NavigateToURL(url));
449 } 448 }
450 CloseBrowserAndServer(); 449 CloseBrowserAndServer();
451 450
452 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; 451 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe";
453 } 452 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/firefox_profile_lock_unittest.cc ('k') | chrome/browser/privacy_blacklist/blacklist_io_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698