Bug 959059 - B2G NFC: Marionette test to check P2P registration for an incorrect manifest Url. r=allstars.chh

This commit is contained in:
Siddartha Pothapragada 2014-04-30 10:17:00 +02:00
parent 067052fe5a
commit 7874282e49

View File

@ -5,6 +5,7 @@ MARIONETTE_TIMEOUT = 30000;
MARIONETTE_HEAD_JS = 'head.js';
let MANIFEST_URL = "app://system.gaiamobile.org/manifest.webapp";
let INCORRECT_MANIFEST_URL = "app://xyz.gaiamobile.org/manifest.webapp";
function peerReadyCb(evt) {
log("peerReadyCb called");
@ -25,6 +26,7 @@ function handleTechnologyDiscoveredRE0(msg) {
let request = nfc.checkP2PRegistration(MANIFEST_URL);
request.onsuccess = function (evt) {
is(request.result, true, "check for P2P registration result");
nfc.notifyUserAcceptedP2P(MANIFEST_URL);
}
@ -34,6 +36,29 @@ function handleTechnologyDiscoveredRE0(msg) {
}
}
function handleTechnologyDiscoveredRE0ForP2PRegFailure(msg) {
log("Received \'nfc-manager-tech-discovered\'");
is(msg.type, "techDiscovered", "check for correct message type");
is(msg.techList[0], "P2P", "check for correct tech type");
nfc.onpeerready = peerReadyCb;
let request = nfc.checkP2PRegistration(INCORRECT_MANIFEST_URL);
request.onsuccess = function (evt) {
is(request.result, false, "check for P2P registration result");
nfc.onpeerready = null;
toggleNFC(false, runNextTest);
}
request.onerror = function () {
ok(false, "checkP2PRegistration failed.");
nfc.onpeerready = null;
toggleNFC(false, runNextTest);
}
}
function activateRE(re) {
let deferred = Promise.defer();
let cmd = "nfc ntf rf_intf_activated " + re;
@ -55,8 +80,18 @@ function testPeerReady() {
});
}
function testCheckP2PRegFailure() {
window.navigator.mozSetMessageHandler(
"nfc-manager-tech-discovered", handleTechnologyDiscoveredRE0ForP2PRegFailure);
toggleNFC(true, function() {
activateRE(0);
});
}
let tests = [
testPeerReady
testPeerReady,
testCheckP2PRegFailure
];
SpecialPowers.pushPermissions(