MCPcopy Create free account
hub / github.com/MITK/MITK / TestFindHook

Function TestFindHook

Modules/CppMicroServices/test/usModuleHooksTest.cpp:80–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78};
79
80void TestFindHook()
81{
82 SharedLibrary libA(LIB_PATH, "TestModuleA");
83
84 try
85 {
86 libA.Load();
87 }
88 catch (const std::exception& e)
89 {
90 US_TEST_FAILED_MSG(<< "Load module exception: " << e.what())
91 }
92
93 Module* moduleA = GetModuleContext()->GetModule("TestModuleA");
94 US_TEST_CONDITION_REQUIRED(moduleA != nullptr, "Test for existing module TestModuleA")
95
96 US_TEST_CONDITION(moduleA->GetName() == "TestModuleA", "Test module name")
97
98 US_TEST_CONDITION(moduleA->IsLoaded() == true, "Test if loaded correctly");
99
100 long moduleAId = moduleA->GetModuleId();
101 US_TEST_CONDITION_REQUIRED(moduleAId > 0, "Test for valid module id")
102
103 US_TEST_CONDITION_REQUIRED(GetModuleContext()->GetModule(moduleAId) != nullptr, "Test for non-filtered GetModule(long) result")
104
105 TestModuleFindHook findHook;
106 ServiceRegistration<ModuleFindHook> findHookReg = GetModuleContext()->RegisterService<ModuleFindHook>(&findHook);
107
108 US_TEST_CONDITION_REQUIRED(GetModuleContext()->GetModule(moduleAId) == nullptr, "Test for filtered GetModule(long) result")
109
110 std::vector<Module*> modules = GetModuleContext()->GetModules();
111 for (std::vector<Module*>::iterator i = modules.begin();
112 i != modules.end(); ++i)
113 {
114 if((*i)->GetName() == "TestModuleA")
115 {
116 US_TEST_FAILED_MSG(<< "TestModuleA not filtered from GetModules()")
117 }
118 }
119
120 findHookReg.Unregister();
121
122 libA.Unload();
123}
124
125void TestEventHook()
126{

Callers 1

usModuleHooksTestFunction · 0.70

Calls 12

GetModuleContextFunction · 0.85
whatMethod · 0.80
GetModuleIdMethod · 0.80
LoadMethod · 0.45
GetModuleMethod · 0.45
GetNameMethod · 0.45
IsLoadedMethod · 0.45
GetModulesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
UnregisterMethod · 0.45
UnloadMethod · 0.45

Tested by

no test coverage detected