Bug 793187 - MMI Codes: Support PIN/PIN2/PUK handling via MMI codes. Part 2 - Tests; r=marshall_law
authorFernando Jiménez <ferjmoreno@gmail.com>
Fri, 19 Oct 2012 11:35:16 +0200
changeset 110893 4807f1c1308ea664f334868bdd36dcf95da71630
parent 110892 c8eb7dfe86781bf76649691cc553d8255bad5502
child 110894 81e812a83e9becc5e8c3cc66d92a2e33fd312e2b
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersmarshall_law
bugs793187
milestone19.0a1
Bug 793187 - MMI Codes: Support PIN/PIN2/PUK handling via MMI codes. Part 2 - Tests; r=marshall_law
dom/system/gonk/tests/test_ril_worker_mmi.js
--- a/dom/system/gonk/tests/test_ril_worker_mmi.js
+++ b/dom/system/gonk/tests/test_ril_worker_mmi.js
@@ -311,19 +311,204 @@ add_test(function test_sendMMI_dial_stri
 
 add_test(function test_sendMMI_call_forwarding() {
   // TODO: Bug 793192 - MMI Codes: support call forwarding
   testSendMMI("*21#", "CALL_FORWARDING_NOT_SUPPORTED_VIA_MMI");
 
   run_next_test();
 });
 
-add_test(function test_sendMMI_sim_function() {
-  // TODO: Bug 793187 - MMI Codes: Support PIN/PIN2/PUK handling via MMI codes
-  testSendMMI("*04#", "SIM_FUNCTION_NOT_SUPPORTED_VIA_MMI");
+add_test(function test_sendMMI_change_PIN() {
+  let postedMessage;
+  let worker = newWorker({
+    postRILMessage: function fakePostRILMessage(data) {
+    },
+    postMessage: function fakePostMessage(message) {
+      postedMessage = message;
+    },
+  });
+
+  worker.RIL.changeICCPIN = function fakeChangeICCPIN(options){
+    worker.RIL[REQUEST_ENTER_SIM_PIN](0, {
+      rilRequestError: ERROR_SUCCESS
+    });
+  }
+
+  worker.RIL.sendMMI({mmi: "**04*1234*4567*4567#"});
+
+  do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS);
+  do_check_true(postedMessage.success);
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN_no_new_PIN() {
+  testSendMMI("**04*1234**4567#", "MISSING_SUPPLEMENTARY_INFORMATION");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN_no_old_PIN() {
+  testSendMMI("**04**1234*4567#", "MISSING_SUPPLEMENTARY_INFORMATION");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN_wrong_procedure() {
+  testSendMMI("*04*1234*4567*4567#", "WRONG_MMI_PROCEDURE");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN_new_PIN_mismatch() {
+  testSendMMI("**04*4567*1234*4567#", "NEW_PIN_MISMATCH");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN2() {
+  let postedMessage;
+  let worker = newWorker({
+    postRILMessage: function fakePostRILMessage(data) {
+    },
+    postMessage: function fakePostMessage(message) {
+      postedMessage = message;
+    },
+  });
+
+  worker.RIL.changeICCPIN2 = function fakeChangeICCPIN2(options){
+    worker.RIL[REQUEST_ENTER_SIM_PIN2](0, {
+      rilRequestError: ERROR_SUCCESS
+    });
+  }
+
+  worker.RIL.sendMMI({mmi: "**042*1234*4567*4567#"});
+
+  do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS);
+  do_check_true(postedMessage.success);
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN2_no_new_PIN2() {
+  testSendMMI("**042*1234**4567#", "MISSING_SUPPLEMENTARY_INFORMATION");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN2_no_old_PIN2() {
+  testSendMMI("**042**1234*4567#", "MISSING_SUPPLEMENTARY_INFORMATION");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN2_wrong_procedure() {
+  testSendMMI("*042*1234*4567*4567#", "WRONG_MMI_PROCEDURE");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_change_PIN2_new_PIN2_mismatch() {
+  testSendMMI("**042*4567*1234*4567#", "NEW_PIN_MISMATCH");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN() {
+  let postedMessage;
+  let worker = newWorker({
+    postRILMessage: function fakePostRILMessage(data) {
+    },
+    postMessage: function fakePostMessage(message) {
+      postedMessage = message;
+    },
+  });
+
+  worker.RIL.enterICCPUK = function fakeEnterICCPUK(options){
+    worker.RIL[REQUEST_ENTER_SIM_PUK](0, {
+      rilRequestError: ERROR_SUCCESS
+    });
+  }
+
+  worker.RIL.sendMMI({mmi: "**05*1234*4567*4567#"});
+
+  do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS);
+  do_check_true(postedMessage.success);
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN_no_new_PIN() {
+  testSendMMI("**05*1234**4567#", "MISSING_SUPPLEMENTARY_INFORMATION");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN_no_PUK() {
+  testSendMMI("**05**1234*4567#", "MISSING_SUPPLEMENTARY_INFORMATION");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN_wrong_procedure() {
+  testSendMMI("*05*1234*4567*4567#", "WRONG_MMI_PROCEDURE");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN_new_PIN_mismatch() {
+  testSendMMI("**05*4567*1234*4567#", "NEW_PIN_MISMATCH");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN2() {
+  let postedMessage;
+  let worker = newWorker({
+    postRILMessage: function fakePostRILMessage(data) {
+    },
+    postMessage: function fakePostMessage(message) {
+      postedMessage = message;
+    },
+  });
+
+  worker.RIL.enterICCPUK2 = function fakeEnterICCPUK2(options){
+    worker.RIL[REQUEST_ENTER_SIM_PUK2](0, {
+      rilRequestError: ERROR_SUCCESS
+    });
+  }
+
+  worker.RIL.sendMMI({mmi: "**052*1234*4567*4567#"});
+
+  do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS);
+  do_check_true(postedMessage.success);
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN2_no_new_PIN2() {
+  testSendMMI("**052*1234**4567#", "MISSING_SUPPLEMENTARY_INFORMATION");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN2_no_PUK2() {
+  testSendMMI("**052**1234*4567#", "MISSING_SUPPLEMENTARY_INFORMATION");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN2_wrong_procedure() {
+  testSendMMI("*052*1234*4567*4567#", "WRONG_MMI_PROCEDURE");
+
+  run_next_test();
+});
+
+add_test(function test_sendMMI_unblock_PIN2_new_PIN_mismatch() {
+  testSendMMI("**052*4567*1234*4567#", "NEW_PIN_MISMATCH");
 
   run_next_test();
 });
 
 add_test(function test_sendMMI_get_IMEI() {
   let postedMessage;
   let mmiOptions;
   let worker = newWorker({