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 "base/run_loop.h" |
10 #include "content/public/test/layouttest_support.h" | 11 #include "content/public/test/layouttest_support.h" |
11 #include "content/shell/common/test_runner/test_preferences.h" | 12 #include "content/shell/common/test_runner/test_preferences.h" |
12 #include "content/shell/renderer/binding_helpers.h" | 13 #include "content/shell/renderer/binding_helpers.h" |
13 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" | 14 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" |
14 #include "content/shell/renderer/test_runner/mock_web_push_client.h" | 15 #include "content/shell/renderer/test_runner/mock_web_push_client.h" |
15 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" | 16 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" |
16 #include "content/shell/renderer/test_runner/notification_presenter.h" | 17 #include "content/shell/renderer/test_runner/notification_presenter.h" |
17 #include "content/shell/renderer/test_runner/test_interfaces.h" | 18 #include "content/shell/renderer/test_runner/test_interfaces.h" |
18 #include "content/shell/renderer/test_runner/web_permissions.h" | 19 #include "content/shell/renderer/test_runner/web_permissions.h" |
19 #include "content/shell/renderer/test_runner/web_test_delegate.h" | 20 #include "content/shell/renderer/test_runner/web_test_delegate.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 const std::string& registration_id); | 299 const std::string& registration_id); |
299 void SetMockPushClientError(const std::string& message); | 300 void SetMockPushClientError(const std::string& message); |
300 void SetBluetoothMockDataSet(const std::string& dataset_name); | 301 void SetBluetoothMockDataSet(const std::string& dataset_name); |
301 | 302 |
302 std::string PlatformName(); | 303 std::string PlatformName(); |
303 std::string TooltipText(); | 304 std::string TooltipText(); |
304 bool DisableNotifyDone(); | 305 bool DisableNotifyDone(); |
305 int WebHistoryItemCount(); | 306 int WebHistoryItemCount(); |
306 bool InterceptPostMessage(); | 307 bool InterceptPostMessage(); |
307 void SetInterceptPostMessage(bool value); | 308 void SetInterceptPostMessage(bool value); |
| 309 void Sleep(int milliseconds); |
308 | 310 |
309 void NotImplemented(const gin::Arguments& args); | 311 void NotImplemented(const gin::Arguments& args); |
310 | 312 |
311 void ForceNextWebGLContextCreationToFail(); | 313 void ForceNextWebGLContextCreationToFail(); |
312 | 314 |
313 base::WeakPtr<TestRunner> runner_; | 315 base::WeakPtr<TestRunner> runner_; |
314 | 316 |
315 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings); | 317 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings); |
316 }; | 318 }; |
317 | 319 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 &TestRunnerBindings::DumpUserGestureInFrameLoadCallbacks) | 455 &TestRunnerBindings::DumpUserGestureInFrameLoadCallbacks) |
454 .SetMethod("dumpTitleChanges", &TestRunnerBindings::DumpTitleChanges) | 456 .SetMethod("dumpTitleChanges", &TestRunnerBindings::DumpTitleChanges) |
455 .SetMethod("dumpCreateView", &TestRunnerBindings::DumpCreateView) | 457 .SetMethod("dumpCreateView", &TestRunnerBindings::DumpCreateView) |
456 .SetMethod("setCanOpenWindows", &TestRunnerBindings::SetCanOpenWindows) | 458 .SetMethod("setCanOpenWindows", &TestRunnerBindings::SetCanOpenWindows) |
457 .SetMethod("dumpResourceLoadCallbacks", | 459 .SetMethod("dumpResourceLoadCallbacks", |
458 &TestRunnerBindings::DumpResourceLoadCallbacks) | 460 &TestRunnerBindings::DumpResourceLoadCallbacks) |
459 .SetMethod("dumpResourceRequestCallbacks", | 461 .SetMethod("dumpResourceRequestCallbacks", |
460 &TestRunnerBindings::DumpResourceRequestCallbacks) | 462 &TestRunnerBindings::DumpResourceRequestCallbacks) |
461 .SetMethod("dumpResourceResponseMIMETypes", | 463 .SetMethod("dumpResourceResponseMIMETypes", |
462 &TestRunnerBindings::DumpResourceResponseMIMETypes) | 464 &TestRunnerBindings::DumpResourceResponseMIMETypes) |
| 465 .SetMethod("sleep", &TestRunnerBindings::Sleep) |
463 .SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed) | 466 .SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed) |
464 .SetMethod("setMediaAllowed", &TestRunnerBindings::SetMediaAllowed) | 467 .SetMethod("setMediaAllowed", &TestRunnerBindings::SetMediaAllowed) |
465 .SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed) | 468 .SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed) |
466 .SetMethod("setStorageAllowed", &TestRunnerBindings::SetStorageAllowed) | 469 .SetMethod("setStorageAllowed", &TestRunnerBindings::SetStorageAllowed) |
467 .SetMethod("setPluginsAllowed", &TestRunnerBindings::SetPluginsAllowed) | 470 .SetMethod("setPluginsAllowed", &TestRunnerBindings::SetPluginsAllowed) |
468 .SetMethod("setAllowDisplayOfInsecureContent", | 471 .SetMethod("setAllowDisplayOfInsecureContent", |
469 &TestRunnerBindings::SetAllowDisplayOfInsecureContent) | 472 &TestRunnerBindings::SetAllowDisplayOfInsecureContent) |
470 .SetMethod("setAllowRunningOfInsecureContent", | 473 .SetMethod("setAllowRunningOfInsecureContent", |
471 &TestRunnerBindings::SetAllowRunningOfInsecureContent) | 474 &TestRunnerBindings::SetAllowRunningOfInsecureContent) |
472 .SetMethod("dumpPermissionClientCallbacks", | 475 .SetMethod("dumpPermissionClientCallbacks", |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 void TestRunnerBindings::DumpResourceRequestCallbacks() { | 1112 void TestRunnerBindings::DumpResourceRequestCallbacks() { |
1110 if (runner_) | 1113 if (runner_) |
1111 runner_->DumpResourceRequestCallbacks(); | 1114 runner_->DumpResourceRequestCallbacks(); |
1112 } | 1115 } |
1113 | 1116 |
1114 void TestRunnerBindings::DumpResourceResponseMIMETypes() { | 1117 void TestRunnerBindings::DumpResourceResponseMIMETypes() { |
1115 if (runner_) | 1118 if (runner_) |
1116 runner_->DumpResourceResponseMIMETypes(); | 1119 runner_->DumpResourceResponseMIMETypes(); |
1117 } | 1120 } |
1118 | 1121 |
| 1122 void TestRunnerBindings::Sleep(int milliseconds) { |
| 1123 if (runner_) |
| 1124 runner_->Sleep(milliseconds); |
| 1125 } |
| 1126 |
1119 void TestRunnerBindings::SetImagesAllowed(bool allowed) { | 1127 void TestRunnerBindings::SetImagesAllowed(bool allowed) { |
1120 if (runner_) | 1128 if (runner_) |
1121 runner_->SetImagesAllowed(allowed); | 1129 runner_->SetImagesAllowed(allowed); |
1122 } | 1130 } |
1123 | 1131 |
1124 void TestRunnerBindings::SetMediaAllowed(bool allowed) { | 1132 void TestRunnerBindings::SetMediaAllowed(bool allowed) { |
1125 if (runner_) | 1133 if (runner_) |
1126 runner_->SetMediaAllowed(allowed); | 1134 runner_->SetMediaAllowed(allowed); |
1127 } | 1135 } |
1128 | 1136 |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2610 } | 2618 } |
2611 | 2619 |
2612 void TestRunner::DumpResourceRequestCallbacks() { | 2620 void TestRunner::DumpResourceRequestCallbacks() { |
2613 dump_resource_request_callbacks_ = true; | 2621 dump_resource_request_callbacks_ = true; |
2614 } | 2622 } |
2615 | 2623 |
2616 void TestRunner::DumpResourceResponseMIMETypes() { | 2624 void TestRunner::DumpResourceResponseMIMETypes() { |
2617 dump_resource_reqponse_mime_types_ = true; | 2625 dump_resource_reqponse_mime_types_ = true; |
2618 } | 2626 } |
2619 | 2627 |
| 2628 void TestRunner::Sleep(int milliseconds) { |
| 2629 web_view_->setDefersLoading(true); |
| 2630 |
| 2631 base::MessageLoop* ml = base::MessageLoop::current(); |
| 2632 base::MessageLoop::ScopedNestableTaskAllower allow_nested_tasks(ml); |
| 2633 base::RunLoop run_loop; |
| 2634 ml->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), |
| 2635 base::TimeDelta::FromMilliseconds(milliseconds)); |
| 2636 run_loop.Run(); |
| 2637 |
| 2638 web_view_->setDefersLoading(false); |
| 2639 } |
| 2640 |
2620 void TestRunner::SetImagesAllowed(bool allowed) { | 2641 void TestRunner::SetImagesAllowed(bool allowed) { |
2621 web_permissions_->SetImagesAllowed(allowed); | 2642 web_permissions_->SetImagesAllowed(allowed); |
2622 } | 2643 } |
2623 | 2644 |
2624 void TestRunner::SetMediaAllowed(bool allowed) { | 2645 void TestRunner::SetMediaAllowed(bool allowed) { |
2625 web_permissions_->SetMediaAllowed(allowed); | 2646 web_permissions_->SetMediaAllowed(allowed); |
2626 } | 2647 } |
2627 | 2648 |
2628 void TestRunner::SetScriptsAllowed(bool allowed) { | 2649 void TestRunner::SetScriptsAllowed(bool allowed) { |
2629 web_permissions_->SetScriptsAllowed(allowed); | 2650 web_permissions_->SetScriptsAllowed(allowed); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2975 } | 2996 } |
2976 | 2997 |
2977 void TestRunner::DidLosePointerLockInternal() { | 2998 void TestRunner::DidLosePointerLockInternal() { |
2978 bool was_locked = pointer_locked_; | 2999 bool was_locked = pointer_locked_; |
2979 pointer_locked_ = false; | 3000 pointer_locked_ = false; |
2980 if (was_locked) | 3001 if (was_locked) |
2981 web_view_->didLosePointerLock(); | 3002 web_view_->didLosePointerLock(); |
2982 } | 3003 } |
2983 | 3004 |
2984 } // namespace content | 3005 } // namespace content |
OLD | NEW |