| test: add MockCheckModuleLoadable(true) to FindNativeModuleByDisk ErrInfo cases The four FindNativeModuleByDisk_ErrInfo_* test cases all failed on device with "module XXX is in blocklist" instead of the expected loadErrInfo strings. Root cause: ModuleManagerTest::SetUp() calls MockResetModuleManagerState(), which resets g_mockCheckModuleLoadable to false. The mock in mock_native_module_manager.cpp overrides ModuleLoadChecker::CheckModuleLoadable to return g_mockCheckModuleLoadable directly. So every test starts with CheckModuleLoadable returning false, hitting the blocklist branch at native_module_manager.cpp:1372-1377, which overwrites loadErrInfo with "module XXX is in blocklist". Fix: call MockCheckModuleLoadable(true) right after ASSERT_NE(nullptr, moduleManager) in each of the four cases, mirroring the pattern in the existing LoadNativeModuleTest_002 (module_manager_test.cpp:106). This unblocks the mock and lets the test reach the expected error classification path. Cases fixed: - FindNativeModuleByDisk_ErrInfo_ModuleNotFound - FindNativeModuleByDisk_ErrInfo_AppLibPathNotRegistered - FindNativeModuleByDisk_ErrInfo_LoadErrInfoNull - FindNativeModuleByDisk_ErrInfo_DlopenFailed The ModuleCreateFailed case was removed in the previous commit because even with the mock unblocked it cannot reach the "internal error: module create failed" branch (OOM-only path). Issue: https://gitcode.com/openharmony/arkui_napi/issues/2144 Signed-off-by: zhang_hao_zheng <zhanghaozheng2@h-partners.com> Co-Authored-By: Agent Change-Id: I45e764e5d75fb3019cb3adda044641b6236156e6 | 20 天前 |