From a8a8dd5dddd5eb26b67e4a2a978717c72751550c Mon Sep 17 00:00:00 2001 From: wangpggg Date: Wed, 18 Sep 2024 09:30:44 +0800 Subject: [PATCH] add ut Signed-off-by: wangpeng --- .../include/ext_extension_stub_mock.h | 41 +++ .../backup_ext/src/ext_backup_js_mock.cpp | 101 ++++++ .../include/bms_adapter_mock.h | 4 + .../module_external/src/bms_adapter_mock.cpp | 11 + .../include/svc_extension_proxy_mock.h | 1 + .../src/svc_session_manager_mock.cpp | 2 + tests/unittests/backup_sa/module_ipc/BUILD.gn | 61 ++++ .../module_ipc/service_incremental_test.cpp | 339 ++++++++++++++++++ 8 files changed, 560 insertions(+) create mode 100644 tests/mock/backup_ext/include/ext_extension_stub_mock.h create mode 100644 tests/mock/backup_ext/src/ext_backup_js_mock.cpp create mode 100644 tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp diff --git a/tests/mock/backup_ext/include/ext_extension_stub_mock.h b/tests/mock/backup_ext/include/ext_extension_stub_mock.h new file mode 100644 index 000000000..6cc34071e --- /dev/null +++ b/tests/mock/backup_ext/include/ext_extension_stub_mock.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 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_FILEMGMT_BACKUP_EXT_EXTENSION_STUB_MOCK_H +#define OHOS_FILEMGMT_BACKUP_EXT_EXTENSION_STUB_MOCK_H + +#include + +#include "ext_extension_stub.h" + +namespace OHOS::FileManagement::Backup { +class ExtExtensionStubMock : public ExtExtensionStub { +public: + MOCK_METHOD(int, OnRemoteRequest, (uint32_t, MessageParcel &, MessageParcel &, MessageOption &)); + MOCK_METHOD(ErrCode, CmdGetFileHandle, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdHandleClear, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdHandleBackup, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdPublishFile, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdHandleRestore, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdGetIncrementalFileHandle, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdPublishIncrementalFile, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdHandleIncrementalBackup, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdIncrementalOnBackup, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdGetIncrementalBackupFileHandle, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdGetBackupInfo, (MessageParcel &, MessageParcel &)); + MOCK_METHOD(ErrCode, CmdUpdateFdSendRate, (MessageParcel &, MessageParcel &)); +}; +} // namespace OHOS::FileManagement::Backup +#endif // OHOS_FILEMGMT_BACKUP_EXT_EXTENSION_STUB_MOCK_H diff --git a/tests/mock/backup_ext/src/ext_backup_js_mock.cpp b/tests/mock/backup_ext/src/ext_backup_js_mock.cpp new file mode 100644 index 000000000..1f97308fd --- /dev/null +++ b/tests/mock/backup_ext/src/ext_backup_js_mock.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2022-2024 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 "ext_backup_js.h" +#include "ext_backup_js_mock.h" + +namespace OHOS::FileManagement::Backup { +using namespace std; +void ExtBackupJs::Init(const shared_ptr &record, + const shared_ptr &application, + shared_ptr &handler, + const sptr &token) +{ + BExtBackupJs::extBackupJs->Init(record, application, handler, token); +} + +void ExtBackupJs::ExportJsContext(void) +{ + BExtBackupJs::extBackupJs->ExportJsContext(); +} + +ExtBackupJs *ExtBackupJs::Create(const unique_ptr &runtime) +{ + return BExtBackupJs::extBackupJs->Create(runtime); +} + +ErrCode ExtBackupJs::OnBackup(function callback, + function callbackEx) +{ + return BExtBackupJs::extBackupJs->OnBackup(callback, callbackEx); +} + +ErrCode ExtBackupJs::CallJsOnBackupEx() +{ + return BExtBackupJs::extBackupJs->CallJsOnBackupEx(); +} + +ErrCode ExtBackupJs::CallJsOnBackup() +{ + return BExtBackupJs::extBackupJs->CallJsOnBackup(); +} + +ErrCode ExtBackupJs::OnRestore(function callback, + function callbackEx) +{ + return BExtBackupJs::extBackupJs->OnRestore(callback, callbackEx); +} + +ErrCode ExtBackupJs::CallJSRestoreEx() +{ + return BExtBackupJs::extBackupJs->CallJSRestoreEx(); +} + +ErrCode ExtBackupJs::CallJSRestore() +{ + return BExtBackupJs::extBackupJs->CallJSRestore(); +} + +ErrCode ExtBackupJs::GetBackupInfo(function callback) +{ + return BExtBackupJs::extBackupJs->GetBackupInfo(callback); +} + +int ExtBackupJs::CallJsMethod(const string &funcName, AbilityRuntime::JsRuntime &jsRuntime, NativeReference *jsObj, + InputArgsParser argParser, ResultValueParser retParser) +{ + return BExtBackupJs::extBackupJs->CallJsMethod(funcName, jsRuntime, jsObj, argParser, retParser); +} + +function &argv)> ExtBackupJs::ParseBackupExInfo() +{ + return BExtBackupJs::extBackupJs->ParseBackupExInfo(); +} + +function &argv)> ExtBackupJs::ParseRestoreExInfo() +{ + return BExtBackupJs::extBackupJs->ParseRestoreExInfo(); +} + +function &argv)> ExtBackupJs::ParseRestoreInfo() +{ + return BExtBackupJs::extBackupJs->ParseRestoreInfo(); +} + +ErrCode ExtBackupJs::InvokeAppExtMethod(ErrCode errCode, const string result) +{ + return BExtBackupJs::extBackupJs->InvokeAppExtMethod(errCode, result); +} +} // namespace OHOS::FileManagement::Backup diff --git a/tests/mock/module_external/include/bms_adapter_mock.h b/tests/mock/module_external/include/bms_adapter_mock.h index 3a98456bd..71be1df2a 100644 --- a/tests/mock/module_external/include/bms_adapter_mock.h +++ b/tests/mock/module_external/include/bms_adapter_mock.h @@ -32,6 +32,9 @@ public: virtual std::string GetExtName(string, int32_t) = 0; virtual std::vector GetBundleInfosForSA() = 0; virtual void GetBundleInfoForSA(std::string, std::vector&) = 0; + virtual bool IsUser0BundleName(std::string, int32_t) = 0; + virtual std::vector + GetBundleInfosForAppend(const std::vector&, int32_t) = 0; public: BBundleMgrAdapter() = default; virtual ~BBundleMgrAdapter() = default; @@ -51,6 +54,7 @@ public: MOCK_METHOD(std::string, GetExtName, (std::string, int32_t)); MOCK_METHOD((std::vector), GetBundleInfosForSA, ()); MOCK_METHOD(void, GetBundleInfoForSA, (std::string, (std::vector&))); + MOCK_METHOD(bool, IsUser0BundleName, (std::string, int32_t)); MOCK_METHOD((std::vector), GetBundleInfosForAppend, ((const std::vector&), int32_t)); }; diff --git a/tests/mock/module_external/src/bms_adapter_mock.cpp b/tests/mock/module_external/src/bms_adapter_mock.cpp index 7421fcaba..88984a7cb 100644 --- a/tests/mock/module_external/src/bms_adapter_mock.cpp +++ b/tests/mock/module_external/src/bms_adapter_mock.cpp @@ -54,4 +54,15 @@ void BundleMgrAdapter::GetBundleInfoForSA(std::string bundleName, std::vectorGetBundleInfoForSA(bundleName, bundleInfos); } + +bool BundleMgrAdapter::IsUser0BundleName(std::string bundleName, int32_t userId) +{ + return BBundleMgrAdapter::bms->IsUser0BundleName(bundleName, userId); +} + +vector BundleMgrAdapter::GetBundleInfosForAppend( + const vector &incrementalDataList, int32_t userId) +{ + return BBundleMgrAdapter::bms->GetBundleInfosForAppend(incrementalDataList, userId); +} } // namespace OHOS::FileManagement::Backup \ No newline at end of file diff --git a/tests/mock/module_ipc/include/svc_extension_proxy_mock.h b/tests/mock/module_ipc/include/svc_extension_proxy_mock.h index 67ec3d9c4..fd4664e77 100644 --- a/tests/mock/module_ipc/include/svc_extension_proxy_mock.h +++ b/tests/mock/module_ipc/include/svc_extension_proxy_mock.h @@ -37,6 +37,7 @@ public: MOCK_METHOD((std::tuple), GetIncrementalBackupFileHandle, ()); MOCK_METHOD(ErrCode, GetBackupInfo, (std::string&)); MOCK_METHOD(ErrCode, UpdateFdSendRate, (std::string&, int32_t)); + MOCK_METHOD(ErrCode, User0OnBackup, ()); }; } // namespace OHOS::FileManagement::Backup #endif // OHOS_FILEMGMT_BACKUP_SVC_BACKUP_CONNECTION_MOCK_H \ No newline at end of file diff --git a/tests/mock/module_ipc/src/svc_session_manager_mock.cpp b/tests/mock/module_ipc/src/svc_session_manager_mock.cpp index 3f394b50a..5c65f93e6 100644 --- a/tests/mock/module_ipc/src/svc_session_manager_mock.cpp +++ b/tests/mock/module_ipc/src/svc_session_manager_mock.cpp @@ -231,4 +231,6 @@ bool SvcSessionManager::GetClearDataFlag(const std::string &bundleName) void SvcSessionManager::IncreaseSessionCnt(const std::string) {} void SvcSessionManager::DecreaseSessionCnt(const std::string) {} + +void SvcSessionManager::SetPublishFlag(const std::string&) {} } // namespace OHOS::FileManagement::Backup diff --git a/tests/unittests/backup_sa/module_ipc/BUILD.gn b/tests/unittests/backup_sa/module_ipc/BUILD.gn index 1c9051f27..aec9584b8 100644 --- a/tests/unittests/backup_sa/module_ipc/BUILD.gn +++ b/tests/unittests/backup_sa/module_ipc/BUILD.gn @@ -398,10 +398,71 @@ ohos_unittest("backup_restore_deps_manager_test") { use_exceptions = true } +ohos_unittest("backup_service_incremental_test") { + module_out_path = path_module_out_tests + + sources = [ + "${path_backup_mock}/accesstoken/accesstoken_kit_mock.cpp", + "${path_backup_mock}/module_external/src/bms_adapter_mock.cpp", + "${path_backup_mock}/module_external/src/sms_adapter_mock.cpp", + "${path_backup_mock}/module_ipc/src/ipc_skeleton_mock.cpp", + "${path_backup_mock}/module_ipc/src/sa_backup_connection_mock.cpp", + "${path_backup_mock}/module_ipc/src/service_stub_mock.cpp", + "${path_backup_mock}/module_ipc/src/svc_backup_connection_mock.cpp", + "${path_backup_mock}/module_ipc/src/svc_session_manager_mock.cpp", + "${path_backup_mock}/module_sched/sched_scheduler_mock.cpp", + "${path_backup_mock}/utils_mock/src/backup_para_mock.cpp", + "${path_backup}/services/backup_sa/src/module_ipc/svc_extension_incremental_proxy.cpp", + "${path_backup}/services/backup_sa/src/module_ipc/svc_extension_proxy.cpp", + "service_incremental_test.cpp", + ] + + include_dirs = [ + "${path_backup}/interfaces/inner_api/native/backup_kit_inner/impl", + "${path_backup}/services/backup_sa/include", + "${path_backup}/services/backup_sa/include/module_ipc", + "${path_backup}/services/backup_sa/src/module_ipc", + "${path_backup}/tests/unittests/backup_api/backup_impl/include", + "${path_backup}/tests/utils/include/", + "${path_backup_mock}/module_external/include", + "${path_backup_mock}/module_ipc/include", + "${path_backup_mock}/utils_mock/include", + "${path_access_token}/interfaces/innerkits/accesstoken/include", + ] + + deps = [ + "${path_backup}/interfaces/inner_api/native/backup_kit_inner:backup_kit_inner", + "${path_backup}/tests/utils:backup_test_utils", + "${path_backup}/utils:backup_utils", + "${path_googletest}:gmock_main", + "${path_jsoncpp}:jsoncpp", + ] + + external_deps = [ + "ability_base:want", + "ability_runtime:ability_manager", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbegetutil", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "storage_service:storage_manager_sa_proxy", + ] + + defines = [ "private=public" ] + use_exceptions = true +} + group("backup_sa_ipc_test") { testonly = true deps = [ ":backup_restore_deps_manager_test", + ":backup_service_incremental_test", ":backup_service_scheduler_test", ":backup_service_session_test", ":backup_service_test", diff --git a/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp b/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp new file mode 100644 index 000000000..00c042573 --- /dev/null +++ b/tests/unittests/backup_sa/module_ipc/service_incremental_test.cpp @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2024 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 + +#include "backup_para_mock.h" +#include "bms_adapter_mock.h" +#include "b_jsonutil_mock.h" +#include "ipc_skeleton_mock.h" +#include "sa_backup_connection_mock.h" +#include "service_reverse_proxy_mock.h" +#include "svc_backup_connection_mock.h" +#include "svc_extension_proxy_mock.h" +#include "svc_session_manager_mock.h" + +#include "service_incremental.cpp" + +namespace OHOS::FileManagement::Backup { +using namespace std; + +void Service::OnStart() {} + +void Service::OnStop() {} + +UniqueFd Service::GetLocalCapabilities() +{ + return UniqueFd(-1); +} + +void Service::StopAll(const wptr &obj, bool force) {} + +string Service::VerifyCallerAndGetCallerName() +{ + return ""; +} + +ErrCode Service::InitRestoreSession(sptr remote) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::InitBackupSession(sptr remote) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::Start() +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::PublishFile(const BFileInfo &fileInfo) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::AppFileReady(const string &fileName, UniqueFd fd, int32_t errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::AppDone(ErrCode errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::ServiceResultReport(const std::string restoreRetInfo, + BackupRestoreScenario sennario, ErrCode errCode) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::AppendBundlesRestoreSession(UniqueFd fd, const std::vector &bundleNames, + const std::vector &detailInfos, RestoreTypeEnum restoreType, int32_t userId) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::AppendBundlesRestoreSession(UniqueFd fd, + const std::vector &bundleNames, + RestoreTypeEnum restoreType, + int32_t userId) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::AppendBundlesBackupSession(const std::vector &bundleNames) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::AppendBundlesDetailsBackupSession(const std::vector &bundleNames, + const std::vector &bundleInfos) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::Finish() +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::LaunchBackupExtension(const BundleName &bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::LaunchBackupSAExtension(const BundleName &bundleName) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::GetFileHandle(const string &bundleName, const string &fileName) +{ + return BError(BError::Codes::OK); +} + +void Service::OnBackupExtensionDied(const string &&bundleName) {} + +void Service::ExtConnectDied(const string &callName) {} + +void Service::ExtStart(const string &bundleName) {} + +int Service::Dump(int fd, const vector &args) +{ + return 0; +} + +void Service::ExtConnectFailed(const string &bundleName, ErrCode ret) +{ + GTEST_LOG_(INFO) << "ExtConnectFailed is OK"; +} + +void Service::ExtConnectDone(string bundleName) {} + +void Service::ClearSessionAndSchedInfo(const string &bundleName) {} + +void Service::VerifyCaller() {} + +void Service::VerifyCaller(IServiceReverse::Scenario scenario) {} + +void Service::OnAllBundlesFinished(ErrCode errCode) {} + +void Service::OnStartSched() {} + +void Service::SendStartAppGalleryNotify(const BundleName &bundleName) {} + +void Service::SessionDeactive() {} + +ErrCode Service::GetBackupInfo(BundleName &bundleName, std::string &result) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::UpdateTimer(BundleName &bundleName, uint32_t timeOut, bool &result) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::UpdateSendRate(std::string &bundleName, int32_t sendRate, bool &result) +{ + return BError(BError::Codes::OK); +} + +void Service::OnSABackup(const std::string &bundleName, + const int &fd, + const std::string &result, + const ErrCode &errCode) +{ +} + +void Service::OnSARestore(const std::string &bundleName, const std::string &result, const ErrCode &errCode) {} + +void Service::SendEndAppGalleryNotify(const BundleName &bundleName) +{ +} + +void Service::NoticeClientFinish(const string &bundleName, ErrCode errCode) +{ +} + +ErrCode Service::ReportAppProcessInfo(const std::string processInfo, BackupRestoreScenario sennario) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::StartExtTimer(bool &isExtStart) +{ + return BError(BError::Codes::OK); +} + +ErrCode Service::StartFwkTimer(bool &isFwkStart) +{ + return BError(BError::Codes::OK); +} + +void Service::SetCurrentSessProperties(std::vector&, std::vector&, + RestoreTypeEnum) {} + +void Service::SetCurrentSessProperties(std::vector&, std::vector&, + std::map>&, std::map&, RestoreTypeEnum) {} + +void Service::SetCurrentSessProperties(BJsonEntityCaps::BundleInfo&, std::map&) {} + +void Service::ReleaseOnException() {} + +bool SvcRestoreDepsManager::UpdateToRestoreBundleMap(const string&, const string&) +{ + return true; +} +} // namespace OHOS::FileManagement::Backup + +namespace OHOS::FileManagement::Backup { +using namespace std; +using namespace testing; +using namespace testing::ext; + +constexpr int32_t SERVICE_ID = 5203; + +class ServiceIncrementalTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(); + void SetUp() {}; + void TearDown() {}; + + static inline sptr service = nullptr; + static inline shared_ptr param = nullptr; + static inline shared_ptr jsonUtil = nullptr; + static inline shared_ptr session = nullptr; + static inline shared_ptr bms = nullptr; + static inline sptr svcProxy = nullptr; + static inline sptr connect = nullptr; + static inline sptr saConnect = nullptr; + static inline shared_ptr skeleton = nullptr; + static inline sptr srProxy = nullptr; +}; + +void ServiceIncrementalTest::SetUpTestCase(void) +{ + GTEST_LOG_(INFO) << "SetUpTestCase enter"; + service = sptr(new Service(SERVICE_ID)); + param = make_shared(); + BackupParaMock::backupPara = param; + jsonUtil = make_shared(); + BJsonUtilMock::jsonUtil = jsonUtil; + session = make_shared(); + SvcSessionManagerMock::sessionManager = session; + svcProxy = sptr(new SvcExtensionProxyMock()); + bms = make_shared(); + BundleMgrAdapterMock::bms = bms; + connect = sptr(new SvcBackupConnectionMock()); + SvcBackupConnectionMock::connect = connect; + saConnect = sptr(new SABackupConnectionMock()); + SABackupConnectionMock::saConnect = saConnect; + skeleton = make_shared(); + IPCSkeletonMock::skeleton = skeleton; + srProxy = sptr(new ServiceReverseProxyMock()); +} + +void ServiceIncrementalTest::TearDownTestCase() +{ + GTEST_LOG_(INFO) << "TearDownTestCase enter"; + service = nullptr; + BackupParaMock::backupPara = nullptr; + param = nullptr; + BJsonUtilMock::jsonUtil = nullptr; + jsonUtil = nullptr; + SvcSessionManagerMock::sessionManager = nullptr; + session = nullptr; + svcProxy = nullptr; + BundleMgrAdapterMock::bms = nullptr; + bms = nullptr; + SvcBackupConnectionMock::connect = nullptr; + connect = nullptr; + SABackupConnectionMock::saConnect = nullptr; + saConnect = nullptr; + IPCSkeletonMock::skeleton = nullptr; + skeleton = nullptr; + srProxy = nullptr; +} + +/** + * @tc.number: SUB_ServiceIncremental_GetUserIdDefault_0000 + * @tc.name: SUB_ServiceIncremental_GetUserIdDefault_0000 + * @tc.desc: 测试 GetUserIdDefault 的正常/异常分支 + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: issueIAKC3I + */ +HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_GetUserIdDefault_0000, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ServiceIncrementalTest-begin SUB_ServiceIncremental_GetUserIdDefault_0000"; + try { + EXPECT_CALL(*param, GetBackupDebugOverrideAccount()) + .WillOnce(Return(make_pair(true, DEBUG_ID + 1))); + auto ret = GetUserIdDefault(); + EXPECT_EQ(ret, DEBUG_ID + 1); + + EXPECT_CALL(*param, GetBackupDebugOverrideAccount()).WillOnce(Return(make_pair(false, 0))); + EXPECT_CALL(*skeleton, GetCallingUid()).WillOnce(Return(BConstants::SYSTEM_UID)); + ret = GetUserIdDefault(); + EXPECT_EQ(ret, BConstants::DEFAULT_USER_ID); + + EXPECT_CALL(*param, GetBackupDebugOverrideAccount()).WillOnce(Return(make_pair(true, 0))); + EXPECT_CALL(*skeleton, GetCallingUid()).WillOnce(Return(BConstants::SYSTEM_UID)); + ret = GetUserIdDefault(); + EXPECT_EQ(ret, BConstants::DEFAULT_USER_ID); + + EXPECT_CALL(*param, GetBackupDebugOverrideAccount()).WillOnce(Return(make_pair(false, 0))); + EXPECT_CALL(*skeleton, GetCallingUid()).WillOnce(Return(BConstants::XTS_UID)); + ret = GetUserIdDefault(); + EXPECT_EQ(ret, BConstants::DEFAULT_USER_ID); + + EXPECT_CALL(*param, GetBackupDebugOverrideAccount()).WillOnce(Return(make_pair(false, 0))); + EXPECT_CALL(*skeleton, GetCallingUid()) + .WillOnce(Return(BConstants::SPAN_USERID_UID + BConstants::SPAN_USERID_UID)); + ret = GetUserIdDefault(); + EXPECT_EQ(ret, 2); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "ServiceIncrementalTest-an exception occurred by GetUserIdDefault."; + } + GTEST_LOG_(INFO) << "ServiceIncrementalTest-end SUB_ServiceIncremental_GetUserIdDefault_0000"; +} +} \ No newline at end of file -- Gitee