1d95e75fdSopenharmony_ci/* 2d95e75fdSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 3d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License. 5d95e75fdSopenharmony_ci * You may obtain a copy of the License at 6d95e75fdSopenharmony_ci * 7d95e75fdSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d95e75fdSopenharmony_ci * 9d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and 13d95e75fdSopenharmony_ci * limitations under the License. 14d95e75fdSopenharmony_ci */ 15d95e75fdSopenharmony_ci 16d95e75fdSopenharmony_ci#define private public 17d95e75fdSopenharmony_ci#define protected public 18d95e75fdSopenharmony_ci#include "cellular_call_config.h" 19d95e75fdSopenharmony_ci#include "cellular_call_handler.h" 20d95e75fdSopenharmony_ci#include "cellular_call_proxy.h" 21d95e75fdSopenharmony_ci#include "cellular_call_register.h" 22d95e75fdSopenharmony_ci#include "cellular_call_service.h" 23d95e75fdSopenharmony_ci#include "tel_ril_call_parcel.h" 24d95e75fdSopenharmony_ci#include "ims_call_callback_proxy.h" 25d95e75fdSopenharmony_ci#include "ims_call_callback_stub.h" 26d95e75fdSopenharmony_ci#include "ims_call_client.h" 27d95e75fdSopenharmony_ci#include "ims_control.h" 28d95e75fdSopenharmony_ci#include "ims_error.h" 29d95e75fdSopenharmony_ci#include "ims_test.h" 30d95e75fdSopenharmony_ci#include "securec.h" 31d95e75fdSopenharmony_ci 32d95e75fdSopenharmony_cinamespace OHOS { 33d95e75fdSopenharmony_cinamespace Telephony { 34d95e75fdSopenharmony_ciusing namespace testing::ext; 35d95e75fdSopenharmony_ciconst std::string PHONE_NUMBER = "0000000"; 36d95e75fdSopenharmony_ciconst int32_t DEFAULT_INDEX = 1; 37d95e75fdSopenharmony_ci 38d95e75fdSopenharmony_ci/** 39d95e75fdSopenharmony_ci * @tc.number cellular_call_ImsCallCallbackProxy_0001 40d95e75fdSopenharmony_ci * @tc.name Test for ImsCallCallbackProxy 41d95e75fdSopenharmony_ci * @tc.desc Function test 42d95e75fdSopenharmony_ci */ 43d95e75fdSopenharmony_ciHWTEST_F(ImsTest, cellular_call_ImsCallCallbackProxy_0001, Function | MediumTest | Level3) 44d95e75fdSopenharmony_ci{ 45d95e75fdSopenharmony_ci const sptr<ImsCallCallbackInterface> imsCallCallback_ = (std::make_unique<ImsCallCallbackStub>()).release(); 46d95e75fdSopenharmony_ci auto callCallbackProxy = 47d95e75fdSopenharmony_ci (std::make_unique<ImsCallCallbackProxy>(imsCallCallback_->AsObject().GetRefPtr())).release(); 48d95e75fdSopenharmony_ci ASSERT_TRUE(callCallbackProxy != nullptr); 49d95e75fdSopenharmony_ci for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) { 50d95e75fdSopenharmony_ci if (!HasSimCard(slotId)) { 51d95e75fdSopenharmony_ci continue; 52d95e75fdSopenharmony_ci } 53d95e75fdSopenharmony_ci EventFwk::MatchingSkills matchingSkills; 54d95e75fdSopenharmony_ci matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED); 55d95e75fdSopenharmony_ci EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); 56d95e75fdSopenharmony_ci auto handler = std::make_shared<CellularCallHandler>(subscriberInfo); 57d95e75fdSopenharmony_ci handler->SetSlotId(slotId); 58d95e75fdSopenharmony_ci handler->RegisterImsCallCallbackHandler(); 59d95e75fdSopenharmony_ci RadioResponseInfo rilRadioResponse; 60d95e75fdSopenharmony_ci rilRadioResponse.error = ErrType::ERR_GENERIC_FAILURE; 61d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->DialResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 62d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->HangUpResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 63d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->RejectWithReasonResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 64d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->AnswerResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 65d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->HoldCallResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 66d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->UnHoldCallResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 67d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SwitchCallResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 68d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->StartDtmfResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 69d95e75fdSopenharmony_ci ASSERT_GE(callCallbackProxy->SendDtmfResponse(slotId, rilRadioResponse, DEFAULT_INDEX), TELEPHONY_SUCCESS); 70d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->StopDtmfResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 71d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetImsSwitchResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 72d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetImsSwitchResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 73d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetImsCallsDataResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 74d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->CallStateChangeReport(slotId), TELEPHONY_SUCCESS); 75d95e75fdSopenharmony_ci ImsCurrentCallList imsCallList; 76d95e75fdSopenharmony_ci imsCallList.callSize = 0; 77d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetImsCallsDataResponse(slotId, imsCallList), TELEPHONY_SUCCESS); 78d95e75fdSopenharmony_ci DisconnectedDetails details; 79d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->LastCallFailReasonResponse(slotId, details), TELEPHONY_SUCCESS); 80d95e75fdSopenharmony_ci RingbackVoice ringback; 81d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->CallRingBackReport(slotId, ringback), TELEPHONY_SUCCESS); 82d95e75fdSopenharmony_ci int32_t active = 0; 83d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetImsSwitchResponse(slotId, active), TELEPHONY_SUCCESS); 84d95e75fdSopenharmony_ci MuteControlResponse muteResponse; 85d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetMuteResponse(slotId, muteResponse), TELEPHONY_SUCCESS); 86d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->CombineConferenceResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 87d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->InviteToConferenceResponse(slotId, rilRadioResponse), TELEPHONY_SUCCESS); 88d95e75fdSopenharmony_ci } 89d95e75fdSopenharmony_ci} 90d95e75fdSopenharmony_ci 91d95e75fdSopenharmony_ci/** 92d95e75fdSopenharmony_ci * @tc.number cellular_call_ImsCallCallbackProxy_0002 93d95e75fdSopenharmony_ci * @tc.name Test for ImsCallCallbackProxy 94d95e75fdSopenharmony_ci * @tc.desc Function test 95d95e75fdSopenharmony_ci */ 96d95e75fdSopenharmony_ciHWTEST_F(ImsTest, cellular_call_ImsCallCallbackProxy_0002, Function | MediumTest | Level3) 97d95e75fdSopenharmony_ci{ 98d95e75fdSopenharmony_ci const sptr<ImsCallCallbackInterface> imsCallCallback_ = (std::make_unique<ImsCallCallbackStub>()).release(); 99d95e75fdSopenharmony_ci auto callCallbackProxy = 100d95e75fdSopenharmony_ci (std::make_unique<ImsCallCallbackProxy>(imsCallCallback_->AsObject().GetRefPtr())).release(); 101d95e75fdSopenharmony_ci ASSERT_TRUE(callCallbackProxy != nullptr); 102d95e75fdSopenharmony_ci for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) { 103d95e75fdSopenharmony_ci if (!HasSimCard(slotId)) { 104d95e75fdSopenharmony_ci continue; 105d95e75fdSopenharmony_ci } 106d95e75fdSopenharmony_ci EventFwk::MatchingSkills matchingSkills; 107d95e75fdSopenharmony_ci matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED); 108d95e75fdSopenharmony_ci EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); 109d95e75fdSopenharmony_ci auto handler = std::make_shared<CellularCallHandler>(subscriberInfo); 110d95e75fdSopenharmony_ci handler->SetSlotId(slotId); 111d95e75fdSopenharmony_ci handler->RegisterImsCallCallbackHandler(); 112d95e75fdSopenharmony_ci GetClipResult clipResult; 113d95e75fdSopenharmony_ci clipResult.result.index = INVALID_INDEX; 114d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetClipResponse(slotId, clipResult), TELEPHONY_SUCCESS); 115d95e75fdSopenharmony_ci GetClirResult clirResult; 116d95e75fdSopenharmony_ci clirResult.result.index = INVALID_INDEX; 117d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetClirResponse(slotId, clirResult), TELEPHONY_SUCCESS); 118d95e75fdSopenharmony_ci SsBaseResult normalResult; 119d95e75fdSopenharmony_ci normalResult.index = DEFAULT_INDEX; 120d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetClipResponse(slotId, normalResult), TELEPHONY_SUCCESS); 121d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetClirResponse(slotId, normalResult), TELEPHONY_SUCCESS); 122d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetCallTransferResponse(slotId, normalResult), TELEPHONY_SUCCESS); 123d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetCallRestrictionResponse(slotId, normalResult), TELEPHONY_SUCCESS); 124d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetCallWaitingResponse(slotId, normalResult), TELEPHONY_SUCCESS); 125d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetColrResponse(slotId, normalResult), TELEPHONY_SUCCESS); 126d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->SetColpResponse(slotId, normalResult), TELEPHONY_SUCCESS); 127d95e75fdSopenharmony_ci CallForwardQueryInfoList callList; 128d95e75fdSopenharmony_ci callList.result.index = INVALID_INDEX; 129d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetCallTransferResponse(slotId, callList), TELEPHONY_SUCCESS); 130d95e75fdSopenharmony_ci CallRestrictionResult crResult; 131d95e75fdSopenharmony_ci crResult.result.index = INVALID_INDEX; 132d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetCallRestrictionResponse(slotId, crResult), TELEPHONY_SUCCESS); 133d95e75fdSopenharmony_ci CallWaitResult cwResult; 134d95e75fdSopenharmony_ci cwResult.result.index = INVALID_INDEX; 135d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetCallWaitingResponse(slotId, cwResult), TELEPHONY_SUCCESS); 136d95e75fdSopenharmony_ci GetColrResult colrResult; 137d95e75fdSopenharmony_ci colrResult.result.index = INVALID_INDEX; 138d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetColrResponse(slotId, colrResult), TELEPHONY_SUCCESS); 139d95e75fdSopenharmony_ci GetColpResult colpResult; 140d95e75fdSopenharmony_ci colpResult.result.index = INVALID_INDEX; 141d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->GetColpResponse(slotId, colpResult), TELEPHONY_SUCCESS); 142d95e75fdSopenharmony_ci } 143d95e75fdSopenharmony_ci} 144d95e75fdSopenharmony_ci 145d95e75fdSopenharmony_ci/** 146d95e75fdSopenharmony_ci * @tc.number cellular_call_ImsCallCallbackProxy_0003 147d95e75fdSopenharmony_ci * @tc.name Test for ImsCallCallbackProxy 148d95e75fdSopenharmony_ci * @tc.desc Function test 149d95e75fdSopenharmony_ci */ 150d95e75fdSopenharmony_ciHWTEST_F(ImsTest, cellular_call_ImsCallCallbackProxy_0003, Function | MediumTest | Level3) 151d95e75fdSopenharmony_ci{ 152d95e75fdSopenharmony_ci const sptr<ImsCallCallbackInterface> imsCallCallback_ = (std::make_unique<ImsCallCallbackStub>()).release(); 153d95e75fdSopenharmony_ci auto callCallbackProxy = 154d95e75fdSopenharmony_ci (std::make_unique<ImsCallCallbackProxy>(imsCallCallback_->AsObject().GetRefPtr())).release(); 155d95e75fdSopenharmony_ci ASSERT_TRUE(callCallbackProxy != nullptr); 156d95e75fdSopenharmony_ci for (int32_t slotId = 0; slotId < SIM_SLOT_COUNT; slotId++) { 157d95e75fdSopenharmony_ci if (!HasSimCard(slotId)) { 158d95e75fdSopenharmony_ci continue; 159d95e75fdSopenharmony_ci } 160d95e75fdSopenharmony_ci EventFwk::MatchingSkills matchingSkills; 161d95e75fdSopenharmony_ci matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED); 162d95e75fdSopenharmony_ci EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); 163d95e75fdSopenharmony_ci auto handler = std::make_shared<CellularCallHandler>(subscriberInfo); 164d95e75fdSopenharmony_ci handler->SetSlotId(slotId); 165d95e75fdSopenharmony_ci handler->RegisterImsCallCallbackHandler(); 166d95e75fdSopenharmony_ci ImsCallModeReceiveInfo callModeReceiveInfo; 167d95e75fdSopenharmony_ci callModeReceiveInfo.callIndex = DEFAULT_INDEX; 168d95e75fdSopenharmony_ci ASSERT_EQ( 169d95e75fdSopenharmony_ci callCallbackProxy->ReceiveUpdateCallMediaModeResponse(slotId, callModeReceiveInfo), TELEPHONY_SUCCESS); 170d95e75fdSopenharmony_ci ASSERT_EQ( 171d95e75fdSopenharmony_ci callCallbackProxy->ReceiveUpdateCallMediaModeRequest(slotId, callModeReceiveInfo), TELEPHONY_SUCCESS); 172d95e75fdSopenharmony_ci ImsCallSessionEventInfo callSessionEventInfo; 173d95e75fdSopenharmony_ci callSessionEventInfo.callIndex = DEFAULT_INDEX; 174d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->CallSessionEventChanged(slotId, callSessionEventInfo), TELEPHONY_SUCCESS); 175d95e75fdSopenharmony_ci ImsCallPeerDimensionsInfo callPeerDimensionsInfo; 176d95e75fdSopenharmony_ci callPeerDimensionsInfo.callIndex = DEFAULT_INDEX; 177d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->PeerDimensionsChanged(slotId, callPeerDimensionsInfo), TELEPHONY_SUCCESS); 178d95e75fdSopenharmony_ci ImsCallDataUsageInfo callDataUsageInfo; 179d95e75fdSopenharmony_ci callDataUsageInfo.callIndex = DEFAULT_INDEX; 180d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->CallDataUsageChanged(slotId, callDataUsageInfo), TELEPHONY_SUCCESS); 181d95e75fdSopenharmony_ci CameraCapabilitiesInfo cameraCapabilitiesInfo; 182d95e75fdSopenharmony_ci cameraCapabilitiesInfo.callIndex = DEFAULT_INDEX; 183d95e75fdSopenharmony_ci ASSERT_EQ(callCallbackProxy->CameraCapabilitiesChanged(slotId, cameraCapabilitiesInfo), TELEPHONY_SUCCESS); 184d95e75fdSopenharmony_ci } 185d95e75fdSopenharmony_ci} 186d95e75fdSopenharmony_ci} // namespace Telephony 187d95e75fdSopenharmony_ci} // namespace OHOS 188