Merge pull request !1377 from wangpggg/master
This commit is contained in:
openharmony_ci 2024-11-22 07:34:02 +00:00 committed by Gitee
commit 90f335d812
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 555 additions and 10 deletions

View File

@ -272,7 +272,6 @@ HWTEST_F(ServiceTest, SUB_Service_GetUserIdDefault_0000, TestSize.Level1)
EXPECT_CALL(*param, GetBackupDebugOverrideAccount()).WillOnce(Return(make_pair<bool, int32_t>(false, 0)));
EXPECT_CALL(*skeleton, GetCallingUid())
.WillOnce(Return(BConstants::SPAN_USERID_UID + BConstants::SPAN_USERID_UID))
.WillOnce(Return(BConstants::SPAN_USERID_UID + BConstants::SPAN_USERID_UID));
ret = GetUserIdDefault();
EXPECT_EQ(ret, 2);
@ -373,8 +372,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnStart_0200, TestSize.Level1)
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(vector<string>(1)))
.WillOnce(Return(vector<string>()));
EXPECT_CALL(*cdConfig, GetAllClearBundleRecords()).WillOnce(Return(vector<string>()));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*skeleton, GetCallingTokenID()).WillOnce(Return(0)).WillOnce(Return(0));
EXPECT_CALL(*skeleton, GetCallingTokenID()).WillOnce(Return(0));
EXPECT_CALL(*param, GetBackupDebugOverrideAccount())
.WillOnce(Return(make_pair<bool, int32_t>(true, DEBUG_ID + 1)))
.WillOnce(Return(make_pair<bool, int32_t>(true, DEBUG_ID + 1)));
@ -407,7 +405,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnStart_0300, TestSize.Level1)
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(vector<string>()))
.WillOnce(Return(vector<string>()));
EXPECT_CALL(*cdConfig, GetAllClearBundleRecords()).WillOnce(Return(vector<string>(1)));
EXPECT_CALL(*skeleton, GetCallingTokenID()).WillOnce(Return(0)).WillOnce(Return(0));
EXPECT_CALL(*skeleton, GetCallingTokenID()).WillOnce(Return(0));
EXPECT_CALL(*param, GetBackupDebugOverrideAccount())
.WillOnce(Return(make_pair<bool, int32_t>(true, DEBUG_ID + 1)))
.WillOnce(Return(make_pair<bool, int32_t>(true, DEBUG_ID + 1)));
@ -419,7 +417,7 @@ HWTEST_F(ServiceTest, SUB_Service_OnStart_0300, TestSize.Level1)
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(vector<string>(1)))
.WillOnce(Return(vector<string>()));
EXPECT_CALL(*cdConfig, GetAllClearBundleRecords()).WillOnce(Return(vector<string>(1)));
EXPECT_CALL(*skeleton, GetCallingTokenID()).WillOnce(Return(0)).WillOnce(Return(0));
EXPECT_CALL(*skeleton, GetCallingTokenID()).WillOnce(Return(0));
EXPECT_CALL(*param, GetBackupDebugOverrideAccount())
.WillOnce(Return(make_pair<bool, int32_t>(true, DEBUG_ID + 1)))
.WillOnce(Return(make_pair<bool, int32_t>(true, DEBUG_ID + 1)))
@ -1705,6 +1703,7 @@ HWTEST_F(ServiceTest, SUB_Service_NotifyCallerCurAppDone_0000, TestSize.Level1)
EXPECT_TRUE(true);
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true));
EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy));
EXPECT_CALL(*srProxy, RestoreOnBundleFinished(_, _)).WillOnce(Return());
service->NotifyCallerCurAppDone(0, "");

View File

