Bug 816893 - Part 4: Marionette tests for reading Sim Contact. r=hsinyi

This commit is contained in:
Yoshi Huang 2012-12-14 12:07:12 +08:00
parent 14f35a6599
commit 6e23fa9d2b
3 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,6 @@
[DEFAULT]
b2g = true
browser = false
qemu = true
[test_sim_contacts.js]

View File

@ -0,0 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 30000;
SpecialPowers.addPermission("contacts-read", true, document);
let mozContacts = window.navigator.mozContacts;
ok(mozContacts);
function testImportSimContacts() {
let request = mozContacts.getSimContacts("ADN");
request.onsuccess = function onsuccess() {
let simContacts = request.result;
// These SIM contacts are harded in external/qemu/telephony/sim_card.c
is(simContacts.length, 4);
is(simContacts[0].name, "Mozilla");
is(simContacts[0].tel[0].value, "15555218201");
is(simContacts[1].name, "Saßê黃");
is(simContacts[1].tel[0].value, "15555218202");
is(simContacts[2].name, "Fire 火");
is(simContacts[2].tel[0].value, "15555218203");
is(simContacts[3].name, "Huang 黃");
is(simContacts[3].tel[0].value, "15555218204");
runNextTest();
};
request.onerror = function onerror() {
ok(false, "Cannot get Sim Contacts");
runNextTest();
};
};
let tests = [
testImportSimContacts,
];
function runNextTest() {
let test = tests.pop();
if (!test) {
cleanUp();
return;
}
test();
}
function cleanUp() {
SpecialPowers.removePermission("contacts-read", document);
finish();
}
runNextTest();

View File

@ -19,6 +19,7 @@ skip = false
[include:../../../../../dom/system/gonk/tests/marionette/manifest.ini]
[include:../../../../../dom/icc/tests/marionette/manifest.ini]
[include:../../../../../dom/system/tests/marionette/manifest.ini]
[include:../../../../../dom/contacts/tests/marionette/manifest.ini]
; marionette unit tests
[include:unit/unit-tests.ini]