OLD | NEW |
---|---|
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/test_runner.h" | 5 #include "content/shell/renderer/test_runner/test_runner.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/shell/common/test_runner/test_preferences.h" | 10 #include "content/shell/common/test_runner/test_preferences.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 void AddMockSpeechRecognitionResult(const std::string& transcript, | 274 void AddMockSpeechRecognitionResult(const std::string& transcript, |
275 double confidence); | 275 double confidence); |
276 void SetMockSpeechRecognitionError(const std::string& error, | 276 void SetMockSpeechRecognitionError(const std::string& error, |
277 const std::string& message); | 277 const std::string& message); |
278 bool WasMockSpeechRecognitionAborted(); | 278 bool WasMockSpeechRecognitionAborted(); |
279 void AddWebPageOverlay(); | 279 void AddWebPageOverlay(); |
280 void RemoveWebPageOverlay(); | 280 void RemoveWebPageOverlay(); |
281 void DisplayAsync(); | 281 void DisplayAsync(); |
282 void DisplayAsyncThen(v8::Handle<v8::Function> callback); | 282 void DisplayAsyncThen(v8::Handle<v8::Function> callback); |
283 void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback); | 283 void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback); |
284 void CopyAtAndCapturePixelsAsyncThen(int x, int y, v8::Handle<v8::Function> ca llback); | |
284 void SetCustomTextOutput(std::string output); | 285 void SetCustomTextOutput(std::string output); |
285 void SetViewSourceForFrame(const std::string& name, bool enabled); | 286 void SetViewSourceForFrame(const std::string& name, bool enabled); |
286 void SetMockPushClientSuccess(const std::string& endpoint, | 287 void SetMockPushClientSuccess(const std::string& endpoint, |
287 const std::string& registration_id); | 288 const std::string& registration_id); |
288 void SetMockPushClientError(const std::string& message); | 289 void SetMockPushClientError(const std::string& message); |
289 | 290 |
290 bool GlobalFlag(); | 291 bool GlobalFlag(); |
291 void SetGlobalFlag(bool value); | 292 void SetGlobalFlag(bool value); |
292 std::string PlatformName(); | 293 std::string PlatformName(); |
293 std::string TooltipText(); | 294 std::string TooltipText(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 &TestRunnerBindings::SetMockSpeechRecognitionError) | 522 &TestRunnerBindings::SetMockSpeechRecognitionError) |
522 .SetMethod("wasMockSpeechRecognitionAborted", | 523 .SetMethod("wasMockSpeechRecognitionAborted", |
523 &TestRunnerBindings::WasMockSpeechRecognitionAborted) | 524 &TestRunnerBindings::WasMockSpeechRecognitionAborted) |
524 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) | 525 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) |
525 .SetMethod("removeWebPageOverlay", | 526 .SetMethod("removeWebPageOverlay", |
526 &TestRunnerBindings::RemoveWebPageOverlay) | 527 &TestRunnerBindings::RemoveWebPageOverlay) |
527 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync) | 528 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync) |
528 .SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen) | 529 .SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen) |
529 .SetMethod("capturePixelsAsyncThen", | 530 .SetMethod("capturePixelsAsyncThen", |
530 &TestRunnerBindings::CapturePixelsAsyncThen) | 531 &TestRunnerBindings::CapturePixelsAsyncThen) |
532 .SetMethod("copyAtAndCapturePixelsAsyncThen", | |
Ken Russell (switch to Gerrit)
2014/07/16 20:40:50
Please name this copyImageAtAndCapturePixelsAsyncT
hj.r.chung
2014/07/17 05:33:39
Done.
| |
533 &TestRunnerBindings::CopyAtAndCapturePixelsAsyncThen) | |
531 .SetMethod("setCustomTextOutput", | 534 .SetMethod("setCustomTextOutput", |
532 &TestRunnerBindings::SetCustomTextOutput) | 535 &TestRunnerBindings::SetCustomTextOutput) |
533 .SetMethod("setViewSourceForFrame", | 536 .SetMethod("setViewSourceForFrame", |
534 &TestRunnerBindings::SetViewSourceForFrame) | 537 &TestRunnerBindings::SetViewSourceForFrame) |
535 .SetMethod("setMockPushClientSuccess", | 538 .SetMethod("setMockPushClientSuccess", |
536 &TestRunnerBindings::SetMockPushClientSuccess) | 539 &TestRunnerBindings::SetMockPushClientSuccess) |
537 .SetMethod("setMockPushClientError", | 540 .SetMethod("setMockPushClientError", |
538 &TestRunnerBindings::SetMockPushClientError) | 541 &TestRunnerBindings::SetMockPushClientError) |
539 | 542 |
540 // Properties. | 543 // Properties. |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1343 if (runner_) | 1346 if (runner_) |
1344 runner_->DisplayAsyncThen(callback); | 1347 runner_->DisplayAsyncThen(callback); |
1345 } | 1348 } |
1346 | 1349 |
1347 void TestRunnerBindings::CapturePixelsAsyncThen( | 1350 void TestRunnerBindings::CapturePixelsAsyncThen( |
1348 v8::Handle<v8::Function> callback) { | 1351 v8::Handle<v8::Function> callback) { |
1349 if (runner_) | 1352 if (runner_) |
1350 runner_->CapturePixelsAsyncThen(callback); | 1353 runner_->CapturePixelsAsyncThen(callback); |
1351 } | 1354 } |
1352 | 1355 |
1356 void TestRunnerBindings::CopyAtAndCapturePixelsAsyncThen( | |
1357 int x, int y, v8::Handle<v8::Function> callback) { | |
1358 if (runner_) | |
1359 runner_->CopyAtAndCapturePixelsAsyncThen(x, y, callback); | |
1360 } | |
1361 | |
1353 void TestRunnerBindings::SetCustomTextOutput(std::string output) { | 1362 void TestRunnerBindings::SetCustomTextOutput(std::string output) { |
1354 runner_->setCustomTextOutput(output); | 1363 runner_->setCustomTextOutput(output); |
1355 } | 1364 } |
1356 | 1365 |
1357 void TestRunnerBindings::SetViewSourceForFrame(const std::string& name, | 1366 void TestRunnerBindings::SetViewSourceForFrame(const std::string& name, |
1358 bool enabled) { | 1367 bool enabled) { |
1359 if (runner_ && runner_->web_view_) { | 1368 if (runner_ && runner_->web_view_) { |
1360 WebFrame* target_frame = | 1369 WebFrame* target_frame = |
1361 runner_->web_view_->findFrameByName(WebString::fromUTF8(name)); | 1370 runner_->web_view_->findFrameByName(WebString::fromUTF8(name)); |
1362 if (target_frame) | 1371 if (target_frame) |
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2782 } | 2791 } |
2783 | 2792 |
2784 void TestRunner::CapturePixelsAsyncThen(v8::Handle<v8::Function> callback) { | 2793 void TestRunner::CapturePixelsAsyncThen(v8::Handle<v8::Function> callback) { |
2785 scoped_ptr<InvokeCallbackTask> task( | 2794 scoped_ptr<InvokeCallbackTask> task( |
2786 new InvokeCallbackTask(this, callback)); | 2795 new InvokeCallbackTask(this, callback)); |
2787 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, | 2796 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, |
2788 base::Unretained(this), | 2797 base::Unretained(this), |
2789 base::Passed(&task))); | 2798 base::Passed(&task))); |
2790 } | 2799 } |
2791 | 2800 |
2801 void TestRunner::CopyAtAndCapturePixelsAsyncThen( | |
2802 int x, int y, v8::Handle<v8::Function> callback) { | |
2803 scoped_ptr<InvokeCallbackTask> task( | |
2804 new InvokeCallbackTask(this, callback)); | |
2805 proxy_->CopyAtAndCapturePixels(x, | |
2806 y, | |
2807 base::Bind(&TestRunner::CapturePixelsCallback, | |
2808 base::Unretained(this), | |
2809 base::Passed(&task))); | |
2810 } | |
2811 | |
2792 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task, | 2812 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task, |
2793 const SkBitmap& snapshot) { | 2813 const SkBitmap& snapshot) { |
2794 v8::Isolate* isolate = blink::mainThreadIsolate(); | 2814 v8::Isolate* isolate = blink::mainThreadIsolate(); |
2795 v8::HandleScope handle_scope(isolate); | 2815 v8::HandleScope handle_scope(isolate); |
2796 | 2816 |
2797 v8::Handle<v8::Context> context = | 2817 v8::Handle<v8::Context> context = |
2798 web_view_->mainFrame()->mainWorldScriptContext(); | 2818 web_view_->mainFrame()->mainWorldScriptContext(); |
2799 if (context.IsEmpty()) | 2819 if (context.IsEmpty()) |
2800 return; | 2820 return; |
2801 | 2821 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2889 } | 2909 } |
2890 | 2910 |
2891 void TestRunner::DidLosePointerLockInternal() { | 2911 void TestRunner::DidLosePointerLockInternal() { |
2892 bool was_locked = pointer_locked_; | 2912 bool was_locked = pointer_locked_; |
2893 pointer_locked_ = false; | 2913 pointer_locked_ = false; |
2894 if (was_locked) | 2914 if (was_locked) |
2895 web_view_->didLosePointerLock(); | 2915 web_view_->didLosePointerLock(); |
2896 } | 2916 } |
2897 | 2917 |
2898 } // namespace content | 2918 } // namespace content |
OLD | NEW |