mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1044721 - Part 6: Add marionette and xpcshell test cases. r=btseng
This commit is contained in:
parent
129bfc3a71
commit
f697daf654
@ -52,3 +52,4 @@ qemu = true
|
||||
[test_ondeleted_event.js]
|
||||
[test_decode_spanish_fallback.js]
|
||||
[test_update_gsm_nl_on_mcc_chanages.js]
|
||||
[test_set_smsc_address.js]
|
||||
|
72
dom/mobilemessage/tests/marionette/test_set_smsc_address.js
Normal file
72
dom/mobilemessage/tests/marionette/test_set_smsc_address.js
Normal file
@ -0,0 +1,72 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const SMSC_ATT = '+13123149810';
|
||||
const SMSC_ATT_TYPO = '+++1312@@@314$$$9,8,1,0';
|
||||
const SMSC_ATT_TEXT = '"+13123149810",145';
|
||||
const SMSC_O2 = '+447802000332';
|
||||
const SMSC_O2_TEXT = '"+447802000332",145';
|
||||
const SMSC_DEF = '+123456789';
|
||||
const SMSC_DEF_TEXT = '"+123456789",145';
|
||||
const SMSC_TON_UNKNOWN = '0407485455'
|
||||
const SMSC_TON_UNKNOWN_TEXT = '"0407485455",129';
|
||||
|
||||
function getSmscAddress() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let req = manager.getSmscAddress();
|
||||
if (!req) {
|
||||
reject("manager.getSmscAddress() returns null.");
|
||||
}
|
||||
|
||||
req.onsuccess = function() {
|
||||
resolve(this.result);
|
||||
};
|
||||
|
||||
req.onerror = function() {
|
||||
reject(this.error);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
startTestBase(function testCaseMain() {
|
||||
return ensureMobileMessage()
|
||||
|
||||
// Verify setting AT&T SMSC address.
|
||||
.then(() => manager.setSmscAddress({ address:SMSC_ATT }))
|
||||
.then(() => getSmscAddress())
|
||||
.then((result) => is(result, SMSC_ATT_TEXT))
|
||||
|
||||
// Verify setting O2 SMSC address.
|
||||
.then(() => manager.setSmscAddress({ address:SMSC_O2 }))
|
||||
.then(() => getSmscAddress())
|
||||
.then((result) => is(result, SMSC_O2_TEXT))
|
||||
|
||||
// Verify setting AT&T SMSC address with extra illegal characters.
|
||||
.then(() => manager.setSmscAddress({ address:SMSC_ATT_TYPO }))
|
||||
.then(() => getSmscAddress())
|
||||
.then((result) => is(result, SMSC_ATT_TEXT))
|
||||
|
||||
// Verify setting a SMSC address with TON=unknown.
|
||||
.then(() => manager.setSmscAddress({ address:SMSC_TON_UNKNOWN }))
|
||||
.then(() => getSmscAddress())
|
||||
.then((result) => is(result, SMSC_TON_UNKNOWN_TEXT))
|
||||
|
||||
// Verify setting invalid SMSC address.
|
||||
.then(() => manager.setSmscAddress({}))
|
||||
.then(() => Promise.reject("Expect for an error."),
|
||||
(err) => log("Got expected error: " + err))
|
||||
.then(() => manager.setSmscAddress({ address:"" }))
|
||||
.then(() => Promise.reject("Expect for an error."),
|
||||
(err) => log("Got expected error: " + err))
|
||||
.then(() => manager.setSmscAddress({ address:"???" }))
|
||||
.then(() => Promise.reject("Expect for an error."),
|
||||
(err) => log("Got expected error: " + err))
|
||||
|
||||
// Restore to default emulator SMSC address.
|
||||
.then(() => manager.setSmscAddress({ address:SMSC_DEF }))
|
||||
.then(() => getSmscAddress())
|
||||
.then((result) => is(result, SMSC_DEF_TEXT));
|
||||
});
|
71
dom/system/gonk/tests/test_ril_worker_smsc_address.js
Normal file
71
dom/system/gonk/tests/test_ril_worker_smsc_address.js
Normal file
@ -0,0 +1,71 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this);
|
||||
|
||||
const SMSC_ATT = '+13123149810';
|
||||
const SMSC_ATT_TYPO = '+++1312@@@314$$$9,8,1,0';
|
||||
const SMSC_ATT_TEXT = '"+13123149810",145';
|
||||
const SMSC_ATT_PDU = '07913121139418F0';
|
||||
const SMSC_O2 = '+447802000332';
|
||||
const SMSC_O2_TEXT = '"+447802000332",145';
|
||||
const SMSC_O2_PDU = '0791448720003023';
|
||||
const SMSC_TON_UNKNOWN = '0407485455'
|
||||
const SMSC_TON_UNKNOWN_TEXT = '"0407485455",129';
|
||||
const SMSC_TON_UNKNOWN_PDU = '06814070844555';
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function setSmsc(context, smsc, ton, npi, expected) {
|
||||
context.Buf.sendParcel = function() {
|
||||
equal(this.readString(), expected);
|
||||
};
|
||||
|
||||
context.RIL.setSmscAddress({
|
||||
smscAddress: smsc,
|
||||
typeOfNumber: ton,
|
||||
numberPlanIdentification: npi
|
||||
});
|
||||
}
|
||||
|
||||
add_test(function test_setSmscAddress() {
|
||||
let worker = newUint8Worker();
|
||||
let context = worker.ContextPool._contexts[0];
|
||||
let parcelTypes = [];
|
||||
context.Buf.newParcel = (type, options) => parcelTypes.push(type);
|
||||
|
||||
// Test text mode.
|
||||
worker.RILQUIRKS_SMSC_ADDRESS_FORMAT = "text";
|
||||
|
||||
setSmsc(context, SMSC_ATT, 1, 1, SMSC_ATT_TEXT);
|
||||
equal(parcelTypes.pop(), REQUEST_SET_SMSC_ADDRESS);
|
||||
|
||||
setSmsc(context, SMSC_O2, 1, 1, SMSC_O2_TEXT);
|
||||
equal(parcelTypes.pop(), REQUEST_SET_SMSC_ADDRESS);
|
||||
|
||||
setSmsc(context, SMSC_ATT_TYPO, 1, 1, SMSC_ATT_TEXT);
|
||||
equal(parcelTypes.pop(), REQUEST_SET_SMSC_ADDRESS);
|
||||
|
||||
setSmsc(context, SMSC_TON_UNKNOWN, 0, 1, SMSC_TON_UNKNOWN_TEXT);
|
||||
equal(parcelTypes.pop(), REQUEST_SET_SMSC_ADDRESS);
|
||||
|
||||
// Test pdu mode.
|
||||
worker.RILQUIRKS_SMSC_ADDRESS_FORMAT = "pdu";
|
||||
|
||||
setSmsc(context, SMSC_ATT, 1, 1, SMSC_ATT_PDU);
|
||||
equal(parcelTypes.pop(), REQUEST_SET_SMSC_ADDRESS);
|
||||
|
||||
setSmsc(context, SMSC_O2, 1, 1, SMSC_O2_PDU);
|
||||
equal(parcelTypes.pop(), REQUEST_SET_SMSC_ADDRESS);
|
||||
|
||||
setSmsc(context, SMSC_ATT_TYPO, 1, 1, SMSC_ATT_PDU);
|
||||
equal(parcelTypes.pop(), REQUEST_SET_SMSC_ADDRESS);
|
||||
|
||||
setSmsc(context, SMSC_TON_UNKNOWN, 0, 1, SMSC_TON_UNKNOWN_PDU);
|
||||
equal(parcelTypes.pop(), REQUEST_SET_SMSC_ADDRESS);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -22,6 +22,7 @@ skip-if = true
|
||||
[test_ril_worker_sms_nl_tables.js]
|
||||
[test_ril_worker_sms_gsmpduhelper.js]
|
||||
[test_ril_worker_sms_segment_info.js]
|
||||
[test_ril_worker_smsc_address.js]
|
||||
[test_ril_worker_mmi.js]
|
||||
[test_ril_worker_mmi_cf.js]
|
||||
[test_ril_worker_cf.js]
|
||||
|
Loading…
Reference in New Issue
Block a user