Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: content/shell/renderer/test_runner/test_runner.cc

Issue 298263002: Battery Status API: add testing support for LayoutTests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 .SetMethod("enableAutoResizeMode", 363 .SetMethod("enableAutoResizeMode",
358 &TestRunnerBindings::EnableAutoResizeMode) 364 &TestRunnerBindings::EnableAutoResizeMode)
359 .SetMethod("disableAutoResizeMode", 365 .SetMethod("disableAutoResizeMode",
360 &TestRunnerBindings::DisableAutoResizeMode) 366 &TestRunnerBindings::DisableAutoResizeMode)
361 .SetMethod("setMockDeviceMotion", 367 .SetMethod("setMockDeviceMotion",
362 &TestRunnerBindings::SetMockDeviceMotion) 368 &TestRunnerBindings::SetMockDeviceMotion)
363 .SetMethod("setMockDeviceOrientation", 369 .SetMethod("setMockDeviceOrientation",
364 &TestRunnerBindings::SetMockDeviceOrientation) 370 &TestRunnerBindings::SetMockDeviceOrientation)
365 .SetMethod("setMockScreenOrientation", 371 .SetMethod("setMockScreenOrientation",
366 &TestRunnerBindings::SetMockScreenOrientation) 372 &TestRunnerBindings::SetMockScreenOrientation)
373 .SetMethod("didChangeBatteryStatus",
374 &TestRunnerBindings::DidChangeBatteryStatus)
375 .SetMethod("resetBatteryStatus",
376 &TestRunnerBindings::ResetBatteryStatus)
367 .SetMethod("didAcquirePointerLock", 377 .SetMethod("didAcquirePointerLock",
368 &TestRunnerBindings::DidAcquirePointerLock) 378 &TestRunnerBindings::DidAcquirePointerLock)
369 .SetMethod("didNotAcquirePointerLock", 379 .SetMethod("didNotAcquirePointerLock",
370 &TestRunnerBindings::DidNotAcquirePointerLock) 380 &TestRunnerBindings::DidNotAcquirePointerLock)
371 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) 381 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock)
372 .SetMethod("setPointerLockWillFailSynchronously", 382 .SetMethod("setPointerLockWillFailSynchronously",
373 &TestRunnerBindings::SetPointerLockWillFailSynchronously) 383 &TestRunnerBindings::SetPointerLockWillFailSynchronously)
374 .SetMethod("setPointerLockWillRespondAsynchronously", 384 .SetMethod("setPointerLockWillRespondAsynchronously",
375 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) 385 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously)
376 .SetMethod("setPopupBlockingEnabled", 386 .SetMethod("setPopupBlockingEnabled",
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 has_absolute, absolute); 869 has_absolute, absolute);
860 } 870 }
861 871
862 void TestRunnerBindings::SetMockScreenOrientation(const std::string& orientation ) { 872 void TestRunnerBindings::SetMockScreenOrientation(const std::string& orientation ) {
863 if (!runner_) 873 if (!runner_)
864 return; 874 return;
865 875
866 runner_->SetMockScreenOrientation(orientation); 876 runner_->SetMockScreenOrientation(orientation);
867 } 877 }
868 878
879 void TestRunnerBindings::DidChangeBatteryStatus(bool charging,
880 double chargingTime,
881 double dischargingTime,
882 double level) {
883 if (runner_) {
884 runner_->DidChangeBatteryStatus(charging, chargingTime,
885 dischargingTime, level);
886 }
887 }
888
889 void TestRunnerBindings::ResetBatteryStatus() {
890 if (runner_)
891 runner_->ResetBatteryStatus();
892 }
893
869 void TestRunnerBindings::DidAcquirePointerLock() { 894 void TestRunnerBindings::DidAcquirePointerLock() {
870 if (runner_) 895 if (runner_)
871 runner_->DidAcquirePointerLock(); 896 runner_->DidAcquirePointerLock();
872 } 897 }
873 898
874 void TestRunnerBindings::DidNotAcquirePointerLock() { 899 void TestRunnerBindings::DidNotAcquirePointerLock() {
875 if (runner_) 900 if (runner_)
876 runner_->DidNotAcquirePointerLock(); 901 runner_->DidNotAcquirePointerLock();
877 } 902 }
878 903
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 orientation = WebScreenOrientationPortraitSecondary; 2255 orientation = WebScreenOrientationPortraitSecondary;
2231 } else if (orientation_str == "landscape-primary") { 2256 } else if (orientation_str == "landscape-primary") {
2232 orientation = WebScreenOrientationLandscapePrimary; 2257 orientation = WebScreenOrientationLandscapePrimary;
2233 } else if (orientation_str == "landscape-secondary") { 2258 } else if (orientation_str == "landscape-secondary") {
2234 orientation = WebScreenOrientationLandscapeSecondary; 2259 orientation = WebScreenOrientationLandscapeSecondary;
2235 } 2260 }
2236 2261
2237 delegate_->setScreenOrientation(orientation); 2262 delegate_->setScreenOrientation(orientation);
2238 } 2263 }
2239 2264
2265 void TestRunner::DidChangeBatteryStatus(bool charging,
2266 double chargingTime,
2267 double dischargingTime,
2268 double level) {
2269 blink::WebBatteryStatus status;
2270 status.charging = charging;
2271 status.chargingTime = chargingTime;
2272 status.dischargingTime = dischargingTime;
2273 status.level = level;
2274 delegate_->didChangeBatteryStatus(status);
2275 }
2276
2277 void TestRunner::ResetBatteryStatus() {
jochen (gone - plz use gerrit) 2014/06/03 11:20:59 can you call this method from TestRunner::Reset()
timvolodine 2014/06/03 15:30:07 Done.
2278 blink::WebBatteryStatus status;
2279 delegate_->didChangeBatteryStatus(status);
2280 }
2281
2240 void TestRunner::DidAcquirePointerLock() { 2282 void TestRunner::DidAcquirePointerLock() {
2241 DidAcquirePointerLockInternal(); 2283 DidAcquirePointerLockInternal();
2242 } 2284 }
2243 2285
2244 void TestRunner::DidNotAcquirePointerLock() { 2286 void TestRunner::DidNotAcquirePointerLock() {
2245 DidNotAcquirePointerLockInternal(); 2287 DidNotAcquirePointerLockInternal();
2246 } 2288 }
2247 2289
2248 void TestRunner::DidLosePointerLock() { 2290 void TestRunner::DidLosePointerLock() {
2249 DidLosePointerLockInternal(); 2291 DidLosePointerLockInternal();
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 } 2689 }
2648 2690
2649 void TestRunner::DidLosePointerLockInternal() { 2691 void TestRunner::DidLosePointerLockInternal() {
2650 bool was_locked = pointer_locked_; 2692 bool was_locked = pointer_locked_;
2651 pointer_locked_ = false; 2693 pointer_locked_ = false;
2652 if (was_locked) 2694 if (was_locked)
2653 web_view_->didLosePointerLock(); 2695 web_view_->didLosePointerLock();
2654 } 2696 }
2655 2697
2656 } // namespace content 2698 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698