Skip to content

Commit

Permalink
Add more dependencies of ShaderFileLoader into unit test
Browse files Browse the repository at this point in the history
Actually calling the parseFiles() method generates code which requires
additional dependencies. Some of these are added as .cpp files in the Makefile,
while the call to GetTextureManager() is linked to a local implementation so we
can avoid depending on the modulesystem.
  • Loading branch information
Matthew Mott committed Mar 7, 2019
1 parent 68e6598 commit 26a840a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion radiant/Makefile.am
Expand Up @@ -455,5 +455,8 @@ facePlaneTest_SOURCES = test/facePlaneTest.cpp \
brush/FacePlane.cpp
facePlaneTest_LDADD = $(top_builddir)/libs/math/libmath.la

vfsTest_SOURCES = test/vfsTest.cpp $(VFS_SOURCES)
vfsTest_SOURCES = test/vfsTest.cpp $(VFS_SOURCES) \
shaders/Doom3ShaderLayer.cpp \
shaders/TableDefinition.cpp \
shaders/textures/GLTextureManager.cpp
vfsTest_LDFLAGS = $(FILESYSTEM_LIBS) $(Z_LIBS)
22 changes: 22 additions & 0 deletions radiant/test/vfsTest.cpp
Expand Up @@ -3,6 +3,7 @@

#include "radiant/vfs/Doom3FileSystem.h"
#include "radiant/shaders/ShaderFileLoader.h"
#include "radiant/shaders/textures/GLTextureManager.h"

struct VFSFixture
{
Expand Down Expand Up @@ -100,14 +101,35 @@ BOOST_FIXTURE_TEST_CASE(handleAssetsLst, VFSFixture)
BOOST_TEST(fileVis.count("assets.lst") == 0);
}

namespace shaders
{

// Provide a local implementation of GetTextureManager since the application
// version calls the module registry.
GLTextureManager& GetTextureManager()
{
static GLTextureManager manager;
return manager;
}

}

using namespace shaders;

// Replacement for ShaderLibrary used in tests
struct MockShaderLibrary
{
bool addTableDefinition(const TableDefinitionPtr& def)
{ return true; }

bool addDefinition(const std::string& name, const ShaderDefinition& def)
{ return true; }
};

BOOST_FIXTURE_TEST_CASE(loaderShaderFiles, VFSFixture)
{
MockShaderLibrary library;
shaders::ShaderFileLoader<MockShaderLibrary> loader("materials", library);

loader.parseFiles();
}

0 comments on commit 26a840a

Please sign in to comment.