Add a test for gltf2 and FBX metadata.

pull/2810/head
Malcolm Tyrrell 2019-12-05 14:05:49 +00:00
parent 81984002d3
commit 6639d5180b
3 changed files with 78 additions and 23 deletions

View File

@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/material.h> #include <assimp/material.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/types.h> #include <assimp/types.h>
#include <assimp/commonMetaData.h>
using namespace Assimp; using namespace Assimp;
@ -283,3 +284,29 @@ TEST_F(utFBXImporterExporter, importOrphantEmbeddedTextureTest) {
ASSERT_TRUE(scene->mTextures[0]->pcData); ASSERT_TRUE(scene->mTextures[0]->pcData);
ASSERT_EQ(9026u, scene->mTextures[0]->mWidth) << "FBX ASCII base64 compression used for a texture."; ASSERT_EQ(9026u, scene->mTextures[0]->mWidth) << "FBX ASCII base64 compression used for a texture.";
} }
TEST_F(utFBXImporterExporter, sceneMetadata) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/global_settings.fbx",
aiProcess_ValidateDataStructure);
ASSERT_NE(scene, nullptr);
ASSERT_NE(scene->mMetaData, nullptr);
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT));
aiString format;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, format));
ASSERT_EQ(strcmp(format.C_Str(), "Autodesk FBX Importer"), 0);
}
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT_VERSION));
aiString version;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT_VERSION, version));
ASSERT_EQ(strcmp(version.C_Str(), "7400"), 0);
}
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_GENERATOR));
aiString generator;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, generator));
ASSERT_EQ(strncmp(generator.C_Str(), "Blender", 7), 0);
}
}

View File

@ -45,6 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Exporter.hpp> #include <assimp/Exporter.hpp>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/commonMetaData.h>
#include <array> #include <array>
using namespace Assimp; using namespace Assimp;
@ -436,3 +438,29 @@ TEST_F(utglTF2ImportExport, error_string_preserved) {
} }
#endif // ASSIMP_BUILD_NO_EXPORT #endif // ASSIMP_BUILD_NO_EXPORT
TEST_F(utglTF2ImportExport, sceneMetadata) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf",
aiProcess_ValidateDataStructure);
ASSERT_NE(scene, nullptr);
ASSERT_NE(scene->mMetaData, nullptr);
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT));
aiString format;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, format));
ASSERT_EQ(strcmp(format.C_Str(), "glTF2 Importer"), 0);
}
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT_VERSION));
aiString version;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT_VERSION, version));
ASSERT_EQ(strcmp(version.C_Str(), "2.0"), 0);
}
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_GENERATOR));
aiString generator;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, generator));
ASSERT_EQ(strcmp(generator.C_Str(), "COLLADA2GLTF"), 0);
}
}

View File

@ -64,6 +64,29 @@ TEST_F( utglTFImportExport, importglTFFromFileTest ) {
EXPECT_TRUE( importerTest() ); EXPECT_TRUE( importerTest() );
} }
TEST_F(utglTFImportExport, incorrect_vertex_arrays) {
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF/IncorrectVertexArrays/Cube_v1.gltf",
aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 36u);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 12u);
EXPECT_EQ(scene->mMeshes[1]->mNumVertices, 35u);
EXPECT_EQ(scene->mMeshes[1]->mNumFaces, 11u);
EXPECT_EQ(scene->mMeshes[2]->mNumVertices, 36u);
EXPECT_EQ(scene->mMeshes[2]->mNumFaces, 18u);
EXPECT_EQ(scene->mMeshes[3]->mNumVertices, 35u);
EXPECT_EQ(scene->mMeshes[3]->mNumFaces, 17u);
EXPECT_EQ(scene->mMeshes[4]->mNumVertices, 36u);
EXPECT_EQ(scene->mMeshes[4]->mNumFaces, 12u);
EXPECT_EQ(scene->mMeshes[5]->mNumVertices, 35u);
EXPECT_EQ(scene->mMeshes[5]->mNumFaces, 11u);
EXPECT_EQ(scene->mMeshes[6]->mNumVertices, 36u);
EXPECT_EQ(scene->mMeshes[6]->mNumFaces, 18u);
EXPECT_EQ(scene->mMeshes[7]->mNumVertices, 35u);
EXPECT_EQ(scene->mMeshes[7]->mNumFaces, 17u);
}
TEST_F(utglTFImportExport, sceneMetadata) { TEST_F(utglTFImportExport, sceneMetadata) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", aiProcess_ValidateDataStructure);
@ -88,26 +111,3 @@ TEST_F(utglTFImportExport, sceneMetadata) {
ASSERT_EQ(strncmp(generator.C_Str(), "collada2gltf", 12), 0); ASSERT_EQ(strncmp(generator.C_Str(), "collada2gltf", 12), 0);
} }
} }
TEST_F(utglTFImportExport, incorrect_vertex_arrays) {
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF/IncorrectVertexArrays/Cube_v1.gltf",
aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 36u);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 12u);
EXPECT_EQ(scene->mMeshes[1]->mNumVertices, 35u);
EXPECT_EQ(scene->mMeshes[1]->mNumFaces, 11u);
EXPECT_EQ(scene->mMeshes[2]->mNumVertices, 36u);
EXPECT_EQ(scene->mMeshes[2]->mNumFaces, 18u);
EXPECT_EQ(scene->mMeshes[3]->mNumVertices, 35u);
EXPECT_EQ(scene->mMeshes[3]->mNumFaces, 17u);
EXPECT_EQ(scene->mMeshes[4]->mNumVertices, 36u);
EXPECT_EQ(scene->mMeshes[4]->mNumFaces, 12u);
EXPECT_EQ(scene->mMeshes[5]->mNumVertices, 35u);
EXPECT_EQ(scene->mMeshes[5]->mNumFaces, 11u);
EXPECT_EQ(scene->mMeshes[6]->mNumVertices, 36u);
EXPECT_EQ(scene->mMeshes[6]->mNumFaces, 18u);
EXPECT_EQ(scene->mMeshes[7]->mNumVertices, 35u);
EXPECT_EQ(scene->mMeshes[7]->mNumFaces, 17u);
}