diff options
| author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-20 00:53:49 +0100 |
|---|---|---|
| committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-20 00:53:49 +0100 |
| commit | 47311cc8b211a7fef033d744d9eba9f308726ea8 (patch) | |
| tree | 348726aef17297729233b93b6d7eef86f25c7a78 /test/core/RegistryTest.cpp | |
| parent | d836d70ea2352dcf277c6fce91ba1ded3f074b44 (diff) | |
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)
Diffstat (limited to 'test/core/RegistryTest.cpp')
| -rw-r--r-- | test/core/RegistryTest.cpp | 48 |
1 files changed, 14 insertions, 34 deletions
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 <gtest/gtest.h> -#include <core/Registry.hpp> - #include <sstream> -#include <core/common/Logger.hpp> +#include <core/resource/ResourceLocator.hpp> +#include <core/Registry.hpp> 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<std::istream> stream( - const std::string &location) const override - { - // trivial test implementation. - std::unique_ptr<std::stringstream> 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()); } - } |
