Skip to content

Commit

Permalink
updated tests for segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
hamaluik committed Apr 4, 2018
1 parent 8f62248 commit 6bef658
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 49 deletions.
68 changes: 39 additions & 29 deletions test/gltf/TestLoading.hx
Expand Up @@ -7,22 +7,22 @@ import haxe.io.Bytes;
import haxe.ds.Vector;

class TestLoading extends BuddySuite {
public function new() {
describe('Loading GLTFs', {
var boxSrc:String = sys.io.File.getContent('samples/Box.gltf');
public function new() {
describe('Loading GLTFs', {
var boxSrc:String = sys.io.File.getContent('samples/Box.gltf');
var boxBin:Bytes = sys.io.File.getBytes('samples/Box0.bin');
var boxRaw:TGLTF = GLTF.parse(boxSrc);
var boxObject:GLTF = GLTF.load(boxRaw, [boxBin]);
var boxRaw:TGLTF = GLTF.parse(boxSrc);
var boxObject:GLTF = GLTF.load(boxRaw, [boxBin]);

var boxTexturedSrc:String = sys.io.File.getContent('samples/BoxTextured.gltf');
var boxTexturedSrc:String = sys.io.File.getContent('samples/BoxTextured.gltf');
var boxTexturedBin:Bytes = sys.io.File.getBytes('samples/BoxTextured0.bin');
var boxTexturedRaw:TGLTF = GLTF.parse(boxTexturedSrc);
var boxTexturedObject:GLTF = GLTF.load(boxTexturedRaw, [boxTexturedBin]);
var boxTexturedRaw:TGLTF = GLTF.parse(boxTexturedSrc);
var boxTexturedObject:GLTF = GLTF.load(boxTexturedRaw, [boxTexturedBin]);

var riggedSimpleSrc:String = sys.io.File.getContent('samples/RiggedSimple.gltf');
var riggedSimpleSrc:String = sys.io.File.getContent('samples/RiggedSimple.gltf');
var riggedSimpleBin:Bytes = sys.io.File.getBytes('samples/RiggedSimple0.bin');
var riggedSimpleRaw:TGLTF = GLTF.parse(riggedSimpleSrc);
var riggedSimpleObject:GLTF = GLTF.load(riggedSimpleRaw, [riggedSimpleBin]);
var riggedSimpleRaw:TGLTF = GLTF.parse(riggedSimpleSrc);
var riggedSimpleObject:GLTF = GLTF.load(riggedSimpleRaw, [riggedSimpleBin]);

it("should load an array of buffers", {
boxObject.buffers.length.should.be(1);
Expand All @@ -49,12 +49,12 @@ class TestLoading extends BuddySuite {
boxObject.accessors[2].type.should.be(gltf.schema.TAttributeType.VEC3);
});

it("should load an array of cameras", {
it("should load an array of cameras", {
// TODO: better model test for cameras
boxObject.cameras.length.should.be(0);
});
it("should load an array of meshes", {

it("should load an array of meshes", {
boxObject.meshes.length.should.be(1);
boxObject.meshes[0].primitives.length.should.be(1);
boxObject.meshes[0].primitives[0].attributes.length.should.be(2);
Expand All @@ -74,26 +74,26 @@ class TestLoading extends BuddySuite {
//trace('normals: ' + boxObject.meshes[0].primitives[0].getFloatAttributeValues("NORMAL"));
});

it("should load an array of skins", {
it("should load an array of skins", {
riggedSimpleObject.skins.length.should.be(1);
riggedSimpleObject.skins[0].skeleton.should.not.be(null);
riggedSimpleObject.skins[0].joints.length.should.be(2);
riggedSimpleObject.skins[0].inverseBindMatrices.length.should.be(2);
});

it("should load an array of nodes", {
boxObject.nodes.length.should.be(2);
boxObject.nodes[0].children.length.should.be(1);
boxObject.nodes[0].matrix.should.not.be(null);
boxObject.nodes[1].mesh.should.not.be(null);
});
it("should load an array of nodes", {
boxObject.nodes.length.should.be(2);
boxObject.nodes[0].children.length.should.be(1);
boxObject.nodes[0].matrix.should.not.be(null);
boxObject.nodes[1].mesh.should.not.be(null);
});

it("should load an array of scenes and set the default scene", {
boxObject.scenes.length.should.be(1);
boxObject.scenes[0].nodes.length.should.be(1);
boxObject.scenes[0].nodes[0].should.be(boxObject.nodes[0]);
boxObject.defaultScene.should.be(boxObject.scenes[0]);
});
it("should load an array of scenes and set the default scene", {
boxObject.scenes.length.should.be(1);
boxObject.scenes[0].nodes.length.should.be(1);
boxObject.scenes[0].nodes[0].should.be(boxObject.nodes[0]);
boxObject.defaultScene.should.be(boxObject.scenes[0]);
});

it("should load an array of images", {
boxTexturedObject.images.length.should.be(1);
Expand All @@ -110,6 +110,16 @@ class TestLoading extends BuddySuite {
boxTexturedObject.textures[0].image.should.be(boxTexturedObject.images[0]);
boxTexturedObject.textures[0].sampler.should.be(boxTexturedObject.samplers[0]);
});
});
}

it('should load all nodes', {
riggedSimpleObject.nodes.length.should.be(5);
});

it('should load the skins appropriately', {
riggedSimpleObject.nodes[1].skin.should.be(riggedSimpleObject.skins[0]);
});

it("should load animations");
});
}
}
106 changes: 88 additions & 18 deletions test/gltf/TestParsing.hx
Expand Up @@ -5,27 +5,97 @@ import buddy.*;
using buddy.Should;

class TestParsing extends BuddySuite {
public function new() {
describe('Parsing GLTF', {
var boxSrc:String = sys.io.File.getContent('samples/Box.gltf');
public function new() {
describe('Parsing GLTF', {
var boxSrc:String = sys.io.File.getContent('samples/Box.gltf');
var riggedSimpleSrc:String = sys.io.File.getContent('samples/RiggedSimple.gltf');
var riggedSimpleRaw:TGLTF = GLTF.parse(riggedSimpleSrc);

it("should parse gltf files", {
var raw:TGLTF = GLTF.parse(boxSrc);
it("should parse gltf files", {
var raw:TGLTF = GLTF.parse(boxSrc);

raw.asset.generator.should.be("COLLADA2GLTF");
raw.asset.version.should.be("2.0");
raw.asset.generator.should.be("COLLADA2GLTF");
raw.asset.version.should.be("2.0");

raw.scene.should.be(0);
raw.scenes.length.should.be(1);
raw.scenes[0].nodes.length.should.be(1);
raw.scenes[0].nodes[0].should.be(0);
raw.scene.should.be(0);
raw.scenes.length.should.be(1);
raw.scenes[0].nodes.length.should.be(1);
raw.scenes[0].nodes[0].should.be(0);

raw.nodes.length.should.be(2);
raw.nodes[0].children.length.should.be(1);
raw.nodes[1].children.should.be(null);
});
raw.nodes.length.should.be(2);
raw.nodes[0].children.length.should.be(1);
raw.nodes[1].children.should.be(null);
});

it("should parse glb files");
});
}
it('should parse all nodes', {
riggedSimpleRaw.nodes.length.should.be(5);
});

it('should parse children arrays', {
riggedSimpleRaw.nodes[0].children.should.not.be(null);
riggedSimpleRaw.nodes[0].children.length.should.be(2);
riggedSimpleRaw.nodes[0].children[0].should.be(4);
riggedSimpleRaw.nodes[0].children[1].should.be(1);
riggedSimpleRaw.nodes[4].children.should.not.be(null);
if(riggedSimpleRaw.nodes[4].children != null) {
riggedSimpleRaw.nodes[4].children.length.should.be(1);
riggedSimpleRaw.nodes[4].children[0].should.be(2);
}
riggedSimpleRaw.nodes[1].children.should.be(null);
});

it('should parse matrices', {
riggedSimpleRaw.nodes[0].matrix.length.should.be(16);
riggedSimpleRaw.nodes[0].matrix[6].should.be(-1.0);
});

it('should parse mesh and skin', {
if(riggedSimpleRaw.nodes[0].mesh != null) fail('node 0 mesh is not null');
if(riggedSimpleRaw.nodes[0].skin != null) fail('node 0 skin is not null');

riggedSimpleRaw.nodes[1].mesh.should.be(0);
riggedSimpleRaw.nodes[1].skin.should.be(0);
});

it('should auto-supply matrix and transform components', {
riggedSimpleRaw.nodes[0].translation.should.not.be(null);
riggedSimpleRaw.nodes[1].matrix.should.not.be(null);
});

it('should load the animations', {
riggedSimpleRaw.animations.should.not.be(null);
riggedSimpleRaw.animations.length.should.be(1);
});

it('should load the animation channels', {
riggedSimpleRaw.animations[0].channels.should.not.be(null);
riggedSimpleRaw.animations[0].channels.length.should.be(6);

riggedSimpleRaw.animations[0].channels[0].should.not.be(null);
riggedSimpleRaw.animations[0].channels[1].should.not.be(null);
riggedSimpleRaw.animations[0].channels[2].should.not.be(null);
riggedSimpleRaw.animations[0].channels[3].should.not.be(null);
riggedSimpleRaw.animations[0].channels[4].should.not.be(null);
riggedSimpleRaw.animations[0].channels[5].should.not.be(null);

riggedSimpleRaw.animations[0].channels[5].sampler.should.be(5);
riggedSimpleRaw.animations[0].channels[5].target.node.should.be(3);
riggedSimpleRaw.animations[0].channels[5].target.path.should.be(gltf.schema.TAnimationChannelTargetPath.SCALE);
});

it('should load the animation samplers', {
riggedSimpleRaw.animations[0].samplers.should.not.be(null);
riggedSimpleRaw.animations[0].samplers.length.should.be(6);

riggedSimpleRaw.animations[0].samplers[0].should.not.be(null);
riggedSimpleRaw.animations[0].samplers[1].should.not.be(null);
riggedSimpleRaw.animations[0].samplers[2].should.not.be(null);
riggedSimpleRaw.animations[0].samplers[3].should.not.be(null);
riggedSimpleRaw.animations[0].samplers[4].should.not.be(null);
riggedSimpleRaw.animations[0].samplers[5].should.not.be(null);
});

it("should parse glb files");
});
}
}
2 changes: 1 addition & 1 deletion test/test.cpp.hxml
@@ -1,4 +1,4 @@
test.each.hxml
-cpp bin
-cmd bin\\TestMain.exe
-cmd bin/TestMain-debug
-D HXCPP_M64
2 changes: 1 addition & 1 deletion test/test.java.hxml
@@ -1,3 +1,3 @@
test.each.hxml
-java bin
-cmd java -jar bin/TestMain.jar
-cmd java -jar bin/TestMain-Debug.jar

0 comments on commit 6bef658

Please sign in to comment.