OLD | NEW |
1 // Copyright (c) 2006-2008 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 "skia/ext/platform_device.h" | 8 #include "skia/ext/platform_device.h" |
9 #include "base/gfx/png_decoder.h" | 9 #include "base/gfx/png_decoder.h" |
10 #include "base/gfx/png_encoder.h" | 10 #include "base/gfx/png_encoder.h" |
11 #include "base/simple_thread.h" | 11 #include "base/simple_thread.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // It's fine fail sometimes because of opened left over .PRN file. | 293 // It's fine fail sometimes because of opened left over .PRN file. |
294 // Explanation: | 294 // Explanation: |
295 // When calling PrintNowTab(), it makes sure the page is rendered and | 295 // When calling PrintNowTab(), it makes sure the page is rendered and |
296 // sent to the spooler. It does *not* wait for the spooler to flush the | 296 // sent to the spooler. It does *not* wait for the spooler to flush the |
297 // job. It is completely unnecessary to wait for that. So the printer | 297 // job. It is completely unnecessary to wait for that. So the printer |
298 // may write the file too late. Since the printer holds an exclusive | 298 // may write the file too late. Since the printer holds an exclusive |
299 // access to the file, it can't be deleted until the printer is done. | 299 // access to the file, it can't be deleted until the printer is done. |
300 if (file_util::Delete(emf_path(), true)) { | 300 if (file_util::Delete(emf_path(), true)) { |
301 break; | 301 break; |
302 } | 302 } |
303 Sleep(100); | 303 PlatformThread::Sleep(100); |
304 } | 304 } |
305 file_util::CreateDirectory(emf_path()); | 305 file_util::CreateDirectory(emf_path()); |
306 } | 306 } |
307 | 307 |
308 // Returns if Clear Type is currently enabled. | 308 // Returns if Clear Type is currently enabled. |
309 static bool IsClearTypeEnabled() { | 309 static bool IsClearTypeEnabled() { |
310 BOOL ct_enabled = 0; | 310 BOOL ct_enabled = 0; |
311 if (SystemParametersInfo(SPI_GETCLEARTYPE, 0, &ct_enabled, 0) && ct_enabled) | 311 if (SystemParametersInfo(SPI_GETCLEARTYPE, 0, &ct_enabled, 0) && ct_enabled) |
312 return true; | 312 return true; |
313 UINT smoothing = 0; | 313 UINT smoothing = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 verification_name << "\""; | 351 verification_name << "\""; |
352 prn_file = file; | 352 prn_file = file; |
353 found_prn = true; | 353 found_prn = true; |
354 file_util::Delete(file, false); | 354 file_util::Delete(file, false); |
355 continue; | 355 continue; |
356 } | 356 } |
357 EXPECT_TRUE(false); | 357 EXPECT_TRUE(false); |
358 } | 358 } |
359 if (found_emf && found_prn) | 359 if (found_emf && found_prn) |
360 break; | 360 break; |
361 Sleep(100); | 361 PlatformThread::Sleep(100); |
362 } | 362 } |
363 EXPECT_TRUE(found_emf) << ".PRN file is: " << prn_file; | 363 EXPECT_TRUE(found_emf) << ".PRN file is: " << prn_file; |
364 EXPECT_TRUE(found_prn) << ".EMF file is: " << emf_file; | 364 EXPECT_TRUE(found_prn) << ".EMF file is: " << emf_file; |
365 return emf_file; | 365 return emf_file; |
366 } | 366 } |
367 | 367 |
368 static bool GenerateFiles() { | 368 static bool GenerateFiles() { |
369 return CommandLine::ForCurrentProcess()->HasSwitch(kGenerateSwitch); | 369 return CommandLine::ForCurrentProcess()->HasSwitch(kGenerateSwitch); |
370 } | 370 } |
371 | 371 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 for (;;) { | 443 for (;;) { |
444 // First enumerate the windows. | 444 // First enumerate the windows. |
445 dialog_window = FindDialogWindow(owner_process_); | 445 dialog_window = FindDialogWindow(owner_process_); |
446 | 446 |
447 // Try to close it. | 447 // Try to close it. |
448 if (dialog_window) { | 448 if (dialog_window) { |
449 if (CloseDialogWindow(dialog_window)) { | 449 if (CloseDialogWindow(dialog_window)) { |
450 break; | 450 break; |
451 } | 451 } |
452 } | 452 } |
453 Sleep(10); | 453 PlatformThread::Sleep(10); |
454 } | 454 } |
455 | 455 |
456 // Now verify that it indeed closed itself. | 456 // Now verify that it indeed closed itself. |
457 while (IsWindow(dialog_window)) { | 457 while (IsWindow(dialog_window)) { |
458 CloseDialogWindow(dialog_window); | 458 CloseDialogWindow(dialog_window); |
459 Sleep(10); | 459 PlatformThread::Sleep(10); |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 DWORD owner_process() { return owner_process_; } | 463 DWORD owner_process() { return owner_process_; } |
464 | 464 |
465 private: | 465 private: |
466 DWORD owner_process_; | 466 DWORD owner_process_; |
467 }; | 467 }; |
468 | 468 |
469 } // namespace | 469 } // namespace |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 615 |
616 // Force a navigation elsewhere to verify that it's fine with it. | 616 // Force a navigation elsewhere to verify that it's fine with it. |
617 url = server->TestServerPage("files/printing/test1.html"); | 617 url = server->TestServerPage("files/printing/test1.html"); |
618 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 618 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
619 tab_proxy->NavigateToURL(url)); | 619 tab_proxy->NavigateToURL(url)); |
620 } | 620 } |
621 CloseBrowserAndServer(); | 621 CloseBrowserAndServer(); |
622 | 622 |
623 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; | 623 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; |
624 } | 624 } |
OLD | NEW |