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.

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

mercurial