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

Function testCustomAutoLoadPath

Modules/CppMicroServices/test/usModuleAutoLoadTest.cpp:96–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void testCustomAutoLoadPath()
97{
98 ModuleContext* mc = GetModuleContext();
99 assert(mc);
100 TestModuleListener listener;
101
102 try
103 {
104 mc->AddModuleListener(&listener, &TestModuleListener::ModuleChanged);
105 }
106 catch (const std::logic_error& ise)
107 {
108 US_TEST_OUTPUT( << "module listener registration failed " << ise.what() );
109 throw;
110 }
111
112 SharedLibrary libAL2(LIB_PATH, "TestModuleAL2");
113
114 try
115 {
116 libAL2.Load();
117 }
118 catch (const std::exception& e)
119 {
120 US_TEST_FAILED_MSG(<< "Load module exception: " << e.what())
121 }
122
123 Module* moduleAL2 = ModuleRegistry::GetModule("TestModuleAL2");
124 US_TEST_CONDITION_REQUIRED(moduleAL2 != nullptr, "Test for existing module TestModuleAL2")
125
126 US_TEST_CONDITION(moduleAL2->GetName() == "TestModuleAL2", "Test module name")
127
128 // check the listeners for events
129 std::vector<ModuleEvent> pEvts;
130 pEvts.push_back(ModuleEvent(ModuleEvent::LOADING, moduleAL2));
131
132 Module* moduleAL2_1 = ModuleRegistry::GetModule("TestModuleAL2_1");
133 US_TEST_CONDITION_REQUIRED(moduleAL2_1 != nullptr, "Test for existing auto-loaded module TestModuleAL2_1")
134 US_TEST_CONDITION(moduleAL2_1->GetName() == "TestModuleAL2_1", "Test module name")
135
136 pEvts.push_back(ModuleEvent(ModuleEvent::LOADING, moduleAL2_1));
137 pEvts.push_back(ModuleEvent(ModuleEvent::LOADED, moduleAL2_1));
138
139 pEvts.push_back(ModuleEvent(ModuleEvent::LOADED, moduleAL2));
140
141 US_TEST_CONDITION(listener.CheckListenerEvents(pEvts), "Test for unexpected events");
142
143 mc->RemoveModuleListener(&listener, &TestModuleListener::ModuleChanged);
144}
145
146} // end unnamed namespace
147

Callers 1

usModuleAutoLoadTestFunction · 0.85

Calls 8

GetModuleContextFunction · 0.85
whatMethod · 0.80
CheckListenerEventsMethod · 0.80
ModuleEventClass · 0.50
AddModuleListenerMethod · 0.45
LoadMethod · 0.45
GetNameMethod · 0.45
RemoveModuleListenerMethod · 0.45

Tested by

no test coverage detected