!9445 增加接口调用返回值的判断

Merge pull request !9445 from m30043719/master
This commit is contained in:
openharmony_ci 2024-07-19 05:03:42 +00:00 committed by Gitee
commit ca8c2f737c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 29 additions and 2 deletions

View File

@ -777,8 +777,12 @@ ErrCode AbilityContextImpl::GetMissionId(int32_t &missionId)
ErrCode AbilityContextImpl::SetMissionContinueState(const AAFwk::ContinueState &state)
{
TAG_LOGD(AAFwkTag::CONTEXT, "SetMissionContinueState: %{public}d", state);
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->SetMissionContinueState(token_, state,
sessionToken_.promote());
auto sessionToken = GetSessionToken();
if (sessionToken == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "sessionToken is null");
return ERR_INVALID_VALUE;
}
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->SetMissionContinueState(token_, state, sessionToken);
if (err != ERR_OK) {
TAG_LOGE(AAFwkTag::CONTEXT, "SetMissionContinueState failed: %{public}d", err);
}

View File

@ -235,6 +235,29 @@ HWTEST_F(AbilityContextImplTest, Ability_Context_Impl_SetMissionContinueState_01
}
}
/**
* @tc.name: Ability_Context_Impl_SetMissionContinueState_0200
* @tc.desc: test set mission continue state.
* @tc.type: FUNC
*/
HWTEST_F(AbilityContextImplTest, Ability_Context_Impl_SetMissionContinueState_0200, Function | MediumTest | Level1)
{
ASSERT_TRUE(g_mockAbilityMs != nullptr);
ASSERT_TRUE(context_ != nullptr);
AAFwk::AbilityManagerClient::GetInstance()->proxy_ = g_mockAbilityMs;
g_mockAbilityMs->SetCommonMockResult(false);
AAFwk::ContinueState state = AAFwk::ContinueState::CONTINUESTATE_INACTIVE;
auto ret = context_->SetMissionContinueState(state);
EXPECT_NE(ret, 0);
g_mockAbilityMs->SetCommonMockResult(true);
ret = context_->SetMissionContinueState(state);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
EXPECT_EQ(ret, 0);
}
}
/**
* @tc.name: Ability_Context_Impl_SetMissionLabel_0100
* @tc.desc: test set mission label.