Unload libB and check for correct events
| 102 | |
| 103 | // Unload libB and check for correct events |
| 104 | void 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 |
no test coverage detected