Bug 947110 - Part2: Add test cases. B2G RIL: Add support for decoding FCP Template in BerTlvHelper. v2. r=yoshi.

This commit is contained in:
Shawn Ku 2013-12-23 13:55:29 +08:00
parent ab82a2b460
commit 17598b0659

View File

@ -2723,3 +2723,98 @@ add_test(function test_read_new_sms_on_sim() {
run_next_test();
});
// Test ICC_COMMAND_GET_RESPONSE with FCP template format.
/**
* Verify transparent structure with FCP template format.
*/
add_test(function test_fcp_template_for_transparent_structure() {
let worker = newUint8Worker();
let pduHelper = worker.GsmPDUHelper;
let berHelper = worker.BerTlvHelper;
berHelper.searchForNextTag = function searchForNextTag(tag, iter) {
for (let [index, tlv] in iter) {
if (tlv.tag === tag) {
return tlv;
}
}
return null;
};
let tag_test = [
0x62,
0x22,
0x82, 0x02, 0x41, 0x21,
0x83, 0x02, 0x2F, 0xE2,
0xA5, 0x09, 0xC1, 0x04, 0x40, 0x0F, 0xF5, 0x55, 0x92, 0x01, 0x00,
0x8A, 0x01, 0x05,
0x8B, 0x03, 0x2F, 0x06, 0x0B,
0x80, 0x02, 0x00, 0x0A,
0x88, 0x01, 0x10];
for (let i = 0; i < tag_test.length; i++) {
pduHelper.writeHexOctet(tag_test[i]);
}
let berTlv = berHelper.decode(tag_test.length);
let iter = Iterator(berTlv.value);
let tlv = berHelper.searchForNextTag(BER_FCP_FILE_DESCRIPTOR_TAG, iter);
do_check_eq(tlv.value.fileStructure, UICC_EF_STRUCTURE[EF_TYPE_TRANSPARENT]);
tlv = berHelper.searchForNextTag(BER_FCP_FILE_IDENTIFIER_TAG, iter);
do_check_eq(tlv.value.fileId, 0x2FE2);
tlv = berHelper.searchForNextTag(BER_FCP_FILE_SIZE_DATA_TAG, iter);
do_check_eq(tlv.value.fileSizeData, 0x0A);
run_next_test();
});
/**
* Verify linear fixed structure with FCP template format.
*/
add_test(function test_fcp_template_for_linear_fixed_structure() {
let worker = newUint8Worker();
let pduHelper = worker.GsmPDUHelper;
let berHelper = worker.BerTlvHelper;
berHelper.searchForNextTag = function searchForNextTag(tag, iter) {
for (let [index, tlv] in iter) {
if (tlv.tag === tag) {
return tlv;
}
}
return null;
};
let tag_test = [
0x62,
0x1E,
0x82, 0x05, 0x42, 0x21, 0x00, 0x1A, 0x01,
0x83, 0x02, 0x6F, 0x40,
0xA5, 0x03, 0x92, 0x01, 0x00,
0x8A, 0x01, 0x07,
0x8B, 0x03, 0x6F, 0x06, 0x02,
0x80, 0x02, 0x00, 0x1A,
0x88, 0x00];
for (let i = 0; i < tag_test.length; i++) {
pduHelper.writeHexOctet(tag_test[i]);
}
let berTlv = berHelper.decode(tag_test.length);
let iter = Iterator(berTlv.value);
let tlv = berHelper.searchForNextTag(BER_FCP_FILE_DESCRIPTOR_TAG, iter);
do_check_eq(tlv.value.fileStructure, UICC_EF_STRUCTURE[EF_TYPE_LINEAR_FIXED]);
do_check_eq(tlv.value.recordLength, 0x1A);
do_check_eq(tlv.value.numOfRecords, 0x01);
tlv = berHelper.searchForNextTag(BER_FCP_FILE_IDENTIFIER_TAG, iter);
do_check_eq(tlv.value.fileId, 0x6F40);
tlv = berHelper.searchForNextTag(BER_FCP_FILE_SIZE_DATA_TAG, iter);
do_check_eq(tlv.value.fileSizeData, 0x1A);
run_next_test();
});