@ -31,10 +31,6 @@ HWTEST_F(ServiceTest, SUB_Service_HandleCurGroupBackupInfos_0000, TestSize.Level
map<string, vector<BJsonUtil::BundleDetailInfo>> bundleNameDetailMap;
map<string, bool> isClearDataFlags;
EXPECT_CALL(*jsonUtil, BuildBundleNameIndexInfo(_, _)).WillOnce(Return(""));
EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy));
EXPECT_CALL(*srProxy, BackupOnBundleStarted(_, _)).WillOnce(Return());
EXPECT_CALL(*param, GetBackupDebugOverrideAccount())
.WillOnce(Return(make_pair<bool, int32_t>(true, DEBUG_ID + 1)));
EXPECT_CALL(*jsonUtil, FindBundleInfoByName(_, _, _, _)).WillOnce(Return(false));
service->HandleCurGroupBackupInfos(backupInfos, bundleNameDetailMap, isClearDataFlags);
EXPECT_TRUE(true);
@ -859,3 +855,553 @@ HWTEST_F(ServiceTest, SUB_Service_HandleRestoreDepsBundle_0000, TestSize.Level1)
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_HandleRestoreDepsBundle_0000";
}
/**
* @tc.number: SUB_Service_OnAllBundlesFinished_0000
* @tc.name: SUB_Service_OnAllBundlesFinished_0000
* @tc.desc: OnAllBundlesFinished /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_OnAllBundlesFinished_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_OnAllBundlesFinished_0000";
try {
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(false));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
service->isInRelease_.store(false);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(true));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
service->isInRelease_.store(true);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(true));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
service->isInRelease_.store(true);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE))
.WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*session, CleanAndCheckIfNeedWait(_, _)).WillOnce(Return(true));
EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(false));
EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy));
EXPECT_CALL(*srProxy, RestoreOnAllBundlesFinished(_)).WillOnce(Return());
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(true));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
service->isInRelease_.store(false);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP));
EXPECT_CALL(*session, GetIsIncrementalBackup()).WillOnce(Return(true));
EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy));
EXPECT_CALL(*srProxy, IncrementalBackupOnAllBundlesFinished(_)).WillOnce(Return());
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(true));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by OnAllBundlesFinished.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_OnAllBundlesFinished_0000";
}
/**
* @tc.number: SUB_Service_OnAllBundlesFinished_0100
* @tc.name: SUB_Service_OnAllBundlesFinished_0100
* @tc.desc: OnAllBundlesFinished /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_OnAllBundlesFinished_0100, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_OnAllBundlesFinished_0100";
try {
service->isInRelease_.store(false);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::BACKUP));
EXPECT_CALL(*session, GetIsIncrementalBackup()).WillOnce(Return(false));
EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy));
EXPECT_CALL(*srProxy, BackupOnAllBundlesFinished(_)).WillOnce(Return());
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(true));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
service->isInRelease_.store(false);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(true));
EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(true));
EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy));
EXPECT_CALL(*srProxy, IncrementalRestoreOnAllBundlesFinished(_)).WillOnce(Return());
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(true));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
service->isInRelease_.store(false);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(true));
EXPECT_CALL(*session, ValidRestoreDataType(_)).WillOnce(Return(false));
EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy));
EXPECT_CALL(*srProxy, RestoreOnAllBundlesFinished(_)).WillOnce(Return());
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(true));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by OnAllBundlesFinished.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_OnAllBundlesFinished_0100";
}
/**
* @tc.number: SUB_Service_OnAllBundlesFinished_0200
* @tc.name: SUB_Service_OnAllBundlesFinished_0200
* @tc.desc: OnAllBundlesFinished /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_OnAllBundlesFinished_0200, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_OnAllBundlesFinished_0200";
try {
service->isInRelease_.store(false);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*param, GetBackupOverrideIncrementalRestore()).WillOnce(Return(false));
EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy));
EXPECT_CALL(*srProxy, RestoreOnAllBundlesFinished(_)).WillOnce(Return());
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(true));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
service->isInRelease_.store(false);
EXPECT_CALL(*session, IsOnAllBundlesFinished()).WillOnce(Return(true));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*param, GetBackupOverrideBackupSARelease()).WillOnce(Return(false));
service->OnAllBundlesFinished(0);
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by OnAllBundlesFinished.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_OnAllBundlesFinished_0200";
}
/**
* @tc.number: SUB_Service_OnStartSched_0000
* @tc.name: SUB_Service_OnStartSched_0000
* @tc.desc: OnStartSched /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_OnStartSched_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_OnStartSched_0000";
try {
EXPECT_CALL(*session, IsOnOnStartSched()).WillOnce(Return(false));
service->OnStartSched();
EXPECT_TRUE(true);
EXPECT_CALL(*session, IsOnOnStartSched()).WillOnce(Return(true));
service->OnStartSched();
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by OnStartSched.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_OnStartSched_0000";
}
/**
* @tc.number: SUB_Service_SendStartAppGalleryNotify_0000
* @tc.name: SUB_Service_SendStartAppGalleryNotify_0000
* @tc.desc: SendStartAppGalleryNotify /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_SendStartAppGalleryNotify_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_SendStartAppGalleryNotify_0000";
try {
BundleName bundleName;
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true));
service->SendStartAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(false));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
service->SendStartAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(false));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*jdConfig, IfBundleNameInDisposalConfigFile(_)).WillOnce(Return(false));
service->SendStartAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(false));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*jdConfig, IfBundleNameInDisposalConfigFile(_)).WillOnce(Return(true));
EXPECT_CALL(*gallery, StartRestore(_)).WillOnce(Return(DisposeErr::OK));
service->SendStartAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by SendStartAppGalleryNotify.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_SendStartAppGalleryNotify_0000";
}
/**
* @tc.number: SUB_Service_SendEndAppGalleryNotify_0000
* @tc.name: SUB_Service_SendEndAppGalleryNotify_0000
* @tc.desc: SendEndAppGalleryNotify /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_SendEndAppGalleryNotify_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_SendEndAppGalleryNotify_0000";
try {
BundleName bundleName;
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(true));
service->SendEndAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(false));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
service->SendEndAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(false));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::REQUEST_FAIL));
service->SendEndAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(false));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::OK));
EXPECT_CALL(*jdConfig, DeleteFromDisposalConfigFile(_)).WillOnce(Return(false));
service->SendEndAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
EXPECT_CALL(*saUtils, IsSABundleName(_)).WillOnce(Return(false));
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::OK));
EXPECT_CALL(*jdConfig, DeleteFromDisposalConfigFile(_)).WillOnce(Return(true));
service->SendEndAppGalleryNotify(bundleName);
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by SendEndAppGalleryNotify.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_SendEndAppGalleryNotify_0000";
}
/**
* @tc.number: SUB_Service_TryToClearDispose_0000
* @tc.name: SUB_Service_TryToClearDispose_0000
* @tc.desc: TryToClearDispose /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_TryToClearDispose_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_TryToClearDispose_0000";
try {
BundleName bundleName;
EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::OK));
EXPECT_CALL(*jdConfig, DeleteFromDisposalConfigFile(_)).WillOnce(Return(true));
service->TryToClearDispose(bundleName);
EXPECT_TRUE(true);
EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::REQUEST_FAIL))
.WillOnce(Return(DisposeErr::OK));
EXPECT_CALL(*jdConfig, DeleteFromDisposalConfigFile(_)).WillOnce(Return(false));
service->TryToClearDispose(bundleName);
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by TryToClearDispose.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_TryToClearDispose_0000";
}
/**
* @tc.number: SUB_Service_SendErrAppGalleryNotify_0000
* @tc.name: SUB_Service_SendErrAppGalleryNotify_0000
* @tc.desc: SendErrAppGalleryNotify /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_SendErrAppGalleryNotify_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_SendErrAppGalleryNotify_0000";
try {
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
service->SendErrAppGalleryNotify();
EXPECT_TRUE(true);
vector<string> bundleNameList;
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(bundleNameList));
service->SendErrAppGalleryNotify();
EXPECT_TRUE(true);
bundleNameList.emplace_back("bundleName");
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(bundleNameList));
EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::OK));
EXPECT_CALL(*jdConfig, DeleteFromDisposalConfigFile(_)).WillOnce(Return(true));
service->SendErrAppGalleryNotify();
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by SendErrAppGalleryNotify.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_SendErrAppGalleryNotify_0000";
}
/**
* @tc.number: SUB_Service_ClearDisposalOnSaStart_0000
* @tc.name: SUB_Service_ClearDisposalOnSaStart_0000
* @tc.desc: ClearDisposalOnSaStart /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_ClearDisposalOnSaStart_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_ClearDisposalOnSaStart_0000";
try {
vector<string> bundleNameList;
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(bundleNameList));
service->ClearDisposalOnSaStart();
EXPECT_TRUE(true);
bundleNameList.emplace_back("bundleName");
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(bundleNameList));
EXPECT_CALL(*gallery, EndRestore(_)).WillOnce(Return(DisposeErr::OK));
EXPECT_CALL(*jdConfig, DeleteFromDisposalConfigFile(_)).WillOnce(Return(true));
service->ClearDisposalOnSaStart();
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by ClearDisposalOnSaStart.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_ClearDisposalOnSaStart_0000";
}
/**
* @tc.number: SUB_Service_DeleteDisConfigFile_0000
* @tc.name: SUB_Service_DeleteDisConfigFile_0000
* @tc.desc: DeleteDisConfigFile /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_DeleteDisConfigFile_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_DeleteDisConfigFile_0000";
try {
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
service->DeleteDisConfigFile();
EXPECT_TRUE(true);
vector<string> bundleNameList {"bundleName"};
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(bundleNameList));
service->DeleteDisConfigFile();
EXPECT_TRUE(true);
bundleNameList.clear();
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(bundleNameList));
EXPECT_CALL(*jdConfig, DeleteConfigFile()).WillOnce(Return(false));
service->DeleteDisConfigFile();
EXPECT_TRUE(true);
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*jdConfig, GetBundleNameFromConfigFile()).WillOnce(Return(bundleNameList));
EXPECT_CALL(*jdConfig, DeleteConfigFile()).WillOnce(Return(true));
service->DeleteDisConfigFile();
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by DeleteDisConfigFile.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_DeleteDisConfigFile_0000";
}
/**
* @tc.number: SUB_Service_SessionDeactive_0000
* @tc.name: SUB_Service_SessionDeactive_0000
* @tc.desc: SessionDeactive /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_SessionDeactive_0000, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_SessionDeactive_0000";
try {
auto session_ = service->session_;
service->session_ = nullptr;
service->SessionDeactive();
service->session_ = session_;
EXPECT_TRUE(true);
auto sched = service->sched_;
service->sched_ = nullptr;
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
service->SessionDeactive();
EXPECT_TRUE(true);
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*session, CleanAndCheckIfNeedWait(_, _)).WillOnce(Return(false));
service->SessionDeactive();
EXPECT_TRUE(true);
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*session, CleanAndCheckIfNeedWait(_, _))
.WillOnce(DoAll(SetArgReferee<0>(BError(BError::Codes::SA_INVAL_ARG)), Return(true)));
service->SessionDeactive();
EXPECT_TRUE(true);
vector<string> bundleNameList {"bundleName"};
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::RESTORE));
EXPECT_CALL(*session, CleanAndCheckIfNeedWait(_, _))
.WillOnce(DoAll(SetArgReferee<1>(bundleNameList), Return(true)));
EXPECT_CALL(*cdConfig, DeleteClearBundleRecord(_)).WillOnce(Return(true));
service->SessionDeactive();
service->sched_ = sched;
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by SessionDeactive.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_SessionDeactive_0000";
}
/**
* @tc.number: SUB_Service_SessionDeactive_0100
* @tc.name: SUB_Service_SessionDeactive_0100
* @tc.desc: SessionDeactive /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_SessionDeactive_0100, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_SessionDeactive_0100";
try {
service->failedBundles_.clear();
service->successBundlesNum_ = 0;
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*session, ClearSessionData()).WillOnce(Return(BError(BError::Codes::SA_INVAL_ARG)));
EXPECT_CALL(*session, GetSessionCnt()).WillOnce(Return(0));
service->SessionDeactive();
EXPECT_TRUE(true);
service->isRmConfigFile_ = true;
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*session, ClearSessionData()).WillOnce(Return(BError(BError::Codes::OK)));
EXPECT_CALL(*cdConfig, DeleteConfigFile()).WillOnce(Return(false));
EXPECT_CALL(*session, GetSessionCnt()).WillOnce(Return(0));
service->SessionDeactive();
EXPECT_TRUE(true);
service->isRmConfigFile_ = false;
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*session, ClearSessionData()).WillOnce(Return(BError(BError::Codes::OK)));
EXPECT_CALL(*session, GetSessionCnt()).WillOnce(Return(0));
service->SessionDeactive();
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by SessionDeactive.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_SessionDeactive_0100";
}
/**
* @tc.number: SUB_Service_SessionDeactive_0200
* @tc.name: SUB_Service_SessionDeactive_0200
* @tc.desc: SessionDeactive /
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: issueIAKC3I
*/
HWTEST_F(ServiceTest, SUB_Service_SessionDeactive_0200, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_Service_SessionDeactive_0200";
try {
service->failedBundles_.clear();
service->successBundlesNum_ = 0;
service->isRmConfigFile_ = false;
auto clearRecorder = service->clearRecorder_;
service->clearRecorder_ = nullptr;
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*session, ClearSessionData()).WillOnce(Return(BError(BError::Codes::SA_INVAL_ARG)));
EXPECT_CALL(*session, GetSessionCnt()).WillOnce(Return(0));
service->SessionDeactive();
EXPECT_TRUE(true);
EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED))
.WillOnce(Return(IServiceReverse::Scenario::UNDEFINED));
EXPECT_CALL(*session, ClearSessionData()).WillOnce(Return(BError(BError::Codes::SA_INVAL_ARG)));
EXPECT_CALL(*session, GetSessionCnt()).WillOnce(Return(-1));
service->SessionDeactive();
service->clearRecorder_ = clearRecorder;
EXPECT_TRUE(true);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by SessionDeactive.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_Service_SessionDeactive_0200";
}