Skip to content

Commit

Permalink
add basic GLU_TESS_MESH test (see TODO in commit for reservations)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Oct 25, 2014
1 parent 0aa6315 commit 7b07b1a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
27 changes: 27 additions & 0 deletions test/basics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ suite('Basic Tests', function() {
boundaryOnly = !boundaryOnly;
}
});
test('GLU_TESS_MESH callback returns something', function() {
// TODO(bckenny): returned mesh is useless in minified form. Decide if
// external mesh interface is worthwhile (can test with checkMesh) or if
// it should just be hidden within
var tess = createTessellator(libtess);
var meshCallbackCalled = false;
tess.gluTessCallback(libtess.gluEnum.GLU_TESS_MESH,
function meshCallback(mesh) {
meshCallbackCalled = true;
assert.isObject(mesh,
'GLU_TESS_MESH callback did not return an object');
});

var resultVerts = [];
tess.gluTessBeginPolygon(resultVerts);
tess.gluTessBeginContour();
tess.gluTessVertex([1, 0, 0], [1, 0, 0]);
tess.gluTessVertex([0, 1, 0], [0, 1, 0]);
tess.gluTessVertex([0, 0, 0], [0, 0, 0]);
tess.gluTessEndContour();
tess.gluTessEndPolygon();

assert.deepEqual(resultVerts, [[1, 0, 0, 0, 1, 0, 0, 0, 0]],
'triangle was not tessellated to itself in GLU_TESS_MESH test');
assert.isTrue(meshCallbackCalled,
'GLU_TESS_MESH callback was not called');
});
});

suite('Basic Geometry', function() {
Expand Down
29 changes: 28 additions & 1 deletion test/browser/tests-browserified.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,33 @@ suite('Basic Tests', function() {
boundaryOnly = !boundaryOnly;
}
});
test('GLU_TESS_MESH callback returns something', function() {
// TODO(bckenny): returned mesh is useless in minified form. Decide if
// external mesh interface is worthwhile (can test with checkMesh) or if
// it should just be hidden within
var tess = createTessellator(libtess);
var meshCallbackCalled = false;
tess.gluTessCallback(libtess.gluEnum.GLU_TESS_MESH,
function meshCallback(mesh) {
meshCallbackCalled = true;
assert.isObject(mesh,
'GLU_TESS_MESH callback did not return an object');
});

var resultVerts = [];
tess.gluTessBeginPolygon(resultVerts);
tess.gluTessBeginContour();
tess.gluTessVertex([1, 0, 0], [1, 0, 0]);
tess.gluTessVertex([0, 1, 0], [0, 1, 0]);
tess.gluTessVertex([0, 0, 0], [0, 0, 0]);
tess.gluTessEndContour();
tess.gluTessEndPolygon();

assert.deepEqual(resultVerts, [[1, 0, 0, 0, 1, 0, 0, 0, 0]],
'triangle was not tessellated to itself in GLU_TESS_MESH test');
assert.isTrue(meshCallbackCalled,
'GLU_TESS_MESH callback was not called');
});
});

suite('Basic Geometry', function() {
Expand Down Expand Up @@ -626,7 +653,7 @@ function testGeometry(geometry) {
* @param {!Array.<!Array.<number>>} contours
* @param {{name: string, value: boolean}} outputType
* @param {{name: string, value: boolean}} provideNormal
* @param {{name: string, value: boolean}} normal
* @param {{name: string, value: !Array.<number>}} normal
* @param {{name: string, value: boolean}} windingRule
* @return {!Array.<!Array.<number>>}
*/
Expand Down
2 changes: 1 addition & 1 deletion test/geometry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function testGeometry(geometry) {
* @param {!Array.<!Array.<number>>} contours
* @param {{name: string, value: boolean}} outputType
* @param {{name: string, value: boolean}} provideNormal
* @param {{name: string, value: boolean}} normal
* @param {{name: string, value: !Array.<number>}} normal
* @param {{name: string, value: boolean}} windingRule
* @return {!Array.<!Array.<number>>}
*/
Expand Down

0 comments on commit 7b07b1a

Please sign in to comment.