Bug 895960 - Part 2: Test cases for reading PBR. r=hsinyi

This commit is contained in:
Yoshi Huang 2013-07-30 17:33:00 +08:00
Родитель 972966a6d8
Коммит 8cd7bf6abd
1 изменённых файлов: 58 добавлений и 0 удалений

Просмотреть файл

@ -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
*/