| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "v8_proxy.h" | 5 #include "v8_proxy.h" |
| 6 #undef LOG | 6 #undef LOG |
| 7 | 7 |
| 8 #include "webkit/tools/test_shell/test_shell.h" | 8 #include "webkit/tools/test_shell/test_shell.h" |
| 9 | 9 |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/md5.h" | 21 #include "base/md5.h" |
| 22 #include "base/message_loop.h" | 22 #include "base/message_loop.h" |
| 23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 24 #include "base/stats_table.h" | 24 #include "base/stats_table.h" |
| 25 #include "base/string_util.h" | 25 #include "base/string_util.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 27 #include "googleurl/src/url_util.h" | 27 #include "googleurl/src/url_util.h" |
| 28 #include "net/base/mime_util.h" | 28 #include "net/base/mime_util.h" |
| 29 #include "net/url_request/url_request_file_job.h" | 29 #include "net/url_request/url_request_file_job.h" |
| 30 #include "net/url_request/url_request_filter.h" | 30 #include "net/url_request/url_request_filter.h" |
| 31 #include "skia/ext/bitmap_platform_device.h" | 31 #include "skia/ext/platform_device.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "webkit/glue/webdatasource.h" | 33 #include "webkit/glue/webdatasource.h" |
| 34 #include "webkit/glue/webframe.h" | 34 #include "webkit/glue/webframe.h" |
| 35 #include "webkit/glue/webkit_glue.h" | 35 #include "webkit/glue/webkit_glue.h" |
| 36 #include "webkit/glue/webpreferences.h" | 36 #include "webkit/glue/webpreferences.h" |
| 37 #include "webkit/glue/weburlrequest.h" | 37 #include "webkit/glue/weburlrequest.h" |
| 38 #include "webkit/glue/webview.h" | 38 #include "webkit/glue/webview.h" |
| 39 #include "webkit/glue/webwidget.h" | 39 #include "webkit/glue/webwidget.h" |
| 40 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 40 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 41 #include "webkit/tools/test_shell/test_navigation_controller.h" | 41 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 DumpBackForwardList(&bfDump); | 219 DumpBackForwardList(&bfDump); |
| 220 printf("%s", WideToUTF8(bfDump).c_str()); | 220 printf("%s", WideToUTF8(bfDump).c_str()); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 if (params->dump_pixels && !should_dump_as_text) { | 224 if (params->dump_pixels && !should_dump_as_text) { |
| 225 // Image output: we write the image data to the file given on the | 225 // Image output: we write the image data to the file given on the |
| 226 // command line (for the dump pixels argument), and the MD5 sum to | 226 // command line (for the dump pixels argument), and the MD5 sum to |
| 227 // stdout. | 227 // stdout. |
| 228 dumped_anything = true; | 228 dumped_anything = true; |
| 229 std::string md5sum = DumpImage(webFrame, params->pixel_file_name); | 229 std::string md5sum = DumpImage(shell->webViewHost(), |
| 230 params->pixel_file_name); |
| 230 printf("#MD5:%s\n", md5sum.c_str()); | 231 printf("#MD5:%s\n", md5sum.c_str()); |
| 231 } | 232 } |
| 232 if (dumped_anything) | 233 if (dumped_anything) |
| 233 printf("#EOF\n"); | 234 printf("#EOF\n"); |
| 234 fflush(stdout); | 235 fflush(stdout); |
| 235 } | 236 } |
| 236 } | 237 } |
| 237 | 238 |
| 238 // static | 239 // static |
| 239 std::string TestShell::DumpImage(WebFrame* web_frame, | 240 std::string TestShell::DumpImage(WebViewHost* web_view_host, |
| 240 const std::wstring& file_name) { | 241 const std::wstring& file_name) { |
| 241 scoped_ptr<skia::BitmapPlatformDevice> device; | |
| 242 if (!web_frame->CaptureImage(&device, true)) | |
| 243 return std::string(); | |
| 244 | 242 |
| 245 const SkBitmap& src_bmp = device->accessBitmap(false); | 243 web_view_host->Paint(); |
| 244 skia::PlatformDevice& device = |
| 245 web_view_host->canvas()->getTopPlatformDevice(); |
| 246 |
| 247 #if defined(OS_WIN) |
| 248 // On windows we need to fixup the alpha on the bitmap. Do the fixup in a |
| 249 // copy of the bitmap so as not to modify the original. |
| 250 SkBitmap src_bmp; |
| 251 const SkBitmap& orig = device.accessBitmap(false); |
| 252 orig.copyTo(&src_bmp, orig.config()); |
| 253 skia::BitmapPlatformDeviceWin::fixupAlpha(src_bmp); |
| 254 #else |
| 255 const SkBitmap& src_bmp = device.accessBitmap(false); |
| 256 #endif |
| 246 | 257 |
| 247 // Encode image. | 258 // Encode image. |
| 248 std::vector<unsigned char> png; | 259 std::vector<unsigned char> png; |
| 249 SkAutoLockPixels src_bmp_lock(src_bmp); | 260 SkAutoLockPixels src_bmp_lock(src_bmp); |
| 250 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA; | 261 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA; |
| 251 #if defined(OS_WIN) || defined(OS_LINUX) | 262 #if defined(OS_WIN) || defined(OS_LINUX) |
| 252 bool discard_transparency = true; | 263 bool discard_transparency = true; |
| 253 #elif defined(OS_MACOSX) | 264 #elif defined(OS_MACOSX) |
| 254 // the expected PNGs in webkit have an alpha channel. We shouldn't discard | 265 // the expected PNGs in webkit have an alpha channel. We shouldn't discard |
| 255 // the transparency for reference purposes, though the hashes will still | 266 // the transparency for reference purposes, though the hashes will still |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 633 |
| 623 uint64 VisitedLinkHash(const char* canonical_url, size_t length) { | 634 uint64 VisitedLinkHash(const char* canonical_url, size_t length) { |
| 624 return 0; | 635 return 0; |
| 625 } | 636 } |
| 626 | 637 |
| 627 bool IsLinkVisited(uint64 link_hash) { | 638 bool IsLinkVisited(uint64 link_hash) { |
| 628 return false; | 639 return false; |
| 629 } | 640 } |
| 630 | 641 |
| 631 } // namespace webkit_glue | 642 } // namespace webkit_glue |
| OLD | NEW |