Bug 1103732 - Part 2: update test cases. r=dimi

From abdfb00788f359f4ed9bbd502a7e723350e3212d Mon Sep 17 00:00:00 2001
---
 dom/nfc/tests/marionette/test_nfc_peer.js          | 16 ++--------------
 dom/nfc/tests/marionette/test_nfc_peer_sendFile.js |  3 +--
 dom/nfc/tests/marionette/test_nfc_peer_sendndef.js |  5 ++---
 3 files changed, 5 insertions(+), 19 deletions(-)
This commit is contained in:
Yoshi Huang 2014-11-27 15:05:29 +08:00
parent 40186f9184
commit e174fe6629
3 changed files with 5 additions and 19 deletions

View File

@ -66,10 +66,7 @@ function testPeerReady() {
function testGetNFCPeer() {
sysMsgHelper.waitForTechDiscovered(function (msg) {
let peer = nfc.getNFCPeer(msg.sessionToken);
ok(peer instanceof MozNFCPeer, "Should get a NFCPeer object.");
let peer1 = nfc.getNFCPeer(msg.sessionToken);
ok(peer == peer1, "Should get the same MozNFCPeer object");
ok(msg.peer instanceof MozNFCPeer, "Should get a NFCPeer object.");
NCI.deactivate().then(() => toggleNFC(false)).then(runNextTest);
});
@ -181,22 +178,13 @@ function testPeerShouldThrow() {
.then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0));
}
function testPeerInvalidToken() {
log("testPeerInvalidToken");
let peer = nfc.getNFCPeer("fakeSessionToken");
is(peer, null, "NFCPeer should be null on wrong session token");
runNextTest();
}
let tests = [
testPeerReady,
testGetNFCPeer,
testCheckP2PRegFailure,
testPeerLostShouldBeCalled,
testPeerLostShouldNotBeCalled,
testPeerShouldThrow,
testPeerInvalidToken
testPeerShouldThrow
];
SpecialPowers.pushPermissions(

View File

@ -8,8 +8,7 @@ let MANIFEST_URL = "app://system.gaiamobile.org/manifest.webapp";
function sendFile(msg) {
log("sendFile msg="+JSON.stringify(msg));
let peer = nfc.getNFCPeer(msg.sessionToken);
ok(peer instanceof MozNFCPeer, "should get a MozNFCPeer");
ok(msg.peer instanceof MozNFCPeer, "should get a MozNFCPeer");
ok(msg.blob instanceof Blob, "should get a Blob");
nfc.peerready = null;

View File

@ -6,13 +6,12 @@ MARIONETTE_HEAD_JS = "head.js";
let url = "https://www.example.com";
function sendNDEF(techType, sessionToken) {
function sendNDEF(techType, peer) {
let tnf = NDEF.TNF_WELL_KNOWN;
let type = new Uint8Array(NfcUtils.fromUTF8("U"));
let payload = new Uint8Array(NfcUtils.fromUTF8(url));
let ndef = [new MozNDEFRecord({tnf: tnf, type: type, payload: payload})];
let peer = window.navigator.mozNfc.getNFCPeer(sessionToken);
let promise = peer.sendNDEF(ndef);
promise.then(() => {
log("Successfully sent NDEF message");
@ -35,7 +34,7 @@ function handleTechnologyDiscoveredRE0(msg) {
is(msg.type, "techDiscovered", "check for correct message type");
let index = msg.techList.indexOf("P2P");
isnot(index, -1, "check for \'P2P\' in tech list");
sendNDEF(msg.techList[index], msg.sessionToken);
sendNDEF(msg.techList[index], msg.peer);
}
function testOnPeerReadyRE0() {