Thu, 22 Jan 2015 13:21:57 +0100
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 | // Emulator's hard coded IMSI: 310260000000000 |
michael@0 | 8 | let testCases = [ |
michael@0 | 9 | // mvno type, mvno data, request success, expected result |
michael@0 | 10 | ["imsi", "3102600", true, true ], |
michael@0 | 11 | // x and X means skip the comparison. |
michael@0 | 12 | ["imsi", "31026xx0", true, true ], |
michael@0 | 13 | ["imsi", "310260x0x", true, true ], |
michael@0 | 14 | ["imsi", "310260X00", true, true ], |
michael@0 | 15 | ["imsi", "310260XX1", true, false ], |
michael@0 | 16 | ["imsi", "31026012", true, false ], |
michael@0 | 17 | ["imsi", "310260000000000", true, true ], |
michael@0 | 18 | ["imsi", "310260000000000123", true, false ], |
michael@0 | 19 | ["imsi", "", false, "InvalidParameter"], |
michael@0 | 20 | // Currently we only support imsi match. |
michael@0 | 21 | ["spn", "Android", false, "ModeNotSupported"] |
michael@0 | 22 | ]; |
michael@0 | 23 | |
michael@0 | 24 | function matchMvno(mvnoType, mvnoData, success, expectedResult) { |
michael@0 | 25 | log("matchMvno: " + mvnoType + ", " + mvnoData); |
michael@0 | 26 | let request = icc.matchMvno(mvnoType, mvnoData); |
michael@0 | 27 | request.onsuccess = function onsuccess() { |
michael@0 | 28 | log("onsuccess: " + request.result); |
michael@0 | 29 | ok(success, "onsuccess while error expected"); |
michael@0 | 30 | is(request.result, expectedResult); |
michael@0 | 31 | testMatchMvno(); |
michael@0 | 32 | } |
michael@0 | 33 | request.onerror = function onerror() { |
michael@0 | 34 | log("onerror: " + request.error.name); |
michael@0 | 35 | ok(!success, "onerror while success expected"); |
michael@0 | 36 | is(request.error.name, expectedResult); |
michael@0 | 37 | testMatchMvno(); |
michael@0 | 38 | } |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function testMatchMvno() { |
michael@0 | 42 | let testCase = testCases.shift(); |
michael@0 | 43 | if (!testCase) { |
michael@0 | 44 | taskHelper.runNext(); |
michael@0 | 45 | return; |
michael@0 | 46 | } |
michael@0 | 47 | matchMvno(testCase[0], testCase[1], testCase[2], testCase[3]); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | taskHelper.push( |
michael@0 | 51 | testMatchMvno |
michael@0 | 52 | ); |
michael@0 | 53 | |
michael@0 | 54 | // Start test |
michael@0 | 55 | taskHelper.runNext(); |
michael@0 | 56 |