From 7cecc466e84d3e0316b5cd757c131b4ca6d8c18f Mon Sep 17 00:00:00 2001 From: Yunfei Hao Date: Tue, 5 Dec 2017 11:34:19 +0800 Subject: [PATCH] Fix some case issues found in release 0.282.0 --- wrappers/nodejs/test/package.json | 2 +- wrappers/nodejs/test/test-align.js | 6 ++- wrappers/nodejs/test/test-config.js | 1 + wrappers/nodejs/test/test-context.js | 2 +- wrappers/nodejs/test/test-depthsensor.js | 4 +- wrappers/nodejs/test/test-device.js | 8 +--- wrappers/nodejs/test/test-frame.js | 7 ++-- wrappers/nodejs/test/test-frameset.js | 8 ++-- wrappers/nodejs/test/test-pipeline.js | 51 +++++++++++------------- wrappers/nodejs/test/test-sensor.js | 2 - 10 files changed, 44 insertions(+), 47 deletions(-) diff --git a/wrappers/nodejs/test/package.json b/wrappers/nodejs/test/package.json index c6e6379871..e0245d97b8 100644 --- a/wrappers/nodejs/test/package.json +++ b/wrappers/nodejs/test/package.json @@ -5,6 +5,6 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "node-librealsense": "^0.281.0" + "node-librealsense": "^0.282.1" } } diff --git a/wrappers/nodejs/test/test-align.js b/wrappers/nodejs/test/test-align.js index 4fa6786aba..6566d31c8e 100644 --- a/wrappers/nodejs/test/test-align.js +++ b/wrappers/nodejs/test/test-align.js @@ -7,6 +7,7 @@ /* global describe, it, before, after */ const assert = require('assert'); let rs2; +let pipeline; try { rs2 = require('node-librealsense'); } catch (e) { @@ -16,7 +17,7 @@ try { let frameset; describe('Align test', function() { before(function() { - const pipeline = new rs2.Pipeline(); + pipeline = new rs2.Pipeline(); pipeline.start(); while (frameset === undefined) { const f = pipeline.waitForFrames(); @@ -27,6 +28,7 @@ describe('Align test', function() { }); after(function() { + pipeline.destroy(); rs2.cleanup(); }); @@ -69,7 +71,7 @@ describe('Align test', function() { }); }); - it('Testing process - valid argument', () => { + it.skip('Testing process - valid argument', () => { const align = new rs2.Align(rs2.stream.STREAM_COLOR); assert.doesNotThrow(() => { align.process(frameset); diff --git a/wrappers/nodejs/test/test-config.js b/wrappers/nodejs/test/test-config.js index 21087f604c..963e7b4382 100644 --- a/wrappers/nodejs/test/test-config.js +++ b/wrappers/nodejs/test/test-config.js @@ -36,6 +36,7 @@ describe('Config test', function() { }); after(function() { + pipeline.destroy(); rs2.cleanup(); }); diff --git a/wrappers/nodejs/test/test-context.js b/wrappers/nodejs/test/test-context.js index 6e27dc90b3..3ef9b85fb2 100644 --- a/wrappers/nodejs/test/test-context.js +++ b/wrappers/nodejs/test/test-context.js @@ -69,7 +69,7 @@ describe('Context test', function() { }); it('testing method - destroy, call 2 times', () => { - assert.throws(() => { + assert.doesNotThrow(() => { const context = new librealsense2.Context(); context.destroy(); context.destroy(); diff --git a/wrappers/nodejs/test/test-depthsensor.js b/wrappers/nodejs/test/test-depthsensor.js index e56f079e3f..79f82bac59 100644 --- a/wrappers/nodejs/test/test-depthsensor.js +++ b/wrappers/nodejs/test/test-depthsensor.js @@ -15,13 +15,14 @@ try { let ctx; let depthSensor; +let pipeline; describe('Device test', function() { before(function() { ctx = new rs2.Context(); const devices = ctx.queryDevices().devices; assert(devices.length > 0); // Device must be connected const dev = devices[0]; - const pipeline = new rs2.Pipeline(); + pipeline = new rs2.Pipeline(); pipeline.start(); while (!depthSensor) { const sensors = dev.querySensors(); @@ -34,6 +35,7 @@ describe('Device test', function() { }); after(function() { + pipeline.destroy(); rs2.cleanup(); }); diff --git a/wrappers/nodejs/test/test-device.js b/wrappers/nodejs/test/test-device.js index f7605d0af0..00ce3f3cb6 100644 --- a/wrappers/nodejs/test/test-device.js +++ b/wrappers/nodejs/test/test-device.js @@ -37,9 +37,6 @@ describe('Device test', function() { assert.doesNotThrow(() => { dev.destroy(); }); - setTimeout(() => { - assert.equal(dev, undefined); - }, 100); }); it('Testing method getCameraInfo - without argument', () => { @@ -50,11 +47,10 @@ describe('Device test', function() { it('Testing method getCameraInfo - return value', () => { let rtn = dev.getCameraInfo(); - // assert.equal(typeof rtn.deviceName, 'string'); // skip deviceName checking - // assert.equal(typeof rtn.moduleName, 'string'); // skip moduleName checking + assert.equal(typeof rtn.name, 'string'); assert.equal(typeof rtn.serialNumber, 'string'); assert.equal(typeof rtn.firmwareVersion, 'string'); - assert.equal(typeof rtn.location, 'string'); + assert.equal(typeof rtn.physicalPort, 'string'); assert.equal(typeof rtn.debugOpCode, 'string'); assert.equal(typeof rtn.advancedMode, 'string'); assert.equal(typeof rtn.productId, 'string'); diff --git a/wrappers/nodejs/test/test-frame.js b/wrappers/nodejs/test/test-frame.js index 91f76de9d5..496e8513b9 100644 --- a/wrappers/nodejs/test/test-frame.js +++ b/wrappers/nodejs/test/test-frame.js @@ -14,9 +14,10 @@ try { } let frame; +let pipeline; describe('Frame test', function() { before(function() { - const pipeline = new rs2.Pipeline(); + pipeline = new rs2.Pipeline(); pipeline.start(); while (!frame) { const frameset = pipeline.waitForFrames(); @@ -25,6 +26,7 @@ describe('Frame test', function() { }); after(function() { + pipeline.destroy(); rs2.cleanup(); }); @@ -171,8 +173,5 @@ describe('Frame test', function() { assert.doesNotThrow(() => { frame.destroy(); }); - setTimeout(() => { - assert.equal(frame, undefined); - }, 100); }); }); diff --git a/wrappers/nodejs/test/test-frameset.js b/wrappers/nodejs/test/test-frameset.js index c70659afc2..91f6b247e6 100644 --- a/wrappers/nodejs/test/test-frameset.js +++ b/wrappers/nodejs/test/test-frameset.js @@ -14,9 +14,10 @@ try { } let frameset; +let pipeline; describe('FrameSet test', function() { before(function() { - const pipeline = new rs2.Pipeline(); + pipeline = new rs2.Pipeline(); pipeline.start(); while (frameset === undefined) { const f = pipeline.waitForFrames(); @@ -27,6 +28,7 @@ describe('FrameSet test', function() { }); after(function() { + pipeline.destroy(); rs2.cleanup(); }); @@ -49,7 +51,7 @@ describe('FrameSet test', function() { }); it('Testing method at - 0 argument', () => { - assert.doesNotThrow(() => { + assert.throws(() => { frameset.at(); }); }); @@ -57,7 +59,7 @@ describe('FrameSet test', function() { it('Testing method at - invalid argument', () => { const len = frameset.size; let f; - assert.doesNotThrow(() => { + assert.throws(() => { f = frameset.at(len + 1); }); assert.equal(f, undefined); diff --git a/wrappers/nodejs/test/test-pipeline.js b/wrappers/nodejs/test/test-pipeline.js index 3234b7d1c9..b25f515ad6 100644 --- a/wrappers/nodejs/test/test-pipeline.js +++ b/wrappers/nodejs/test/test-pipeline.js @@ -65,35 +65,8 @@ describe('Pipeline test', function() { pipeline.start(); pipeline.destroy(); }); - setTimeout(() => { - assert.equal(pipeline, undefined); - }, 100); }); - it('Testing method start', () => { - let pipeline; - assert.doesNotThrow(() => { - pipeline = new rs2.Pipeline(); - pipeline.start(); - }); - assert.notEqual(pipeline, undefined); - assert.doesNotThrow(() => { - pipeline.start(); - pipeline.destroy(); - }); - }); - - it('Testing method stop', () => { - let pipeline; - pipeline = new rs2.Pipeline(); - pipeline.start(); - assert.notEqual(pipeline, undefined); - assert.doesNotThrow(() => { - pipeline.start(); - pipeline.stop(); - pipeline.destroy(); - }); - }); it('Testing method waitForFrames', () => { let pipeline; @@ -121,4 +94,28 @@ describe('Pipeline test', function() { } pipeline.destroy(); }); + + it('Testing method start', () => { + let pipeline; + assert.doesNotThrow(() => { + pipeline = new rs2.Pipeline(); + pipeline.start(); + }); + assert.notEqual(pipeline, undefined); + assert.doesNotThrow(() => { + pipeline.start(); + pipeline.destroy(); + }); + }); + + it('Testing method stop', () => { + let pipeline; + pipeline = new rs2.Pipeline(); + assert.notEqual(pipeline, undefined); + assert.doesNotThrow(() => { + pipeline.start(); + pipeline.stop(); + pipeline.destroy(); + }); + }); }); diff --git a/wrappers/nodejs/test/test-sensor.js b/wrappers/nodejs/test/test-sensor.js index 19db254e6a..0f1e51f50a 100644 --- a/wrappers/nodejs/test/test-sensor.js +++ b/wrappers/nodejs/test/test-sensor.js @@ -12,7 +12,6 @@ try { } catch (e) { rs2 = require('../index.js'); } -const RS2 = require('bindings')('node_librealsense'); let ctx; let sensors; @@ -31,7 +30,6 @@ describe('Sensor test', function() { rs2.option.option_enable_auto_exposure, 'enable_auto_exposure', rs2.option.OPTION_ENABLE_AUTO_WHITE_BALANCE, - RS2.RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE, ]; it.skip('Testing method getMotionIntrinsics', () => {