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

Side by Side Diff: webkit/tools/test_shell/test_shell.cc

Issue 180033: Implement layoutTestController.display() method.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Prettify. 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
« no previous file with comments | « webkit/tools/test_shell/test_shell.h ('k') | webkit/tools/test_shell/webwidget_host.h » ('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) 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 #undef LOG 5 #undef LOG
6 6
7 #include "webkit/tools/test_shell/test_shell.h" 7 #include "webkit/tools/test_shell/test_shell.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 DumpAllBackForwardLists(&bfDump); 234 DumpAllBackForwardLists(&bfDump);
235 printf("%s", WideToUTF8(bfDump).c_str()); 235 printf("%s", WideToUTF8(bfDump).c_str());
236 } 236 }
237 } 237 }
238 238
239 if (params->dump_pixels && !should_dump_as_text) { 239 if (params->dump_pixels && !should_dump_as_text) {
240 // Image output: we write the image data to the file given on the 240 // Image output: we write the image data to the file given on the
241 // command line (for the dump pixels argument), and the MD5 sum to 241 // command line (for the dump pixels argument), and the MD5 sum to
242 // stdout. 242 // stdout.
243 dumped_anything = true; 243 dumped_anything = true;
244 std::string md5sum = DumpImage(shell->webView(), params->pixel_file_name, 244 WebViewHost* view_host = shell->webViewHost();
245 params->pixel_hash); 245 view_host->webview()->layout();
246 view_host->Paint();
247 std::string md5sum = DumpImage(view_host->canvas(),
248 params->pixel_file_name, params->pixel_hash);
246 printf("#MD5:%s\n", md5sum.c_str()); 249 printf("#MD5:%s\n", md5sum.c_str());
247 } 250 }
248 if (dumped_anything) 251 if (dumped_anything)
249 printf("#EOF\n"); 252 printf("#EOF\n");
250 fflush(stdout); 253 fflush(stdout);
251 } 254 }
252 } 255 }
253 256
254 // static 257 // static
255 std::string TestShell::DumpImage(WebView* view, 258 std::string TestShell::DumpImage(skia::PlatformCanvas* canvas,
256 const std::wstring& file_name, const std::string& pixel_hash) { 259 const std::wstring& file_name, const std::string& pixel_hash) {
257 view->layout();
258 const WebSize& size = view->size();
259
260 skia::PlatformCanvas canvas;
261 if (!canvas.initialize(size.width, size.height, true))
262 return std::string();
263 view->paint(webkit_glue::ToWebCanvas(&canvas),
264 WebRect(0, 0, size.width, size.height));
265
266 skia::BitmapPlatformDevice& device = 260 skia::BitmapPlatformDevice& device =
267 static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice()); 261 static_cast<skia::BitmapPlatformDevice&>(canvas->getTopPlatformDevice());
268 const SkBitmap& src_bmp = device.accessBitmap(false); 262 const SkBitmap& src_bmp = device.accessBitmap(false);
269 263
270 // Encode image. 264 // Encode image.
271 std::vector<unsigned char> png; 265 std::vector<unsigned char> png;
272 SkAutoLockPixels src_bmp_lock(src_bmp); 266 SkAutoLockPixels src_bmp_lock(src_bmp);
273 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA; 267 PNGEncoder::ColorFormat color_format = PNGEncoder::FORMAT_BGRA;
274 268
275 // Fix the alpha. The expected PNGs on Mac have an alpha channel, so we want 269 // Fix the alpha. The expected PNGs on Mac have an alpha channel, so we want
276 // to keep it. On Windows, the alpha channel is wrong since text/form control 270 // to keep it. On Windows, the alpha channel is wrong since text/form control
277 // drawing may have erased it in a few places. So on Windows we force it to 271 // drawing may have erased it in a few places. So on Windows we force it to
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 669
676 void CloseIdleConnections() { 670 void CloseIdleConnections() {
677 // Used in benchmarking, Ignored for test_shell. 671 // Used in benchmarking, Ignored for test_shell.
678 } 672 }
679 673
680 void SetCacheMode(bool enabled) { 674 void SetCacheMode(bool enabled) {
681 // Used in benchmarking, Ignored for test_shell. 675 // Used in benchmarking, Ignored for test_shell.
682 } 676 }
683 677
684 } // namespace webkit_glue 678 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell.h ('k') | webkit/tools/test_shell/webwidget_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698