1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/system/gonk/tests/marionette/test_screen_state.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +MARIONETTE_TIMEOUT = 10000; 1.8 + 1.9 +let Services = SpecialPowers.Services; 1.10 + 1.11 +function testScreenState(on, expected, msg) { 1.12 + // send event to RadioInterface 1.13 + Services.obs.notifyObservers(null, 'screen-state-changed', on); 1.14 + // maybe rild/qemu needs some time to process the event 1.15 + window.setTimeout(function() { 1.16 + runEmulatorCmd('gsm report creg', function(result) { 1.17 + is(result.pop(), 'OK', '\'gsm report creg\' successful'); 1.18 + ok(result.indexOf(expected) !== -1, msg); 1.19 + runNextTest(); 1.20 + })}, 1000); 1.21 +} 1.22 + 1.23 +function testScreenStateDisabled() { 1.24 + testScreenState('off', '+CREG: 1', 'screen is disabled'); 1.25 +} 1.26 + 1.27 +function testScreenStateEnabled() { 1.28 + testScreenState('on', '+CREG: 2', 'screen is enabled'); 1.29 +} 1.30 + 1.31 +let tests = [ 1.32 + testScreenStateDisabled, 1.33 + testScreenStateEnabled 1.34 +]; 1.35 + 1.36 +function runNextTest() { 1.37 + let test = tests.shift(); 1.38 + if (!test) { 1.39 + cleanUp(); 1.40 + return; 1.41 + } 1.42 + 1.43 + test(); 1.44 +} 1.45 + 1.46 +function cleanUp() { 1.47 + finish(); 1.48 +} 1.49 + 1.50 +runNextTest();