Bug 1087928 - write marionette-webapi tests for ontagfound. r=yoshi

--HG--
extra : rebase_source : c7b0762cbfd496fdf358f9a327431198f3c0237d
This commit is contained in:
Thomas Nguyen 2015-11-24 18:00:00 +01:00
Родитель fb992c848d
Коммит 7b306d81e1
3 изменённых файлов: 84 добавлений и 0 удалений

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

@ -14,3 +14,5 @@ qemu=true
[test_nfc_read_tag.js]
[test_nfc_checkP2PRegistration.js]
[test_nfc_error_messages.js]
[test_nfc_tag_found.js]
[test_nfc_tag_lost.js]

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

@ -0,0 +1,46 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 30000;
MARIONETTE_HEAD_JS = 'head.js';
function handleTechnologyDiscoveredRE0(msg) {
log('Received \'nfc-manager-tech-discovered\'');
ok(msg.peer, 'check for correct tech type');
deactivateAndWaitForTechLost().then(() => toggleNFC(false)).then(runNextTest);
}
function tagFoundCb(evt) {
log("tagFoundCb called ");
ok(evt.tag instanceof MozNFCTag, "Should get a NFCTag object.");
nfc.ontagfound = null;
deactivateAndWaitForTechLost().then(() => toggleNFC(false)).then(runNextTest);
}
function tagFoundErrorCb(evt) {
ok(false, "ontagfound shouldn't be called");
}
function testTagFound() {
nfc.ontagfound = tagFoundCb;
toggleNFC(true).then(() => NCI.activateRE(emulator.T1T_RE_INDEX));
}
function testTagFoundShouldNotFired() {
nfc.ontagfound = tagFoundErrorCb;
sysMsgHelper.waitForTechDiscovered(handleTechnologyDiscoveredRE0);
toggleNFC(true).then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0));
}
var tests = [
testTagFound,
testTagFoundShouldNotFired
];
SpecialPowers.pushPermissions(
[{"type": "nfc", "allow": true, context: document},
{'type': 'nfc-manager', 'allow': true, context: document}], runTests);

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

@ -0,0 +1,36 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 30000;
MARIONETTE_HEAD_JS = 'head.js';
function tagFoundCb(evt) {
log("tagFoundCb called ");
ok(evt.tag instanceof MozNFCTag, "Should get a NFCTag object.");
NCI.deactivate();
}
function tagLostCb(evt) {
log("tagLostCb called ");
ok(true);
nfc.ontagfound = null;
nfc.ontaglost = null;
toggleNFC(false).then(runNextTest);
}
function testTagLost() {
nfc.ontagfound = tagFoundCb;
nfc.ontaglost = tagLostCb;
toggleNFC(true).then(() => NCI.activateRE(emulator.T1T_RE_INDEX));
}
var tests = [
testTagLost
];
SpecialPowers.pushPermissions(
[{"type": "nfc", "allow": true, context: document},
{'type': 'nfc-manager', 'allow': true, context: document}], runTests);