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

Function frame02a

Modules/CppMicroServices/test/usModuleTest.cpp:48–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46// Verify that the same member function pointers registered as listeners
47// with different receivers works.
48void frame02a()
49{
50 ModuleContext* mc = GetModuleContext();
51
52 TestModuleListener listener1;
53 TestModuleListener listener2;
54
55 try
56 {
57 mc->RemoveModuleListener(&listener1, &TestModuleListener::ModuleChanged);
58 mc->AddModuleListener(&listener1, &TestModuleListener::ModuleChanged);
59 mc->RemoveModuleListener(&listener2, &TestModuleListener::ModuleChanged);
60 mc->AddModuleListener(&listener2, &TestModuleListener::ModuleChanged);
61 }
62 catch (const std::logic_error& ise)
63 {
64 US_TEST_FAILED_MSG( << "module listener registration failed " << ise.what()
65 << " : frameSL02a:FAIL" );
66 }
67
68 SharedLibrary target(LIB_PATH, "TestModuleA");
69
70 // Start the test target
71 try
72 {
73 target.Load();
74 }
75 catch (const std::exception& e)
76 {
77 US_TEST_FAILED_MSG( << "Failed to load module, got exception: "
78 << e.what() << " + in frameSL02a:FAIL" );
79 }
80
81 Module* moduleA = ModuleRegistry::GetModule("TestModuleA");
82 US_TEST_CONDITION_REQUIRED(moduleA != nullptr, "Test for existing module TestModuleA")
83
84 std::vector<ModuleEvent> pEvts;
85 pEvts.push_back(ModuleEvent(ModuleEvent::LOADING, moduleA));
86 pEvts.push_back(ModuleEvent(ModuleEvent::LOADED, moduleA));
87
88 std::vector<ServiceEvent> seEvts;
89
90 US_TEST_CONDITION(listener1.CheckListenerEvents(pEvts, seEvts), "Check first module listener")
91 US_TEST_CONDITION(listener2.CheckListenerEvents(pEvts, seEvts), "Check second module listener")
92
93 mc->RemoveModuleListener(&listener1, &TestModuleListener::ModuleChanged);
94 mc->RemoveModuleListener(&listener2, &TestModuleListener::ModuleChanged);
95
96 target.Unload();
97}
98
99// Verify information from the ModuleInfo struct
100void frame005a(ModuleContext* mc)

Callers 1

usModuleTestFunction · 0.85

Calls 8

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

Tested by

no test coverage detected