Bug 1218721 - Part 2 - Improve Test Coverage. r=echen
--- a/dom/icc/tests/marionette/test_icc_contact_add.js
+++ b/dom/icc/tests/marionette/test_icc_contact_add.js
@@ -25,16 +25,24 @@ var TEST_ADD_DATA = [{
// a contact with anr but without email.
name: ["add5"],
tel: [{value: "01234567890123456789"}, {value: "123456"}, {value: "123"}],
}, {
// a contact with email and anr.
name: ["add6"],
tel: [{value: "01234567890123456789"}, {value: "123456"}, {value: "123"}],
email:[{value: "test@mozilla.com"}],
+ }, {
+ // a contact without number.
+ name: ["add7"],
+ tel: [{value: ""}],
+ }, {
+ // a contact without name.
+ name: [""],
+ tel: [{value: "0987654321"}],
}];
function testAddContact(aIcc, aType, aMozContact, aPin2) {
log("testAddContact: type=" + aType + ", pin2=" + aPin2);
let contact = new mozContact(aMozContact);
return aIcc.updateContact(aType, contact, aPin2)
.then((aResult) => {
--- a/dom/icc/tests/marionette/test_icc_contact_update.js
+++ b/dom/icc/tests/marionette/test_icc_contact_update.js
@@ -20,17 +20,17 @@ const TEST_UPDATE_DATA = [{
// We don't support extension chain now.
number: "9876543210987654321099887766554433221100"}
}, {
id: 3,
data: {
name: ["Fire 火"],
tel: [{value: ""}]},
expect: {
- number: null}
+ number: ""}
}, {
id: 5,
data: {
name: ["Contact001"],
tel: [{value: "9988776655443322110098765432109876543210"}]},
expect: {
number: "9988776655443322110098765432109876543210"}
}, {
@@ -47,22 +47,18 @@ function testUpdateContact(aIcc, aType,
", mozContact=" + JSON.stringify(aMozContact) +
", expect=" + aExpect.number + ", pin2=" + aPin2);
let contact = new mozContact(aMozContact);
contact.id = aIcc.iccInfo.iccid + aContactId;
return aIcc.updateContact(aType, contact, aPin2)
.then((aResult) => {
- if (aExpect.number === null) {
- is(aResult.tel, null);
- } else {
- is(aResult.tel[0].value, aExpect.number);
- ok(aResult.tel.length == 1);
- }
+ is(aResult.tel[0].value, aExpect.number);
+ ok(aResult.tel.length == 1);
// We only support SIM in emulator, so we don't have anr and email field.
ok(!aResult.email);
is(contact.id, aIcc.iccInfo.iccid + aContactId);
}, (aError) => {
if (aType === "fdn" && aPin2 === undefined) {
ok(aError.name === "SimPin2",
"expected error when pin2 is not provided");
} else {
@@ -96,21 +92,17 @@ function testUpdateContacts(aIcc, aType,
promise = promise.then(() => aIcc.readContacts(aType))
.then((aResult) => {
for (let i = 0; i < TEST_UPDATE_DATA.length; i++) {
let expectedResult = TEST_UPDATE_DATA[i];
let contact = aResult[expectedResult.id - 1];
is(contact.name[0], expectedResult.data.name[0]);
is(contact.id, aIcc.iccInfo.iccid + expectedResult.id);
- if (expectedResult.expect.number === null) {
- is(contact.tel, null);
- } else {
- is(contact.tel[0].value, expectedResult.expect.number);
- }
+ is(contact.tel[0].value, expectedResult.expect.number);
}
return revertContacts(aIcc, aCacheContacts, aType, aPin2);
});
return promise;
}
// Start tests
--- a/dom/system/gonk/tests/test_ril_worker_icc_ICCPDUHelper.js
+++ b/dom/system/gonk/tests/test_ril_worker_icc_ICCPDUHelper.js
@@ -362,17 +362,17 @@ add_test(function test_write_alpha_ident
let context = worker.ContextPool._contexts[0];
let helper = context.GsmPDUHelper;
let iccHelper = context.ICCPDUHelper;
// Length of trailing 0xff.
let ffLen = 2;
// Removal
let writenAlphaId = iccHelper.writeAlphaIdentifier(10, null);
- equal(writenAlphaId, null);
+ equal(writenAlphaId, "");
equal(iccHelper.readAlphaIdentifier(10), "");
// GSM 8 bit
let str = "Mozilla";
writenAlphaId = iccHelper.writeAlphaIdentifier(str.length + ffLen, str);
equal(writenAlphaId , str);
equal(iccHelper.readAlphaIdentifier(str.length + ffLen), str);
@@ -396,17 +396,17 @@ add_test(function test_write_alpha_ident
writenAlphaId = iccHelper.writeAlphaIdentifier(4, str);
helper.writeHexOctet(0xff); // dummy octet.
equal(writenAlphaId , str.substring(0, 1));
equal(iccHelper.readAlphaIdentifier(5), str.substring(0, 1));
// Write 0 octet.
writenAlphaId = iccHelper.writeAlphaIdentifier(0, "1");
helper.writeHexOctet(0xff); // dummy octet.
- equal(writenAlphaId, null);
+ equal(writenAlphaId, "");
equal(iccHelper.readAlphaIdentifier(1), "");
run_next_test();
});
/**
* Verify ICCPDUHelper.readAlphaIdDiallingNumber
*/
@@ -485,18 +485,18 @@ add_test(function test_write_alpha_id_di
equal(writtenContact.alphaId, contactR.alphaId);
equal(writtenContact.number, contactR.number);
equal(0xff, contactR.extRecordNumber);
// Write a null contact (Removal).
writtenContact = helper.writeAlphaIdDiallingNumber(recordSize);
contactR = helper.readAlphaIdDiallingNumber(recordSize);
equal(contactR, null);
- equal(writtenContact.alphaId, null);
- equal(writtenContact.number, null);
+ equal(writtenContact.alphaId, "");
+ equal(writtenContact.number, "");
// Write a longer alphaId/dialling number
// Dialling Number : Maximum 20 digits(10 octets).
// Alpha Identifier: 32(recordSize) - 14 (10 octets for Dialling Number, 1
// octet for TON/NPI, 1 for number length octet, and 2 for
// Ext) = Maximum 18 octets.
let longContact = {
alphaId: "AAAAAAAAABBBBBBBBBCCCCCCCCC",