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

Unified Diff: content/shell/renderer/test_runner/web_test_proxy.cc

Issue 396953002: Add testRunner.copyAtAndCapturePixelsAsyncThen() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added initialization for members 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/renderer/test_runner/web_test_proxy.h ('k') | content/test/mock_webclipboard_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/test_runner/web_test_proxy.cc
diff --git a/content/shell/renderer/test_runner/web_test_proxy.cc b/content/shell/renderer/test_runner/web_test_proxy.cc
index e3838f6481af96bc6dddcad9c6b5b929aafc52a9..270f990ec7876cfd7b79f9d226cb383ef331d8a5 100644
--- a/content/shell/renderer/test_runner/web_test_proxy.cc
+++ b/content/shell/renderer/test_runner/web_test_proxy.cc
@@ -26,7 +26,9 @@
#include "content/shell/renderer/test_runner/web_test_runner.h"
// FIXME: Including platform_canvas.h here is a layering violation.
#include "skia/ext/platform_canvas.h"
+#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebCString.h"
+#include "third_party/WebKit/public/platform/WebClipboard.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
@@ -468,6 +470,28 @@ void WebTestProxyBase::SetAcceptLanguages(const std::string& accept_languages) {
GetWebView()->acceptLanguagesChanged();
}
+void WebTestProxyBase::CopyImageAtAndCapturePixels(
+ int x, int y, const base::Callback<void(const SkBitmap&)>& callback) {
+ DCHECK(web_widget_->isAcceleratedCompositingActive());
+ DCHECK(!callback.is_null());
+ uint64_t sequence_number = blink::Platform::current()->clipboard()->
+ sequenceNumber(blink::WebClipboard::Buffer());
+ GetWebView()->copyImageAt(blink::WebPoint(x, y));
+ if (sequence_number == blink::Platform::current()->clipboard()->
+ sequenceNumber(blink::WebClipboard::Buffer())) {
+ SkBitmap emptyBitmap;
+ callback.Run(emptyBitmap);
+ return;
+ }
+
+ blink::WebData data = blink::Platform::current()->clipboard()->readImage(
+ blink::WebClipboard::Buffer());
+ blink::WebImage image = blink::WebImage::fromData(data, blink::WebSize());
+ const SkBitmap& bitmap = image.getSkBitmap();
+ SkAutoLockPixels autoLock(bitmap);
+ callback.Run(bitmap);
+}
+
void WebTestProxyBase::CapturePixelsForPrinting(
const base::Callback<void(const SkBitmap&)>& callback) {
web_widget_->layout();
« no previous file with comments | « content/shell/renderer/test_runner/web_test_proxy.h ('k') | content/test/mock_webclipboard_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698