dom/mobileconnection/tests/marionette/test_mobile_operator_names_roaming.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/mobileconnection/tests/marionette/test_mobile_operator_names_roaming.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     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 = 60000;
     1.8 +MARIONETTE_HEAD_JS = "head.js";
     1.9 +
    1.10 +function check(aLongName, aShortName, aRoaming) {
    1.11 +  let voice = mobileConnection.voice;
    1.12 +  let network = voice.network;
    1.13 +
    1.14 +  is(network.longName, aLongName, "network.longName");
    1.15 +  is(network.shortName, aShortName, "network.shortName");
    1.16 +  is(voice.roaming, aRoaming, "voice.roaming");
    1.17 +}
    1.18 +
    1.19 +function setEmulatorOperatorNamesAndWait(aWhich, aLongName, aShortName) {
    1.20 +  let promises = [];
    1.21 +  promises.push(waitForManagerEvent("voicechange"));
    1.22 +  promises.push(setEmulatorOperatorNames(aWhich, aLongName, aShortName));
    1.23 +  return Promise.all(promises);
    1.24 +}
    1.25 +
    1.26 +// See bug 797972 - B2G RIL: False roaming situation
    1.27 +//
    1.28 +// Steps to test:
    1.29 +// 1. set roaming operator names
    1.30 +// 2. set emulator roaming
    1.31 +// 3. wait for onvoicechange event and test passing conditions
    1.32 +// 4. set emulator roaming back to false
    1.33 +// 5. wait for onvoicechange event again and callback
    1.34 +function test(aLongName, aShortName, aRoaming) {
    1.35 +  log("Testing roaming check '" + aLongName + "', '" + aShortName + "':");
    1.36 +
    1.37 +  return Promise.resolve()
    1.38 +
    1.39 +    // We should not have voicechange here, but, yes, we do.
    1.40 +    .then(() => setEmulatorOperatorNamesAndWait("roaming", aLongName, aShortName))
    1.41 +
    1.42 +    .then(() => setEmulatorVoiceDataStateAndWait("voice", "roaming"))
    1.43 +    .then(() => check(aLongName, aShortName, aRoaming))
    1.44 +    .then(() => setEmulatorVoiceDataStateAndWait("voice", "home"));
    1.45 +}
    1.46 +
    1.47 +startTestCommon(function() {
    1.48 +  return getEmulatorOperatorNames()
    1.49 +    .then(function(aOperators) {
    1.50 +      let {longName: longName, shortName: shortName} = aOperators[0];
    1.51 +
    1.52 +      return Promise.resolve()
    1.53 +
    1.54 +        // If Either long name or short name of current registered operator
    1.55 +        // matches SPN("Android"), then the `roaming` attribute should be set
    1.56 +        // to false.
    1.57 +        .then(() => test(longName,               shortName,               false))
    1.58 +        .then(() => test(longName,               shortName.toLowerCase(), false))
    1.59 +        .then(() => test(longName,               "Bar",                   false))
    1.60 +        .then(() => test(longName.toLowerCase(), shortName,               false))
    1.61 +        .then(() => test(longName.toLowerCase(), shortName.toLowerCase(), false))
    1.62 +        .then(() => test(longName.toLowerCase(), "Bar",                   false))
    1.63 +        .then(() => test("Foo",                  shortName,               false))
    1.64 +        .then(() => test("Foo",                  shortName.toLowerCase(), false))
    1.65 +        .then(() => test("Foo",                  "Bar",                   true))
    1.66 +
    1.67 +        // Reset roaming operator.
    1.68 +        .then(() => setEmulatorOperatorNamesAndWait("roaming",
    1.69 +                                                    aOperators[1].longName,
    1.70 +                                                    aOperators[1].shortName));
    1.71 +    });
    1.72 +});

mercurial