New tests for importers.

pull/1090/head
Kim Kulling 2016-12-01 10:29:39 +01:00
parent c80777f13f
commit edfb3fc410
11 changed files with 356 additions and 102 deletions

View File

@ -193,7 +193,6 @@ public:
*/ */
aiReturn UnregisterPPStep(BaseProcess* pImp); aiReturn UnregisterPPStep(BaseProcess* pImp);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Set an integer configuration property. /** Set an integer configuration property.
* @param szName Name of the property. All supported properties * @param szName Name of the property. All supported properties
@ -292,10 +291,10 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Supplies a custom IO handler to the importer to use to open and /** Supplies a custom IO handler to the importer to use to open and
* access files. If you need the importer to use custion IO logic to * access files. If you need the importer to use custom IO logic to
* access the files, you need to provide a custom implementation of * access the files, you need to provide a custom implementation of
* IOSystem and IOFile to the importer. Then create an instance of * IOSystem and IOFile to the importer. Then create an instance of
* your custion IOSystem implementation and supply it by this function. * your custom IOSystem implementation and supply it by this function.
* *
* The Importer takes ownership of the object and will destroy it * The Importer takes ownership of the object and will destroy it
* afterwards. The previously assigned handler will be deleted. * afterwards. The previously assigned handler will be deleted.
@ -357,7 +356,7 @@ public:
bool IsDefaultProgressHandler() const; bool IsDefaultProgressHandler() const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Check whether a given set of postprocessing flags /** @brief Check whether a given set of post-processing flags
* is supported. * is supported.
* *
* Some flags are mutually exclusive, others are probably * Some flags are mutually exclusive, others are probably
@ -517,9 +516,6 @@ public:
* It will work as well for static linkage with Assimp.*/ * It will work as well for static linkage with Assimp.*/
aiScene* GetOrphanedScene(); aiScene* GetOrphanedScene();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns whether a given file extension is supported by ASSIMP. /** Returns whether a given file extension is supported by ASSIMP.
* *
@ -558,7 +554,7 @@ public:
inline void GetExtensionList(std::string& szOut) const; inline void GetExtensionList(std::string& szOut) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Get the number of importrs currently registered with Assimp. */ /** Get the number of importers currently registered with Assimp. */
size_t GetImporterCount() const; size_t GetImporterCount() const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -601,9 +597,6 @@ public:
* @return (size_t)-1 if no importer is found */ * @return (size_t)-1 if no importer is found */
size_t GetImporterIndex (const char* szExtension) const; size_t GetImporterIndex (const char* szExtension) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns the storage allocated by ASSIMP to hold the scene data /** Returns the storage allocated by ASSIMP to hold the scene data
* in memory. * in memory.
@ -624,7 +617,6 @@ public:
* intended for use in production environments. */ * intended for use in production environments. */
void SetExtraVerbose(bool bDo); void SetExtraVerbose(bool bDo);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Private, do not use. */ /** Private, do not use. */
ImporterPimpl* Pimpl() { return pimpl; } ImporterPimpl* Pimpl() { return pimpl; }

View File

