diff --git a/radiant/Makefile.am b/radiant/Makefile.am index 4ff429b0f6..109415a6f0 100644 --- a/radiant/Makefile.am +++ b/radiant/Makefile.am @@ -459,4 +459,5 @@ facePlaneTest_LDADD = $(top_builddir)/libs/math/libmath.la vfsTest_SOURCES = test/vfsTest.cpp $(VFS_SOURCES) vfsTest_LDFLAGS = $(FILESYSTEM_LIBS) $(Z_LIBS) -shadersTest_SOURCES = test/shadersTest.cpp $(SHADERS_SOURCES) +shadersTest_SOURCES = test/shadersTest.cpp $(SHADERS_SOURCES) $(VFS_SOURCES) +shadersTest_LDFLAGS = $(FILESYSTEM_LIBS) $(Z_LIBS) diff --git a/radiant/test/VFSFixture.h b/radiant/test/VFSFixture.h new file mode 100644 index 0000000000..f083501c27 --- /dev/null +++ b/radiant/test/VFSFixture.h @@ -0,0 +1,29 @@ +#pragma once + +#include "radiant/vfs/Doom3FileSystem.h" + +// Fixture for tests that make use of the VFS +struct VFSFixture +{ + // The Doom3FileSystem under test + vfs::Doom3FileSystem fs; + + // Initialisation parameters for the Doom3FileSystem + vfs::VirtualFileSystem::ExtensionSet pakExtensions; + vfs::SearchPaths searchPaths; + + VFSFixture() + { + // Setup the output stream + GlobalOutputStream().setStream(std::cout); + + // Configure search paths and extensions + pakExtensions.insert("pk4"); + searchPaths.insertIfNotExists( + std::string(getenv("srcdir")) + "/test/data/vfs_root" + ); + + // Initialise the VFS + fs.initialise(searchPaths, pakExtensions); + } +}; diff --git a/radiant/test/shadersTest.cpp b/radiant/test/shadersTest.cpp index 0eceddf473..d95a43fb12 100644 --- a/radiant/test/shadersTest.cpp +++ b/radiant/test/shadersTest.cpp @@ -1,6 +1,8 @@ #define BOOST_TEST_MODULE shadersTest #include +#include "VFSFixture.h" + #include "radiant/shaders/ShaderFileLoader.h" #include "radiant/shaders/textures/GLTextureManager.h" @@ -29,7 +31,7 @@ struct MockShaderLibrary { return true; } }; -BOOST_AUTO_TEST_CASE(loaderShaderFiles) +BOOST_FIXTURE_TEST_CASE(loaderShaderFiles, VFSFixture) { MockShaderLibrary library; shaders::ShaderFileLoader loader("materials", library); diff --git a/radiant/test/vfsTest.cpp b/radiant/test/vfsTest.cpp index 0422207582..f802efb03f 100644 --- a/radiant/test/vfsTest.cpp +++ b/radiant/test/vfsTest.cpp @@ -1,32 +1,7 @@ #define BOOST_TEST_MODULE vfsTest #include -#include "radiant/vfs/Doom3FileSystem.h" - -struct VFSFixture -{ - // The Doom3FileSystem under test - vfs::Doom3FileSystem fs; - - // Initialisation parameters for the Doom3FileSystem - vfs::VirtualFileSystem::ExtensionSet pakExtensions; - vfs::SearchPaths searchPaths; - - VFSFixture() - { - // Setup the output stream - GlobalOutputStream().setStream(std::cout); - - // Configure search paths and extensions - pakExtensions.insert("pk4"); - searchPaths.insertIfNotExists( - std::string(getenv("srcdir")) + "/test/data/vfs_root" - ); - - // Initialise the VFS - fs.initialise(searchPaths, pakExtensions); - } -}; +#include "VFSFixture.h" BOOST_FIXTURE_TEST_CASE(constructFileSystemModule, VFSFixture) {