Bug 926302 - 3/3: test cases. r=hsinyi

This commit is contained in:
Vicamo Yang 2013-10-24 16:15:15 +08:00
Родитель 7424816c3c
Коммит b2e1f24146
8 изменённых файлов: 430 добавлений и 0 удалений

Просмотреть файл

@ -36,3 +36,4 @@ qemu = true
[test_invalid_address.js] [test_invalid_address.js]
[test_mmsmessage_attachments.js] [test_mmsmessage_attachments.js]
[test_getthreads.js] [test_getthreads.js]
[test_dsds_default_service_id.js]

Просмотреть файл

@ -0,0 +1,130 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_CONTEXT = "chrome";
Cu.import("resource://gre/modules/Promise.jsm");
const MMS_SERVICE_CONTRACTID = "@mozilla.org/mms/mmsservice;1";
const SMS_SERVICE_CONTRACTID = "@mozilla.org/sms/smsservice;1";
const PREF_RIL_NUM_RADIO_INTERFACES = "ril.numRadioInterfaces";
const PREF_MMS_DEFAULT_SERVICE_ID = "dom.mms.defaultServiceId";
const PREF_SMS_DEFAULT_SERVICE_ID = "dom.sms.defaultServiceId";
function setPrefAndVerify(prefKey, setVal, service, attrName, expectedVal, deferred) {
log(" Set '" + prefKey + "' to " + setVal);
Services.prefs.setIntPref(prefKey, setVal);
let prefVal = Services.prefs.getIntPref(prefKey);
is(prefVal, setVal, "'" + prefKey + "' set to " + setVal);
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, expectedVal, attrName);
deferred.resolve(service);
}, 0);
}
function getNumRadioInterfaces() {
let deferred = Promise.defer();
window.setTimeout(function () {
let numRil = Services.prefs.getIntPref(PREF_RIL_NUM_RADIO_INTERFACES);
log("numRil = " + numRil);
deferred.resolve(numRil);
}, 0);
return deferred.promise;
}
function getService(contractId, ifaceName) {
let deferred = Promise.defer();
window.setTimeout(function () {
log("Getting service for " + ifaceName);
let service = Cc[contractId].getService(Ci[ifaceName]);
ok(service, "service.constructor is " + service.constructor);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkInitialEquality(attrName, prefKey, service) {
let deferred = Promise.defer();
log(" Checking initial value for '" + prefKey + "'");
let origPrefVal = Services.prefs.getIntPref(prefKey);
ok(isFinite(origPrefVal), "default '" + prefKey + "' value");
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, origPrefVal, attrName);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkSetToNegtiveValue(attrName, prefKey, service) {
let deferred = Promise.defer();
// Set to -1 and verify defaultVal == 0.
setPrefAndVerify(prefKey, -1, service, attrName, 0, deferred);
return deferred.promise;
}
function checkSetToOverflowedValue(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
// Set to larger-equal than numRil and verify defaultVal == 0.
setPrefAndVerify(prefKey, numRil, service, attrName, 0, deferred);
return deferred.promise;
}
function checkValueChange(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
if (numRil > 1) {
// Set to (numRil - 1) and verify defaultVal equals.
setPrefAndVerify(prefKey, numRil - 1, service, attrName, numRil - 1, deferred);
} else {
window.setTimeout(function () {
deferred.resolve(service);
}, 0);
}
return deferred.promise;
}
function verify(contractId, ifaceName, attrName, prefKey, numRil) {
let deferred = Promise.defer();
getService(contractId, ifaceName)
.then(checkInitialEquality.bind(null, attrName, prefKey))
.then(checkSetToNegtiveValue.bind(null, attrName, prefKey))
.then(checkSetToOverflowedValue.bind(null, attrName, prefKey, numRil))
.then(checkValueChange.bind(null, attrName, prefKey, numRil))
.then(function () {
// Reset.
Services.prefs.clearUserPref(prefKey);
deferred.resolve(numRil);
});
return deferred.promise;
}
getNumRadioInterfaces()
.then(verify.bind(null, MMS_SERVICE_CONTRACTID, "nsIMmsService",
"mmsDefaultServiceId", PREF_MMS_DEFAULT_SERVICE_ID))
.then(verify.bind(null, SMS_SERVICE_CONTRACTID, "nsISmsService",
"smsDefaultServiceId", PREF_SMS_DEFAULT_SERVICE_ID))
.then(finish);

Просмотреть файл

@ -8,3 +8,4 @@ disabled = Bug 808783
[test_fakevolume.js] [test_fakevolume.js]
[test_ril_code_quality.py] [test_ril_code_quality.py]
[test_screen_state.js] [test_screen_state.js]
[test_dsds_numRadioInterfaces.js]

Просмотреть файл

@ -0,0 +1,43 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_CONTEXT = "chrome";
Cu.import("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/systemlibs.js");
const NS_RIL_CONTRACTID = "@mozilla.org/ril;1";
const PROP_RO_MOZ_RIL_NUMCLIENTS = "ro.moz.ril.numclients";
const PREF_RIL_NUM_RADIO_INTERFACES = "ril.numRadioInterfaces";
ok(libcutils, "libcutils is available");
let propNum = (function () {
try {
let numString = libcutils.property_get(PROP_RO_MOZ_RIL_NUMCLIENTS, "1");
let num = parseInt(numString, 10);
if (num >= 0) {
return num;
}
} catch (e) {}
})();
log("Retrieved '" + PROP_RO_MOZ_RIL_NUMCLIENTS + "' = " + propNum);
ok(propNum, PROP_RO_MOZ_RIL_NUMCLIENTS);
let prefNum = Services.prefs.getIntPref(PREF_RIL_NUM_RADIO_INTERFACES);
log("Retrieved '" + PREF_RIL_NUM_RADIO_INTERFACES + "' = " + prefNum);
let ril = Cc[NS_RIL_CONTRACTID].getService(Ci.nsIRadioInterfaceLayer);
ok(ril, "ril.constructor is " + ril.constructor);
let ifaceNum = ril.numRadioInterfaces;
log("Retrieved 'nsIRadioInterfaceLayer.numRadioInterfaces' = " + ifaceNum);
is(propNum, prefNum);
is(propNum, ifaceNum);
finish();

Просмотреть файл

@ -43,3 +43,4 @@ disabled = Bug 821958
[test_outgoing_emergency_in_airplane_mode.js] [test_outgoing_emergency_in_airplane_mode.js]
[test_emergency_label.js] [test_emergency_label.js]
[test_conference.js] [test_conference.js]
[test_dsds_default_service_id.js]

Просмотреть файл

@ -0,0 +1,127 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_CONTEXT = "chrome";
Cu.import("resource://gre/modules/Promise.jsm");
const TELEPHONY_PROVIDER_CONTRACTID =
"@mozilla.org/telephony/telephonyprovider;1";
const PREF_RIL_NUM_RADIO_INTERFACES = "ril.numRadioInterfaces";
const PREF_DEFAULT_SERVICE_ID = "dom.telephony.defaultServiceId";
function setPrefAndVerify(prefKey, setVal, service, attrName, expectedVal, deferred) {
log(" Set '" + prefKey + "' to " + setVal);
Services.prefs.setIntPref(prefKey, setVal);
let prefVal = Services.prefs.getIntPref(prefKey);
is(prefVal, setVal, "'" + prefKey + "' set to " + setVal);
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, expectedVal, attrName);
deferred.resolve(service);
}, 0);
}
function getNumRadioInterfaces() {
let deferred = Promise.defer();
window.setTimeout(function () {
let numRil = Services.prefs.getIntPref(PREF_RIL_NUM_RADIO_INTERFACES);
log("numRil = " + numRil);
deferred.resolve(numRil);
}, 0);
return deferred.promise;
}
function getService(contractId, ifaceName) {
let deferred = Promise.defer();
window.setTimeout(function () {
log("Getting service for " + ifaceName);
let service = Cc[contractId].getService(Ci[ifaceName]);
ok(service, "service.constructor is " + service.constructor);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkInitialEquality(attrName, prefKey, service) {
let deferred = Promise.defer();
log(" Checking initial value for '" + prefKey + "'");
let origPrefVal = Services.prefs.getIntPref(prefKey);
ok(isFinite(origPrefVal), "default '" + prefKey + "' value");
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, origPrefVal, attrName);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkSetToNegtiveValue(attrName, prefKey, service) {
let deferred = Promise.defer();
// Set to -1 and verify defaultVal == 0.
setPrefAndVerify(prefKey, -1, service, attrName, 0, deferred);
return deferred.promise;
}
function checkSetToOverflowedValue(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
// Set to larger-equal than numRil and verify defaultVal == 0.
setPrefAndVerify(prefKey, numRil, service, attrName, 0, deferred);
return deferred.promise;
}
function checkValueChange(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
if (numRil > 1) {
// Set to (numRil - 1) and verify defaultVal equals.
setPrefAndVerify(prefKey, numRil - 1, service, attrName, numRil - 1, deferred);
} else {
window.setTimeout(function () {
deferred.resolve(service);
}, 0);
}
return deferred.promise;
}
function verify(contractId, ifaceName, attrName, prefKey, numRil) {
let deferred = Promise.defer();
getService(contractId, ifaceName)
.then(checkInitialEquality.bind(null, attrName, prefKey))
.then(checkSetToNegtiveValue.bind(null, attrName, prefKey))
.then(checkSetToOverflowedValue.bind(null, attrName, prefKey, numRil))
.then(checkValueChange.bind(null, attrName, prefKey, numRil))
.then(function () {
// Reset.
Services.prefs.clearUserPref(prefKey);
deferred.resolve(numRil);
});
return deferred.promise;
}
getNumRadioInterfaces()
.then(verify.bind(null, TELEPHONY_PROVIDER_CONTRACTID, "nsITelephonyProvider",
"defaultServiceId", PREF_DEFAULT_SERVICE_ID))
.then(finish);

Просмотреть файл

@ -5,3 +5,4 @@ qemu = true
[test_voicemail_statuschanged.py] [test_voicemail_statuschanged.py]
[test_voicemail_number.js] [test_voicemail_number.js]
[test_dsds_default_service_id.js]

Просмотреть файл

@ -0,0 +1,126 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_CONTEXT = "chrome";
Cu.import("resource://gre/modules/Promise.jsm");
const VOICEMAIL_PROVIDER_CONTRACTID = "@mozilla.org/ril/content-helper;1";
const PREF_RIL_NUM_RADIO_INTERFACES = "ril.numRadioInterfaces";
const PREF_DEFAULT_SERVICE_ID = "dom.voicemail.defaultServiceId";
function setPrefAndVerify(prefKey, setVal, service, attrName, expectedVal, deferred) {
log(" Set '" + prefKey + "' to " + setVal);
Services.prefs.setIntPref(prefKey, setVal);
let prefVal = Services.prefs.getIntPref(prefKey);
is(prefVal, setVal, "'" + prefKey + "' set to " + setVal);
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, expectedVal, attrName);
deferred.resolve(service);
}, 0);
}
function getNumRadioInterfaces() {
let deferred = Promise.defer();
window.setTimeout(function () {
let numRil = Services.prefs.getIntPref(PREF_RIL_NUM_RADIO_INTERFACES);
log("numRil = " + numRil);
deferred.resolve(numRil);
}, 0);
return deferred.promise;
}
function getService(contractId, ifaceName) {
let deferred = Promise.defer();
window.setTimeout(function () {
log("Getting service for " + ifaceName);
let service = Cc[contractId].getService(Ci[ifaceName]);
ok(service, "service.constructor is " + service.constructor);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkInitialEquality(attrName, prefKey, service) {
let deferred = Promise.defer();
log(" Checking initial value for '" + prefKey + "'");
let origPrefVal = Services.prefs.getIntPref(prefKey);
ok(isFinite(origPrefVal), "default '" + prefKey + "' value");
window.setTimeout(function () {
let defaultVal = service[attrName];
is(defaultVal, origPrefVal, attrName);
deferred.resolve(service);
}, 0);
return deferred.promise;
}
function checkSetToNegtiveValue(attrName, prefKey, service) {
let deferred = Promise.defer();
// Set to -1 and verify defaultVal == 0.
setPrefAndVerify(prefKey, -1, service, attrName, 0, deferred);
return deferred.promise;
}
function checkSetToOverflowedValue(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
// Set to larger-equal than numRil and verify defaultVal == 0.
setPrefAndVerify(prefKey, numRil, service, attrName, 0, deferred);
return deferred.promise;
}
function checkValueChange(attrName, prefKey, numRil, service) {
let deferred = Promise.defer();
if (numRil > 1) {
// Set to (numRil - 1) and verify defaultVal equals.
setPrefAndVerify(prefKey, numRil - 1, service, attrName, numRil - 1, deferred);
} else {
window.setTimeout(function () {
deferred.resolve(service);
}, 0);
}
return deferred.promise;
}
function verify(contractId, ifaceName, attrName, prefKey, numRil) {
let deferred = Promise.defer();
getService(contractId, ifaceName)
.then(checkInitialEquality.bind(null, attrName, prefKey))
.then(checkSetToNegtiveValue.bind(null, attrName, prefKey))
.then(checkSetToOverflowedValue.bind(null, attrName, prefKey, numRil))
.then(checkValueChange.bind(null, attrName, prefKey, numRil))
.then(function () {
// Reset.
Services.prefs.clearUserPref(prefKey);
deferred.resolve(numRil);
});
return deferred.promise;
}
getNumRadioInterfaces()
.then(verify.bind(null, VOICEMAIL_PROVIDER_CONTRACTID, "nsIVoicemailProvider",
"voicemailDefaultServiceId", PREF_DEFAULT_SERVICE_ID))
.then(finish);