| 78 | }; |
| 79 | |
| 80 | void 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 | |
| 125 | void TestEventHook() |
| 126 | { |
no test coverage detected