@ -55,6 +55,7 @@ SOURCE_GROUP( unit FILES
) )
SET( TEST_SRCS SET( TEST_SRCS
unit/AbstractImportExportBase.cpp
unit/TestIOSystem.h unit/TestIOSystem.h
unit/TestModelFactory.h unit/TestModelFactory.h
unit/utAnim.cpp unit/utAnim.cpp
@ -101,6 +102,7 @@ SET( TEST_SRCS
unit/utTypes.cpp unit/utTypes.cpp
unit/utVertexTriangleAdjacency.cpp unit/utVertexTriangleAdjacency.cpp
unit/utVersion.cpp unit/utVersion.cpp
unit/utXImporterExporter.cpp
) )
SOURCE_GROUP( tests FILES ${TEST_SRCS} ) SOURCE_GROUP( tests FILES ${TEST_SRCS} )

View File

@ -0,0 +1,47 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
using namespace ::Assimp;
AbstractImportExportBase::~AbstractImportExportBase() {
// empty
}

View File

@ -0,0 +1,49 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#include "UnitTestPCH.h"
class AbstractImportExportBase : public ::testing::Test {
public:
virtual ~AbstractImportExportBase();
virtual bool importerTest() = 0;
};

View File

@ -44,9 +44,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/material.h> #include <assimp/material.h>
#include <sstream> #include <sstream>
using namespace Assimp; namespace Assimp {
SceneDiffer::SceneDiffer() { SceneDiffer::SceneDiffer()
: m_diffs() {
// empty // empty
} }
@ -156,7 +157,8 @@ static std::string dumpFace( const aiFace &face ) {
stream << face.mIndices[ i ]; stream << face.mIndices[ i ];
if ( i < face.mNumIndices - 1 ) { if ( i < face.mNumIndices - 1 ) {
stream << ", "; stream << ", ";
} else { }
else {
stream << "\n"; stream << "\n";
} }
} }
@ -367,3 +369,5 @@ bool SceneDiffer::compareMaterial( aiMaterial *expected, aiMaterial *toCompare )
return true; return true;
} }
}

View File

@ -50,6 +50,8 @@ struct aiMesh;
struct aiMaterial; struct aiMaterial;
struct aiFace; struct aiFace;
namespace Assimp {
class SceneDiffer { class SceneDiffer {
public: public:
SceneDiffer(); SceneDiffer();
@ -67,3 +69,5 @@ protected:
private: private:
std::vector<std::string> m_diffs; std::vector<std::string> m_diffs;
}; };
}

View File

@ -1,3 +1,43 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once #pragma once
#include "UnitTestPCH.h" #include "UnitTestPCH.h"

View File

@ -1,3 +1,43 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once #pragma once
#include "UnitTestPCH.h" #include "UnitTestPCH.h"

View File

@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "UnitTestPCH.h" #include "UnitTestPCH.h"
#include "SceneDiffer.h" #include "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
@ -100,7 +101,7 @@ static const std::string ObjModel =
"\n" "\n"
"# End of file\n"; "# End of file\n";
class utObjImportExport : public ::testing::Test { class utObjImportExport : public AbstractImportExportBase {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
m_im = new Assimp::Importer; m_im = new Assimp::Importer;
@ -173,11 +174,22 @@ protected:
return expScene; return expScene;
} }
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", 0 );
return nullptr != scene;
}
protected: protected:
Assimp::Importer *m_im; Assimp::Importer *m_im;
aiScene *m_expectedScene; aiScene *m_expectedScene;
}; };
TEST_F( utObjImportExport, importObjFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utObjImportExport, obj_import_test ) { TEST_F( utObjImportExport, obj_import_test ) {
const aiScene *scene = m_im->ReadFileFromMemory( (void*) ObjModel.c_str(), ObjModel.size(), 0 ); const aiScene *scene = m_im->ReadFileFromMemory( (void*) ObjModel.c_str(), ObjModel.size(), 0 );
aiScene *expected = createScene(); aiScene *expected = createScene();

View File

@ -42,11 +42,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SIBImporter.h" #include "SIBImporter.h"
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include "AbstractImportExportBase.h"
using namespace ::Assimp; using namespace ::Assimp;
class utSIBImporter : public ::testing::Test { class utSIBImporter : public AbstractImportExportBase {
// empty public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", 0 );
return nullptr != scene;
}
}; };
TEST_F( utSIBImporter, createTest ) { TEST_F( utSIBImporter, createTest ) {
@ -60,8 +66,5 @@ TEST_F( utSIBImporter, createTest ) {
} }
TEST_F( utSIBImporter, importTest ) { TEST_F( utSIBImporter, importTest ) {
Assimp::Importer importer; EXPECT_TRUE( importerTest() );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", 0 );
EXPECT_NE( nullptr, scene );
} }

View File

@ -0,0 +1,61 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
using namespace Assimp;
class utXImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/test.x", 0 );
return nullptr != scene;
}
};
TEST_F( utXImporterExporter, importXFromFileTest ) {
EXPECT_TRUE( importerTest() );
}