| 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" |
| 11 #include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" | 11 #include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" |
| 12 #include "content/shell/renderer/test_runner/TestInterfaces.h" | 12 #include "content/shell/renderer/test_runner/TestInterfaces.h" |
| 13 #include "content/shell/renderer/test_runner/WebPermissions.h" | 13 #include "content/shell/renderer/test_runner/WebPermissions.h" |
| 14 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 14 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 15 #include "content/shell/renderer/test_runner/notification_presenter.h" | 15 #include "content/shell/renderer/test_runner/notification_presenter.h" |
| 16 #include "content/shell/renderer/test_runner/web_test_proxy.h" | 16 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
| 17 #include "gin/arguments.h" | 17 #include "gin/arguments.h" |
| 18 #include "gin/array_buffer.h" | 18 #include "gin/array_buffer.h" |
| 19 #include "gin/handle.h" | 19 #include "gin/handle.h" |
| 20 #include "gin/object_template_builder.h" | 20 #include "gin/object_template_builder.h" |
| 21 #include "gin/wrappable.h" | 21 #include "gin/wrappable.h" |
| 22 #include "third_party/WebKit/public/platform/WebBatteryStatus.h" |
| 22 #include "third_party/WebKit/public/platform/WebCanvas.h" | 23 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 23 #include "third_party/WebKit/public/platform/WebData.h" | 24 #include "third_party/WebKit/public/platform/WebData.h" |
| 24 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" | 25 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" |
| 25 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" | 26 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" |
| 26 #include "third_party/WebKit/public/platform/WebPoint.h" | 27 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 27 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 28 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 28 #include "third_party/WebKit/public/web/WebBindings.h" | 29 #include "third_party/WebKit/public/web/WebBindings.h" |
| 29 #include "third_party/WebKit/public/web/WebDataSource.h" | 30 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 30 #include "third_party/WebKit/public/web/WebDocument.h" | 31 #include "third_party/WebKit/public/web/WebDocument.h" |
| 31 #include "third_party/WebKit/public/web/WebFindOptions.h" | 32 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void SetTextDirection(const std::string& direction_name); | 167 void SetTextDirection(const std::string& direction_name); |
| 167 void UseUnfortunateSynchronousResizeMode(); | 168 void UseUnfortunateSynchronousResizeMode(); |
| 168 bool EnableAutoResizeMode(int min_width, | 169 bool EnableAutoResizeMode(int min_width, |
| 169 int min_height, | 170 int min_height, |
| 170 int max_width, | 171 int max_width, |
| 171 int max_height); | 172 int max_height); |
| 172 bool DisableAutoResizeMode(int new_width, int new_height); | 173 bool DisableAutoResizeMode(int new_width, int new_height); |
| 173 void SetMockDeviceMotion(gin::Arguments* args); | 174 void SetMockDeviceMotion(gin::Arguments* args); |
| 174 void SetMockDeviceOrientation(gin::Arguments* args); | 175 void SetMockDeviceOrientation(gin::Arguments* args); |
| 175 void SetMockScreenOrientation(const std::string& orientation); | 176 void SetMockScreenOrientation(const std::string& orientation); |
| 177 void DidChangeBatteryStatus(bool charging, |
| 178 double chargingTime, |
| 179 double dischargingTime, |
| 180 double level); |
| 181 void ResetBatteryStatus(); |
| 176 void DidAcquirePointerLock(); | 182 void DidAcquirePointerLock(); |
| 177 void DidNotAcquirePointerLock(); | 183 void DidNotAcquirePointerLock(); |
| 178 void DidLosePointerLock(); | 184 void DidLosePointerLock(); |
| 179 void SetPointerLockWillFailSynchronously(); | 185 void SetPointerLockWillFailSynchronously(); |
| 180 void SetPointerLockWillRespondAsynchronously(); | 186 void SetPointerLockWillRespondAsynchronously(); |
| 181 void SetPopupBlockingEnabled(bool block_popups); | 187 void SetPopupBlockingEnabled(bool block_popups); |
| 182 void SetJavaScriptCanAccessClipboard(bool can_access); | 188 void SetJavaScriptCanAccessClipboard(bool can_access); |
| 183 void SetXSSAuditorEnabled(bool enabled); | 189 void SetXSSAuditorEnabled(bool enabled); |
| 184 void SetAllowUniversalAccessFromFileURLs(bool allow); | 190 void SetAllowUniversalAccessFromFileURLs(bool allow); |
| 185 void SetAllowFileAccessFromFileURLs(bool allow); | 191 void SetAllowFileAccessFromFileURLs(bool allow); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 .SetMethod("enableAutoResizeMode", | 366 .SetMethod("enableAutoResizeMode", |
| 361 &TestRunnerBindings::EnableAutoResizeMode) | 367 &TestRunnerBindings::EnableAutoResizeMode) |
| 362 .SetMethod("disableAutoResizeMode", | 368 .SetMethod("disableAutoResizeMode", |
| 363 &TestRunnerBindings::DisableAutoResizeMode) | 369 &TestRunnerBindings::DisableAutoResizeMode) |
| 364 .SetMethod("setMockDeviceMotion", | 370 .SetMethod("setMockDeviceMotion", |
| 365 &TestRunnerBindings::SetMockDeviceMotion) | 371 &TestRunnerBindings::SetMockDeviceMotion) |
| 366 .SetMethod("setMockDeviceOrientation", | 372 .SetMethod("setMockDeviceOrientation", |
| 367 &TestRunnerBindings::SetMockDeviceOrientation) | 373 &TestRunnerBindings::SetMockDeviceOrientation) |
| 368 .SetMethod("setMockScreenOrientation", | 374 .SetMethod("setMockScreenOrientation", |
| 369 &TestRunnerBindings::SetMockScreenOrientation) | 375 &TestRunnerBindings::SetMockScreenOrientation) |
| 376 .SetMethod("didChangeBatteryStatus", |
| 377 &TestRunnerBindings::DidChangeBatteryStatus) |
| 378 .SetMethod("resetBatteryStatus", |
| 379 &TestRunnerBindings::ResetBatteryStatus) |
| 370 .SetMethod("didAcquirePointerLock", | 380 .SetMethod("didAcquirePointerLock", |
| 371 &TestRunnerBindings::DidAcquirePointerLock) | 381 &TestRunnerBindings::DidAcquirePointerLock) |
| 372 .SetMethod("didNotAcquirePointerLock", | 382 .SetMethod("didNotAcquirePointerLock", |
| 373 &TestRunnerBindings::DidNotAcquirePointerLock) | 383 &TestRunnerBindings::DidNotAcquirePointerLock) |
| 374 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) | 384 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) |
| 375 .SetMethod("setPointerLockWillFailSynchronously", | 385 .SetMethod("setPointerLockWillFailSynchronously", |
| 376 &TestRunnerBindings::SetPointerLockWillFailSynchronously) | 386 &TestRunnerBindings::SetPointerLockWillFailSynchronously) |
| 377 .SetMethod("setPointerLockWillRespondAsynchronously", | 387 .SetMethod("setPointerLockWillRespondAsynchronously", |
| 378 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) | 388 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) |
| 379 .SetMethod("setPopupBlockingEnabled", | 389 .SetMethod("setPopupBlockingEnabled", |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 has_absolute, absolute); | 877 has_absolute, absolute); |
| 868 } | 878 } |
| 869 | 879 |
| 870 void TestRunnerBindings::SetMockScreenOrientation(const std::string& orientation
) { | 880 void TestRunnerBindings::SetMockScreenOrientation(const std::string& orientation
) { |
| 871 if (!runner_) | 881 if (!runner_) |
| 872 return; | 882 return; |
| 873 | 883 |
| 874 runner_->SetMockScreenOrientation(orientation); | 884 runner_->SetMockScreenOrientation(orientation); |
| 875 } | 885 } |
| 876 | 886 |
| 887 void TestRunnerBindings::DidChangeBatteryStatus(bool charging, |
| 888 double chargingTime, |
| 889 double dischargingTime, |
| 890 double level) { |
| 891 if (runner_) { |
| 892 runner_->DidChangeBatteryStatus(charging, chargingTime, |
| 893 dischargingTime, level); |
| 894 } |
| 895 } |
| 896 |
| 897 void TestRunnerBindings::ResetBatteryStatus() { |
| 898 if (runner_) |
| 899 runner_->ResetBatteryStatus(); |
| 900 } |
| 901 |
| 877 void TestRunnerBindings::DidAcquirePointerLock() { | 902 void TestRunnerBindings::DidAcquirePointerLock() { |
| 878 if (runner_) | 903 if (runner_) |
| 879 runner_->DidAcquirePointerLock(); | 904 runner_->DidAcquirePointerLock(); |
| 880 } | 905 } |
| 881 | 906 |
| 882 void TestRunnerBindings::DidNotAcquirePointerLock() { | 907 void TestRunnerBindings::DidNotAcquirePointerLock() { |
| 883 if (runner_) | 908 if (runner_) |
| 884 runner_->DidNotAcquirePointerLock(); | 909 runner_->DidNotAcquirePointerLock(); |
| 885 } | 910 } |
| 886 | 911 |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 // Reset the default quota for each origin to 5MB | 1493 // Reset the default quota for each origin to 5MB |
| 1469 delegate_->setDatabaseQuota(5 * 1024 * 1024); | 1494 delegate_->setDatabaseQuota(5 * 1024 * 1024); |
| 1470 delegate_->setDeviceColorProfile("sRGB"); | 1495 delegate_->setDeviceColorProfile("sRGB"); |
| 1471 delegate_->setDeviceScaleFactor(1); | 1496 delegate_->setDeviceScaleFactor(1); |
| 1472 delegate_->setAcceptAllCookies(false); | 1497 delegate_->setAcceptAllCookies(false); |
| 1473 delegate_->setLocale(""); | 1498 delegate_->setLocale(""); |
| 1474 delegate_->useUnfortunateSynchronousResizeMode(false); | 1499 delegate_->useUnfortunateSynchronousResizeMode(false); |
| 1475 delegate_->disableAutoResizeMode(WebSize()); | 1500 delegate_->disableAutoResizeMode(WebSize()); |
| 1476 delegate_->deleteAllCookies(); | 1501 delegate_->deleteAllCookies(); |
| 1477 delegate_->resetScreenOrientation(); | 1502 delegate_->resetScreenOrientation(); |
| 1503 ResetBatteryStatus(); |
| 1478 } | 1504 } |
| 1479 | 1505 |
| 1480 dump_editting_callbacks_ = false; | 1506 dump_editting_callbacks_ = false; |
| 1481 dump_as_text_ = false; | 1507 dump_as_text_ = false; |
| 1482 dump_as_markup_ = false; | 1508 dump_as_markup_ = false; |
| 1483 generate_pixel_results_ = true; | 1509 generate_pixel_results_ = true; |
| 1484 dump_child_frame_scroll_positions_ = false; | 1510 dump_child_frame_scroll_positions_ = false; |
| 1485 dump_child_frames_as_markup_ = false; | 1511 dump_child_frames_as_markup_ = false; |
| 1486 dump_child_frames_as_text_ = false; | 1512 dump_child_frames_as_text_ = false; |
| 1487 dump_icon_changes_ = false; | 1513 dump_icon_changes_ = false; |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 orientation = WebScreenOrientationPortraitSecondary; | 2289 orientation = WebScreenOrientationPortraitSecondary; |
| 2264 } else if (orientation_str == "landscape-primary") { | 2290 } else if (orientation_str == "landscape-primary") { |
| 2265 orientation = WebScreenOrientationLandscapePrimary; | 2291 orientation = WebScreenOrientationLandscapePrimary; |
| 2266 } else if (orientation_str == "landscape-secondary") { | 2292 } else if (orientation_str == "landscape-secondary") { |
| 2267 orientation = WebScreenOrientationLandscapeSecondary; | 2293 orientation = WebScreenOrientationLandscapeSecondary; |
| 2268 } | 2294 } |
| 2269 | 2295 |
| 2270 delegate_->setScreenOrientation(orientation); | 2296 delegate_->setScreenOrientation(orientation); |
| 2271 } | 2297 } |
| 2272 | 2298 |
| 2299 void TestRunner::DidChangeBatteryStatus(bool charging, |
| 2300 double chargingTime, |
| 2301 double dischargingTime, |
| 2302 double level) { |
| 2303 blink::WebBatteryStatus status; |
| 2304 status.charging = charging; |
| 2305 status.chargingTime = chargingTime; |
| 2306 status.dischargingTime = dischargingTime; |
| 2307 status.level = level; |
| 2308 delegate_->didChangeBatteryStatus(status); |
| 2309 } |
| 2310 |
| 2311 void TestRunner::ResetBatteryStatus() { |
| 2312 blink::WebBatteryStatus status; |
| 2313 delegate_->didChangeBatteryStatus(status); |
| 2314 } |
| 2315 |
| 2273 void TestRunner::DidAcquirePointerLock() { | 2316 void TestRunner::DidAcquirePointerLock() { |
| 2274 DidAcquirePointerLockInternal(); | 2317 DidAcquirePointerLockInternal(); |
| 2275 } | 2318 } |
| 2276 | 2319 |
| 2277 void TestRunner::DidNotAcquirePointerLock() { | 2320 void TestRunner::DidNotAcquirePointerLock() { |
| 2278 DidNotAcquirePointerLockInternal(); | 2321 DidNotAcquirePointerLockInternal(); |
| 2279 } | 2322 } |
| 2280 | 2323 |
| 2281 void TestRunner::DidLosePointerLock() { | 2324 void TestRunner::DidLosePointerLock() { |
| 2282 DidLosePointerLockInternal(); | 2325 DidLosePointerLockInternal(); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 } | 2732 } |
| 2690 | 2733 |
| 2691 void TestRunner::DidLosePointerLockInternal() { | 2734 void TestRunner::DidLosePointerLockInternal() { |
| 2692 bool was_locked = pointer_locked_; | 2735 bool was_locked = pointer_locked_; |
| 2693 pointer_locked_ = false; | 2736 pointer_locked_ = false; |
| 2694 if (was_locked) | 2737 if (was_locked) |
| 2695 web_view_->didLosePointerLock(); | 2738 web_view_->didLosePointerLock(); |
| 2696 } | 2739 } |
| 2697 | 2740 |
| 2698 } // namespace content | 2741 } // namespace content |
| OLD | NEW |