| OLD | NEW |
| 1 description('Tests using null values for some of the event properties.'); | 1 description('Tests using null values for some of the event properties.'); |
| 2 | 2 |
| 3 var mockEvent; | 3 var mockEvent; |
| 4 function setMockOrientation(alpha, beta, gamma) { | 4 function setMockOrientation(alpha, beta, gamma, absolute) { |
| 5 mockEvent = {alpha: alpha, beta: beta, gamma: gamma}; | 5 mockEvent = {alpha: alpha, beta: beta, gamma: gamma, absolute: absolute}; |
| 6 if (window.testRunner) | 6 if (window.testRunner) |
| 7 testRunner.setMockDeviceOrientation( | 7 testRunner.setMockDeviceOrientation( |
| 8 null != mockEvent.alpha, null == mockEvent.alpha ? 0 : mockEvent.alp
ha, | 8 null != mockEvent.alpha, null == mockEvent.alpha ? 0 : mockEvent.alp
ha, |
| 9 null != mockEvent.beta, null == mockEvent.beta ? 0 : mockEvent.beta, | 9 null != mockEvent.beta, null == mockEvent.beta ? 0 : mockEvent.beta, |
| 10 null != mockEvent.gamma, null == mockEvent.gamma ? 0 : mockEvent.gam
ma); | 10 null != mockEvent.gamma, null == mockEvent.gamma ? 0 : mockEvent.gam
ma, |
| 11 null != mockEvent.absolute, null == mockEvent.absolute ? false : moc
kEvent.absolute); |
| 11 else | 12 else |
| 12 debug('This test can not be run without the TestRunner'); | 13 debug('This test can not be run without the TestRunner'); |
| 13 } | 14 } |
| 14 | 15 |
| 15 var deviceOrientationEvent; | 16 var deviceOrientationEvent; |
| 16 function checkOrientation(event) { | 17 function checkOrientation(event) { |
| 17 deviceOrientationEvent = event; | 18 deviceOrientationEvent = event; |
| 18 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); | 19 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); |
| 19 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); | 20 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); |
| 20 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); | 21 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); |
| 22 shouldBe('deviceOrientationEvent.absolute', 'mockEvent.absolute'); |
| 21 } | 23 } |
| 22 | 24 |
| 23 function firstListener(event) { | 25 function firstListener(event) { |
| 24 checkOrientation(event); | 26 checkOrientation(event); |
| 25 window.removeEventListener('deviceorientation', firstListener); | 27 window.removeEventListener('deviceorientation', firstListener); |
| 28 setTimeout(function(){initSecondListener();}, 0); |
| 29 } |
| 26 | 30 |
| 27 setMockOrientation(1.1, null, null); | 31 function initSecondListener() { |
| 32 setMockOrientation(1.1, null, null, true); |
| 28 window.addEventListener('deviceorientation', secondListener); | 33 window.addEventListener('deviceorientation', secondListener); |
| 29 } | 34 } |
| 30 | 35 |
| 31 function secondListener(event) { | 36 function secondListener(event) { |
| 32 checkOrientation(event); | 37 checkOrientation(event); |
| 33 window.removeEventListener('deviceorientation', secondListener); | 38 window.removeEventListener('deviceorientation', secondListener); |
| 39 setTimeout(function(){initThirdListener();}, 0); |
| 40 } |
| 34 | 41 |
| 35 setMockOrientation(null, 2.2, null); | 42 function initThirdListener() { |
| 43 setMockOrientation(null, 2.2, null, true); |
| 36 window.addEventListener('deviceorientation', thirdListener); | 44 window.addEventListener('deviceorientation', thirdListener); |
| 37 } | 45 } |
| 38 | 46 |
| 39 function thirdListener(event) { | 47 function thirdListener(event) { |
| 40 checkOrientation(event); | 48 checkOrientation(event); |
| 41 window.removeEventListener('deviceorientation', thirdListener); | 49 window.removeEventListener('deviceorientation', thirdListener); |
| 50 setTimeout(function(){initFourthListener();}, 0); |
| 51 } |
| 42 | 52 |
| 43 setMockOrientation(null, null, 3.3); | 53 function initFourthListener() { |
| 54 setMockOrientation(null, null, 3.3, true); |
| 44 window.addEventListener('deviceorientation', fourthListener); | 55 window.addEventListener('deviceorientation', fourthListener); |
| 45 } | 56 } |
| 46 | 57 |
| 47 function fourthListener(event) { | 58 function fourthListener(event) { |
| 48 checkOrientation(event); | 59 checkOrientation(event); |
| 49 finishJSTest(); | 60 finishJSTest(); |
| 50 } | 61 } |
| 51 | 62 |
| 52 setMockOrientation(null, null, null); | 63 setMockOrientation(null, null, null, false); |
| 53 window.addEventListener('deviceorientation', firstListener); | 64 window.addEventListener('deviceorientation', firstListener); |
| 54 | 65 |
| 55 window.jsTestIsAsync = true; | 66 window.jsTestIsAsync = true; |
| OLD | NEW |