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

Unified Diff: content/test/data/device_orientation/device_motion_test.html

Issue 10827415: Chromium-side implementation of DeviceMotion. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test should set the kEnableDeviceMotion flag Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/test/data/device_orientation/device_motion_test.html
diff --git a/content/test/data/device_orientation/device_motion_test.html b/content/test/data/device_orientation/device_motion_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..ebebe887402a153dec57b149092a164bf551783b
--- /dev/null
+++ b/content/test/data/device_orientation/device_motion_test.html
@@ -0,0 +1,44 @@
+<html>
+ <head>
+ <title>DeviceMotion test</title>
+ <script type="text/javascript">
+ var eventCount = 0;
+
+ function checkMotionEvent(event) {
+ // Return true iff the motion is close enough to
+ // (1, 2, 3, 4, 5, 6, 7, 8, 9, 10).
+ return Math.abs(event.acceleration.x - 1) < 0.01 &&
+ Math.abs(event.acceleration.y - 2) < 0.01 &&
+ Math.abs(event.acceleration.z - 3) < 0.01 &&
+ Math.abs(event.accelerationIncludingGravity.x - 4) < 0.01 &&
+ Math.abs(event.accelerationIncludingGravity.y - 5) < 0.01 &&
+ Math.abs(event.accelerationIncludingGravity.z - 6) < 0.01 &&
+ Math.abs(event.rotationRate.alpha - 7) < 0.01 &&
+ Math.abs(event.rotationRate.beta - 8) < 0.01 &&
+ Math.abs(event.rotationRate.gamma - 9) < 0.01 &&
+ Math.abs(event.interval - 10) < 0.01;
+ }
+
+ function onMotion(event) {
+ if (checkMotionEvent(event)) {
+ window.removeEventListener('devicemotion', onMotion);
+ pass();
+ } else {
+ fail();
+ }
+ }
+
+ function pass() {
+ document.getElementById('status').innerHTML = 'PASS';
+ document.location = '#pass';
+ }
+
+ function fail() {
+ document.location = '#fail';
+ }
+ </script>
+ </head>
+ <body onLoad="window.addEventListener('devicemotion', onMotion)">
+ <div id="status">FAIL</div>
+ </body>
+</html>
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.cc ('k') | webkit/support/test_webkit_platform_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698