Skip to content

Commit

Permalink
[nodejs] Update test-sensor.js for getStreamProfiles method
Browse files Browse the repository at this point in the history
Impacted tests: new 0, update 1, delete 0
Unit test platform: Ubuntu 16.04
Unit test result summary: pass 1, fail 0, block 0
  • Loading branch information
zhaoming0 committed Jul 31, 2018
1 parent 14b04a5 commit d70b836
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions wrappers/nodejs/test/test-sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,36 @@ describe('Sensor test', function() {
}).timeout(5000);

it('Testing method open, profileArray', () => {
sensors.forEach((sensor) => {
const profiles = sensor.getStreamProfiles();
assert.doesNotThrow(() => { // jshint ignore:line
sensor.open(profiles);
sensor.close();
});
});
let dict = {};
let sensor = sensors[0];
let profiles;
assert.doesNotThrow(() => {
profiles = sensor.getStreamProfiles();
});
/* eslint-disable guard-for-in */
for (let i in profiles) {
let strings = '' + profiles[i].widthValue + profiles[i].heightValue +
profiles[i].fps + profiles[i].formatValue;
if (dict.hasOwnProperty(strings)) {
let strs = dict[strings];
strs.push(i);
dict[strings] = strs;
} else {
dict[strings] = [i];
}
}
/* eslint-disable guard-for-in */
for (let m in Object.values(dict)) {
let arr = [];
if (Object.values(dict)[m].length <= 1) continue;
/* eslint-disable guard-for-in */
for (let j in Object.values(dict)[m]) {
arr.push(profiles[Object.values(dict)[m][j]]);
}
sensor.open(arr);
sensor.close();
break;
}
});

it('Testing method open, w/ two args', () => {
Expand Down

0 comments on commit d70b836

Please sign in to comment.