Mercurial > hg > orthanc
diff UnitTestsSources/PluginsTests.cpp @ 887:4066e6f2d134 plugins
PluginsManager
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 14 Jun 2014 19:20:38 +0200 |
parents | 29087d728e0a |
children | d44b845c1c89 |
line wrap: on
line diff
--- a/UnitTestsSources/PluginsTests.cpp Sat Jun 14 18:50:14 2014 +0200 +++ b/UnitTestsSources/PluginsTests.cpp Sat Jun 14 19:20:38 2014 +0200 @@ -35,8 +35,7 @@ #include <glog/logging.h> -#include "../Plugins/Engine/SharedLibrary.h" -#include "../Plugins/OrthancCPlugin/OrthancCPlugin.h" +#include "../Plugins/Engine/PluginsManager.h" using namespace Orthanc; @@ -59,72 +58,17 @@ } - -static void LogError(const char* str) -{ - LOG(ERROR) << str; -} - -static void LogWarning(const char* str) -{ - LOG(WARNING) << str; -} - -static void LogInfo(const char* str) -{ - LOG(INFO) << str; -} - -static int32_t InvokeService(const char* serviceName, - const void* serviceParameters) -{ - return 0; -} - - - TEST(SharedLibrary, Development) { + PluginsManager manager; + #if defined(_WIN32) #error Support your platform here #elif defined(__linux) - SharedLibrary l("./libPluginTest.so"); - ASSERT_TRUE(l.HasFunction("OrthancPluginFinalize")); - ASSERT_TRUE(l.HasFunction("OrthancPluginInitialize")); - - OrthancPluginContext context; - context.orthancVersion = ORTHANC_VERSION; - context.InvokeService = InvokeService; - context.LogError = LogError; - context.LogWarning = LogWarning; - context.LogInfo = LogInfo; - - typedef void (*Finalize) (); - typedef int32_t (*Initialize) (const OrthancPluginContext*); - - /** - * gcc would complain about "ISO C++ forbids casting between - * pointer-to-function and pointer-to-object" without the trick - * below, that is known as "the POSIX.1-2003 (Technical Corrigendum - * 1) workaround". See the man page of "dlsym()". - * http://www.trilithium.com/johan/2004/12/problem-with-dlsym/ - * http://stackoverflow.com/a/14543811/881731 - **/ - - Finalize finalize; - *(void **) (&finalize) = l.GetFunction("OrthancPluginFinalize"); - assert(finalize != NULL); - - Initialize initialize; - *(void **) (&initialize) = l.GetFunction("OrthancPluginInitialize"); - assert(initialize != NULL); - - initialize(&context); - finalize(); + manager.RegisterPlugin("./libPluginTest.so"); #else #error Support your platform here -#endif - +#endif }