From 8cd7bf6abdfbeae34a31c6bf43fb751b2f88a54b Mon Sep 17 00:00:00 2001 From: Yoshi Huang Date: Tue, 30 Jul 2013 17:33:00 +0800 Subject: [PATCH] Bug 895960 - Part 2: Test cases for reading PBR. r=hsinyi --- dom/system/gonk/tests/test_ril_worker_icc.js | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/dom/system/gonk/tests/test_ril_worker_icc.js b/dom/system/gonk/tests/test_ril_worker_icc.js index 8cc631170c4e..681eba9b25d1 100644 --- a/dom/system/gonk/tests/test_ril_worker_icc.js +++ b/dom/system/gonk/tests/test_ril_worker_icc.js @@ -1790,6 +1790,64 @@ add_test(function test_load_linear_fixed_ef() { io.loadLinearFixedEF({}); }); +/** + * Verify ICCRecordHelper.readPBR + */ +add_test(function test_read_pbr() { + let worker = newUint8Worker(); + let helper = worker.GsmPDUHelper; + let record = worker.ICCRecordHelper; + let buf = worker.Buf; + let io = worker.ICCIOHelper; + + io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) { + let pbr_1 = [ + 0xa8, 0x05, 0xc0, 0x03, 0x4f, 0x3a, 0x01 + ]; + + // Write data size + buf.writeUint32(pbr_1.length * 2); + + // Write pbr + for (let i = 0; i < pbr_1.length; i++) { + helper.writeHexOctet(pbr_1[i]); + } + + // Write string delimiter + buf.writeStringDelimiter(pbr_1.length * 2); + + options.totalRecords = 2; + if (options.callback) { + options.callback(options); + } + }; + + io.loadNextRecord = function fakeLoadNextRecord(options) { + let pbr_2 = [ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + ]; + + options.p1++; + if (options.callback) { + options.callback(options); + } + }; + + let successCb = function successCb(pbrs) { + do_check_eq(pbrs[0].adn.fileId, 0x4f3a); + do_check_eq(pbrs.length, 1); + run_next_test(); + }; + + let errorCb = function errorCb(errorMsg) { + do_print("Reading EF_PBR failed, msg = " + errorMsg); + do_check_true(false); + run_next_test(); + }; + + record.readPBR(successCb, errorCb); +}); + /** * Verify ICCRecordHelper.readEmail */