| 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 "content/shell/webkit_test_controller.h" | 5 #include "content/shell/webkit_test_controller.h" |
| 6 | 6 |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "content/public/browser/render_widget_host_view.h" | 23 #include "content/public/browser/render_widget_host_view.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/browser/web_contents_view.h" | 25 #include "content/public/browser/web_contents_view.h" |
| 26 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
| 27 #include "content/shell/common/shell_messages.h" | 27 #include "content/shell/common/shell_messages.h" |
| 28 #include "content/shell/common/shell_switches.h" | 28 #include "content/shell/common/shell_switches.h" |
| 29 #include "content/shell/common/webkit_test_helpers.h" | 29 #include "content/shell/common/webkit_test_helpers.h" |
| 30 #include "content/shell/shell.h" | 30 #include "content/shell/shell.h" |
| 31 #include "content/shell/shell_browser_context.h" | 31 #include "content/shell/shell_browser_context.h" |
| 32 #include "content/shell/shell_content_browser_client.h" | 32 #include "content/shell/shell_content_browser_client.h" |
| 33 #include "webkit/support/webkit_support_gfx.h" | 33 #include "ui/gfx/codec/png_codec.h" |
| 34 | 34 |
| 35 namespace content { | 35 namespace content { |
| 36 | 36 |
| 37 const int kTestSVGWindowWidthDip = 480; | 37 const int kTestSVGWindowWidthDip = 480; |
| 38 const int kTestSVGWindowHeightDip = 360; | 38 const int kTestSVGWindowHeightDip = 360; |
| 39 | 39 |
| 40 // WebKitTestResultPrinter ---------------------------------------------------- | 40 // WebKitTestResultPrinter ---------------------------------------------------- |
| 41 | 41 |
| 42 WebKitTestResultPrinter::WebKitTestResultPrinter( | 42 WebKitTestResultPrinter::WebKitTestResultPrinter( |
| 43 std::ostream* output, std::ostream* error) | 43 std::ostream* output, std::ostream* error) |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 if (actual_pixel_hash != expected_pixel_hash_) { | 505 if (actual_pixel_hash != expected_pixel_hash_) { |
| 506 std::vector<unsigned char> png; | 506 std::vector<unsigned char> png; |
| 507 | 507 |
| 508 // Only the expected PNGs for Mac have a valid alpha channel. | 508 // Only the expected PNGs for Mac have a valid alpha channel. |
| 509 #if defined(OS_MACOSX) | 509 #if defined(OS_MACOSX) |
| 510 bool discard_transparency = false; | 510 bool discard_transparency = false; |
| 511 #else | 511 #else |
| 512 bool discard_transparency = true; | 512 bool discard_transparency = true; |
| 513 #endif | 513 #endif |
| 514 | 514 |
| 515 bool success = webkit_support::EncodeBGRAPNGWithChecksum( | 515 std::vector<gfx::PNGCodec::Comment> comments; |
| 516 reinterpret_cast<const unsigned char*>(image.getPixels()), | 516 comments.push_back(gfx::PNGCodec::Comment("checksum", actual_pixel_hash)); |
| 517 image.width(), | 517 bool success = gfx::PNGCodec::Encode( |
| 518 image.height(), | 518 static_cast<const unsigned char*>(image.getPixels()), |
| 519 gfx::PNGCodec::FORMAT_BGRA, |
| 520 gfx::Size(image.width(), image.height()), |
| 519 static_cast<int>(image.rowBytes()), | 521 static_cast<int>(image.rowBytes()), |
| 520 discard_transparency, | 522 discard_transparency, |
| 521 actual_pixel_hash, | 523 comments, |
| 522 &png); | 524 &png); |
| 523 if (success) | 525 if (success) |
| 524 printer_->PrintImageBlock(png); | 526 printer_->PrintImageBlock(png); |
| 525 } | 527 } |
| 526 printer_->PrintImageFooter(); | 528 printer_->PrintImageFooter(); |
| 527 } | 529 } |
| 528 | 530 |
| 529 void WebKitTestController::OnAudioDump(const std::vector<unsigned char>& dump) { | 531 void WebKitTestController::OnAudioDump(const std::vector<unsigned char>& dump) { |
| 530 printer_->PrintAudioHeader(); | 532 printer_->PrintAudioHeader(); |
| 531 printer_->PrintAudioBlock(dump); | 533 printer_->PrintAudioBlock(dump); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 } | 623 } |
| 622 base::MessageLoop::current()->RunUntilIdle(); | 624 base::MessageLoop::current()->RunUntilIdle(); |
| 623 } | 625 } |
| 624 | 626 |
| 625 void WebKitTestController::OnResetDone() { | 627 void WebKitTestController::OnResetDone() { |
| 626 base::MessageLoop::current()->PostTask(FROM_HERE, | 628 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 627 base::MessageLoop::QuitClosure()); | 629 base::MessageLoop::QuitClosure()); |
| 628 } | 630 } |
| 629 | 631 |
| 630 } // namespace content | 632 } // namespace content |
| OLD | NEW |