Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit b88e8ef

Browse files
author
Gabriel Schulhof
committed
Tests: Re-introduce presence test in limited fashion
"devicelost" cannot be tested
1 parent f24d489 commit b88e8ef

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

tests/Presence/client.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2016 Intel Corporation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// The file names for client and server are reversed in this test, because the test suite uses the
16+
// file name to decide which to run first ("server.js"). In the case of presence, however, the
17+
// client must run first, because it must catch the announcement from the server when it comes up.
18+
19+
var ocf = require( process.argv[ 3 ] );
20+
21+
console.log( JSON.stringify( { assertionCount: 0 } ) );
22+
23+
ocf.device.name = "test-device-" + process.argv[ 2 ];

tests/Presence/server.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2016 Intel Corporation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// The file names for client and server are reversed in this test, because the test suite uses the
16+
// file name to decide which to run first ("server.js"). In the case of presence, however, the
17+
// client must run first, because it must catch the announcement from the server when it comes up.
18+
19+
var client = require( process.argv[ 3 ] ).client;
20+
21+
console.log( JSON.stringify( { assertionCount: 1 } ) );
22+
23+
client
24+
.on( "devicefound", function( device ) {
25+
if ( device.name === "test-device-" + process.argv[ 2 ] ) {
26+
console.log( JSON.stringify( { assertion: "ok", arguments: [
27+
true, "Client: test device has appeared"
28+
] } ) );
29+
console.log( JSON.stringify( { finished: 0 } ) );
30+
}
31+
} );
32+
33+
console.log( JSON.stringify( { ready: true } ) );

0 commit comments

Comments
 (0)