mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 859659 - Part 3: xpcshell-tests. r=vicamo
This commit is contained in:
parent
0401e46b5c
commit
cb4f4a9b9c
@ -1821,10 +1821,101 @@ add_test(function test_read_email() {
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCRecordHelper.updateEmail
|
||||
*/
|
||||
add_test(function test_update_email() {
|
||||
const recordSize = 0x20;
|
||||
const recordNumber = 1;
|
||||
const fileId = 0x4f50;
|
||||
const NUM_TESTS = 2;
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
ril.appType = CARD_APPTYPE_USIM;
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let ioHelper = worker.ICCIOHelper;
|
||||
let pbr = {email: {fileId: fileId, fileType: ICC_USIM_TYPE1_TAG},
|
||||
adn: {sfi: 1}};
|
||||
let count = 0;
|
||||
|
||||
// Override.
|
||||
ioHelper.updateLinearFixedEF = function (options) {
|
||||
options.pathId = worker.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.command = ICC_COMMAND_UPDATE_RECORD;
|
||||
options.p1 = options.recordNumber;
|
||||
options.p2 = READ_RECORD_ABSOLUTE_MODE;
|
||||
options.p3 = recordSize;
|
||||
ril.iccIO(options);
|
||||
};
|
||||
|
||||
function do_test(pbr, expectedEmail, expectedAdnRecordId) {
|
||||
buf.sendParcel = function () {
|
||||
count++;
|
||||
|
||||
// Request Type.
|
||||
do_check_eq(this.readUint32(), REQUEST_SIM_IO);
|
||||
|
||||
// Token : we don't care
|
||||
this.readUint32();
|
||||
|
||||
// command.
|
||||
do_check_eq(this.readUint32(), ICC_COMMAND_UPDATE_RECORD);
|
||||
|
||||
// fileId.
|
||||
do_check_eq(this.readUint32(), fileId);
|
||||
|
||||
// pathId.
|
||||
do_check_eq(this.readString(),
|
||||
EF_PATH_MF_SIM + EF_PATH_DF_TELECOM + EF_PATH_DF_PHONEBOOK);
|
||||
|
||||
// p1.
|
||||
do_check_eq(this.readUint32(), recordNumber);
|
||||
|
||||
// p2.
|
||||
do_check_eq(this.readUint32(), READ_RECORD_ABSOLUTE_MODE);
|
||||
|
||||
// p3.
|
||||
do_check_eq(this.readUint32(), recordSize);
|
||||
|
||||
// data.
|
||||
let strLen = this.readUint32();
|
||||
let email;
|
||||
if (pbr.email.fileType === ICC_USIM_TYPE1_TAG) {
|
||||
email = pduHelper.read8BitUnpackedToString(recordSize);
|
||||
} else {
|
||||
email = pduHelper.read8BitUnpackedToString(recordSize - 2);
|
||||
do_check_eq(pduHelper.readHexOctet(), pbr.adn.sfi);
|
||||
do_check_eq(pduHelper.readHexOctet(), expectedAdnRecordId);
|
||||
}
|
||||
this.readStringDelimiter(strLen);
|
||||
do_check_eq(email, expectedEmail);
|
||||
|
||||
// pin2.
|
||||
do_check_eq(this.readString(), null);
|
||||
|
||||
if (!worker.RILQUIRKS_V5_LEGACY) {
|
||||
// AID. Ignore because it's from modem.
|
||||
this.readUint32();
|
||||
}
|
||||
|
||||
if (count == NUM_TESTS) {
|
||||
run_next_test();
|
||||
}
|
||||
};
|
||||
recordHelper.updateEmail(pbr, recordNumber, expectedEmail, expectedAdnRecordId);
|
||||
}
|
||||
|
||||
do_test(pbr, "test@mail.com");
|
||||
pbr.email.fileType = ICC_USIM_TYPE2_TAG;
|
||||
do_test(pbr, "test@mail.com", 1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCRecordHelper.readANR
|
||||
*/
|
||||
add_test(function test_read_email() {
|
||||
add_test(function test_read_anr() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let record = worker.ICCRecordHelper;
|
||||
@ -1871,6 +1962,230 @@ add_test(function test_read_email() {
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCRecordHelper.updateANR
|
||||
*/
|
||||
add_test(function test_update_anr() {
|
||||
const recordSize = 0x20;
|
||||
const recordNumber = 1;
|
||||
const fileId = 0x4f11;
|
||||
const NUM_TESTS = 2;
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
ril.appType = CARD_APPTYPE_USIM;
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let ioHelper = worker.ICCIOHelper;
|
||||
let pbr = {anr0: {fileId: fileId, fileType: ICC_USIM_TYPE1_TAG},
|
||||
adn: {sfi: 1}};
|
||||
let count = 0;
|
||||
|
||||
// Override.
|
||||
ioHelper.updateLinearFixedEF = function (options) {
|
||||
options.pathId = worker.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.command = ICC_COMMAND_UPDATE_RECORD;
|
||||
options.p1 = options.recordNumber;
|
||||
options.p2 = READ_RECORD_ABSOLUTE_MODE;
|
||||
options.p3 = recordSize;
|
||||
ril.iccIO(options);
|
||||
};
|
||||
|
||||
function do_test(pbr, expectedANR, expectedAdnRecordId) {
|
||||
buf.sendParcel = function () {
|
||||
count++;
|
||||
|
||||
// Request Type.
|
||||
do_check_eq(this.readUint32(), REQUEST_SIM_IO);
|
||||
|
||||
// Token : we don't care
|
||||
this.readUint32();
|
||||
|
||||
// command.
|
||||
do_check_eq(this.readUint32(), ICC_COMMAND_UPDATE_RECORD);
|
||||
|
||||
// fileId.
|
||||
do_check_eq(this.readUint32(), fileId);
|
||||
|
||||
// pathId.
|
||||
do_check_eq(this.readString(),
|
||||
EF_PATH_MF_SIM + EF_PATH_DF_TELECOM + EF_PATH_DF_PHONEBOOK);
|
||||
|
||||
// p1.
|
||||
do_check_eq(this.readUint32(), recordNumber);
|
||||
|
||||
// p2.
|
||||
do_check_eq(this.readUint32(), READ_RECORD_ABSOLUTE_MODE);
|
||||
|
||||
// p3.
|
||||
do_check_eq(this.readUint32(), recordSize);
|
||||
|
||||
// data.
|
||||
let strLen = this.readUint32();
|
||||
// EF_AAS, ignore.
|
||||
pduHelper.readHexOctet();
|
||||
do_check_eq(pduHelper.readNumberWithLength(), expectedANR);
|
||||
// EF_CCP, ignore.
|
||||
pduHelper.readHexOctet();
|
||||
// EF_EXT1, ignore.
|
||||
pduHelper.readHexOctet();
|
||||
if (pbr.anr0.fileType === ICC_USIM_TYPE2_TAG) {
|
||||
do_check_eq(pduHelper.readHexOctet(), pbr.adn.sfi);
|
||||
do_check_eq(pduHelper.readHexOctet(), expectedAdnRecordId);
|
||||
}
|
||||
this.readStringDelimiter(strLen);
|
||||
|
||||
// pin2.
|
||||
do_check_eq(this.readString(), null);
|
||||
|
||||
if (!worker.RILQUIRKS_V5_LEGACY) {
|
||||
// AID. Ignore because it's from modem.
|
||||
this.readUint32();
|
||||
}
|
||||
|
||||
if (count == NUM_TESTS) {
|
||||
run_next_test();
|
||||
}
|
||||
};
|
||||
recordHelper.updateANR(pbr, recordNumber, expectedANR, expectedAdnRecordId);
|
||||
}
|
||||
|
||||
do_test(pbr, "+123456789");
|
||||
pbr.anr0.fileType = ICC_USIM_TYPE2_TAG;
|
||||
do_test(pbr, "123456789", 1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCRecordHelper.readIAP
|
||||
*/
|
||||
add_test(function test_read_iap() {
|
||||
let worker = newUint8Worker();
|
||||
let helper = worker.GsmPDUHelper;
|
||||
let record = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let io = worker.ICCIOHelper;
|
||||
let recordSize;
|
||||
|
||||
io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
|
||||
let iap_1 = [0x01, 0x02];
|
||||
|
||||
// Write data size/
|
||||
buf.writeUint32(iap_1.length * 2);
|
||||
|
||||
// Write iap.
|
||||
for (let i = 0; i < iap_1.length; i++) {
|
||||
helper.writeHexOctet(iap_1[i]);
|
||||
}
|
||||
|
||||
// Write string delimiter.
|
||||
buf.writeStringDelimiter(iap_1.length * 2);
|
||||
|
||||
recordSize = iap_1.length;
|
||||
options.recordSize = recordSize;
|
||||
if (options.callback) {
|
||||
options.callback(options);
|
||||
}
|
||||
};
|
||||
|
||||
function doTestReadIAP(expectedIAP) {
|
||||
const fileId = 0x4f17;
|
||||
const recordNumber = 1;
|
||||
|
||||
let successCb = function successCb(iap) {
|
||||
for (let i = 0; i < iap.length; i++) {
|
||||
do_check_eq(expectedIAP[i], iap[i]);
|
||||
}
|
||||
run_next_test();
|
||||
}.bind(this);
|
||||
|
||||
let errorCb = function errorCb(errorMsg) {
|
||||
do_print(errorMsg);
|
||||
do_check_true(false);
|
||||
run_next_test();
|
||||
}.bind(this);
|
||||
|
||||
record.readIAP(fileId, recordNumber, successCb, errorCb);
|
||||
};
|
||||
|
||||
doTestReadIAP([1, 2]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCRecordHelper.updateIAP
|
||||
*/
|
||||
add_test(function test_update_iap() {
|
||||
const recordSize = 2;
|
||||
const recordNumber = 1;
|
||||
const fileId = 0x4f17;
|
||||
let worker = newUint8Worker();
|
||||
let pduHelper = worker.GsmPDUHelper;
|
||||
let ril = worker.RIL;
|
||||
ril.appType = CARD_APPTYPE_USIM;
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let buf = worker.Buf;
|
||||
let ioHelper = worker.ICCIOHelper;
|
||||
let count = 0;
|
||||
|
||||
// Override.
|
||||
ioHelper.updateLinearFixedEF = function (options) {
|
||||
options.pathId = worker.ICCFileHelper.getEFPath(options.fileId);
|
||||
options.command = ICC_COMMAND_UPDATE_RECORD;
|
||||
options.p1 = options.recordNumber;
|
||||
options.p2 = READ_RECORD_ABSOLUTE_MODE;
|
||||
options.p3 = recordSize;
|
||||
ril.iccIO(options);
|
||||
};
|
||||
|
||||
function do_test(expectedIAP) {
|
||||
buf.sendParcel = function () {
|
||||
// Request Type.
|
||||
do_check_eq(this.readUint32(), REQUEST_SIM_IO);
|
||||
|
||||
// Token : we don't care
|
||||
this.readUint32();
|
||||
|
||||
// command.
|
||||
do_check_eq(this.readUint32(), ICC_COMMAND_UPDATE_RECORD);
|
||||
|
||||
// fileId.
|
||||
do_check_eq(this.readUint32(), fileId);
|
||||
|
||||
// pathId.
|
||||
do_check_eq(this.readString(),
|
||||
EF_PATH_MF_SIM + EF_PATH_DF_TELECOM + EF_PATH_DF_PHONEBOOK);
|
||||
|
||||
// p1.
|
||||
do_check_eq(this.readUint32(), recordNumber);
|
||||
|
||||
// p2.
|
||||
do_check_eq(this.readUint32(), READ_RECORD_ABSOLUTE_MODE);
|
||||
|
||||
// p3.
|
||||
do_check_eq(this.readUint32(), recordSize);
|
||||
|
||||
// data.
|
||||
let strLen = this.readUint32();
|
||||
for (let i = 0; i < recordSize; i++) {
|
||||
do_check_eq(expectedIAP[i], pduHelper.readHexOctet());
|
||||
}
|
||||
this.readStringDelimiter(strLen);
|
||||
|
||||
// pin2.
|
||||
do_check_eq(this.readString(), null);
|
||||
|
||||
if (!worker.RILQUIRKS_V5_LEGACY) {
|
||||
// AID. Ignore because it's from modem.
|
||||
this.readUint32();
|
||||
}
|
||||
|
||||
run_next_test();
|
||||
};
|
||||
recordHelper.updateIAP(fileId, recordNumber, expectedIAP);
|
||||
}
|
||||
|
||||
do_test([1, 2]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Verify ICCRecordHelper.updateADNLike.
|
||||
*/
|
||||
@ -1928,7 +2243,7 @@ add_test(function test_update_adn_like() {
|
||||
|
||||
// pin2.
|
||||
if (fileId == ICC_EF_ADN) {
|
||||
do_check_eq(this.readString(), "");
|
||||
do_check_eq(this.readString(), null);
|
||||
} else {
|
||||
do_check_eq(this.readString(), "1111");
|
||||
}
|
||||
@ -1945,8 +2260,7 @@ add_test(function test_update_adn_like() {
|
||||
|
||||
fileId = ICC_EF_ADN;
|
||||
record.updateADNLike(fileId,
|
||||
{recordId: 1, alphaId: "test", number: "123456"},
|
||||
"");
|
||||
{recordId: 1, alphaId: "test", number: "123456"});
|
||||
|
||||
fileId = ICC_EF_FDN;
|
||||
record.updateADNLike(fileId,
|
||||
@ -2091,22 +2405,95 @@ add_test(function test_update_icc_contact() {
|
||||
let worker = newUint8Worker();
|
||||
let recordHelper = worker.ICCRecordHelper;
|
||||
let contactHelper = worker.ICCContactHelper;
|
||||
const FILE_ID = 0x4f3a;
|
||||
const NUM_TESTS = 2;
|
||||
const ADN_RECORD_ID = 100;
|
||||
const ADN_FILE_ID = 0x4f3a;
|
||||
const ADN_SFI = 1;
|
||||
const IAP_FILE_ID = 0x4f17;
|
||||
const EMAIL_FILE_ID = 0x4f50;
|
||||
const EMAIL_RECORD_ID = 20;
|
||||
const ANR0_FILE_ID = 0x4f11;
|
||||
const ANR0_RECORD_ID = 30;
|
||||
let count = 0;
|
||||
let oldContact = {recordId: ADN_RECORD_ID,
|
||||
alphaId: "test",
|
||||
number: "123456",
|
||||
email: "test@mail.com",
|
||||
anr: ["+654321"]};
|
||||
|
||||
recordHelper.readPBR = function (onsuccess, onerror) {
|
||||
onsuccess([{adn:{fileId: FILE_ID}}]);
|
||||
};
|
||||
function do_test(pbrs, onsuccess, onerror) {
|
||||
recordHelper.readPBR = function (onsuccess, onerror) {
|
||||
onsuccess(pbrs) ;
|
||||
};
|
||||
|
||||
let oldContact = {recordId: 1, alphaId: "test", number: "123456"};
|
||||
recordHelper.updateADNLike = function (fileId, contact, pin2, onsuccess, onerror) {
|
||||
do_check_eq(fileId, FILE_ID);
|
||||
do_check_eq(contact.alphaId, oldContact.alphaId);
|
||||
do_check_eq(contact.number, oldContact.number);
|
||||
recordHelper.updateADNLike = function (fileId, contact, pin2, onsuccess, onerror) {
|
||||
do_check_eq(fileId, ADN_FILE_ID);
|
||||
do_check_eq(contact.alphaId, oldContact.alphaId);
|
||||
do_check_eq(contact.number, oldContact.number);
|
||||
onsuccess();
|
||||
};
|
||||
|
||||
recordHelper.readIAP = function (fileId, recordNumber, onsuccess, onerror) {
|
||||
do_check_eq(fileId, IAP_FILE_ID);
|
||||
do_check_eq(recordNumber, ADN_RECORD_ID);
|
||||
onsuccess([EMAIL_RECORD_ID, ANR0_RECORD_ID]);
|
||||
};
|
||||
|
||||
recordHelper.updateEmail = function (pbr, recordNumber, email, adnRecordId, onsuccess, onerror) {
|
||||
do_check_eq(pbr.email.fileId, EMAIL_FILE_ID);
|
||||
if (pbr.email.fileType === ICC_USIM_TYPE1_TAG) {
|
||||
do_check_eq(recordNumber, ADN_RECORD_ID);
|
||||
} else if (pbr.email.fileType === ICC_USIM_TYPE2_TAG) {
|
||||
do_check_eq(recordNumber, EMAIL_RECORD_ID);
|
||||
}
|
||||
do_check_eq(email, oldContact.email);
|
||||
onsuccess();
|
||||
};
|
||||
|
||||
recordHelper.updateANR = function (pbr, recordNumber, number, adnRecordId, onsuccess, onerror) {
|
||||
do_check_eq(pbr.anr0.fileId, ANR0_FILE_ID);
|
||||
if (pbr.anr0.fileType === ICC_USIM_TYPE1_TAG) {
|
||||
do_check_eq(recordNumber, ADN_RECORD_ID);
|
||||
} else if (pbr.anr0.fileType === ICC_USIM_TYPE2_TAG) {
|
||||
do_check_eq(recordNumber, ANR0_RECORD_ID);
|
||||
}
|
||||
do_check_eq(number, oldContact.anr[0]);
|
||||
onsuccess();
|
||||
};
|
||||
|
||||
contactHelper.updateICCContact(CARD_APPTYPE_USIM, "adn", oldContact, null, onsuccess, onerror);
|
||||
}
|
||||
|
||||
let successCb = function () {
|
||||
count++;
|
||||
if (count == NUM_TESTS) {
|
||||
run_next_test();
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
let errorCb = function (errorMsg) {
|
||||
do_print("updateICCContact failed " + errorMsg);
|
||||
do_check_true(false);
|
||||
run_next_test();
|
||||
};
|
||||
}.bind(this);
|
||||
|
||||
do_test([{adn:{fileId: ADN_FILE_ID},
|
||||
email: {fileId: EMAIL_FILE_ID, fileType: ICC_USIM_TYPE1_TAG},
|
||||
anr0: {fileId: ANR0_FILE_ID, fileType: ICC_USIM_TYPE1_TAG}}],
|
||||
successCb,
|
||||
errorCb);
|
||||
|
||||
do_test([{adn:{fileId: ADN_FILE_ID, sfi: ADN_SFI},
|
||||
iap: {fileId: IAP_FILE_ID},
|
||||
email: {fileId: EMAIL_FILE_ID,
|
||||
fileType: ICC_USIM_TYPE2_TAG,
|
||||
indexInIAP: 0},
|
||||
anr0: {fileId: ANR0_FILE_ID,
|
||||
fileType: ICC_USIM_TYPE2_TAG,
|
||||
indexInIAP: 1}}],
|
||||
successCb,
|
||||
errorCb);
|
||||
|
||||
contactHelper.updateICCContact(CARD_APPTYPE_USIM, "adn", oldContact);
|
||||
});
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user