From 47311cc8b211a7fef033d744d9eba9f308726ea8 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 20 Jan 2015 00:53:49 +0100 Subject: Refactored stuff surrounding the ResourceLocator class, implemented StaticResourceLocator which can be used for registering static resources (mainly for testing or if certain resources need to be available from the executable) --- test/core/RegistryTest.cpp | 48 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) (limited to 'test/core/RegistryTest.cpp') diff --git a/test/core/RegistryTest.cpp b/test/core/RegistryTest.cpp index 8280188..45e09d3 100644 --- a/test/core/RegistryTest.cpp +++ b/test/core/RegistryTest.cpp @@ -18,46 +18,26 @@ #include -#include - #include -#include +#include +#include namespace ousia { -class TestResourceLocator : public ResourceLocator { -public: - ResourceLocator::Location locate( - const std::string &path, const std::string &relativeTo, - const ResourceLocator::Type type) const override - { - // trivial test implementation. - return ResourceLocator::Location(true, *this, type, path); - } - - std::unique_ptr stream( - const std::string &location) const override - { - // trivial test implementation. - std::unique_ptr ss(new std::stringstream()); - (*ss) << "test"; - return std::move(ss); - } -}; - TEST(Registry, locateResource) { - TestResourceLocator locator; - Logger logger; - Registry instance {logger}; - instance.registerResourceLocator(&locator); - - ResourceLocator::Location location = - instance.locateResource("path", "", ResourceLocator::Type::DOMAIN_DESC); - ASSERT_TRUE(location.found); - ASSERT_EQ(ResourceLocator::Type::DOMAIN_DESC, location.type); - ASSERT_EQ("path", location.location); + StaticResourceLocator locator; + locator.store("path", "test"); + + Registry registry; + registry.registerResourceLocator(locator); + + Resource res; + ASSERT_TRUE( + registry.locateResource(res, "path", ResourceType::DOMAIN_DESC)); + ASSERT_TRUE(res.isValid()); + ASSERT_EQ(ResourceType::DOMAIN_DESC, res.getType()); + ASSERT_EQ("path", res.getLocation()); } - } -- cgit v1.2.3