dom/mobileconnection/tests/marionette/test_mobile_voice_state.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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 const INITIAL_STATES = {
     8   state: "registered",
     9   connected: true,
    10   emergencyCallsOnly: false,
    11   roaming: false,
    12   signalStrength: -99,
    13   relSignalStrength: 44,
    15   cell: {
    16     gsmLocationAreaCode: 65535,
    17     gsmCellId: 268435455,
    18     cdmaBaseStationId: -1,
    19     cdmaBaseStationLatitude: -2147483648,
    20     cdmaBaseStationLongitude: -2147483648,
    21     cdmaSystemId: -1,
    22     cdmaNetworkId: -1,
    23   }
    24 };
    26 const TEST_DATA = [{
    27     // Test state becomes to "unregistered"
    28     state: "unregistered",
    29     expected: {
    30       state: "notSearching",
    31       connected: false,
    32       emergencyCallsOnly: true,
    33       roaming: false,
    34       signalStrength: null,
    35       relSignalStrength: null,
    36       cell: null
    37     }
    38   }, {
    39     // Test state becomes to "searching"
    40     state: "searching",
    41     expected: {
    42       state: "searching",
    43       connected: false,
    44       emergencyCallsOnly: true,
    45       roaming: false,
    46       signalStrength: null,
    47       relSignalStrength: null,
    48       cell: null
    49     }
    50   }, {
    51     // Test state becomes to "denied"
    52     state: "denied",
    53     expected: {
    54       state: "denied",
    55       connected: false,
    56       emergencyCallsOnly: true,
    57       roaming: false,
    58       signalStrength: null,
    59       relSignalStrength: null,
    60       cell: null
    61     }
    62   }, {
    63     // Test state becomes to "roaming"
    64     state: "roaming",
    65     expected: {
    66       state: "registered",
    67       connected: true,
    68       emergencyCallsOnly: false,
    69       roaming: true,
    70       signalStrength: -99,
    71       relSignalStrength: 44,
    72       cell: {
    73         gsmLocationAreaCode: 65535,
    74         gsmCellId: 268435455
    75       }
    76     }
    77   }, {
    78     // Reset state to default value.
    79     state: "home",
    80     expected: {
    81       state: "registered",
    82       connected: true,
    83       emergencyCallsOnly: false,
    84       roaming: false,
    85       signalStrength: -99,
    86       relSignalStrength: 44,
    87       cell: {
    88         gsmLocationAreaCode: 65535,
    89         gsmCellId: 268435455
    90       }
    91     }
    92   }
    93 ];
    95 function compareTo(aPrefix, aFrom, aTo) {
    96   for (let field in aTo) {
    97     let fullName = aPrefix + field;
    99     let lhs = aFrom[field];
   100     let rhs = aTo[field];
   101     ok(true, "lhs=" + JSON.stringify(lhs) + ", rhs=" + JSON.stringify(rhs));
   102     if (typeof rhs !== "object") {
   103       is(lhs, rhs, fullName);
   104     } else if (rhs) {
   105       ok(lhs, fullName);
   106       compareTo(fullName + ".", lhs, rhs);
   107     } else {
   108       is(lhs, null, fullName);
   109     }
   110   }
   111 }
   113 function verifyVoiceInfo(aExpected) {
   114   compareTo("voice.", mobileConnection.voice, aExpected);
   115 }
   117 /* Test Voice State Changed */
   118 function testVoiceStateUpdate(aNewState, aExpected) {
   119   log("Test voice info with state='" + aNewState + "'");
   121   // Set emulator's lac/cid and wait for 'onvoicechange' event.
   122   return setEmulatorVoiceDataStateAndWait("voice", aNewState)
   123     .then(() => verifyVoiceInfo(aExpected));
   124 }
   126 startTestCommon(function() {
   127   log("Test initial voice connection info");
   129   verifyVoiceInfo(INITIAL_STATES);
   131   let promise = Promise.resolve();
   132   for (let i = 0; i < TEST_DATA.length; i++) {
   133     let entry = TEST_DATA[i];
   134     promise =
   135       promise.then(testVoiceStateUpdate.bind(null, entry.state, entry.expected));
   136   }
   138   return promise;
   139 });

mercurial