| 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 "components/test_runner/test_runner.h" | 5 #include "components/test_runner/test_runner.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "components/test_runner/mock_credential_manager_client.h" | 17 #include "components/test_runner/mock_credential_manager_client.h" |
| 18 #include "components/test_runner/mock_web_speech_recognizer.h" | 18 #include "components/test_runner/mock_web_speech_recognizer.h" |
| 19 #include "components/test_runner/test_interfaces.h" | 19 #include "components/test_runner/test_interfaces.h" |
| 20 #include "components/test_runner/test_preferences.h" | 20 #include "components/test_runner/test_preferences.h" |
| 21 #include "components/test_runner/web_content_settings.h" | 21 #include "components/test_runner/web_content_settings.h" |
| 22 #include "components/test_runner/web_test_delegate.h" | 22 #include "components/test_runner/web_test_delegate.h" |
| 23 #include "components/test_runner/web_test_proxy.h" | 23 #include "components/test_runner/web_test_proxy.h" |
| 24 #include "gin/arguments.h" | 24 #include "gin/arguments.h" |
| 25 #include "gin/array_buffer.h" | 25 #include "gin/array_buffer.h" |
| 26 #include "gin/handle.h" | 26 #include "gin/handle.h" |
| 27 #include "gin/object_template_builder.h" | 27 #include "gin/object_template_builder.h" |
| 28 #include "gin/wrappable.h" | 28 #include "gin/wrappable.h" |
| 29 #include "third_party/WebKit/public/platform/WebBatteryStatus.h" | |
| 30 #include "third_party/WebKit/public/platform/WebCanvas.h" | 29 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 31 #include "third_party/WebKit/public/platform/WebData.h" | 30 #include "third_party/WebKit/public/platform/WebData.h" |
| 32 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" | 31 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" |
| 33 #include "third_party/WebKit/public/platform/WebPoint.h" | 32 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 34 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 33 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 35 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionData.h" | 34 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionData.h" |
| 36 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationData.h" | 35 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationData.h" |
| 37 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerRegistration.h" | 36 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerRegistration.h" |
| 38 #include "third_party/WebKit/public/web/WebArrayBuffer.h" | 37 #include "third_party/WebKit/public/web/WebArrayBuffer.h" |
| 39 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h" | 38 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 bool EnableAutoResizeMode(int min_width, | 213 bool EnableAutoResizeMode(int min_width, |
| 215 int min_height, | 214 int min_height, |
| 216 int max_width, | 215 int max_width, |
| 217 int max_height); | 216 int max_height); |
| 218 bool DisableAutoResizeMode(int new_width, int new_height); | 217 bool DisableAutoResizeMode(int new_width, int new_height); |
| 219 void SetMockDeviceLight(double value); | 218 void SetMockDeviceLight(double value); |
| 220 void ResetDeviceLight(); | 219 void ResetDeviceLight(); |
| 221 void SetMockDeviceMotion(gin::Arguments* args); | 220 void SetMockDeviceMotion(gin::Arguments* args); |
| 222 void SetMockDeviceOrientation(gin::Arguments* args); | 221 void SetMockDeviceOrientation(gin::Arguments* args); |
| 223 void SetMockScreenOrientation(const std::string& orientation); | 222 void SetMockScreenOrientation(const std::string& orientation); |
| 224 void DidChangeBatteryStatus(bool charging, | |
| 225 double chargingTime, | |
| 226 double dischargingTime, | |
| 227 double level); | |
| 228 void ResetBatteryStatus(); | |
| 229 void DidAcquirePointerLock(); | 223 void DidAcquirePointerLock(); |
| 230 void DidNotAcquirePointerLock(); | 224 void DidNotAcquirePointerLock(); |
| 231 void DidLosePointerLock(); | 225 void DidLosePointerLock(); |
| 232 void SetPointerLockWillFailSynchronously(); | 226 void SetPointerLockWillFailSynchronously(); |
| 233 void SetPointerLockWillRespondAsynchronously(); | 227 void SetPointerLockWillRespondAsynchronously(); |
| 234 void SetPopupBlockingEnabled(bool block_popups); | 228 void SetPopupBlockingEnabled(bool block_popups); |
| 235 void SetJavaScriptCanAccessClipboard(bool can_access); | 229 void SetJavaScriptCanAccessClipboard(bool can_access); |
| 236 void SetXSSAuditorEnabled(bool enabled); | 230 void SetXSSAuditorEnabled(bool enabled); |
| 237 void SetAllowUniversalAccessFromFileURLs(bool allow); | 231 void SetAllowUniversalAccessFromFileURLs(bool allow); |
| 238 void SetAllowFileAccessFromFileURLs(bool allow); | 232 void SetAllowFileAccessFromFileURLs(bool allow); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 .SetMethod("disableAutoResizeMode", | 448 .SetMethod("disableAutoResizeMode", |
| 455 &TestRunnerBindings::DisableAutoResizeMode) | 449 &TestRunnerBindings::DisableAutoResizeMode) |
| 456 .SetMethod("setMockDeviceLight", &TestRunnerBindings::SetMockDeviceLight) | 450 .SetMethod("setMockDeviceLight", &TestRunnerBindings::SetMockDeviceLight) |
| 457 .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight) | 451 .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight) |
| 458 .SetMethod("setMockDeviceMotion", | 452 .SetMethod("setMockDeviceMotion", |
| 459 &TestRunnerBindings::SetMockDeviceMotion) | 453 &TestRunnerBindings::SetMockDeviceMotion) |
| 460 .SetMethod("setMockDeviceOrientation", | 454 .SetMethod("setMockDeviceOrientation", |
| 461 &TestRunnerBindings::SetMockDeviceOrientation) | 455 &TestRunnerBindings::SetMockDeviceOrientation) |
| 462 .SetMethod("setMockScreenOrientation", | 456 .SetMethod("setMockScreenOrientation", |
| 463 &TestRunnerBindings::SetMockScreenOrientation) | 457 &TestRunnerBindings::SetMockScreenOrientation) |
| 464 .SetMethod("didChangeBatteryStatus", | |
| 465 &TestRunnerBindings::DidChangeBatteryStatus) | |
| 466 .SetMethod("resetBatteryStatus", &TestRunnerBindings::ResetBatteryStatus) | |
| 467 .SetMethod("didAcquirePointerLock", | 458 .SetMethod("didAcquirePointerLock", |
| 468 &TestRunnerBindings::DidAcquirePointerLock) | 459 &TestRunnerBindings::DidAcquirePointerLock) |
| 469 .SetMethod("didNotAcquirePointerLock", | 460 .SetMethod("didNotAcquirePointerLock", |
| 470 &TestRunnerBindings::DidNotAcquirePointerLock) | 461 &TestRunnerBindings::DidNotAcquirePointerLock) |
| 471 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) | 462 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) |
| 472 .SetMethod("setPointerLockWillFailSynchronously", | 463 .SetMethod("setPointerLockWillFailSynchronously", |
| 473 &TestRunnerBindings::SetPointerLockWillFailSynchronously) | 464 &TestRunnerBindings::SetPointerLockWillFailSynchronously) |
| 474 .SetMethod("setPointerLockWillRespondAsynchronously", | 465 .SetMethod("setPointerLockWillRespondAsynchronously", |
| 475 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) | 466 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) |
| 476 .SetMethod("setPopupBlockingEnabled", | 467 .SetMethod("setPopupBlockingEnabled", |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 } | 1004 } |
| 1014 | 1005 |
| 1015 void TestRunnerBindings::SetMockScreenOrientation( | 1006 void TestRunnerBindings::SetMockScreenOrientation( |
| 1016 const std::string& orientation) { | 1007 const std::string& orientation) { |
| 1017 if (!runner_) | 1008 if (!runner_) |
| 1018 return; | 1009 return; |
| 1019 | 1010 |
| 1020 runner_->SetMockScreenOrientation(orientation); | 1011 runner_->SetMockScreenOrientation(orientation); |
| 1021 } | 1012 } |
| 1022 | 1013 |
| 1023 void TestRunnerBindings::DidChangeBatteryStatus(bool charging, | |
| 1024 double chargingTime, | |
| 1025 double dischargingTime, | |
| 1026 double level) { | |
| 1027 if (runner_) { | |
| 1028 runner_->DidChangeBatteryStatus(charging, chargingTime, | |
| 1029 dischargingTime, level); | |
| 1030 } | |
| 1031 } | |
| 1032 | |
| 1033 void TestRunnerBindings::ResetBatteryStatus() { | |
| 1034 if (runner_) | |
| 1035 runner_->ResetBatteryStatus(); | |
| 1036 } | |
| 1037 | |
| 1038 void TestRunnerBindings::DidAcquirePointerLock() { | 1014 void TestRunnerBindings::DidAcquirePointerLock() { |
| 1039 if (runner_) | 1015 if (runner_) |
| 1040 runner_->DidAcquirePointerLock(); | 1016 runner_->DidAcquirePointerLock(); |
| 1041 } | 1017 } |
| 1042 | 1018 |
| 1043 void TestRunnerBindings::DidNotAcquirePointerLock() { | 1019 void TestRunnerBindings::DidNotAcquirePointerLock() { |
| 1044 if (runner_) | 1020 if (runner_) |
| 1045 runner_->DidNotAcquirePointerLock(); | 1021 runner_->DidNotAcquirePointerLock(); |
| 1046 } | 1022 } |
| 1047 | 1023 |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor()); | 1709 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor()); |
| 1734 delegate_->SetAcceptAllCookies(false); | 1710 delegate_->SetAcceptAllCookies(false); |
| 1735 delegate_->SetLocale(""); | 1711 delegate_->SetLocale(""); |
| 1736 delegate_->UseUnfortunateSynchronousResizeMode(false); | 1712 delegate_->UseUnfortunateSynchronousResizeMode(false); |
| 1737 delegate_->DisableAutoResizeMode(WebSize()); | 1713 delegate_->DisableAutoResizeMode(WebSize()); |
| 1738 delegate_->DeleteAllCookies(); | 1714 delegate_->DeleteAllCookies(); |
| 1739 delegate_->ResetScreenOrientation(); | 1715 delegate_->ResetScreenOrientation(); |
| 1740 delegate_->SetBluetoothMockDataSet(""); | 1716 delegate_->SetBluetoothMockDataSet(""); |
| 1741 delegate_->ClearGeofencingMockProvider(); | 1717 delegate_->ClearGeofencingMockProvider(); |
| 1742 delegate_->ResetPermissions(); | 1718 delegate_->ResetPermissions(); |
| 1743 ResetBatteryStatus(); | |
| 1744 ResetDeviceLight(); | 1719 ResetDeviceLight(); |
| 1745 } | 1720 } |
| 1746 | 1721 |
| 1747 dump_editting_callbacks_ = false; | 1722 dump_editting_callbacks_ = false; |
| 1748 dump_as_text_ = false; | 1723 dump_as_text_ = false; |
| 1749 dump_as_markup_ = false; | 1724 dump_as_markup_ = false; |
| 1750 generate_pixel_results_ = true; | 1725 generate_pixel_results_ = true; |
| 1751 dump_child_frame_scroll_positions_ = false; | 1726 dump_child_frame_scroll_positions_ = false; |
| 1752 dump_child_frames_as_markup_ = false; | 1727 dump_child_frames_as_markup_ = false; |
| 1753 dump_child_frames_as_text_ = false; | 1728 dump_child_frames_as_text_ = false; |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2564 orientation = WebScreenOrientationPortraitSecondary; | 2539 orientation = WebScreenOrientationPortraitSecondary; |
| 2565 } else if (orientation_str == "landscape-primary") { | 2540 } else if (orientation_str == "landscape-primary") { |
| 2566 orientation = WebScreenOrientationLandscapePrimary; | 2541 orientation = WebScreenOrientationLandscapePrimary; |
| 2567 } else if (orientation_str == "landscape-secondary") { | 2542 } else if (orientation_str == "landscape-secondary") { |
| 2568 orientation = WebScreenOrientationLandscapeSecondary; | 2543 orientation = WebScreenOrientationLandscapeSecondary; |
| 2569 } | 2544 } |
| 2570 | 2545 |
| 2571 delegate_->SetScreenOrientation(orientation); | 2546 delegate_->SetScreenOrientation(orientation); |
| 2572 } | 2547 } |
| 2573 | 2548 |
| 2574 void TestRunner::DidChangeBatteryStatus(bool charging, | |
| 2575 double chargingTime, | |
| 2576 double dischargingTime, | |
| 2577 double level) { | |
| 2578 blink::WebBatteryStatus status; | |
| 2579 status.charging = charging; | |
| 2580 status.chargingTime = chargingTime; | |
| 2581 status.dischargingTime = dischargingTime; | |
| 2582 status.level = level; | |
| 2583 delegate_->DidChangeBatteryStatus(status); | |
| 2584 } | |
| 2585 | |
| 2586 void TestRunner::ResetBatteryStatus() { | |
| 2587 blink::WebBatteryStatus status; | |
| 2588 delegate_->DidChangeBatteryStatus(status); | |
| 2589 } | |
| 2590 | |
| 2591 void TestRunner::DidAcquirePointerLock() { | 2549 void TestRunner::DidAcquirePointerLock() { |
| 2592 DidAcquirePointerLockInternal(); | 2550 DidAcquirePointerLockInternal(); |
| 2593 } | 2551 } |
| 2594 | 2552 |
| 2595 void TestRunner::DidNotAcquirePointerLock() { | 2553 void TestRunner::DidNotAcquirePointerLock() { |
| 2596 DidNotAcquirePointerLockInternal(); | 2554 DidNotAcquirePointerLockInternal(); |
| 2597 } | 2555 } |
| 2598 | 2556 |
| 2599 void TestRunner::DidLosePointerLock() { | 2557 void TestRunner::DidLosePointerLock() { |
| 2600 DidLosePointerLockInternal(); | 2558 DidLosePointerLockInternal(); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3241 } | 3199 } |
| 3242 | 3200 |
| 3243 void TestRunner::DidLosePointerLockInternal() { | 3201 void TestRunner::DidLosePointerLockInternal() { |
| 3244 bool was_locked = pointer_locked_; | 3202 bool was_locked = pointer_locked_; |
| 3245 pointer_locked_ = false; | 3203 pointer_locked_ = false; |
| 3246 if (was_locked) | 3204 if (was_locked) |
| 3247 web_view_->didLosePointerLock(); | 3205 web_view_->didLosePointerLock(); |
| 3248 } | 3206 } |
| 3249 | 3207 |
| 3250 } // namespace test_runner | 3208 } // namespace test_runner |
| OLD | NEW |