From 3ea766b65654f3c8a91fc85eb64819b88ea9c701 Mon Sep 17 00:00:00 2001 From: zhushupei Date: Thu, 22 May 2025 15:59:44 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BD=92=E4=B8=80?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushupei --- BUILD.gn | 1 + .../include/data_center/form_basic_info_mgr.h | 70 +++++++ .../form_record/form_record_report.h | 3 - .../form_render/form_render_mgr_inner.h | 6 +- .../database/form_rdb_data_mgr.cpp | 3 - .../src/data_center/form_basic_info_mgr.cpp | 174 ++++++++++++++++ services/src/data_center/form_cache_mgr.cpp | 1 - services/src/data_center/form_data_mgr.cpp | 15 +- .../form_record/form_record_report.cpp | 10 +- .../bundle_lock/form_bundle_lock_mgr.cpp | 1 - .../src/form_render/form_render_mgr_inner.cpp | 10 +- services/src/reporter/form_record_report.cpp | 10 +- test/BUILD.gn | 1 + .../fms_form_data_mgr_test.cpp | 7 +- .../mock_form_db_cache.cpp | 29 +++ .../mock_form_db_cache.h | 30 +++ .../form_basic_info_mgr_test/BUILD.gn | 54 +++++ .../form_basic_info_mgr_test.cpp | 196 ++++++++++++++++++ .../form_record_report_test.cpp | 22 -- 19 files changed, 588 insertions(+), 55 deletions(-) create mode 100644 services/include/data_center/form_basic_info_mgr.h create mode 100644 services/src/data_center/form_basic_info_mgr.cpp create mode 100644 test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h create mode 100644 test/unittest/form_basic_info_mgr_test/BUILD.gn create mode 100644 test/unittest/form_basic_info_mgr_test/form_basic_info_mgr_test.cpp diff --git a/BUILD.gn b/BUILD.gn index 42fd7fe6b9..2c559e4a1c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -124,6 +124,7 @@ ohos_shared_library("libfms") { "services/src/data_center/database/form_db_cache.cpp", "services/src/data_center/database/form_db_info.cpp", "services/src/data_center/database/form_rdb_data_mgr.cpp", + "services/src/data_center/form_basic_info_mgr.cpp", "services/src/data_center/form_cache_mgr.cpp", "services/src/data_center/form_data_mgr.cpp", "services/src/data_center/form_data_proxy_mgr.cpp", diff --git a/services/include/data_center/form_basic_info_mgr.h b/services/include/data_center/form_basic_info_mgr.h new file mode 100644 index 0000000000..0bc3edb1dc --- /dev/null +++ b/services/include/data_center/form_basic_info_mgr.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_FORM_FWK_FORM_BASIC_INFO_MGR_H +#define OHOS_FORM_FWK_FORM_BASIC_INFO_MGR_H + +#include +#include +#include +#include + +namespace OHOS { +namespace AppExecFwk { +struct FormBasicInfo { + int64_t formId{0}; + std::string abilityName{""}; + std::string bundleName{""}; + std::string moduleName{""}; + std::string formName{""}; + std::string packageName{""}; +}; + +/** + * @class FormBaseInfoMgr + * form basic info mananger. + */ +class FormBasicInfoMgr final : public DelayedRefSingleton { +DECLARE_DELAYED_REF_SINGLETON(FormBasicInfoMgr) +public: + DISALLOW_COPY_AND_MOVE(FormBasicInfoMgr); + +public: + void AddFormBasicInfo(const FormBasicInfo& baseInfo); + void DeleteFormBasicInfo(int64_t formId); + void ClearFormBasicInfo(); + + int GetBasinInfoCount() const; + bool GetBasicInfoByFormId(int64_t formId, FormBasicInfo& basicInfo); + + const std::string& GetFormAbilityName(int64_t formId); + const std::string& GetFormBundleName(int64_t formId); + const std::string& GetFormModuleName(int64_t formId); + const std::string& GetFormName(int64_t formId); + const std::string& GetFormPackageName(int64_t formId); + + void UpdateAbilityName(int64_t formId, const std::string& abilityName); + void UpdateBundleName(int64_t formId, const std::string& bundleName); + void UpdateMoudleName(int64_t formId, const std::string& moduleName); + void UpdateFormName(int64_t formId, const std::string& formName); + void UpdatePackageName(int64_t formId, const std::string& packageName); + +private: + mutable std::mutex formBasicInfoMutex_; + std::unordered_map formBasicInfoMap_; +}; +} // namespace AppExecFwk +} // namespace OHOS + +#endif // OHOS_FORM_FWK_FORM_BASIC_INFO_MGR_H \ No newline at end of file diff --git a/services/include/data_center/form_record/form_record_report.h b/services/include/data_center/form_record/form_record_report.h index c7f00fe725..42dd9b608b 100644 --- a/services/include/data_center/form_record/form_record_report.h +++ b/services/include/data_center/form_record/form_record_report.h @@ -37,9 +37,6 @@ enum HiSysEventPointType { }; struct FormRecordReportInfo { - std::string bundleName; - std::string moduleName; - std::string formName; int32_t dailyRefreshTimes; int32_t invisibleRefreshTimes; int32_t hfRefreshBlockTimes; diff --git a/services/include/form_render/form_render_mgr_inner.h b/services/include/form_render/form_render_mgr_inner.h index b510a9dd0c..8b3d7436b3 100644 --- a/services/include/form_render/form_render_mgr_inner.h +++ b/services/include/form_render/form_render_mgr_inner.h @@ -115,11 +115,11 @@ private: bool GetRenderFormConnectId(const int64_t formId, int32_t& connectId); - bool GetRenderFormConnection(sptr& connection, const int64_t formId); + bool GetRenderFormConnection(sptr &connection, const int64_t formId); - void GetConnectedForms(const std::vector &formIds, std::vector& connectedForms); + void GetConnectedForms(const std::vector &formIds, std::vector &connectedForms); - ErrCode RenderConnectedForm(const FormRecord &formRecord, Want &want, const sptr& connection); + ErrCode RenderConnectedForm(const FormRecord &formRecord, Want &want, const sptr &connection); ErrCode PostStopRenderingFormTask(const FormRecord &formRecord, Want &want); diff --git a/services/src/data_center/database/form_rdb_data_mgr.cpp b/services/src/data_center/database/form_rdb_data_mgr.cpp index fce354b29d..a7456e7808 100644 --- a/services/src/data_center/database/form_rdb_data_mgr.cpp +++ b/services/src/data_center/database/form_rdb_data_mgr.cpp @@ -172,7 +172,6 @@ ErrCode FormRdbDataMgr::InsertData(const std::string &tableName, const std::stri int64_t rowId = -1; ret = rdbStore_->InsertWithConflictResolution(rowId, tableName, valuesBucket, NativeRdb::ConflictResolution::ON_CONFLICT_REPLACE); - if (ret == NativeRdb::E_OK) { if (rdbStore_->IsSlaveDiffFromMaster()) { auto backupRet = rdbStore_->Backup(""); @@ -214,7 +213,6 @@ ErrCode FormRdbDataMgr::InsertData(const std::string &tableName, const std::stri int64_t rowId = -1; ret = rdbStore_->InsertWithConflictResolution(rowId, tableName, valuesBucket, NativeRdb::ConflictResolution::ON_CONFLICT_REPLACE); - if (ret == NativeRdb::E_OK) { if (rdbStore_->IsSlaveDiffFromMaster()) { auto backupRet = rdbStore_->Backup(""); @@ -554,7 +552,6 @@ bool FormRdbDataMgr::InsertData( int32_t ret = NativeRdb::E_OK; ret = rdbStore_->InsertWithConflictResolution( rowId, tableName, valuesBucket, NativeRdb::ConflictResolution::ON_CONFLICT_REPLACE); - if (ret == NativeRdb::E_OK) { if (rdbStore_->IsSlaveDiffFromMaster()) { auto backupRet = rdbStore_->Backup(""); diff --git a/services/src/data_center/form_basic_info_mgr.cpp b/services/src/data_center/form_basic_info_mgr.cpp new file mode 100644 index 0000000000..73ba4022e8 --- /dev/null +++ b/services/src/data_center/form_basic_info_mgr.cpp @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2025-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "data_center/form_basic_info_mgr.h" + +#include "fms_log_wrapper.h" +#include "form_mgr_errors.h" + +namespace OHOS { +namespace AppExecFwk { +const std::string INVALID_VALUE = ""; + +FormBasicInfoMgr::FormBasicInfoMgr() +{ + HILOG_INFO("Create"); +} + +FormBasicInfoMgr::~FormBasicInfoMgr() +{ + HILOG_INFO("Destroy"); +} + +void FormBasicInfoMgr::AddFormBasicInfo(const FormBasicInfo& baseInfo) +{ + HILOG_INFO("FormBasicInfoMgr::AddFormBasicInfo"); + std::lock_guard lock(formBasicInfoMutex_); + auto iter = formBasicInfoMap_.find(baseInfo.formId); + if (iter != formBasicInfoMap_.end()) { + iter->second = baseInfo; + return; + } + formBasicInfoMap_.emplace(baseInfo.formId, baseInfo); +} + +void FormBasicInfoMgr::DeleteFormBasicInfo(int64_t formId) +{ + std::lock_guard lock(formBasicInfoMutex_); + auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + formBasicInfoMap_.erase(iter); + } +} + +void FormBasicInfoMgr::ClearFormBasicInfo() +{ + formBasicInfoMap_.clear(); +} + +int FormBasicInfoMgr::GetBasinInfoCount() const +{ + return formBasicInfoMap_.size(); +} + +bool FormBasicInfoMgr::GetBasicInfoByFormId(int64_t formId, FormBasicInfo& basicInfo) +{ + HILOG_DEBUG("get form basic info by formId"); + std::lock_guard lock(formBasicInfoMutex_); + auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + HILOG_DEBUG("get form basic info successfully"); + basicInfo = iter->second; + return true; + } + HILOG_ERROR("form basic info not find"); + return false; +} + +const std::string& FormBasicInfoMgr::GetFormAbilityName(int64_t formId) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + return iter->second.abilityName; + } + return INVALID_VALUE; +} + +const std::string& FormBasicInfoMgr::GetFormBundleName(int64_t formId) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + return iter->second.bundleName; + } + return INVALID_VALUE; +} + +const std::string& FormBasicInfoMgr::GetFormModuleName(int64_t formId) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + return iter->second.moduleName; + } + return INVALID_VALUE; +} + +const std::string& FormBasicInfoMgr::GetFormName(int64_t formId) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + return iter->second.formName; + } + return INVALID_VALUE; +} + +const std::string& FormBasicInfoMgr::GetFormPackageName(int64_t formId) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + return iter->second.packageName; + } + return INVALID_VALUE; +} + +void FormBasicInfoMgr::UpdateAbilityName(int64_t formId, const std::string& abilityName) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + iter->second.abilityName = abilityName; + } +} + +void FormBasicInfoMgr::UpdateBundleName(int64_t formId, const std::string& bundleName) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + iter->second.bundleName = bundleName; + } +} + +void FormBasicInfoMgr::UpdateMoudleName(int64_t formId, const std::string& moduleName) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + iter->second.moduleName = moduleName; + } +} + +void FormBasicInfoMgr::UpdateFormName(int64_t formId, const std::string& formName) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + iter->second.formName = formName; + } +} + +void FormBasicInfoMgr::UpdatePackageName(int64_t formId, const std::string& packageName) +{ + std::lock_guard lock(formBasicInfoMutex_); + const auto iter = formBasicInfoMap_.find(formId); + if (iter != formBasicInfoMap_.end()) { + iter->second.packageName = packageName; + } +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/services/src/data_center/form_cache_mgr.cpp b/services/src/data_center/form_cache_mgr.cpp index 021f32139a..fb948b2be7 100644 --- a/services/src/data_center/form_cache_mgr.cpp +++ b/services/src/data_center/form_cache_mgr.cpp @@ -456,7 +456,6 @@ bool FormCacheMgr::GetImgCacheFromDb( NativeRdb::AbsRdbPredicates absRdbPredicates(IMG_CACHE_TABLE); absRdbPredicates.EqualTo(IMAGE_ID, std::to_string(rowId)); auto absSharedResultSet = FormRdbDataMgr::GetInstance().QueryData(absRdbPredicates); - if (absSharedResultSet == nullptr) { HILOG_ERROR("GetImgCacheFromDb failed"); return false; diff --git a/services/src/data_center/form_data_mgr.cpp b/services/src/data_center/form_data_mgr.cpp index 740bd2eec5..d04df92ede 100644 --- a/services/src/data_center/form_data_mgr.cpp +++ b/services/src/data_center/form_data_mgr.cpp @@ -23,6 +23,7 @@ #include "feature/bundle_forbidden/form_bundle_forbid_mgr.h" #include "data_center/form_cache_mgr.h" #include "form_constants.h" +#include "data_center/form_basic_info_mgr.h" #include "data_center/form_data_proxy_mgr.h" #include "data_center/database/form_db_cache.h" #include "form_mgr_errors.h" @@ -85,6 +86,10 @@ FormRecord FormDataMgr::AllotFormRecord(const FormItemInfo &formInfo, const int } } HILOG_INFO("end formId: %{public}" PRId64, formInfo.GetFormId()); + FormBasicInfo basic { + record.formId, record.abilityName, record.bundleName, record.moduleName, record.formName, record.packageName + }; + FormBasicInfoMgr::GetInstance().AddFormBasicInfo(basic); return record; } /** @@ -103,8 +108,10 @@ bool FormDataMgr::DeleteFormRecord(const int64_t formId) } formRecords_.erase(iter); FormUtil::DeleteFormId(formId); + FormBasicInfoMgr::GetInstance().DeleteFormBasicInfo(formId); return true; } + /** * @brief Allot form host record by caller token. * @param info The form item info. @@ -837,6 +844,7 @@ void FormDataMgr::HandleHostDied(const sptr &remoteHost) if (std::find(recordTempForms.begin(), recordTempForms.end(), formId) != recordTempForms.end()) { FormRecord formRecord = itFormRecord->second; itFormRecord = formRecords_.erase(itFormRecord); + FormBasicInfoMgr::GetInstance().DeleteFormBasicInfo(formId); FormProviderMgr::GetInstance().NotifyProviderFormDelete(formId, formRecord); FormDataProxyMgr::GetInstance().UnsubscribeFormData(formId); } else { @@ -1247,6 +1255,7 @@ void FormDataMgr::CleanRemovedFormRecords(const std::string &bundleName, std::se FormCacheMgr::GetInstance().DeleteData(itFormRecord->first); FormRenderMgr::GetInstance().StopRenderingForm(itFormRecord->first, itFormRecord->second); itFormRecord = formRecords_.erase(itFormRecord); + FormBasicInfoMgr::GetInstance().DeleteFormBasicInfo(itFormRecord->first); } else { itFormRecord++; } @@ -1271,6 +1280,7 @@ void FormDataMgr::CleanRemovedTempFormRecords(const std::string &bundleName, con removedTempForms.emplace(itFormRecord->second.formId); FormRenderMgr::GetInstance().StopRenderingForm(itFormRecord->first, itFormRecord->second); itFormRecord = formRecords_.erase(itFormRecord); + FormBasicInfoMgr::GetInstance().DeleteFormBasicInfo(itFormRecord->first); } else { itFormRecord++; } @@ -1840,6 +1850,7 @@ void FormDataMgr::DeleteFormsByUserId(const int32_t userId, std::vector } removedFormIds.emplace_back(itFormRecord->second.formId); itFormRecord = formRecords_.erase(itFormRecord); + FormBasicInfoMgr::GetInstance().DeleteFormBasicInfo(itFormRecord->second.formId); } else { ++itFormRecord; } @@ -2427,7 +2438,7 @@ ErrCode FormDataMgr::GetFormInstanceById(const int64_t formId, FormInstance &for } FormRecord formRecord; notFindFormRecord = GetFormRecordById(formId, formRecord); - if (!notFindFormRecord ) { + if (!notFindFormRecord) { std::vector formHostRecords; GetFormHostRecord(formId, formHostRecords); if (formHostRecords.empty()) { @@ -3003,7 +3014,7 @@ bool FormDataMgr::GetFormRecordById(const int64_t formId, FormRecord& formRecord std::lock_guard lock(formRecordMutex_); auto info = formRecords_.find(formId); notFindFormRecord = info == formRecords_.end(); - if (!notFindFormRecord ) { + if (!notFindFormRecord) { formRecord = info->second; } return notFindFormRecord ; diff --git a/services/src/data_center/form_record/form_record_report.cpp b/services/src/data_center/form_record/form_record_report.cpp index b142ec30ce..07540ab292 100644 --- a/services/src/data_center/form_record/form_record_report.cpp +++ b/services/src/data_center/form_record/form_record_report.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "data_center/form_basic_info_mgr.h" #include "data_center/form_record/form_record_report.h" #include "fms_log_wrapper.h" #include "common/event/form_event_report.h" @@ -37,9 +38,6 @@ void FormRecordReport::SetFormRecordRecordInfo(int64_t formId, const Want &want) { FormRecordReportInfo info; std::lock_guard guard(formRecordReportMutex_); - info.bundleName = want.GetElement().GetBundleName(); - info.moduleName = want.GetStringParam(Constants::PARAM_MODULE_NAME_KEY); - info.formName = want.GetStringParam(Constants::PARAM_FORM_NAME_KEY); if (formRecordReportMap_.find(formId) == formRecordReportMap_.end()) { formRecordReportMap_[formId] = info; } @@ -98,9 +96,9 @@ void FormRecordReport::HandleFormRefreshCount() FormRecordReportInfo record = entry.second; NewFormEventInfo eventInfo; eventInfo.formId = formId; - eventInfo.bundleName = record.bundleName; - eventInfo.moduleName = record.moduleName; - eventInfo.formName = record.formName; + eventInfo.bundleName = FormBasicInfoMgr::GetInstance().GetFormBundleName(formId); + eventInfo.moduleName = FormBasicInfoMgr::GetInstance().GetFormModuleName(formId); + eventInfo.formName = FormBasicInfoMgr::GetInstance().GetFormName(formId); eventInfo.dailyRefreshTimes = record.dailyRefreshTimes; eventInfo.invisibleRefreshTimes = record.invisibleRefreshTimes; eventInfo.hfRefreshBlockTimes = record.hfRefreshBlockTimes; diff --git a/services/src/feature/bundle_lock/form_bundle_lock_mgr.cpp b/services/src/feature/bundle_lock/form_bundle_lock_mgr.cpp index 4d15454e0a..3c2c744f16 100644 --- a/services/src/feature/bundle_lock/form_bundle_lock_mgr.cpp +++ b/services/src/feature/bundle_lock/form_bundle_lock_mgr.cpp @@ -151,6 +151,5 @@ bool FormBundleLockMgr::IsBundleLockMgrInit() } return true; } - } // namespace AppExecFwk } // namespace OHOS diff --git a/services/src/form_render/form_render_mgr_inner.cpp b/services/src/form_render/form_render_mgr_inner.cpp index f2ef8559d8..bc82492903 100644 --- a/services/src/form_render/form_render_mgr_inner.cpp +++ b/services/src/form_render/form_render_mgr_inner.cpp @@ -727,7 +727,7 @@ ErrCode FormRenderMgrInner::GetRenderObject(sptr &renderObj) return ERR_OK; } -bool FormRenderMgrInner::GetRenderFormConnectId(const int64_t formId, int32_t& connectId) +bool FormRenderMgrInner::GetRenderFormConnectId(const int64_t formId, int32_t &connectId) { std::lock_guard lock(resourceMutex_); auto conIterator = renderFormConnections_.find(formId); @@ -744,7 +744,7 @@ bool FormRenderMgrInner::GetRenderFormConnectId(const int64_t formId, int32_t& c return false; } -bool FormRenderMgrInner::GetRenderFormConnection(sptr& connection, const int64_t formId) +bool FormRenderMgrInner::GetRenderFormConnection(sptr &connection, const int64_t formId) { std::lock_guard lock(resourceMutex_); HILOG_DEBUG("renderFormConnections_ size:%{public}zu", renderFormConnections_.size()); @@ -756,10 +756,10 @@ bool FormRenderMgrInner::GetRenderFormConnection(sptr& con return false; } -void FormRenderMgrInner::GetConnectedForms(const std::vector &formIds, std::vector& connectedForms) +void FormRenderMgrInner::GetConnectedForms(const std::vector &formIds, std::vector &connectedForms) { std::lock_guard lock(resourceMutex_); - for (const int64_t &formId : formIds) { + for (const int64_t formId : formIds) { auto conIterator = renderFormConnections_.find(formId); if (conIterator != renderFormConnections_.end()) { auto connection = conIterator->second; @@ -775,7 +775,7 @@ void FormRenderMgrInner::GetConnectedForms(const std::vector &formIds, } ErrCode FormRenderMgrInner::RenderConnectedForm(const FormRecord &formRecord, Want &want, - const sptr& connection) + const sptr &connection) { if (connection == nullptr) { HILOG_ERROR("null connection"); diff --git a/services/src/reporter/form_record_report.cpp b/services/src/reporter/form_record_report.cpp index b142ec30ce..07540ab292 100644 --- a/services/src/reporter/form_record_report.cpp +++ b/services/src/reporter/form_record_report.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "data_center/form_basic_info_mgr.h" #include "data_center/form_record/form_record_report.h" #include "fms_log_wrapper.h" #include "common/event/form_event_report.h" @@ -37,9 +38,6 @@ void FormRecordReport::SetFormRecordRecordInfo(int64_t formId, const Want &want) { FormRecordReportInfo info; std::lock_guard guard(formRecordReportMutex_); - info.bundleName = want.GetElement().GetBundleName(); - info.moduleName = want.GetStringParam(Constants::PARAM_MODULE_NAME_KEY); - info.formName = want.GetStringParam(Constants::PARAM_FORM_NAME_KEY); if (formRecordReportMap_.find(formId) == formRecordReportMap_.end()) { formRecordReportMap_[formId] = info; } @@ -98,9 +96,9 @@ void FormRecordReport::HandleFormRefreshCount() FormRecordReportInfo record = entry.second; NewFormEventInfo eventInfo; eventInfo.formId = formId; - eventInfo.bundleName = record.bundleName; - eventInfo.moduleName = record.moduleName; - eventInfo.formName = record.formName; + eventInfo.bundleName = FormBasicInfoMgr::GetInstance().GetFormBundleName(formId); + eventInfo.moduleName = FormBasicInfoMgr::GetInstance().GetFormModuleName(formId); + eventInfo.formName = FormBasicInfoMgr::GetInstance().GetFormName(formId); eventInfo.dailyRefreshTimes = record.dailyRefreshTimes; eventInfo.invisibleRefreshTimes = record.invisibleRefreshTimes; eventInfo.hfRefreshBlockTimes = record.hfRefreshBlockTimes; diff --git a/test/BUILD.gn b/test/BUILD.gn index a193d519e0..17d92bb981 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -116,6 +116,7 @@ group("unittest") { "unittest/fms_provider_connect_proxy_test:unittest", "unittest/fms_provider_connect_stub_test:unittest", "unittest/fms_running_form_info_test:unittest", + "unittest/form_basic_info_mgr_test:unittest", "unittest/form_bundle_forbid_mgr_test:unittest", "unittest/form_bundle_lock_mgr_test:unittest", "unittest/form_errors_test:unittest", diff --git a/test/unittest/fms_form_data_mgr_test/fms_form_data_mgr_test.cpp b/test/unittest/fms_form_data_mgr_test/fms_form_data_mgr_test.cpp index ab7b9fe123..c44dceb5dd 100644 --- a/test/unittest/fms_form_data_mgr_test/fms_form_data_mgr_test.cpp +++ b/test/unittest/fms_form_data_mgr_test/fms_form_data_mgr_test.cpp @@ -18,6 +18,7 @@ #include #include +#include "mock_form_db_cache.h" #include "appexecfwk_errors.h" #define private public #include "data_center/database/form_db_cache.h" @@ -515,7 +516,7 @@ HWTEST_F(FmsFormDataMgrTest, FmsFormDataMgrTest_CheckEnoughForm_001, TestSize.Le int32_t checkAllDBFormMaxSize = 2; // set formDbInfos size is over 512 - MockGetAllFormInfo(checkAllDBFormMaxSize); + MockGetAllFormInfoSize(checkAllDBFormMaxSize, callingUid); EXPECT_EQ(ERR_APPEXECFWK_FORM_MAX_SYSTEM_FORMS, formDataMgr_.CheckEnoughForm(callingUid)); @@ -536,7 +537,7 @@ HWTEST_F(FmsFormDataMgrTest, FmsFormDataMgrTest_CheckEnoughForm_002, TestSize.Le int callingUid = 0; int32_t checkAllDBFormPreAPPSize = 1; - MockGetAllFormInfo(checkAllDBFormPreAPPSize); + MockGetAllFormInfoSize(checkAllDBFormPreAPPSize, callingUid); EXPECT_EQ(ERR_OK, formDataMgr_.CheckEnoughForm(callingUid)); @@ -558,7 +559,7 @@ HWTEST_F(FmsFormDataMgrTest, FmsFormDataMgrTest_CheckEnoughForm_003, TestSize.Le int32_t checkAllDBFormPreAPPSize = 1; // set formDbInfos size is over 256 - MockGetAllFormInfo(checkAllDBFormPreAPPSize); + MockGetAllFormInfoSize(checkAllDBFormPreAPPSize, callingUid); EXPECT_EQ(ERR_APPEXECFWK_FORM_MAX_FORMS_PER_CLIENT, formDataMgr_.CheckEnoughForm(callingUid)); diff --git a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.cpp b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.cpp index 3f78c89042..a54c88ead1 100644 --- a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.cpp +++ b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.cpp @@ -25,8 +25,17 @@ namespace { int32_t g_mockAllDBFormMaxSize = 2; int32_t g_mockCheckAllDbFormPreAppSize = 1; int32_t g_mockCheckType = g_mockAllDBFormMaxSize; + int g_callingUid = 0; } +namespace OHOS { +void MockGetAllFormInfoSize(int32_t mockRet, int callingUid) +{ + g_mockCheckType = mockRet; + g_callingUid = callingUid; +} +} // namespace OHOS + void MockGetAllFormInfo(int32_t mockRet) { g_mockCheckType = mockRet; @@ -58,5 +67,25 @@ void FormDbCache::GetAllFormInfo(std::vector &formDBInfos) formDBInfos = formDBInfos_; } } + +/** + * @brief Get all form data size from DbCache. + * @param formDBInfos Storage all DbCache. + * @return int32_t. + */ +int32_t FormDbCache::GetAllFormInfoSize() +{ + if (g_mockCheckType == g_mockAllDBFormMaxSize) { + return Constants::MAX_FORMS; + } else if (g_mockCheckType == g_mockCheckAllDbFormPreAppSize && g_callingUid == -1) { + return Constants::MAX_RECORD_PER_APP; + } + return 0; +} + +int FormDbCache::GetFormCountsByCallingUid(const int32_t currentAccountId, const int callingUid) +{ + return (g_callingUid == -1) ? Constants::MAX_RECORD_PER_APP : 0; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h new file mode 100644 index 0000000000..954d4bd700 --- /dev/null +++ b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h @@ -0,0 +1,30 @@ +code/foundation/ability/form_fwk/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h + +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_MOCK_FORM_DB_CACHE_H +#define OHOS_MOCK_FORM_DB_CACHE_H + +#include + +#include "fms_log_wrapper.h" +#include "form_mgr_errors.h" +#include "common/util/form_util.h" + +namespace OHOS { +void MockGetAllFormInfoSize(int32_t mockRet, int callingUid); +} +#endif // OHOS_MOCK_FORM_DB_CACHE_H \ No newline at end of file diff --git a/test/unittest/form_basic_info_mgr_test/BUILD.gn b/test/unittest/form_basic_info_mgr_test/BUILD.gn new file mode 100644 index 0000000000..77335c1d9a --- /dev/null +++ b/test/unittest/form_basic_info_mgr_test/BUILD.gn @@ -0,0 +1,54 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//build/test.gni") +import("//foundation/ability/form_fwk/form_fwk.gni") + +config("Form_basic_info_mgr_config") { + include_dirs = [ + "${form_fwk_path}/interfaces/kits/native/include", + "${form_fwk_path}/test/mock/include", + "${form_fwk_path}/services/include", + ] +} + +# ohos_unittest is a template that will add gtest as deps. +ohos_unittest("FormBasicInfoMgrTest") { + module_out_path = "form_fwk/form_fwk/form_mgr" + + configs = [ ":Form_basic_info_mgr_config" ] + + sources = [ + "${form_fwk_path}/services/src/data_center/form_basic_info_mgr.cpp", + "form_basic_info_mgr_test.cpp", + ] + + deps = [ "${form_fwk_path}:fmskit_native" ] + + external_deps = [ + "ability_base:want", + "ability_runtime:app_manager", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "eventhandler:libeventhandler", + "form_fwk:form_manager", + "hilog:libhilog", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] +} + +group("unittest") { + testonly = true + deps = [ ":FormBasicInfoMgrTest" ] +} diff --git a/test/unittest/form_basic_info_mgr_test/form_basic_info_mgr_test.cpp b/test/unittest/form_basic_info_mgr_test/form_basic_info_mgr_test.cpp new file mode 100644 index 0000000000..687f46196a --- /dev/null +++ b/test/unittest/form_basic_info_mgr_test/form_basic_info_mgr_test.cpp @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#define private public +#include "data_center/form_basic_info_mgr.h" +#include "want.h" + +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::AppExecFwk; +namespace { +int64_t TEST_FORM_ID = 12345; +const std::string BUNDLE_NAME = "com.example.test"; +const std::string FORM_NAME = "TestForm"; +const std::string ABILITY_NAME = "com.huawei.hmos.notepad"; +const std::string MODULE_NAME = "TestModule"; +const std::string PACKAGE_NAME = "TestPackage"; +const std::string INVALID_VALUE = ""; + +class FormBasicInfoMgrTest : public testing::Test { +public: + void SetUp() override; + void TearDown() override; + FormBasicInfoMgr& formBasicInfoMgr = FormBasicInfoMgr::GetInstance(); +}; + +void FormBasicInfoMgrTest::SetUp() +{ + FormBasicInfo basicInfo { + TEST_FORM_ID, + ABILITY_NAME, + BUNDLE_NAME, + MODULE_NAME, + FORM_NAME, + PACKAGE_NAME + }; + formBasicInfoMgr.AddFormBasicInfo(basicInfo); +} + +void FormBasicInfoMgrTest::TearDown() +{ + formBasicInfoMgr.ClearFormBasicInfo(); +} + +/** + * @tc.name: FormBasicInfoMgr_001 + * @tc.desc: test GetFormBasicInfo function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_001, TestSize.Level1) +{ + const auto formSize = formBasicInfoMgr.GetBasinInfoCount(); + EXPECT_EQ(formSize, 1); +} + +/** + * @tc.name: FormBasicInfoMgr_002 + * @tc.desc: test get expect value function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_002, TestSize.Level1) +{ + const auto abilityName = formBasicInfoMgr.GetFormAbilityName(TEST_FORM_ID); + const auto bundleName = formBasicInfoMgr.GetFormBundleName(TEST_FORM_ID); + const auto moudleName = formBasicInfoMgr.GetFormModuleName(TEST_FORM_ID); + const auto formName = formBasicInfoMgr.GetFormName(TEST_FORM_ID); + const auto packageName = formBasicInfoMgr.GetFormPackageName(TEST_FORM_ID); + EXPECT_EQ(abilityName, ABILITY_NAME); + EXPECT_EQ(bundleName, BUNDLE_NAME); + EXPECT_EQ(moudleName, MODULE_NAME); + EXPECT_EQ(formName, FORM_NAME); + EXPECT_EQ(packageName, PACKAGE_NAME); +} + +/** + * @tc.name: FormBasicInfoMgr_003 + * @tc.desc: test get null value with wrong form id function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_003, TestSize.Level1) +{ + int64_t formId = 1; + const auto abilityName = formBasicInfoMgr.GetFormAbilityName(formId); + const auto bundleName = formBasicInfoMgr.GetFormBundleName(formId); + const auto moudleName = formBasicInfoMgr.GetFormModuleName(formId); + const auto formName = formBasicInfoMgr.GetFormName(formId); + const auto packageName = formBasicInfoMgr.GetFormPackageName(formId); + EXPECT_EQ(abilityName, INVALID_VALUE); + EXPECT_EQ(bundleName, INVALID_VALUE); + EXPECT_EQ(moudleName, INVALID_VALUE); + EXPECT_EQ(formName, INVALID_VALUE); + EXPECT_EQ(packageName, INVALID_VALUE); +} + +/** + * @tc.name: FormBasicInfoMgr_004 + * @tc.desc: test delete basic info function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_004, TestSize.Level1) +{ + const auto formSize = formBasicInfoMgr.GetBasinInfoCount(); + EXPECT_EQ(formSize, 1); + formBasicInfoMgr.DeleteFormBasicInfo(TEST_FORM_ID); + const auto formSizeDeleted = formBasicInfoMgr.GetBasinInfoCount(); + EXPECT_EQ(formSizeDeleted, 0); +} + +/** + * @tc.name: FormBasicInfoMgr_005 + * @tc.desc: test update basic info abilityName function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_005, TestSize.Level1) +{ + const auto abilityName = formBasicInfoMgr.GetFormAbilityName(TEST_FORM_ID); + EXPECT_EQ(abilityName, ABILITY_NAME); + const std::string newAbilityName = "newAbilityName"; + formBasicInfoMgr.UpdateAbilityName(TEST_FORM_ID, newAbilityName); + const auto updatedName = formBasicInfoMgr.GetFormAbilityName(TEST_FORM_ID); + EXPECT_NE(updatedName, abilityName); +} + +/** + * @tc.name: FormBasicInfoMgr_006 + * @tc.desc: test update basic info moduleName function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_006, TestSize.Level1) +{ + const auto moduleName = formBasicInfoMgr.GetFormModuleName(TEST_FORM_ID); + EXPECT_EQ(moduleName, ABILITY_NAME); + const std::string newModuleName = "newModuleName"; + formBasicInfoMgr.UpdateMoudleName(TEST_FORM_ID, newModuleName); + const auto updatedName = formBasicInfoMgr.GetFormModuleName(TEST_FORM_ID); + EXPECT_NE(updatedName, moduleName); +} + +/** + * @tc.name: FormBasicInfoMgr_007 + * @tc.desc: test update basic info bundleName function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_007, TestSize.Level1) +{ + const auto bundleName = formBasicInfoMgr.GetFormBundleName(TEST_FORM_ID); + EXPECT_EQ(bundleName, BUNDLE_NAME); + const std::string newBundleName = "newBundleName"; + formBasicInfoMgr.UpdateBundleName(TEST_FORM_ID, newBundleName); + const auto updatedName = formBasicInfoMgr.GetFormBundleName(TEST_FORM_ID); + EXPECT_NE(updatedName, bundleName); +} + +/** + * @tc.name: FormBasicInfoMgr_008 + * @tc.desc: test update basic info formName function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_008, TestSize.Level1) +{ + const auto formName = formBasicInfoMgr.GetFormName(TEST_FORM_ID); + EXPECT_EQ(formName, BUNDLE_NAME); + const std::string newFormName = "newFormName"; + formBasicInfoMgr.UpdateFormName(TEST_FORM_ID, newFormName); + const auto updatedName = formBasicInfoMgr.GetFormName(TEST_FORM_ID); + EXPECT_NE(updatedName, formName); +} + +/** + * @tc.name: FormBasicInfoMgr_009 + * @tc.desc: test update basic info formName function. + * @tc.type: FUNC + */ +HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_009, TestSize.Level1) +{ + const auto packageName = formBasicInfoMgr.GetFormPackageName(TEST_FORM_ID); + EXPECT_EQ(packageName, BUNDLE_NAME); + const std::string newPackageName = "newPackageName"; + formBasicInfoMgr.UpdatePackageName(TEST_FORM_ID, newPackageName); + const auto updatedName = formBasicInfoMgr.GetFormPackageName(TEST_FORM_ID); + EXPECT_NE(updatedName, packageName); +} +} // namespace \ No newline at end of file diff --git a/test/unittest/form_record_report_test/form_record_report_test.cpp b/test/unittest/form_record_report_test/form_record_report_test.cpp index 5c53ad527e..1ad2939ae0 100644 --- a/test/unittest/form_record_report_test/form_record_report_test.cpp +++ b/test/unittest/form_record_report_test/form_record_report_test.cpp @@ -57,10 +57,7 @@ HWTEST_F(FormRecordReportTest, FormRecordReport_001, TestSize.Level1) formRecordReport.SetFormRecordRecordInfo(TEST_FORM_ID, want); auto it = formRecordReport.GetFormRecords().find(TEST_FORM_ID); ASSERT_NE(it, formRecordReport.GetFormRecords().end()); - EXPECT_EQ(it->second.bundleName, BUNDLE_NAME); - EXPECT_EQ(it->second.formName, FORM_NAME); } - /** * @tc.name: FormRecordReport_002 * @tc.desc: test IncreaseUpdateTimes function. @@ -222,23 +219,4 @@ HWTEST_F(FormRecordReportTest, FormRecordReport_011, TestSize.Level1) auto iter = formRecordReport.formRecordReportMap_.find(formId); EXPECT_EQ(iter->second.offloadRecoverRefreshTimes, 0); } - -/** - * @tc.name: FormRecordReport_012 - * @tc.desc: test IncreaseUpdateTimes function. - * @tc.type: FUNC - */ -HWTEST_F(FormRecordReportTest, FormRecordReport_012, TestSize.Level1) -{ - FormRecordReportInfo formRecordReportInfo; - formRecordReportInfo.bundleName = "bundleName"; - int64_t formId = 1; - formRecordReport.formRecordReportMap_[formId] = formRecordReportInfo; - std::string bundleName = "test_bundleName"; - Want want; - want.GetElement().SetBundleName(bundleName); - formRecordReport.SetFormRecordRecordInfo(formId, want); - auto iter = formRecordReport.formRecordReportMap_.find(formId); - EXPECT_NE(iter->second.bundleName, bundleName); -} } // namespace \ No newline at end of file -- Gitee From 162523903ff68e4b02e63f411f8a9d2a2727f4fd Mon Sep 17 00:00:00 2001 From: zhushupei Date: Thu, 22 May 2025 16:48:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BD=92=E4=B8=80?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushupei --- test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h index 954d4bd700..8a88b0c637 100644 --- a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h +++ b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h @@ -1,5 +1,3 @@ -code/foundation/ability/form_fwk/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h - /* * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); -- Gitee From 10dcd4dfacb7e8ed62ded610fba5010d8886a7f0 Mon Sep 17 00:00:00 2001 From: zhushupei Date: Thu, 22 May 2025 20:55:21 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BD=92=E4=B8=80?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushupei --- services/include/data_center/form_basic_info_mgr.h | 2 +- services/src/data_center/form_basic_info_mgr.cpp | 2 +- .../fms_form_data_mgr_test/mock_form_db_cache.cpp | 3 +-- .../form_basic_info_mgr_test.cpp | 14 +++++++------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/services/include/data_center/form_basic_info_mgr.h b/services/include/data_center/form_basic_info_mgr.h index 0bc3edb1dc..8034e2aa37 100644 --- a/services/include/data_center/form_basic_info_mgr.h +++ b/services/include/data_center/form_basic_info_mgr.h @@ -45,7 +45,7 @@ public: void DeleteFormBasicInfo(int64_t formId); void ClearFormBasicInfo(); - int GetBasinInfoCount() const; + int GetBasicInfoCount() const; bool GetBasicInfoByFormId(int64_t formId, FormBasicInfo& basicInfo); const std::string& GetFormAbilityName(int64_t formId); diff --git a/services/src/data_center/form_basic_info_mgr.cpp b/services/src/data_center/form_basic_info_mgr.cpp index 73ba4022e8..09c06c8505 100644 --- a/services/src/data_center/form_basic_info_mgr.cpp +++ b/services/src/data_center/form_basic_info_mgr.cpp @@ -57,7 +57,7 @@ void FormBasicInfoMgr::ClearFormBasicInfo() formBasicInfoMap_.clear(); } -int FormBasicInfoMgr::GetBasinInfoCount() const +int FormBasicInfoMgr::GetBasicInfoCount() const { return formBasicInfoMap_.size(); } diff --git a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.cpp b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.cpp index a54c88ead1..6e9754e5ed 100644 --- a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.cpp +++ b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.cpp @@ -69,8 +69,7 @@ void FormDbCache::GetAllFormInfo(std::vector &formDBInfos) } /** - * @brief Get all form data size from DbCache. - * @param formDBInfos Storage all DbCache. + * @brief Get all form data size. * @return int32_t. */ int32_t FormDbCache::GetAllFormInfoSize() diff --git a/test/unittest/form_basic_info_mgr_test/form_basic_info_mgr_test.cpp b/test/unittest/form_basic_info_mgr_test/form_basic_info_mgr_test.cpp index 687f46196a..b7ec93a80b 100644 --- a/test/unittest/form_basic_info_mgr_test/form_basic_info_mgr_test.cpp +++ b/test/unittest/form_basic_info_mgr_test/form_basic_info_mgr_test.cpp @@ -62,7 +62,7 @@ void FormBasicInfoMgrTest::TearDown() */ HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_001, TestSize.Level1) { - const auto formSize = formBasicInfoMgr.GetBasinInfoCount(); + const auto formSize = formBasicInfoMgr.GetBasicInfoCount(); EXPECT_EQ(formSize, 1); } @@ -94,10 +94,10 @@ HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_003, TestSize.Level1) { int64_t formId = 1; const auto abilityName = formBasicInfoMgr.GetFormAbilityName(formId); - const auto bundleName = formBasicInfoMgr.GetFormBundleName(formId); - const auto moudleName = formBasicInfoMgr.GetFormModuleName(formId); - const auto formName = formBasicInfoMgr.GetFormName(formId); - const auto packageName = formBasicInfoMgr.GetFormPackageName(formId); + const auto bundleName = formBasicInfoMgr.GetFormBundleName(formId); + const auto moudleName = formBasicInfoMgr.GetFormModuleName(formId); + const auto formName = formBasicInfoMgr.GetFormName(formId); + const auto packageName = formBasicInfoMgr.GetFormPackageName(formId); EXPECT_EQ(abilityName, INVALID_VALUE); EXPECT_EQ(bundleName, INVALID_VALUE); EXPECT_EQ(moudleName, INVALID_VALUE); @@ -112,10 +112,10 @@ HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_003, TestSize.Level1) */ HWTEST_F(FormBasicInfoMgrTest, FormBasicInfoMgr_004, TestSize.Level1) { - const auto formSize = formBasicInfoMgr.GetBasinInfoCount(); + const auto formSize = formBasicInfoMgr.GetBasicInfoCount(); EXPECT_EQ(formSize, 1); formBasicInfoMgr.DeleteFormBasicInfo(TEST_FORM_ID); - const auto formSizeDeleted = formBasicInfoMgr.GetBasinInfoCount(); + const auto formSizeDeleted = formBasicInfoMgr.GetBasicInfoCount(); EXPECT_EQ(formSizeDeleted, 0); } -- Gitee From cbdb4cae02eadf9444be2be33dfadba4b4a28b86 Mon Sep 17 00:00:00 2001 From: zhushupei Date: Thu, 22 May 2025 21:25:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BD=92=E4=B8=80?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushupei --- services/include/data_center/form_basic_info_mgr.h | 2 +- services/src/data_center/form_record/form_record_report.cpp | 2 +- test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/include/data_center/form_basic_info_mgr.h b/services/include/data_center/form_basic_info_mgr.h index 8034e2aa37..508d816ef9 100644 --- a/services/include/data_center/form_basic_info_mgr.h +++ b/services/include/data_center/form_basic_info_mgr.h @@ -36,7 +36,7 @@ struct FormBasicInfo { * form basic info mananger. */ class FormBasicInfoMgr final : public DelayedRefSingleton { -DECLARE_DELAYED_REF_SINGLETON(FormBasicInfoMgr) + DECLARE_DELAYED_REF_SINGLETON(FormBasicInfoMgr) public: DISALLOW_COPY_AND_MOVE(FormBasicInfoMgr); diff --git a/services/src/data_center/form_record/form_record_report.cpp b/services/src/data_center/form_record/form_record_report.cpp index 07540ab292..334ddd5d25 100644 --- a/services/src/data_center/form_record/form_record_report.cpp +++ b/services/src/data_center/form_record/form_record_report.cpp @@ -13,10 +13,10 @@ * limitations under the License. */ -#include "data_center/form_basic_info_mgr.h" #include "data_center/form_record/form_record_report.h" #include "fms_log_wrapper.h" #include "common/event/form_event_report.h" +#include "data_center/form_basic_info_mgr.h" namespace OHOS { namespace AppExecFwk { diff --git a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h index 8a88b0c637..329ae64889 100644 --- a/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h +++ b/test/unittest/fms_form_data_mgr_test/mock_form_db_cache.h @@ -23,6 +23,6 @@ #include "common/util/form_util.h" namespace OHOS { -void MockGetAllFormInfoSize(int32_t mockRet, int callingUid); + void MockGetAllFormInfoSize(int32_t mockRet, int callingUid); } #endif // OHOS_MOCK_FORM_DB_CACHE_H \ No newline at end of file -- Gitee