| OLD | NEW |
| 1 description('Tests that updates to the orientation causes new events to fire.'); | 1 description('Tests that updates to the orientation causes new events to fire.'); |
| 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(true, mockEvent.alpha, true, mockEve
nt.beta, true, mockEvent.gamma); | 7 testRunner.setMockDeviceOrientation(true, mockEvent.alpha, true, mockEve
nt.beta, true, mockEvent.gamma, true, mockEvent.absolute); |
| 8 else | 8 else |
| 9 debug('This test can not be run without the TestRunner'); | 9 debug('This test can not be run without the TestRunner'); |
| 10 } | 10 } |
| 11 | 11 |
| 12 var deviceOrientationEvent; | 12 var deviceOrientationEvent; |
| 13 function checkOrientation(event) { | 13 function checkOrientation(event) { |
| 14 deviceOrientationEvent = event; | 14 deviceOrientationEvent = event; |
| 15 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); | 15 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); |
| 16 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); | 16 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); |
| 17 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); | 17 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); |
| 18 shouldBe('deviceOrientationEvent.absolute', 'mockEvent.absolute'); |
| 18 } | 19 } |
| 19 | 20 |
| 20 function firstListener(event) { | 21 function firstListener(event) { |
| 21 checkOrientation(event); | 22 checkOrientation(event); |
| 22 window.removeEventListener('deviceorientation', firstListener); | 23 window.removeEventListener('deviceorientation', firstListener); |
| 24 setTimeout(function(){initUpdateListener();}, 0); |
| 25 } |
| 23 | 26 |
| 24 setMockOrientation(11.1, 22.2, 33.3); | 27 function initUpdateListener() { |
| 28 setMockOrientation(11.1, 22.2, 33.3, true); |
| 25 window.addEventListener('deviceorientation', updateListener); | 29 window.addEventListener('deviceorientation', updateListener); |
| 26 } | 30 } |
| 27 | 31 |
| 28 function updateListener(event) { | 32 function updateListener(event) { |
| 29 checkOrientation(event); | 33 checkOrientation(event); |
| 30 finishJSTest(); | 34 finishJSTest(); |
| 31 } | 35 } |
| 32 | 36 |
| 33 setMockOrientation(1.1, 2.2, 3.3); | 37 setMockOrientation(1.1, 2.2, 3.3, true); |
| 34 window.addEventListener('deviceorientation', firstListener); | 38 window.addEventListener('deviceorientation', firstListener); |
| 35 | 39 |
| 36 window.jsTestIsAsync = true; | 40 window.jsTestIsAsync = true; |
| OLD | NEW |