From 6748fd023849d4878d0d009c5f2ce4c2c81add83 Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 07:55:33 +0000 Subject: [PATCH 01/13] update frameworks/native/backup_ext/src/untar_file.cpp. Signed-off-by: chensihan --- frameworks/native/backup_ext/src/untar_file.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frameworks/native/backup_ext/src/untar_file.cpp b/frameworks/native/backup_ext/src/untar_file.cpp index 5e40a6725..da3723215 100644 --- a/frameworks/native/backup_ext/src/untar_file.cpp +++ b/frameworks/native/backup_ext/src/untar_file.cpp @@ -284,9 +284,9 @@ int UntarFile::DealIncreParseTarFileResult(const std::tuple Date: Tue, 22 Oct 2024 07:56:08 +0000 Subject: [PATCH 02/13] update frameworks/native/backup_ext/src/tar_file.cpp. Signed-off-by: chensihan --- frameworks/native/backup_ext/src/tar_file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/backup_ext/src/tar_file.cpp b/frameworks/native/backup_ext/src/tar_file.cpp index 51dba1aac..6f456bf84 100644 --- a/frameworks/native/backup_ext/src/tar_file.cpp +++ b/frameworks/native/backup_ext/src/tar_file.cpp @@ -307,7 +307,7 @@ bool TarFile::WriteFileContent(const string &fileName, off_t size, int &err) int fd = open(fileName.c_str(), O_RDONLY | O_CLOEXEC); if (fd < 0) { err = errno; - HILOGE("Failed to open file %{public}s, err = %{public}d", fileName.data(), errno); + HILOGE("Failed to open file %{public}s, err = %{public}d", GetAnonyString(fileName).data(), errno); return false; } -- Gitee From dd886c060fad588fcbca889103669bd0c56bb528 Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 07:59:00 +0000 Subject: [PATCH 03/13] update services/backup_sa/include/module_ipc/svc_session_manager.h. Signed-off-by: chensihan --- services/backup_sa/include/module_ipc/svc_session_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/backup_sa/include/module_ipc/svc_session_manager.h b/services/backup_sa/include/module_ipc/svc_session_manager.h index e420dc5fc..2671c0fd6 100644 --- a/services/backup_sa/include/module_ipc/svc_session_manager.h +++ b/services/backup_sa/include/module_ipc/svc_session_manager.h @@ -60,7 +60,7 @@ struct BackupExtInfo { /* Timer Status: true is start & false is stop */ bool extTimerStatus {false}; bool fwkTimerStatus {false}; - uint32_t timeout; + uint32_t timeout = BConstants::TIMEOUT_INVALID; uint32_t startTime; int64_t dataSize; int64_t lastIncrementalTime; -- Gitee From ecec7b646056545934cdeb72172a96a0279b3acd Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 08:01:15 +0000 Subject: [PATCH 04/13] update services/backup_sa/src/module_external/bms_adapter.cpp. Signed-off-by: chensihan --- services/backup_sa/src/module_external/bms_adapter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index e1f415e89..072902b0d 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -342,7 +342,7 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement vector bundleNames; vector bundleInfos; - HILOGI("End get installedBundles count is:%{public}zu", installedBundles.size()); + HILOGI("Begin get bundle infos"); for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { @@ -353,8 +353,8 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement GetAllowAndExtName(installedBundle.extensionInfos); if (!allToBackup) { bundleInfos.emplace_back(BJsonEntityCaps::BundleInfo {installedBundle.name, installedBundle.appIndex, - installedBundle.versionCode, installedBundle.versionName, 0, 0, allToBackup, fullBackupOnly, extName, - restoreDeps, supportScene, extraInfo}); + installedBundle.versionCode, installedBundle.versionName, 0, 0, allToBackup, fullBackupOnly, + extName, restoreDeps, supportScene, extraInfo}); continue; } auto it = std::find_if(extraIncreData.begin(), extraIncreData.end(), @@ -385,15 +385,14 @@ vector BundleMgrAdapter::GetFullBundleInfos(int32_t } vector bundleNames; vector bundleInfos; - HILOGI("End get installedBundles count is:%{public}zu", installedBundles.size()); for (auto const &installedBundle : installedBundles) { + HILOGI("Begin get bundle infos, bundleName = %{public}s", installedBundle.name.data()); if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } if (installedBundle.appIndex > 0) { - HILOGI("Current bundle %{public}s is a twin application", installedBundle.name.c_str()); std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(installedBundle.name, installedBundle.appIndex); bundleNames.emplace_back(bundleNameIndexInfo); -- Gitee From 1fec83701e0f01d77c48ccfd853bb7cbcb9618f5 Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 08:02:36 +0000 Subject: [PATCH 05/13] update services/backup_sa/src/module_ipc/svc_restore_deps_manager.cpp. Signed-off-by: chensihan --- services/backup_sa/src/module_ipc/svc_restore_deps_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/backup_sa/src/module_ipc/svc_restore_deps_manager.cpp b/services/backup_sa/src/module_ipc/svc_restore_deps_manager.cpp index 70879196a..682b0a2b4 100644 --- a/services/backup_sa/src/module_ipc/svc_restore_deps_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_restore_deps_manager.cpp @@ -33,7 +33,7 @@ vector SvcRestoreDepsManager::GetRestoreBundleNames(const vector Date: Tue, 22 Oct 2024 08:03:35 +0000 Subject: [PATCH 06/13] update services/backup_sa/src/module_ipc/svc_session_manager.cpp. Signed-off-by: chensihan --- services/backup_sa/src/module_ipc/svc_session_manager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/backup_sa/src/module_ipc/svc_session_manager.cpp b/services/backup_sa/src/module_ipc/svc_session_manager.cpp index ada69b648..6e2b04b88 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -163,7 +163,7 @@ bool SvcSessionManager::OnBundleFileReady(const string &bundleName, const string if (!impl_.clientToken) { throw BError(BError::Codes::SA_INVAL_ARG, "No caller token was specified"); } - HILOGD("Begin, bundleName name is:%{public}s", bundleName.c_str()); + HILOGD("Begin, bundleName name is:%{private}s", bundleName.c_str()); auto it = impl_.backupExtNameMap.find(bundleName); if (it == impl_.backupExtNameMap.end()) { stringstream ss; @@ -190,7 +190,7 @@ bool SvcSessionManager::OnBundleFileReady(const string &bundleName, const string return true; } } - HILOGD("End, bundleName name is:%{public}s", bundleName.c_str()); + HILOGD("End, bundleName name is:%{private}s", bundleName.c_str()); return false; } @@ -574,7 +574,6 @@ bool SvcSessionManager::IsOnAllBundlesFinished() bool SvcSessionManager::IsOnOnStartSched() { - HILOGI("Begin"); shared_lock lock(lock_); if (!impl_.clientToken) { throw BError(BError::Codes::SA_INVAL_ARG, "No caller token was specified"); @@ -582,7 +581,7 @@ bool SvcSessionManager::IsOnOnStartSched() if (impl_.isBackupStart && impl_.backupExtNameMap.size()) { return true; } - HILOGI("End"); + return false; } -- Gitee From 2951d69d2305f1286f86007e244db5699e46a1a6 Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 08:08:14 +0000 Subject: [PATCH 07/13] update tests/unittests/backup_sa/module_ipc/service_test.cpp. Signed-off-by: chensihan --- tests/unittests/backup_sa/module_ipc/service_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unittests/backup_sa/module_ipc/service_test.cpp b/tests/unittests/backup_sa/module_ipc/service_test.cpp index e0224ccd3..214931079 100644 --- a/tests/unittests/backup_sa/module_ipc/service_test.cpp +++ b/tests/unittests/backup_sa/module_ipc/service_test.cpp @@ -22,6 +22,7 @@ #include "module_ipc/service.h" #include "service.cpp" #include "service_reverse_mock.h" +#include "sub_service.cpp" #include "test_manager.h" namespace OHOS::FileManagement::Backup { -- Gitee From 29cb7bcccb50fc34236f04a022f07f97559efb21 Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 08:12:09 +0000 Subject: [PATCH 08/13] update tests/unittests/backup_utils/b_json/b_json_entity_ext_manage_test.cpp. Signed-off-by: chensihan --- .../b_json/b_json_entity_ext_manage_test.cpp | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/unittests/backup_utils/b_json/b_json_entity_ext_manage_test.cpp b/tests/unittests/backup_utils/b_json/b_json_entity_ext_manage_test.cpp index a09c55ebc..239a274bd 100644 --- a/tests/unittests/backup_utils/b_json/b_json_entity_ext_manage_test.cpp +++ b/tests/unittests/backup_utils/b_json/b_json_entity_ext_manage_test.cpp @@ -526,6 +526,31 @@ HWTEST_F(BJsonEntityExtManageTest, b_json_entity_ext_manage_0803, testing::ext:: GTEST_LOG_(INFO) << "BJsonEntityExtManageTest-end b_json_entity_ext_manage_0803"; } +/** + * @tc.number: SUB_backup_b_json_entity_ext_manage_0804 + * @tc.name: b_json_entity_ext_manage_0804 + * @tc.desc: 测试GetExtManageInfo + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BJsonEntityExtManageTest, b_json_entity_ext_manage_0804, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BJsonEntityExtManageTest-begin b_json_entity_ext_manage_0804"; + try { + string_view sv = R"([{"isBigFile":false}, {"fileName":"test"}])"; + BJsonCachedEntity cachedEntity(sv); + auto cache = cachedEntity.Structuralize(); + auto mp = cache.GetExtManageInfo(); + EXPECT_TRUE(mp.empty()); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "BJsonEntityExtManageTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BJsonEntityExtManageTest-end b_json_entity_ext_manage_0804"; +} + /** * @tc.number: SUB_backup_b_json_entity_ext_manage_0900 * @tc.name: b_json_entity_ext_manage_0900 @@ -674,4 +699,32 @@ HWTEST_F(BJsonEntityExtManageTest, b_json_entity_ext_manage_0903, testing::ext:: } GTEST_LOG_(INFO) << "BJsonEntityExtManageTest-end b_json_entity_ext_manage_0903"; } + +/** + * @tc.number: SUB_backup_b_json_entity_ext_manage_0904 + * @tc.name: b_json_entity_ext_manage_0904 + * @tc.desc: 测试CheckOwnPackTar各种异常分支 + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: issuesI9JXNH + */ +HWTEST_F(BJsonEntityExtManageTest, b_json_entity_ext_manage_0904, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BJsonEntityExtManageTest-begin b_json_entity_ext_manage_0904"; + try { + string fileName = "/home/user/test.tar"; + auto ret = CheckOwnPackTar(fileName); + EXPECT_FALSE(ret); + + fileName = string(BConstants::PATH_BUNDLE_BACKUP_HOME) + .append(BConstants::SA_BUNDLE_BACKUP_BACKUP).append("/part1.tar"); + ret = CheckOwnPackTar(fileName); + EXPECT_TRUE(ret); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "BJsonEntityExtManageTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BJsonEntityExtManageTest-end b_json_entity_ext_manage_0904"; +} } // namespace OHOS::FileManagement::Backup \ No newline at end of file -- Gitee From dc305c0123720dc331c02e794cf71efd77fcc453 Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 08:12:55 +0000 Subject: [PATCH 09/13] update tests/unittests/backup_utils/b_json/b_report_entity_test.cpp. Signed-off-by: chensihan --- .../b_json/b_report_entity_test.cpp | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/tests/unittests/backup_utils/b_json/b_report_entity_test.cpp b/tests/unittests/backup_utils/b_json/b_report_entity_test.cpp index 3e51ac258..cbdba7332 100644 --- a/tests/unittests/backup_utils/b_json/b_report_entity_test.cpp +++ b/tests/unittests/backup_utils/b_json/b_report_entity_test.cpp @@ -227,4 +227,124 @@ HWTEST_F(BReportEntityTest, b_report_entity_DealLine_0100, testing::ext::TestSiz GTEST_LOG_(INFO) << "BReportEntityTest-end b_report_entity_DealLine_0100"; } +/** + * @tc.number: SUB_backup_b_report_entity_DealLine_0101 + * @tc.name: b_report_entity_DealLine_0101 + * @tc.desc: Test function of DealLine interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(BReportEntityTest, b_report_entity_DealLine_0101, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BReportEntityTest-begin b_report_entity_DealLine_0101"; + try { + unordered_map keys; + int num = 1; + string line = ""; + unordered_map infos; + DealLine(keys, num, line, infos); + EXPECT_EQ(infos.size(), 0); + } catch (const exception &e) { + GTEST_LOG_(INFO) << "BReportEntityTest-an exception occurred by DealLine. " << e.what(); + EXPECT_TRUE(false); + } + GTEST_LOG_(INFO) << "BReportEntityTest-end b_report_entity_DealLine_0101"; +} + +/** + * @tc.number: SUB_backup_b_report_entity_StorageDealLine_0100 + * @tc.name: b_report_entity_StorageDealLine_0100 + * @tc.desc: Test function of DealLine interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(BReportEntityTest, b_report_entity_StorageDealLine_0100, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BReportEntityTest-begin b_report_entity_StorageDealLine_0100"; + try { + unordered_map keys; + int num = 1; + string line = ""; + StorageDealLine(keys, num, line); + EXPECT_TRUE(true); + } catch (const exception &e) { + GTEST_LOG_(INFO) << "BReportEntityTest-an exception occurred by DealLine. " << e.what(); + EXPECT_TRUE(false); + } + GTEST_LOG_(INFO) << "BReportEntityTest-end b_report_entity_StorageDealLine_0100"; +} + +/** + * @tc.number: SUB_backup_b_report_entity_StorageDealLine_0101 + * @tc.name: b_report_entity_StorageDealLine_0101 + * @tc.desc: Test function of DealLine interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(BReportEntityTest, b_report_entity_StorageDealLine_0101, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BReportEntityTest-begin b_report_entity_StorageDealLine_0101"; + try { + unordered_map keys; + int num = 0; + string line = "test\r"; + StorageDealLine(keys, num, line); + EXPECT_TRUE(true); + } catch (const exception &e) { + GTEST_LOG_(INFO) << "BReportEntityTest-an exception occurred by DealLine. " << e.what(); + EXPECT_TRUE(false); + } + GTEST_LOG_(INFO) << "BReportEntityTest-end b_report_entity_StorageDealLine_0101"; +} + +/** + * @tc.number: SUB_backup_b_report_entity_StorageDealLine_0102 + * @tc.name: b_report_entity_StorageDealLine_0102 + * @tc.desc: Test function of DealLine interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(BReportEntityTest, b_report_entity_StorageDealLine_0102, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BReportEntityTest-begin b_report_entity_StorageDealLine_0102"; + try { + unordered_map keys; + int num = 1; + string line = "key1;key2;key3"; + StorageDealLine(keys, num, line); + EXPECT_TRUE(true); + } catch (const exception &e) { + GTEST_LOG_(INFO) << "BReportEntityTest-an exception occurred by DealLine. " << e.what(); + EXPECT_TRUE(false); + } + GTEST_LOG_(INFO) << "BReportEntityTest-end b_report_entity_StorageDealLine_0102"; +} + +/** + * @tc.number: SUB_backup_b_report_entity_StorageDealLine_0103 + * @tc.name: b_report_entity_StorageDealLine_0103 + * @tc.desc: Test function of DealLine interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(BReportEntityTest, b_report_entity_StorageDealLine_0103, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BReportEntityTest-begin b_report_entity_StorageDealLine_0103"; + try { + unordered_map keys; + int num = INFO_ALIGN_NUM; + string line = "key1;key2;key3"; + StorageDealLine(keys, num, line); + EXPECT_TRUE(true); + } catch (const exception &e) { + GTEST_LOG_(INFO) << "BReportEntityTest-an exception occurred by DealLine. " << e.what(); + EXPECT_TRUE(false); + } + GTEST_LOG_(INFO) << "BReportEntityTest-end b_report_entity_StorageDealLine_0103"; +} } // namespace OHOS::FileManagement::Backup \ No newline at end of file -- Gitee From fd0238babda9a6907202411dc370409df6fdae2c Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 08:14:37 +0000 Subject: [PATCH 10/13] update utils/src/b_jsonutil/b_jsonutil.cpp. Signed-off-by: chensihan --- utils/src/b_jsonutil/b_jsonutil.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/utils/src/b_jsonutil/b_jsonutil.cpp b/utils/src/b_jsonutil/b_jsonutil.cpp index f3e55f4f1..751054b9a 100644 --- a/utils/src/b_jsonutil/b_jsonutil.cpp +++ b/utils/src/b_jsonutil/b_jsonutil.cpp @@ -167,13 +167,11 @@ bool BJsonUtil::HasUnicastInfo(std::string &bundleInfo) cJSON *infoItem = cJSON_GetArrayItem(infos, i); if (!cJSON_IsObject(infoItem)) { HILOGE("Parse json error, info item is not an object"); - cJSON_Delete(root); continue; } cJSON *type = cJSON_GetObjectItem(infoItem, "type"); if (type == nullptr || !cJSON_IsString(type) || (type->valuestring == nullptr)) { HILOGE("Parse json type element error"); - cJSON_Delete(root); continue; } if (string(type->valuestring).compare(BConstants::UNICAST_TYPE) == 0) { @@ -306,17 +304,6 @@ bool BJsonUtil::BuildExtensionErrInfo(std::string &jsonStr, int errCode, std::st return true; } -std::string BJsonUtil::BuildBundleNameIndexInfo(const std::string &bundleName, int appIndex) -{ - std::string result = bundleName; - if (appIndex == BUNDLE_INDEX_DEFAULT_VAL) { - return result; - } - result += BUNDLE_INDEX_SPLICE; - result += std::to_string(appIndex); - return result; -} - bool BJsonUtil::BuildExtensionErrInfo(std::string &jsonStr, std::map> errFileInfo) { cJSON *errJson = cJSON_CreateObject(); @@ -353,7 +340,6 @@ bool BJsonUtil::BuildExtensionErrInfo(std::string &jsonStr, std::map Date: Tue, 22 Oct 2024 08:14:58 +0000 Subject: [PATCH 11/13] update utils/include/b_jsonutil/b_jsonutil.h. Signed-off-by: chensihan --- utils/include/b_jsonutil/b_jsonutil.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/utils/include/b_jsonutil/b_jsonutil.h b/utils/include/b_jsonutil/b_jsonutil.h index 075816580..37c050a31 100644 --- a/utils/include/b_jsonutil/b_jsonutil.h +++ b/utils/include/b_jsonutil/b_jsonutil.h @@ -96,17 +96,7 @@ public: */ static bool BuildExtensionErrInfo(std::string &jsonStr, int errCode, std::string errMsg); - /** - * @brief 拼接包名和分身对应的索引 - * - * @param bundleName 包名 - * @param bundleIndex 索引 - * - * @return 拼接结果 - */ - static std::string BuildBundleNameIndexInfo(const std::string &bundleName, int bundleIndex); - - /** + /* * * @brief 组建恢复文件错误信息的json * * @param jsonStr 组建结果 @@ -117,9 +107,8 @@ public: */ static bool BuildExtensionErrInfo(std::string &jsonStr, std::map> errFileInfo); - /** + /* * * @brief 组建App进度返回的信息 - * * @param jsonStr 组建结果 * @param onProcessRet onProcess接口返回值 * @@ -128,6 +117,15 @@ public: */ static bool BuildOnProcessRetInfo(std::string &jsonStr, std::string onProcessRet); + /* * + * @brief 拼接包名和分身对应的索引 + * + * @param bundleName 包名 + * @param bundleIndex 索引 + * + * @return 拼接结果 + */ + static std::string BuildBundleNameIndexInfo(const std::string &bundleName, int bundleIndex); /** * @brief 组建App进度返回的信息 * -- Gitee From fba476e06c8be08d54af370257a8500c39e307eb Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 08:17:33 +0000 Subject: [PATCH 12/13] update tests/mock/napi/src/napi_mock.cpp. Signed-off-by: chensihan --- tests/mock/napi/src/napi_mock.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/mock/napi/src/napi_mock.cpp b/tests/mock/napi/src/napi_mock.cpp index 0310429d3..5b672ce66 100644 --- a/tests/mock/napi/src/napi_mock.cpp +++ b/tests/mock/napi/src/napi_mock.cpp @@ -18,12 +18,6 @@ int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, uv_after_work_cb after_work_cb) { - if (work_cb) { - work_cb(req); - } - if (after_work_cb) { - after_work_cb(req, 0); - } return OHOS::FileManagement::Backup::Napi::napi->uv_queue_work(loop, req, work_cb, after_work_cb); } @@ -163,4 +157,9 @@ NAPI_EXTERN napi_status napi_open_handle_scope(napi_env env, napi_handle_scope* NAPI_EXTERN napi_status napi_close_handle_scope(napi_env env, napi_handle_scope scope) { return OHOS::FileManagement::Backup::Napi::napi->napi_close_handle_scope(env, scope); +} + +napi_status napi_is_exception_pending(napi_env env, bool* result) +{ + return OHOS::FileManagement::Backup::Napi::napi->napi_is_exception_pending(env, result); } \ No newline at end of file -- Gitee From 9919446bb503ca91f2a144117a294d5b095ec440 Mon Sep 17 00:00:00 2001 From: chensihan Date: Tue, 22 Oct 2024 08:19:25 +0000 Subject: [PATCH 13/13] update tests/mock/napi/include/napi_mock.h. Signed-off-by: chensihan --- tests/mock/napi/include/napi_mock.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/mock/napi/include/napi_mock.h b/tests/mock/napi/include/napi_mock.h index bc699b791..5f70f4f02 100644 --- a/tests/mock/napi/include/napi_mock.h +++ b/tests/mock/napi/include/napi_mock.h @@ -60,6 +60,7 @@ public: virtual napi_status napi_create_function(napi_env, const char*, size_t, napi_callback, void*, napi_value*) = 0; virtual napi_status napi_open_handle_scope(napi_env, napi_handle_scope*) = 0; virtual napi_status napi_close_handle_scope(napi_env, napi_handle_scope) = 0; + virtual napi_status napi_is_exception_pending(napi_env, bool*) = 0; public: static inline std::shared_ptr napi = nullptr; }; @@ -96,6 +97,7 @@ public: MOCK_METHOD6(napi_create_function, napi_status(napi_env, const char*, size_t, napi_callback, void*, napi_value*)); MOCK_METHOD2(napi_open_handle_scope, napi_status(napi_env, napi_handle_scope*)); MOCK_METHOD2(napi_close_handle_scope, napi_status(napi_env, napi_handle_scope)); + MOCK_METHOD2(napi_is_exception_pending, napi_status(napi_env, bool*)); }; } // namespace OHOS::FileManagement::Backup #endif // TEST_UNITTEST_MOCK_NAPI_H \ No newline at end of file -- Gitee