Bug 848662 - Add marionette tests for FDN contacts manipulation; r=yoshi
authorGabriele Svelto <gsvelto@mozilla.com>
Fri, 21 Jun 2013 11:11:23 +0200
changeset 147585 2cecdcdd4c7714a7d37f5a999b34748d282bcefb
parent 147584 adf667b425905160b9eed12ca7de62e03e5710fa
child 147586 5ee0caa5506d10737dbb3d0ce2f4214730d9f34e
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoshi
bugs848662
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 848662 - Add marionette tests for FDN contacts manipulation; r=yoshi
dom/icc/tests/marionette/test_icc_contact.js
--- a/dom/icc/tests/marionette/test_icc_contact.js
+++ b/dom/icc/tests/marionette/test_icc_contact.js
@@ -3,86 +3,104 @@
 
 MARIONETTE_TIMEOUT = 30000;
 
 SpecialPowers.addPermission("mobileconnection", true, document);
 
 let icc = navigator.mozIccManager;
 ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
 
-function testImportSimContacts() {
-  let request = icc.readContacts("adn");
+function testReadContacts(type) {
+  let request = icc.readContacts(type);
   request.onsuccess = function onsuccess() {
-    let simContacts = request.result;
+    let contacts = request.result;
 
-    is(Array.isArray(simContacts), true);
+    is(Array.isArray(contacts), true);
 
-    is(simContacts[0].name, "Mozilla");
-    is(simContacts[0].tel[0].value, "15555218201");
+    is(contacts[0].name, "Mozilla");
+    is(contacts[0].tel[0].value, "15555218201");
 
-    is(simContacts[1].name, "Saßê黃");
-    is(simContacts[1].tel[0].value, "15555218202");
+    is(contacts[1].name, "Saßê黃");
+    is(contacts[1].tel[0].value, "15555218202");
 
-    is(simContacts[2].name, "Fire 火");
-    is(simContacts[2].tel[0].value, "15555218203");
+    is(contacts[2].name, "Fire 火");
+    is(contacts[2].tel[0].value, "15555218203");
 
-    is(simContacts[3].name, "Huang 黃");
-    is(simContacts[3].tel[0].value, "15555218204");
+    is(contacts[3].name, "Huang 黃");
+    is(contacts[3].tel[0].value, "15555218204");
 
     runNextTest();
   };
 
   request.onerror = function onerror() {
-    ok(false, "Cannot get Sim Contacts");
+    ok(false, "Cannot get " + type + " contacts");
     runNextTest();
   };
 };
 
-function testAddIccContact() {
+function testAddContact(type, pin2) {
   let contact = new mozContact();
 
   contact.init({
     name: "add",
     tel: [{value: "0912345678"}]
   });
 
-  let updateRequest = icc.updateContact("adn", contact);
+  let updateRequest = icc.updateContact(type, contact, pin2);
 
   updateRequest.onsuccess = function onsuccess() {
     // Get ICC contact for checking new contact
 
-    let getRequest = icc.readContacts("adn");
+    let getRequest = icc.readContacts(type);
 
     getRequest.onsuccess = function onsuccess() {
-      let simContacts = getRequest.result;
+      let contacts = getRequest.result;
 
       // There are 4 SIM contacts which are harded in emulator
-      is(simContacts.length, 5);
+      is(contacts.length, 5);
 
-      is(simContacts[4].name, "add");
-      is(simContacts[4].tel[0].value, "0912345678");
+      is(contacts[4].name, "add");
+      is(contacts[4].tel[0].value, "0912345678");
 
       runNextTest();
     };
 
     getRequest.onerror = function onerror() {
-      ok(false, "Cannot get ICC contacts: " + getRequest.error.name);
+      ok(false, "Cannot get " + type + " contacts: " + getRequest.error.name);
       runNextTest();
     };
   };
 
   updateRequest.onerror = function onerror() {
-    ok(false, "Cannot add ICC contact: " + updateRequest.error.name);
+    ok(false, "Cannot add " + type + " contact: " + updateRequest.error.name);
     runNextTest();
   };
 };
 
+function testReadAdnContacts() {
+  testReadContacts("adn");
+}
+
+function testAddAdnContact() {
+  testAddContact("adn");
+}
+
+function testReadFdnContacts() {
+  testReadContacts("fdn");
+}
+
+function testAddFdnContact() {
+  testAddContact("fdn", "0000");
+}
+
 let tests = [
-  testImportSimContacts,
-  testAddIccContact,
+  testReadAdnContacts,
+  testAddAdnContact,
+  testReadFdnContacts,
+  testAddFdnContact
 ];
 
 function runNextTest() {
   let test = tests.pop();
   if (!test) {
     cleanUp();
     return;
   }