Skip to content

Commit

Permalink
Merge branch 'develop' into feature/closecloud_adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Kunovski committed Jun 8, 2017
2 parents 387f7de + 16917dd commit 5512db0
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"trailing": true,
"quotmark": "single",
"proto": true,
"laxbreak": true
"laxbreak": true,
"mocha": true
}

3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module.exports = function(grunt) {
},
files: [
'Gruntfile.js',
'./build/ros3d.js'
'./build/ros3d.js',
'./tests/*.js'
]
},
karma: {
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ros3djs [![Build Status](https://api.travis-ci.org/RobotWebTools/ros3djs.png)](h
=======

#### 3D Visualization Library for use with the ROS JavaScript Libraries
For full documentation, see [the ROS wiki](http://ros.org/wiki/ros3djs) or check out some [working demos](http://robotwebtools.org/).
For full documentation, see [the ROS wiki](http://ros.org/wiki/ros3djs) or check out some [working demos](http://robotwebtools.org/demos.html).

[JSDoc](http://robotwebtools.org/jsdoc/ros3djs/current/) can be found on the Robot Web Tools website.

Expand Down Expand Up @@ -89,6 +89,11 @@ To run the build tasks:

`grunt doc` will rebuild all JSDoc for the project.

### Testing
Utilizes [mocha](https://mochajs.org/) and [chai](http://chaijs.com/) for in browser testing.

To run tests simply open `tests/index.html` in a web browser

### License
ros3djs is released with a BSD license. For full terms and conditions, see the [LICENSE](LICENSE) file.

Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"license": "BSD-3-Clause",
"main": "./src/Ros3D.js",
"devDependencies": {
"chai": "^3.5.0",
"grunt": "~1.0.1",
"grunt-contrib-clean": "~1.0.0",
"grunt-contrib-concat": "~1.0.1",
"grunt-contrib-jshint": "~1.1.0",
"grunt-karma": "~2.0.0",
"grunt-contrib-watch": "~1.0.0",
"grunt-contrib-uglify": "~2.0.0",
"grunt-contrib-watch": "~1.0.0",
"grunt-jsdoc": "~2.1.0",
"grunt-contrib-clean": "~1.0.0"
"grunt-karma": "~2.0.0",
"mocha": "^3.2.0"
},
"repository": {
"type": "git",
Expand Down
25 changes: 25 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tests</title>
<link rel="stylesheet" media="all" href="../node_modules/mocha/mocha.css">
</head>
<body>
<div id="mocha"><p>ros3d.js Tests</p></div>
<div id="messages"></div>
<div id="fixtures"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="https://cdn.jsdelivr.net/lodash/4.17.4/lodash.core.min.js"></script>

<script src="http://cdn.robotwebtools.org/threejs/current/three.js"></script>
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="../build/ros3d.js"></script>

<script>mocha.setup('bdd')</script>
<script src="tests.js"></script>
<script>mocha.run();</script>
</body>
</html>
67 changes: 67 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*global describe, it, before, beforeEach, after, afterEach, chai, ROS3D, _ */

var assert = chai.assert;

describe('Initialization', function() {


describe('Arrow', function() {
var arrow = new ROS3D.Arrow();

it('matrix should be equal to the proper Matrix4', function() {
var a = new THREE.Vector3(0, 1, 0);
arrow.setDirection(a);
var b = new THREE.Matrix4();
b.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
assert.isTrue(_.isEqual(arrow.matrix.toArray(), b.toArray()));
});

it('scale should be equal to THREE.Vector3(2, 2, 2)', function() {
arrow.setLength(2);
assert.isTrue(arrow.scale.equals(new THREE.Vector3(2, 2, 2)));
});

it('material.color should be equal to THREE.Color(0xfff000)', function() {
arrow.setColor(0xfff000);
assert.equal(arrow.material.color.getHex(), new THREE.Color(0xfff000).getHex());
});

});

describe('depthCloud', function() {
// Setup Kinect DepthCloud stream
var depthCloud = new ROS3D.DepthCloud({
url : 'http://'+window.location.hostname+':9999/stream?topic=/depthcloud_encoded&type=vp8&bitrate=250000&quality=best',
f : 525.0
});

it('should return 525.0 for value of f', function() {
assert.equal(525.0, depthCloud.f);
});
});

describe('Grid', function() {
var grid = new ROS3D.Grid();

it('should default to 22 children', function() {
assert.equal(grid.children.length, 22);
});

it('each child\'s color is THREE.Color(\'#cccccc\') by default', function() {
var sample = new THREE.Color('#cccccc').getHex();
function correctColor(element, index, array) {
return element.material.color.getHex() === sample;
}
assert.isTrue(grid.children.every(correctColor));
});

it('each child\'s linewidth is 1 by default', function() {
function isOne(element, index, array) {
return element.material.linewidth === 1;
}
assert.isTrue(grid.children.every(isOne));
});

});

});

0 comments on commit 5512db0

Please sign in to comment.