| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <body> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 <script> | |
| 6 description('Tests using null values for some or all of the event properties.'); | |
| 7 | |
| 8 var mockEvent; | |
| 9 function setMockMotion(accelerationX, accelerationY, accelerationZ, | |
| 10 accelerationIncludingGravityX, accelerationIncludingGravi
tyY, accelerationIncludingGravityZ, | |
| 11 rotationRateAlpha, rotationRateBeta, rotationRateGamma, | |
| 12 interval) { | |
| 13 | |
| 14 mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, acc
elerationZ: accelerationZ, | |
| 15 accelerationIncludingGravityX: accelerationIncludingGravityX, a
ccelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludi
ngGravityZ: accelerationIncludingGravityZ, | |
| 16 rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotatio
nRateBeta, rotationRateGamma: rotationRateGamma, | |
| 17 interval: interval}; | |
| 18 | |
| 19 if (window.testRunner) | |
| 20 testRunner.setMockDeviceMotion(null != mockEvent.accelerationX, null ==
mockEvent.accelerationX ? 0 : mockEvent.accelerationX, | |
| 21 null != mockEvent.accelerationY, null ==
mockEvent.accelerationY ? 0 : mockEvent.accelerationY, | |
| 22 null != mockEvent.accelerationZ, null ==
mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ, | |
| 23 null != mockEvent.accelerationIncludingGr
avityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelera
tionIncludingGravityX, | |
| 24 null != mockEvent.accelerationIncludingGr
avityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelera
tionIncludingGravityY, | |
| 25 null != mockEvent.accelerationIncludingGr
avityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelera
tionIncludingGravityZ, | |
| 26 null != mockEvent.rotationRateAlpha, null
== mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha, | |
| 27 null != mockEvent.rotationRateBeta, null
== mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta, | |
| 28 null != mockEvent.rotationRateGamma, null
== mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma, | |
| 29 interval); | |
| 30 else | |
| 31 debug('This test can not be run without the TestRunner'); | |
| 32 } | |
| 33 | |
| 34 | |
| 35 var deviceMotionEvent; | |
| 36 function checkMotion(event) { | |
| 37 deviceMotionEvent = event; | |
| 38 shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX'); | |
| 39 shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY'); | |
| 40 shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ'); | |
| 41 | |
| 42 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.acce
lerationIncludingGravityX'); | |
| 43 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.acce
lerationIncludingGravityY'); | |
| 44 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.acce
lerationIncludingGravityZ'); | |
| 45 | |
| 46 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlph
a'); | |
| 47 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta'
); | |
| 48 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamm
a'); | |
| 49 | |
| 50 shouldBe('deviceMotionEvent.interval', 'mockEvent.interval'); | |
| 51 } | |
| 52 | |
| 53 function firstListener(event) { | |
| 54 checkMotion(event); | |
| 55 window.removeEventListener('devicemotion', firstListener); | |
| 56 setTimeout(function(){initSecondListener();}, 0); | |
| 57 } | |
| 58 | |
| 59 function initSecondListener() { | |
| 60 setMockMotion(1, 2, 3, | |
| 61 null, null, null, | |
| 62 null, null, null, | |
| 63 100); | |
| 64 window.addEventListener('devicemotion', secondListener); | |
| 65 } | |
| 66 | |
| 67 function secondListener(event) { | |
| 68 checkMotion(event); | |
| 69 window.removeEventListener('devicemotion', secondListener); | |
| 70 setTimeout(function(){initThirdListener();}, 0); | |
| 71 } | |
| 72 | |
| 73 function initThirdListener() { | |
| 74 setMockMotion(null, null, null, | |
| 75 1, 2, 3, | |
| 76 null, null, null, | |
| 77 100); | |
| 78 window.addEventListener('devicemotion', thirdListener); | |
| 79 } | |
| 80 | |
| 81 function thirdListener(event) { | |
| 82 checkMotion(event); | |
| 83 window.removeEventListener('devicemotion', thirdListener); | |
| 84 setTimeout(function(){initFourthListener();}, 0); | |
| 85 } | |
| 86 | |
| 87 function initFourthListener() { | |
| 88 setMockMotion(null, null, null, | |
| 89 null, null, null, | |
| 90 1, 2, 3, | |
| 91 100); | |
| 92 window.addEventListener('devicemotion', fourthListener); | |
| 93 } | |
| 94 | |
| 95 function fourthListener(event) { | |
| 96 checkMotion(event); | |
| 97 finishJSTest(); | |
| 98 } | |
| 99 | |
| 100 setMockMotion(null, null, null, | |
| 101 null, null, null, | |
| 102 null, null, null, | |
| 103 0); | |
| 104 window.addEventListener('devicemotion', firstListener); | |
| 105 | |
| 106 window.jsTestIsAsync = true; | |
| 107 </script> | |
| 108 </body> | |
| 109 </html> | |
| OLD | NEW |