dom/icc/tests/marionette/test_icc_detected_undetected_event.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 = 30000;
michael@0 5 MARIONETTE_HEAD_JS = "icc_header.js";
michael@0 6
michael@0 7 let origNumICCs = iccManager.iccIds.length;
michael@0 8
michael@0 9 function setRadioEnabled(enabled) {
michael@0 10 let connection = navigator.mozMobileConnections[0];
michael@0 11 ok(connection);
michael@0 12
michael@0 13 let request = connection.setRadioEnabled(enabled);
michael@0 14
michael@0 15 request.onsuccess = function onsuccess() {
michael@0 16 log('setRadioEnabled: ' + enabled);
michael@0 17 };
michael@0 18
michael@0 19 request.onerror = function onerror() {
michael@0 20 ok(false, "setRadioEnabled should be ok");
michael@0 21 };
michael@0 22 }
michael@0 23
michael@0 24 /* Test iccundetected event */
michael@0 25 taskHelper.push(function testIccUndetectedEvent() {
michael@0 26 setRadioEnabled(false);
michael@0 27 iccManager.addEventListener("iccundetected", function oniccundetected(evt) {
michael@0 28 log("got icc undetected event");
michael@0 29 iccManager.removeEventListener("iccundetected", oniccundetected);
michael@0 30
michael@0 31 is(evt.iccId, iccId, "icc " + evt.iccId + " becomes undetected");
michael@0 32 is(iccManager.iccIds.length, origNumICCs - 1,
michael@0 33 "iccIds.length becomes to " + iccManager.iccIds.length);
michael@0 34 is(iccManager.getIccById(evt.iccId), null,
michael@0 35 "should not get a valid icc object here");
michael@0 36
michael@0 37 taskHelper.runNext();
michael@0 38 });
michael@0 39 });
michael@0 40
michael@0 41 /* Test iccdetected event */
michael@0 42 taskHelper.push(function testIccDetectedEvent() {
michael@0 43 setRadioEnabled(true);
michael@0 44 iccManager.addEventListener("iccdetected", function oniccdetected(evt) {
michael@0 45 log("got icc detected event");
michael@0 46 iccManager.removeEventListener("iccdetected", oniccdetected);
michael@0 47
michael@0 48 is(evt.iccId, iccId, "icc " + evt.iccId + " is detected");
michael@0 49 is(iccManager.iccIds.length, origNumICCs,
michael@0 50 "iccIds.length becomes to " + iccManager.iccIds.length);
michael@0 51 ok(iccManager.getIccById(evt.iccId) instanceof MozIcc,
michael@0 52 "should get a valid icc object here");
michael@0 53
michael@0 54 taskHelper.runNext();
michael@0 55 });
michael@0 56 });
michael@0 57
michael@0 58 // Start test
michael@0 59 taskHelper.runNext();

mercurial