OLD | NEW |
(Empty) | |
| 1 description('Tests using null values for some or all of the event properties.'); |
| 2 |
| 3 var mockEvent; |
| 4 function setMockLight(lightValue) { |
| 5 |
| 6 mockEvent = {value: lightValue}; |
| 7 |
| 8 if (window.testRunner) |
| 9 testRunner.setMockDeviceLight(null != mockEvent.value, null == mockEvent
.value ? 0 : mockEvent.value); |
| 10 else |
| 11 debug('This test can not be run without the TestRunner'); |
| 12 } |
| 13 |
| 14 |
| 15 var deviceLightEvent; |
| 16 function checkLight(event) { |
| 17 deviceLightEvent = event; |
| 18 shouldBe('deviceLightEvent.value', 'mockEvent.value'); |
| 19 } |
| 20 |
| 21 function firstListener(event) { |
| 22 checkLight(event); |
| 23 window.removeEventListener('devicelight', firstListener); |
| 24 setTimeout(function(){initSecondListener();}, 0); |
| 25 } |
| 26 |
| 27 function initSecondListener() { |
| 28 setMockLight(20); |
| 29 window.addEventListener('devicelight', secondListener); |
| 30 } |
| 31 |
| 32 function secondListener(event) { |
| 33 checkLight(event); |
| 34 window.removeEventListener('devicelight', secondListener); |
| 35 setTimeout(function(){initThirdListener();}, 0); |
| 36 } |
| 37 |
| 38 function initThirdListener() { |
| 39 setMockLight(30); |
| 40 window.addEventListener('devicelight', thirdListener); |
| 41 } |
| 42 |
| 43 function thirdListener(event) { |
| 44 checkLight(event); |
| 45 window.removeEventListener('devicelight', thirdListener); |
| 46 setTimeout(function(){initFourthListener();}, 0); |
| 47 } |
| 48 |
| 49 function initFourthListener() { |
| 50 setMockLight(40); |
| 51 window.addEventListener('devicelight', fourthListener); |
| 52 } |
| 53 |
| 54 function fourthListener(event) { |
| 55 checkLight(event); |
| 56 finishJSTest(); |
| 57 } |
| 58 |
| 59 setMockLight(50); |
| 60 window.addEventListener('devicelight', firstListener); |
| 61 |
| 62 window.jsTestIsAsync = true; |
OLD | NEW |