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