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

Unified Diff: content/shell/renderer/test_runner/test_runner.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
Index: content/shell/renderer/test_runner/test_runner.cc
diff --git a/content/shell/renderer/test_runner/test_runner.cc b/content/shell/renderer/test_runner/test_runner.cc
index 9e280747656eb04f990c2c9b398bfd5b428c44f0..c039b189421fec2d03daa52178086b38ededdd58 100644
--- a/content/shell/renderer/test_runner/test_runner.cc
+++ b/content/shell/renderer/test_runner/test_runner.cc
@@ -281,6 +281,9 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void DisplayAsync();
void DisplayAsyncThen(v8::Handle<v8::Function> callback);
void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback);
+ void CopyImageAtAndCapturePixelsAsyncThen(int x,
+ int y,
+ v8::Handle<v8::Function> callback);
void SetCustomTextOutput(std::string output);
void SetViewSourceForFrame(const std::string& name, bool enabled);
void SetMockPushClientSuccess(const std::string& endpoint,
@@ -528,6 +531,8 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
.SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen)
.SetMethod("capturePixelsAsyncThen",
&TestRunnerBindings::CapturePixelsAsyncThen)
+ .SetMethod("copyImageAtAndCapturePixelsAsyncThen",
+ &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen)
.SetMethod("setCustomTextOutput",
&TestRunnerBindings::SetCustomTextOutput)
.SetMethod("setViewSourceForFrame",
@@ -1350,6 +1355,12 @@ void TestRunnerBindings::CapturePixelsAsyncThen(
runner_->CapturePixelsAsyncThen(callback);
}
+void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen(
+ int x, int y, v8::Handle<v8::Function> callback) {
+ if (runner_)
+ runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback);
+}
+
void TestRunnerBindings::SetCustomTextOutput(std::string output) {
runner_->setCustomTextOutput(output);
}
@@ -2789,6 +2800,16 @@ void TestRunner::CapturePixelsAsyncThen(v8::Handle<v8::Function> callback) {
base::Passed(&task)));
}
+void TestRunner::CopyImageAtAndCapturePixelsAsyncThen(
+ int x, int y, v8::Handle<v8::Function> callback) {
+ scoped_ptr<InvokeCallbackTask> task(
+ new InvokeCallbackTask(this, callback));
+ proxy_->CopyImageAtAndCapturePixels(
+ x, y, base::Bind(&TestRunner::CapturePixelsCallback,
+ base::Unretained(this),
+ base::Passed(&task)));
+}
+
void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task,
const SkBitmap& snapshot) {
v8::Isolate* isolate = blink::mainThreadIsolate();
@@ -2803,12 +2824,12 @@ void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task,
v8::Handle<v8::Value> argv[3];
SkAutoLockPixels snapshot_lock(snapshot);
+ // Size can be 0 for cases where copyImageAt was called on position
+ // that doesn't have an image.
int width = snapshot.info().fWidth;
- DCHECK_NE(0, width);
argv[0] = v8::Number::New(isolate, width);
int height = snapshot.info().fHeight;
- DCHECK_NE(0, height);
argv[1] = v8::Number::New(isolate, height);
blink::WebArrayBuffer buffer =
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.h ('k') | content/shell/renderer/test_runner/web_test_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698