1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/icc/tests/marionette/test_icc_match_mvno.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 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 = 30000; 1.8 +MARIONETTE_HEAD_JS = "icc_header.js"; 1.9 + 1.10 +// Emulator's hard coded IMSI: 310260000000000 1.11 +let testCases = [ 1.12 + // mvno type, mvno data, request success, expected result 1.13 + ["imsi", "3102600", true, true ], 1.14 + // x and X means skip the comparison. 1.15 + ["imsi", "31026xx0", true, true ], 1.16 + ["imsi", "310260x0x", true, true ], 1.17 + ["imsi", "310260X00", true, true ], 1.18 + ["imsi", "310260XX1", true, false ], 1.19 + ["imsi", "31026012", true, false ], 1.20 + ["imsi", "310260000000000", true, true ], 1.21 + ["imsi", "310260000000000123", true, false ], 1.22 + ["imsi", "", false, "InvalidParameter"], 1.23 + // Currently we only support imsi match. 1.24 + ["spn", "Android", false, "ModeNotSupported"] 1.25 +]; 1.26 + 1.27 +function matchMvno(mvnoType, mvnoData, success, expectedResult) { 1.28 + log("matchMvno: " + mvnoType + ", " + mvnoData); 1.29 + let request = icc.matchMvno(mvnoType, mvnoData); 1.30 + request.onsuccess = function onsuccess() { 1.31 + log("onsuccess: " + request.result); 1.32 + ok(success, "onsuccess while error expected"); 1.33 + is(request.result, expectedResult); 1.34 + testMatchMvno(); 1.35 + } 1.36 + request.onerror = function onerror() { 1.37 + log("onerror: " + request.error.name); 1.38 + ok(!success, "onerror while success expected"); 1.39 + is(request.error.name, expectedResult); 1.40 + testMatchMvno(); 1.41 + } 1.42 +} 1.43 + 1.44 +function testMatchMvno() { 1.45 + let testCase = testCases.shift(); 1.46 + if (!testCase) { 1.47 + taskHelper.runNext(); 1.48 + return; 1.49 + } 1.50 + matchMvno(testCase[0], testCase[1], testCase[2], testCase[3]); 1.51 +} 1.52 + 1.53 +taskHelper.push( 1.54 + testMatchMvno 1.55 +); 1.56 + 1.57 +// Start test 1.58 +taskHelper.runNext(); 1.59 +