From b61f6689583f8a49821ef41f3efd7265b430f977 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Tue, 25 Sep 2012 18:24:10 +0800 Subject: [PATCH] Bug 791935 - Part 3: Test case r=philikon --- dom/system/gonk/tests/test_ril_worker_icc.js | 76 ++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/dom/system/gonk/tests/test_ril_worker_icc.js b/dom/system/gonk/tests/test_ril_worker_icc.js index 1dc135525c4..92142fb1038 100644 --- a/dom/system/gonk/tests/test_ril_worker_icc.js +++ b/dom/system/gonk/tests/test_ril_worker_icc.js @@ -233,6 +233,27 @@ add_test(function test_write_location_info_tlv() { run_next_test(); }); +/** + * Verify ComprehensionTlvHelper.writeErrorNumber + */ +add_test(function test_write_disconnecting_cause() { + let worker = newUint8Worker(); + let pduHelper = worker.GsmPDUHelper; + let tlvHelper = worker.ComprehensionTlvHelper; + + tlvHelper.writeCauseTlv(RIL_ERROR_TO_GECKO_ERROR[ERROR_GENERIC_FAILURE]); + let tag = pduHelper.readHexOctet(); + do_check_eq(tag, COMPREHENSIONTLV_TAG_CAUSE | COMPREHENSIONTLV_FLAG_CR); + let len = pduHelper.readHexOctet(); + do_check_eq(len, 2); // We have one cause. + let standard = pduHelper.readHexOctet(); + do_check_eq(standard, 0x60); + let cause = pduHelper.readHexOctet(); + do_check_eq(cause, 0x80 | ERROR_GENERIC_FAILURE); + + run_next_test(); +}); + /** * Verify Proactive Command : Refresh */ @@ -341,3 +362,58 @@ add_test(function test_stk_proactive_command_poll_interval() { run_next_test(); }); + +/** + * Verify ComprehensionTlvHelper.getSizeOfLengthOctets + */ +add_test(function test_get_size_of_length_octets() { + let worker = newUint8Worker(); + let tlvHelper = worker.ComprehensionTlvHelper; + + let length = 0x70; + do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 1); + + length = 0x80; + do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 2); + + length = 0x180; + do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 3); + + length = 0x18000; + do_check_eq(tlvHelper.getSizeOfLengthOctets(length), 4); + + run_next_test(); +}); + +/** + * Verify ComprehensionTlvHelper.writeLength + */ +add_test(function test_write_length() { + let worker = newUint8Worker(); + let pduHelper = worker.GsmPDUHelper; + let tlvHelper = worker.ComprehensionTlvHelper; + + let length = 0x70; + tlvHelper.writeLength(length); + do_check_eq(pduHelper.readHexOctet(), length); + + length = 0x80; + tlvHelper.writeLength(length); + do_check_eq(pduHelper.readHexOctet(), 0x81); + do_check_eq(pduHelper.readHexOctet(), length); + + length = 0x180; + tlvHelper.writeLength(length); + do_check_eq(pduHelper.readHexOctet(), 0x82); + do_check_eq(pduHelper.readHexOctet(), (length >> 8) & 0xff); + do_check_eq(pduHelper.readHexOctet(), length & 0xff); + + length = 0x18000; + tlvHelper.writeLength(length); + do_check_eq(pduHelper.readHexOctet(), 0x83); + do_check_eq(pduHelper.readHexOctet(), (length >> 16) & 0xff); + do_check_eq(pduHelper.readHexOctet(), (length >> 8) & 0xff); + do_check_eq(pduHelper.readHexOctet(), length & 0xff); + + run_next_test(); +}); \ No newline at end of file