|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 MARIONETTE_TIMEOUT = 10000; |
|
5 |
|
6 let Services = SpecialPowers.Services; |
|
7 |
|
8 function testScreenState(on, expected, msg) { |
|
9 // send event to RadioInterface |
|
10 Services.obs.notifyObservers(null, 'screen-state-changed', on); |
|
11 // maybe rild/qemu needs some time to process the event |
|
12 window.setTimeout(function() { |
|
13 runEmulatorCmd('gsm report creg', function(result) { |
|
14 is(result.pop(), 'OK', '\'gsm report creg\' successful'); |
|
15 ok(result.indexOf(expected) !== -1, msg); |
|
16 runNextTest(); |
|
17 })}, 1000); |
|
18 } |
|
19 |
|
20 function testScreenStateDisabled() { |
|
21 testScreenState('off', '+CREG: 1', 'screen is disabled'); |
|
22 } |
|
23 |
|
24 function testScreenStateEnabled() { |
|
25 testScreenState('on', '+CREG: 2', 'screen is enabled'); |
|
26 } |
|
27 |
|
28 let tests = [ |
|
29 testScreenStateDisabled, |
|
30 testScreenStateEnabled |
|
31 ]; |
|
32 |
|
33 function runNextTest() { |
|
34 let test = tests.shift(); |
|
35 if (!test) { |
|
36 cleanUp(); |
|
37 return; |
|
38 } |
|
39 |
|
40 test(); |
|
41 } |
|
42 |
|
43 function cleanUp() { |
|
44 finish(); |
|
45 } |
|
46 |
|
47 runNextTest(); |