summaryrefslogtreecommitdiffstats
path: root/dom/system/gonk/tests/test_ril_worker_icc_BerTlvHelper.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/system/gonk/tests/test_ril_worker_icc_BerTlvHelper.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/system/gonk/tests/test_ril_worker_icc_BerTlvHelper.js')
-rw-r--r--dom/system/gonk/tests/test_ril_worker_icc_BerTlvHelper.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/dom/system/gonk/tests/test_ril_worker_icc_BerTlvHelper.js b/dom/system/gonk/tests/test_ril_worker_icc_BerTlvHelper.js
new file mode 100644
index 000000000..89fcd874d
--- /dev/null
+++ b/dom/system/gonk/tests/test_ril_worker_icc_BerTlvHelper.js
@@ -0,0 +1,87 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this);
+
+function run_test() {
+ 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 context = worker.ContextPool._contexts[0];
+ let pduHelper = context.GsmPDUHelper;
+ let berHelper = context.BerTlvHelper;
+
+ 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 = berTlv.value.values();
+ let tlv = berHelper.searchForNextTag(BER_FCP_FILE_DESCRIPTOR_TAG, iter);
+ equal(tlv.value.fileStructure, UICC_EF_STRUCTURE[EF_STRUCTURE_TRANSPARENT]);
+
+ tlv = berHelper.searchForNextTag(BER_FCP_FILE_IDENTIFIER_TAG, iter);
+ equal(tlv.value.fileId, 0x2FE2);
+
+ tlv = berHelper.searchForNextTag(BER_FCP_FILE_SIZE_DATA_TAG, iter);
+ equal(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 context = worker.ContextPool._contexts[0];
+ let pduHelper = context.GsmPDUHelper;
+ let berHelper = context.BerTlvHelper;
+
+ 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 = berTlv.value.values();
+ let tlv = berHelper.searchForNextTag(BER_FCP_FILE_DESCRIPTOR_TAG, iter);
+ equal(tlv.value.fileStructure, UICC_EF_STRUCTURE[EF_STRUCTURE_LINEAR_FIXED]);
+ equal(tlv.value.recordLength, 0x1A);
+ equal(tlv.value.numOfRecords, 0x01);
+
+ tlv = berHelper.searchForNextTag(BER_FCP_FILE_IDENTIFIER_TAG, iter);
+ equal(tlv.value.fileId, 0x6F40);
+
+ tlv = berHelper.searchForNextTag(BER_FCP_FILE_SIZE_DATA_TAG, iter);
+ equal(tlv.value.fileSizeData, 0x1A);
+
+ run_next_test();
+});