Chromium Code Reviews| 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(gin::Arguments* args); | |
| 178 | |
| 176 void DidAcquirePointerLock(); | 179 void DidAcquirePointerLock(); |
| 177 void DidNotAcquirePointerLock(); | 180 void DidNotAcquirePointerLock(); |
| 178 void DidLosePointerLock(); | 181 void DidLosePointerLock(); |
| 179 void SetPointerLockWillFailSynchronously(); | 182 void SetPointerLockWillFailSynchronously(); |
| 180 void SetPointerLockWillRespondAsynchronously(); | 183 void SetPointerLockWillRespondAsynchronously(); |
| 181 void SetPopupBlockingEnabled(bool block_popups); | 184 void SetPopupBlockingEnabled(bool block_popups); |
| 182 void SetJavaScriptCanAccessClipboard(bool can_access); | 185 void SetJavaScriptCanAccessClipboard(bool can_access); |
| 183 void SetXSSAuditorEnabled(bool enabled); | 186 void SetXSSAuditorEnabled(bool enabled); |
| 184 void SetAllowUniversalAccessFromFileURLs(bool allow); | 187 void SetAllowUniversalAccessFromFileURLs(bool allow); |
| 185 void SetAllowFileAccessFromFileURLs(bool allow); | 188 void SetAllowFileAccessFromFileURLs(bool allow); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 .SetMethod("enableAutoResizeMode", | 359 .SetMethod("enableAutoResizeMode", |
| 357 &TestRunnerBindings::EnableAutoResizeMode) | 360 &TestRunnerBindings::EnableAutoResizeMode) |
| 358 .SetMethod("disableAutoResizeMode", | 361 .SetMethod("disableAutoResizeMode", |
| 359 &TestRunnerBindings::DisableAutoResizeMode) | 362 &TestRunnerBindings::DisableAutoResizeMode) |
| 360 .SetMethod("setMockDeviceMotion", | 363 .SetMethod("setMockDeviceMotion", |
| 361 &TestRunnerBindings::SetMockDeviceMotion) | 364 &TestRunnerBindings::SetMockDeviceMotion) |
| 362 .SetMethod("setMockDeviceOrientation", | 365 .SetMethod("setMockDeviceOrientation", |
| 363 &TestRunnerBindings::SetMockDeviceOrientation) | 366 &TestRunnerBindings::SetMockDeviceOrientation) |
| 364 .SetMethod("setMockScreenOrientation", | 367 .SetMethod("setMockScreenOrientation", |
| 365 &TestRunnerBindings::SetMockScreenOrientation) | 368 &TestRunnerBindings::SetMockScreenOrientation) |
| 369 .SetMethod("didChangeBatteryStatus", | |
| 370 &TestRunnerBindings::DidChangeBatteryStatus) | |
| 366 .SetMethod("didAcquirePointerLock", | 371 .SetMethod("didAcquirePointerLock", |
| 367 &TestRunnerBindings::DidAcquirePointerLock) | 372 &TestRunnerBindings::DidAcquirePointerLock) |
| 368 .SetMethod("didNotAcquirePointerLock", | 373 .SetMethod("didNotAcquirePointerLock", |
| 369 &TestRunnerBindings::DidNotAcquirePointerLock) | 374 &TestRunnerBindings::DidNotAcquirePointerLock) |
| 370 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) | 375 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) |
| 371 .SetMethod("setPointerLockWillFailSynchronously", | 376 .SetMethod("setPointerLockWillFailSynchronously", |
| 372 &TestRunnerBindings::SetPointerLockWillFailSynchronously) | 377 &TestRunnerBindings::SetPointerLockWillFailSynchronously) |
| 373 .SetMethod("setPointerLockWillRespondAsynchronously", | 378 .SetMethod("setPointerLockWillRespondAsynchronously", |
| 374 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) | 379 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) |
| 375 .SetMethod("setPopupBlockingEnabled", | 380 .SetMethod("setPopupBlockingEnabled", |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 has_absolute, absolute); | 862 has_absolute, absolute); |
| 858 } | 863 } |
| 859 | 864 |
| 860 void TestRunnerBindings::SetMockScreenOrientation(const std::string& orientation ) { | 865 void TestRunnerBindings::SetMockScreenOrientation(const std::string& orientation ) { |
| 861 if (!runner_) | 866 if (!runner_) |
| 862 return; | 867 return; |
| 863 | 868 |
| 864 runner_->SetMockScreenOrientation(orientation); | 869 runner_->SetMockScreenOrientation(orientation); |
| 865 } | 870 } |
| 866 | 871 |
| 872 void TestRunnerBindings::DidChangeBatteryStatus(gin::Arguments* args) { | |
|
jochen (gone - plz use gerrit)
2014/05/28 12:08:17
you don't need to use gin::Arguments, just use boo
timvolodine
2014/05/29 08:52:06
that's great! done.
| |
| 873 if (!runner_) | |
| 874 return; | |
| 875 | |
| 876 bool charging; | |
| 877 double chargingTime; | |
| 878 double dischargingTime; | |
| 879 double level; | |
| 880 | |
| 881 args->GetNext(&charging); | |
| 882 args->GetNext(&chargingTime); | |
| 883 args->GetNext(&dischargingTime); | |
| 884 args->GetNext(&level); | |
| 885 | |
| 886 runner_->DidChangeBatteryStatus(charging, chargingTime, | |
| 887 dischargingTime, level); | |
| 888 } | |
| 889 | |
| 867 void TestRunnerBindings::DidAcquirePointerLock() { | 890 void TestRunnerBindings::DidAcquirePointerLock() { |
| 868 if (runner_) | 891 if (runner_) |
| 869 runner_->DidAcquirePointerLock(); | 892 runner_->DidAcquirePointerLock(); |
| 870 } | 893 } |
| 871 | 894 |
| 872 void TestRunnerBindings::DidNotAcquirePointerLock() { | 895 void TestRunnerBindings::DidNotAcquirePointerLock() { |
| 873 if (runner_) | 896 if (runner_) |
| 874 runner_->DidNotAcquirePointerLock(); | 897 runner_->DidNotAcquirePointerLock(); |
| 875 } | 898 } |
| 876 | 899 |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2220 orientation = WebScreenOrientationPortraitSecondary; | 2243 orientation = WebScreenOrientationPortraitSecondary; |
| 2221 } else if (orientation_str == "landscape-primary") { | 2244 } else if (orientation_str == "landscape-primary") { |
| 2222 orientation = WebScreenOrientationLandscapePrimary; | 2245 orientation = WebScreenOrientationLandscapePrimary; |
| 2223 } else if (orientation_str == "landscape-secondary") { | 2246 } else if (orientation_str == "landscape-secondary") { |
| 2224 orientation = WebScreenOrientationLandscapeSecondary; | 2247 orientation = WebScreenOrientationLandscapeSecondary; |
| 2225 } | 2248 } |
| 2226 | 2249 |
| 2227 delegate_->setScreenOrientation(orientation); | 2250 delegate_->setScreenOrientation(orientation); |
| 2228 } | 2251 } |
| 2229 | 2252 |
| 2253 void TestRunner::DidChangeBatteryStatus(bool charging, | |
| 2254 double chargingTime, | |
| 2255 double dischargingTime, | |
| 2256 double level) { | |
| 2257 blink::WebBatteryStatus status; | |
| 2258 status.charging = charging; | |
| 2259 status.chargingTime = chargingTime; | |
| 2260 status.dischargingTime = dischargingTime; | |
| 2261 status.level = level; | |
| 2262 delegate_->didChangeBatteryStatus(status); | |
| 2263 } | |
| 2264 | |
| 2230 void TestRunner::DidAcquirePointerLock() { | 2265 void TestRunner::DidAcquirePointerLock() { |
| 2231 DidAcquirePointerLockInternal(); | 2266 DidAcquirePointerLockInternal(); |
| 2232 } | 2267 } |
| 2233 | 2268 |
| 2234 void TestRunner::DidNotAcquirePointerLock() { | 2269 void TestRunner::DidNotAcquirePointerLock() { |
| 2235 DidNotAcquirePointerLockInternal(); | 2270 DidNotAcquirePointerLockInternal(); |
| 2236 } | 2271 } |
| 2237 | 2272 |
| 2238 void TestRunner::DidLosePointerLock() { | 2273 void TestRunner::DidLosePointerLock() { |
| 2239 DidLosePointerLockInternal(); | 2274 DidLosePointerLockInternal(); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2633 } | 2668 } |
| 2634 | 2669 |
| 2635 void TestRunner::DidLosePointerLockInternal() { | 2670 void TestRunner::DidLosePointerLockInternal() { |
| 2636 bool was_locked = pointer_locked_; | 2671 bool was_locked = pointer_locked_; |
| 2637 pointer_locked_ = false; | 2672 pointer_locked_ = false; |
| 2638 if (was_locked) | 2673 if (was_locked) |
| 2639 web_view_->didLosePointerLock(); | 2674 web_view_->didLosePointerLock(); |
| 2640 } | 2675 } |
| 2641 | 2676 |
| 2642 } // namespace content | 2677 } // namespace content |
| OLD | NEW |