Bug 859215 - 0005. Marionette test for read SMSC address. r=vicamo.

This commit is contained in:
Chuck Lee 2013-09-16 10:12:45 +08:00
Родитель e3013dfef6
Коммит 341028fd97
2 изменённых файлов: 79 добавлений и 0 удалений

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

@ -36,4 +36,5 @@ 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_smsc_address.js]
[test_dsds_default_service_id.js] [test_dsds_default_service_id.js]

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

@ -0,0 +1,78 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("sms", true, document);
// Expected SMSC addresses of emulator
const SMSC = "\"+123456789\",145";
let manager = window.navigator.mozMobileMessage;
let tasks = {
// List of test fuctions. Each of them should call |tasks.next()| when
// completed or |tasks.finish()| to jump to the last one.
_tasks: [],
_nextTaskIndex: 0,
push: function push(func) {
this._tasks.push(func);
},
next: function next() {
let index = this._nextTaskIndex++;
let task = this._tasks[index];
try {
task();
} catch (ex) {
ok(false, "test task[" + index + "] throws: " + ex);
// Run last task as clean up if possible.
if (index != this._tasks.length - 1) {
this.finish();
}
}
},
finish: function finish() {
this._tasks[this._tasks.length - 1]();
},
run: function run() {
this.next();
}
};
tasks.push(function init() {
log("Initialize test object.");
ok(manager instanceof MozMobileMessageManager,
"manager is instance of " + manager.constructor);
tasks.next();
});
tasks.push(function readSmscAddress() {
log("read SMSC address");
let req = manager.getSmscAddress();
ok(req, "DOMRequest object for getting smsc address");
req.onsuccess = function(e) {
is(e.target.result, SMSC, "SMSC address");
tasks.next();
};
req.onerror = function(error) {
ok(false, "readSmscAddress(): Received 'onerror'");
tasks.finish();
};
});
// WARNING: All tasks should be pushed before this!!!
tasks.push(function cleanUp() {
manager.onreceived = null;
SpecialPowers.removePermission("sms", document);
finish();
});
// Start the test
tasks.run();