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

Side by Side Diff: content/shell/renderer/test_runner/web_test_proxy.cc

Issue 386803003: Be robust to printing too large pages in tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer/test_runner/web_test_proxy.h" 5 #include "content/shell/renderer/test_runner/web_test_proxy.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 471
472 blink::WebSize page_size_in_pixels = web_widget_->size(); 472 blink::WebSize page_size_in_pixels = web_widget_->size();
473 blink::WebFrame* web_frame = GetWebView()->mainFrame(); 473 blink::WebFrame* web_frame = GetWebView()->mainFrame();
474 474
475 int page_count = web_frame->printBegin(page_size_in_pixels); 475 int page_count = web_frame->printBegin(page_size_in_pixels);
476 int totalHeight = page_count * (page_size_in_pixels.height + 1) - 1; 476 int totalHeight = page_count * (page_size_in_pixels.height + 1) - 1;
477 477
478 bool is_opaque = false; 478 bool is_opaque = false;
479 skia::RefPtr<SkCanvas> canvas(skia::AdoptRef(skia::TryCreateBitmapCanvas( 479 skia::RefPtr<SkCanvas> canvas(skia::AdoptRef(skia::TryCreateBitmapCanvas(
480 page_size_in_pixels.width, totalHeight, is_opaque))); 480 page_size_in_pixels.width, totalHeight, is_opaque)));
481 if (canvas) 481 if (!canvas) {
482 web_frame->printPagesWithBoundaries(canvas.get(), page_size_in_pixels); 482 callback.Run(SkBitmap());
483 return;
484 }
485 web_frame->printPagesWithBoundaries(canvas.get(), page_size_in_pixels);
483 web_frame->printEnd(); 486 web_frame->printEnd();
484 487
485 DrawSelectionRect(canvas.get()); 488 DrawSelectionRect(canvas.get());
486 SkBaseDevice* device = skia::GetTopDevice(*canvas); 489 SkBaseDevice* device = skia::GetTopDevice(*canvas);
487 const SkBitmap& bitmap = device->accessBitmap(false); 490 const SkBitmap& bitmap = device->accessBitmap(false);
488 callback.Run(bitmap); 491 callback.Run(bitmap);
489 } 492 }
490 493
491 void WebTestProxyBase::CapturePixelsAsync( 494 void WebTestProxyBase::CapturePixelsAsync(
492 const base::Callback<void(const SkBitmap&)>& callback) { 495 const base::Callback<void(const SkBitmap&)>& callback) {
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 if (!push_client_.get()) 1242 if (!push_client_.get())
1240 push_client_.reset(new MockWebPushClient); 1243 push_client_.reset(new MockWebPushClient);
1241 return push_client_.get(); 1244 return push_client_.get();
1242 } 1245 }
1243 1246
1244 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { 1247 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() {
1245 return GetPushClientMock(); 1248 return GetPushClientMock();
1246 } 1249 }
1247 1250
1248 } // namespace content 1251 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698