Added two unit tests for cases where Assimp returned a scene that didn't have a root node:

- NoScene tests that Assimp correctly fails importing an invalid GLTF2 file that doesn't have a scene.

- SceneWithoutNodes tests that Assimp correctly creates an empty root node for GLTF2 files with a scene that has no nodes.
pull/3069/head
Max Vollmer 2020-03-11 15:56:54 +00:00
parent 3f75ef68ae
commit a4bbd9b936
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,6 @@
{
"asset": {
"version": "2.0"
},
"scene": 0
}

View File

@ -0,0 +1,10 @@
{
"asset": {
"version": "2.0"
},
"scene": 0,
"scenes": [
{
}
]
}

View File

@ -493,3 +493,16 @@ TEST_F(utglTF2ImportExport, texcoords) {
EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_UNKNOWN, 0), &uvIndex), aiReturn_SUCCESS); EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_UNKNOWN, 0), &uvIndex), aiReturn_SUCCESS);
EXPECT_EQ(uvIndex, 1); EXPECT_EQ(uvIndex, 1);
} }
TEST_F(utglTF2ImportExport, norootnode_noscene) {
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/TestNoRootNode/NoScene.gltf", aiProcess_ValidateDataStructure);
ASSERT_EQ(scene, nullptr);
}
TEST_F(utglTF2ImportExport, norootnode_scenewithoutnodes) {
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/TestNoRootNode/SceneWithoutNodes.gltf", aiProcess_ValidateDataStructure);
ASSERT_NE(scene, nullptr);
ASSERT_NE(scene->mRootNode, nullptr);
}