forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-streamprofile.js
154 lines (135 loc) · 3.71 KB
/
test-streamprofile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright (c) 2017 Intel Corporation. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license
// that can be found in the LICENSE file.
'use strict';
/* global describe, it, before, after */
const assert = require('assert');
let rs2;
try {
rs2 = require('node-librealsense');
} catch (e) {
rs2 = require('../index.js');
}
let ctx;
let pipeline;
let pipelineProfile;
let streamProfiles;
describe('StreamProfile test', function() {
before(function() {
ctx = new rs2.Context();
const devices = ctx.queryDevices().devices;
assert(devices.length > 0); // Device must be connected
pipeline = new rs2.Pipeline(ctx);
pipeline.start();
pipelineProfile = pipeline.getActiveProfile();
streamProfiles = pipelineProfile.getStreams();
});
after(function() {
pipeline.stop();
pipeline.destroy();
rs2.cleanup();
});
it('Testing constructor - 0 option', () => {
assert.throws(() => {
new rs2.StreamProfile();
});
});
it('Testing member - streamIndex', () => {
streamProfiles.forEach( (stream) => {
assert.equal(typeof stream.streamIndex, 'number');
});
});
it('Testing member - streamType', () => {
streamProfiles.forEach( (stream) => {
assert.equal(typeof stream.streamType, 'number');
});
});
it('Testing member - format', () => {
streamProfiles.forEach( (stream) => {
assert.equal(typeof stream.format, 'number');
});
});
it('Testing member - fps', () => {
streamProfiles.forEach( (stream) => {
assert.equal(typeof stream.fps, 'number');
});
});
it('Testing member - uniqueID', () => {
streamProfiles.forEach( (stream) => {
assert.equal(typeof stream.uniqueID, 'number');
});
});
it('Testing member - isDefault', () => {
streamProfiles.forEach( (stream) => {
assert.equal(typeof stream.isDefault, 'boolean');
});
});
it('Testing method getExtrinsicsTo - 0 argument', () => {
streamProfiles.forEach( (stream) => {
assert.throws(() => {
stream.getExtrinsicsTo();
});
});
});
it('Testing method getExtrinsicsTo - valid argument', () => {
let ExtrinsicsObject;
assert.doesNotThrow(() => {
ExtrinsicsObject = streamProfiles[0].getExtrinsicsTo(streamProfiles[1]);
});
assert.equal(Object.prototype.toString.call(ExtrinsicsObject.rotation), '[object Array]');
});
it('Testing method getExtrinsicsTo - invalid argument', () => {
assert.throws(() => {
streamProfiles[0].getExtrinsicsTo('dummy');
});
});
it('Testing method streamToString - with stream number', () => {
const streams = [
'any',
'depth',
'color',
'infrared',
'fisheye',
'gyro',
'accel',
'gpio',
'pose',
'confidence',
];
assert.doesNotThrow(() => {
for (let i = rs2.stream.STREAM_ANY; i < rs2.stream.STREAM_COUNT; i++) {
let res = rs2.stream.streamToString(i);
assert.equal(res, streams[i]);
}
});
});
it('Testing method streamToString - with two arguments', () => {
assert.throws(() => {
rs2.stream.streamToString(1, 1);
});
});
it('Testing method streamToString - without argument', () => {
assert.throws(() => {
rs2.stream.streamToString();
});
});
it('Testing method streamToString - with stream string', () => {
const streams = [
'stream_any',
'stream_depth',
'stream_color',
'stream_infrared',
'stream_fisheye',
'stream_gyro',
'stream_accel',
'stream_gpio',
'stream_pose',
'stream_confidence',
];
streams.forEach((s) => {
assert.doesNotThrow(() => {
rs2.stream.streamToString(rs2.stream[s]);
});
});
});
});