mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1159622 - Split test_icc_contact.js into read contact and add contact. r=echen
This commit is contained in:
parent
0c7f9c974f
commit
26582948ac
@ -3,7 +3,8 @@ b2g = true
|
||||
browser = false
|
||||
qemu = true
|
||||
|
||||
[test_icc_contact.js]
|
||||
[test_icc_contact_read.js]
|
||||
[test_icc_contact_add.js]
|
||||
[test_icc_card_lock_get_retry_count.js]
|
||||
[test_icc_card_lock_change_pin.js]
|
||||
[test_icc_card_lock_enable_pin.js]
|
||||
|
@ -1,85 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = "head.js";
|
||||
|
||||
function testReadContacts(aIcc, aType) {
|
||||
log("testReadContacts: type=" + aType);
|
||||
let iccId = aIcc.iccInfo.iccid;
|
||||
return aIcc.readContacts(aType)
|
||||
.then((aResult) => {
|
||||
is(Array.isArray(aResult), true);
|
||||
|
||||
is(aResult[0].name[0], "Mozilla");
|
||||
is(aResult[0].tel[0].value, "15555218201");
|
||||
is(aResult[0].id, iccId + "1");
|
||||
|
||||
is(aResult[1].name[0], "Saßê黃");
|
||||
is(aResult[1].tel[0].value, "15555218202");
|
||||
is(aResult[1].id, iccId + "2");
|
||||
|
||||
is(aResult[2].name[0], "Fire 火");
|
||||
is(aResult[2].tel[0].value, "15555218203");
|
||||
is(aResult[2].id, iccId + "3");
|
||||
|
||||
is(aResult[3].name[0], "Huang 黃");
|
||||
is(aResult[3].tel[0].value, "15555218204");
|
||||
is(aResult[3].id, iccId + "4");
|
||||
}, (aError) => {
|
||||
ok(false, "Cannot get " + aType + " contacts");
|
||||
});
|
||||
}
|
||||
|
||||
function testAddContact(aIcc, aType, aPin2) {
|
||||
log("testAddContact: type=" + aType + ", pin2=" + aPin2);
|
||||
let contact = new mozContact({
|
||||
name: ["add"],
|
||||
tel: [{value: "0912345678"}],
|
||||
email:[]
|
||||
});
|
||||
|
||||
return aIcc.updateContact(aType, contact, aPin2)
|
||||
.then((aResult) => {
|
||||
is(aResult.id, aIcc.iccInfo.iccid + "5");
|
||||
is(aResult.name[0], "add");
|
||||
is(aResult.tel[0].value, "0912345678");
|
||||
// Get ICC contact for checking new contact
|
||||
return aIcc.readContacts(aType)
|
||||
.then((aResult) => {
|
||||
// There are 4 SIM contacts which are harded in emulator
|
||||
is(aResult.length, 5);
|
||||
|
||||
is(aResult[4].name[0], "add");
|
||||
is(aResult[4].tel[0].value, "0912345678");
|
||||
is(aResult[4].id, aIcc.iccInfo.iccid + "5");
|
||||
}, (aError) => {
|
||||
ok(false, "Cannot get " + aType + " contacts: " + aError.name);
|
||||
})
|
||||
}, (aError) => {
|
||||
if (aType === "fdn" && aPin2 === undefined) {
|
||||
ok(aError.name === "SimPin2",
|
||||
"expected error when pin2 is not provided");
|
||||
} else {
|
||||
ok(false, "Cannot add " + aType + " contact: " + aError.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Start tests
|
||||
startTestCommon(function() {
|
||||
let icc = getMozIcc();
|
||||
|
||||
// Test read adn contacts
|
||||
return testReadContacts(icc, "adn")
|
||||
// Test add adn contacts
|
||||
.then(() => testAddContact(icc, "adn"))
|
||||
// Test read fdn contact
|
||||
.then(() => testReadContacts(icc, "fdn"))
|
||||
// Test add fdn contacts
|
||||
.then(() => testAddContact(icc, "fdn", "0000"))
|
||||
// Test add fdn contacts without passing pin2
|
||||
.then(() => testAddContact(icc, "fdn"))
|
||||
// Test read sdn contacts
|
||||
.then(() => testReadContacts(icc, "sdn"));
|
||||
});
|
70
dom/icc/tests/marionette/test_icc_contact_add.js
Normal file
70
dom/icc/tests/marionette/test_icc_contact_add.js
Normal file
@ -0,0 +1,70 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 90000;
|
||||
MARIONETTE_HEAD_JS = "head.js";
|
||||
|
||||
let TEST_ADD_DATA = [{
|
||||
name: ["add"],
|
||||
tel: [{value: "0912345678"}],
|
||||
email:[]
|
||||
}];
|
||||
|
||||
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) => {
|
||||
is(aResult.name[0], aMozContact.name[0]);
|
||||
is(aResult.tel[0].value, aMozContact.tel[0].value);
|
||||
|
||||
// Get ICC contact for checking new contact
|
||||
return aIcc.readContacts(aType)
|
||||
.then((aResult) => {
|
||||
let contact = aResult[aResult.length - 1];
|
||||
|
||||
is(contact.name[0], aMozContact.name[0]);
|
||||
is(contact.tel[0].value, aMozContact.tel[0].value);
|
||||
is(contact.id, aIcc.iccInfo.iccid + aResult.length);
|
||||
|
||||
return contact.id;
|
||||
})
|
||||
.then((aContactId) => {
|
||||
// Clean up contact
|
||||
return removeContact(aIcc, aContactId, aType, aPin2);
|
||||
});
|
||||
}, (aError) => {
|
||||
if (aType === "fdn" && aPin2 === undefined) {
|
||||
ok(aError.name === "SimPin2",
|
||||
"expected error when pin2 is not provided");
|
||||
} else {
|
||||
ok(false, "Cannot add " + aType + " contact: " + aError.name);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function removeContact(aIcc, aContactId, aType, aPin2) {
|
||||
log("removeContact: contactId=" + aContactId +
|
||||
", type=" + aType + ", pin2=" + aPin2);
|
||||
|
||||
let contact = new mozContact({});
|
||||
contact.id = aIcc.iccInfo.iccid + aContactId;
|
||||
|
||||
return aIcc.updateContact(aType, contact, aPin2);
|
||||
}
|
||||
|
||||
// Start tests
|
||||
startTestCommon(function() {
|
||||
let icc = getMozIcc();
|
||||
|
||||
for (let i = 0; i < TEST_ADD_DATA.length; i++) {
|
||||
let test_data = TEST_ADD_DATA[i];
|
||||
// Test add adn contacts
|
||||
return testAddContact(icc, "adn", test_data)
|
||||
// Test add fdn contacts
|
||||
.then(() => testAddContact(icc, "fdn", test_data, "0000"))
|
||||
// Test add fdn contacts without passing pin2
|
||||
.then(() => testAddContact(icc, "fdn", test_data));
|
||||
}
|
||||
});
|
50
dom/icc/tests/marionette/test_icc_contact_read.js
Normal file
50
dom/icc/tests/marionette/test_icc_contact_read.js
Normal file
@ -0,0 +1,50 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = "head.js";
|
||||
|
||||
function testReadContacts(aIcc, aType) {
|
||||
log("testReadContacts: type=" + aType);
|
||||
let iccId = aIcc.iccInfo.iccid;
|
||||
return aIcc.readContacts(aType)
|
||||
.then((aResult) => {
|
||||
is(Array.isArray(aResult), true);
|
||||
is(aResult.length, 4, "Check contact number.");
|
||||
|
||||
// Alpha Id(Encoded with GSM 8 bit): "Mozilla", Dialling Number: 15555218201
|
||||
is(aResult[0].name[0], "Mozilla");
|
||||
is(aResult[0].tel[0].value, "15555218201");
|
||||
is(aResult[0].id, iccId + "1");
|
||||
|
||||
// Alpha Id(Encoded with UCS2 0x80: "Saßê\u9ec3", Dialling Number: 15555218202
|
||||
is(aResult[1].name[0], "Saßê黃");
|
||||
is(aResult[1].tel[0].value, "15555218202");
|
||||
is(aResult[1].id, iccId + "2");
|
||||
|
||||
// Alpha Id(Encoded with UCS2 0x81): "Fire \u706b", Dialling Number: 15555218203
|
||||
is(aResult[2].name[0], "Fire 火");
|
||||
is(aResult[2].tel[0].value, "15555218203");
|
||||
is(aResult[2].id, iccId + "3");
|
||||
|
||||
// Alpha Id(Encoded with UCS2 0x82): "Huang \u9ec3", Dialling Number: 15555218204
|
||||
is(aResult[3].name[0], "Huang 黃");
|
||||
is(aResult[3].tel[0].value, "15555218204");
|
||||
is(aResult[3].id, iccId + "4");
|
||||
}, (aError) => {
|
||||
ok(false, "Cannot get " + aType + " contacts");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Start tests
|
||||
startTestCommon(function() {
|
||||
let icc = getMozIcc();
|
||||
|
||||
// Test read adn contacts
|
||||
return testReadContacts(icc, "adn")
|
||||
// Test read fdn contact
|
||||
.then(() => testReadContacts(icc, "fdn"))
|
||||
// Test read sdn contacts
|
||||
.then(() => testReadContacts(icc, "sdn"));
|
||||
});
|
Loading…
Reference in New Issue
Block a user