dom/mobileconnection/tests/marionette/test_mobile_operator_names_roaming.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 MARIONETTE_TIMEOUT = 60000;
     5 MARIONETTE_HEAD_JS = "head.js";
     7 function check(aLongName, aShortName, aRoaming) {
     8   let voice = mobileConnection.voice;
     9   let network = voice.network;
    11   is(network.longName, aLongName, "network.longName");
    12   is(network.shortName, aShortName, "network.shortName");
    13   is(voice.roaming, aRoaming, "voice.roaming");
    14 }
    16 function setEmulatorOperatorNamesAndWait(aWhich, aLongName, aShortName) {
    17   let promises = [];
    18   promises.push(waitForManagerEvent("voicechange"));
    19   promises.push(setEmulatorOperatorNames(aWhich, aLongName, aShortName));
    20   return Promise.all(promises);
    21 }
    23 // See bug 797972 - B2G RIL: False roaming situation
    24 //
    25 // Steps to test:
    26 // 1. set roaming operator names
    27 // 2. set emulator roaming
    28 // 3. wait for onvoicechange event and test passing conditions
    29 // 4. set emulator roaming back to false
    30 // 5. wait for onvoicechange event again and callback
    31 function test(aLongName, aShortName, aRoaming) {
    32   log("Testing roaming check '" + aLongName + "', '" + aShortName + "':");
    34   return Promise.resolve()
    36     // We should not have voicechange here, but, yes, we do.
    37     .then(() => setEmulatorOperatorNamesAndWait("roaming", aLongName, aShortName))
    39     .then(() => setEmulatorVoiceDataStateAndWait("voice", "roaming"))
    40     .then(() => check(aLongName, aShortName, aRoaming))
    41     .then(() => setEmulatorVoiceDataStateAndWait("voice", "home"));
    42 }
    44 startTestCommon(function() {
    45   return getEmulatorOperatorNames()
    46     .then(function(aOperators) {
    47       let {longName: longName, shortName: shortName} = aOperators[0];
    49       return Promise.resolve()
    51         // If Either long name or short name of current registered operator
    52         // matches SPN("Android"), then the `roaming` attribute should be set
    53         // to false.
    54         .then(() => test(longName,               shortName,               false))
    55         .then(() => test(longName,               shortName.toLowerCase(), false))
    56         .then(() => test(longName,               "Bar",                   false))
    57         .then(() => test(longName.toLowerCase(), shortName,               false))
    58         .then(() => test(longName.toLowerCase(), shortName.toLowerCase(), false))
    59         .then(() => test(longName.toLowerCase(), "Bar",                   false))
    60         .then(() => test("Foo",                  shortName,               false))
    61         .then(() => test("Foo",                  shortName.toLowerCase(), false))
    62         .then(() => test("Foo",                  "Bar",                   true))
    64         // Reset roaming operator.
    65         .then(() => setEmulatorOperatorNamesAndWait("roaming",
    66                                                     aOperators[1].longName,
    67                                                     aOperators[1].shortName));
    68     });
    69 });

mercurial