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

Function frame030b

Modules/CppMicroServices/test/usStaticModuleTest.cpp:104–138  ·  view source on GitHub ↗

Unload libB and check for correct events

Source from the content-addressed store, hash-verified

102
103// Unload libB and check for correct events
104void frame030b(ModuleContext* mc, TestModuleListener& listener, SharedLibrary& libB)
105{
106 Module* moduleB = ModuleRegistry::GetModule("TestModuleB");
107 US_TEST_CONDITION_REQUIRED(moduleB != nullptr, "Test for non-null module")
108
109 Module* moduleImportedByB = ModuleRegistry::GetModule("TestModuleImportedByB");
110 US_TEST_CONDITION_REQUIRED(moduleImportedByB != nullptr, "Test for non-null module")
111
112 std::vector<ServiceReferenceU> refs
113 = mc->GetServiceReferences("us::TestModuleBService");
114 US_TEST_CONDITION(refs.front(), "Test for first valid service reference")
115 US_TEST_CONDITION(refs.back(), "Test for second valid service reference")
116
117 try
118 {
119 libB.Unload();
120 US_TEST_CONDITION(moduleB->IsLoaded() == false, "Test for unloaded state")
121 }
122 catch (const std::exception& e)
123 {
124 US_TEST_FAILED_MSG(<< "UnLoad module exception: " << e.what())
125 }
126
127 std::vector<ModuleEvent> pEvts;
128 pEvts.push_back(ModuleEvent(ModuleEvent::UNLOADING, moduleImportedByB));
129 pEvts.push_back(ModuleEvent(ModuleEvent::UNLOADED, moduleImportedByB));
130 pEvts.push_back(ModuleEvent(ModuleEvent::UNLOADING, moduleB));
131 pEvts.push_back(ModuleEvent(ModuleEvent::UNLOADED, moduleB));
132
133 std::vector<ServiceEvent> seEvts;
134 seEvts.push_back(ServiceEvent(ServiceEvent::UNREGISTERING, refs.front()));
135 seEvts.push_back(ServiceEvent(ServiceEvent::UNREGISTERING, refs.back()));
136
137 US_TEST_CONDITION(listener.CheckListenerEvents(pEvts, seEvts), "Test for unexpected events");
138}
139
140} // end unnamed namespace
141

Callers 1

usStaticModuleTestFunction · 0.70

Calls 9

ServiceEventClass · 0.85
GetServiceReferencesMethod · 0.80
frontMethod · 0.80
backMethod · 0.80
whatMethod · 0.80
CheckListenerEventsMethod · 0.80
ModuleEventClass · 0.50
UnloadMethod · 0.45
IsLoadedMethod · 0.45

Tested by

no test coverage detected