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