1 /*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #define private public
16 #define protected public
17
18 #include "gtest/gtest.h"
19 #include "ims_call_callback_stub.h"
20 #include "ipc_types.h"
21 #include "ims_call_callback_ipc_interface_code.h"
22 #include "ims_call_ipc_interface_code.h"
23
24
25 namespace OHOS {
26 namespace Telephony {
27 using namespace testing::ext;
28 class ImsCallCallbackStubTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 void SetUp();
33 void TearDown();
34 };
35
SetUpTestCase()36 void ImsCallCallbackStubTest::SetUpTestCase() {}
37
TearDownTestCase()38 void ImsCallCallbackStubTest::TearDownTestCase() {}
39
SetUp()40 void ImsCallCallbackStubTest::SetUp() {}
41
TearDown()42 void ImsCallCallbackStubTest::TearDown() {}
43
44 /**
45 * @tc.number Telephony_ImsCallCallbackStubTest_0001
46 * @tc.name Test ImsCallCallbackStub
47 * @tc.desc Function test
48 */
49 HWTEST_F(ImsCallCallbackStubTest, ImsCallCallbackStubTest_0001, Function | MediumTest | Level1)
50 {
51 ImsCallCallbackStub callBackStub;
52 int32_t slotId = 0;
53 uint32_t code = 150;
54 MessageParcel data;
55 MessageParcel reply;
56 MessageOption option;
57 RadioResponseInfo rilRadioResponse;
58 rilRadioResponse.error = ErrType::ERR_GENERIC_FAILURE;
59 data.WriteInt32(slotId);
60 data.WriteRawData((const void *)&rilRadioResponse, sizeof(RadioResponseInfo));
61 EXPECT_NE(callBackStub.OnRemoteRequest(code, data, reply, option), IPC_STUB_UNKNOW_TRANS_ERR);
62
63 code = static_cast<uint32_t>(ImsCallInterfaceCode::IMS_ANSWER);
64 callBackStub.OnRemoteRequest(code, data, reply, option);
65
66 EXPECT_NE(callBackStub.OnDialResponseInner(data, reply), TELEPHONY_SUCCESS);
67 EXPECT_NE(callBackStub.OnHangUpResponseInner(data, reply), TELEPHONY_SUCCESS);
68 EXPECT_NE(callBackStub.OnRejectResponseInner(data, reply), TELEPHONY_SUCCESS);
69 EXPECT_NE(callBackStub.OnAnswerResponseInner(data, reply), TELEPHONY_SUCCESS);
70 EXPECT_NE(callBackStub.OnHoldCallResponseInner(data, reply), TELEPHONY_SUCCESS);
71 EXPECT_NE(callBackStub.OnUnHoldCallResponseInner(data, reply), TELEPHONY_SUCCESS);
72 EXPECT_NE(callBackStub.OnSwitchCallResponseInner(data, reply), TELEPHONY_SUCCESS);
73 EXPECT_NE(callBackStub.OnStartDtmfResponseInner(data, reply), TELEPHONY_SUCCESS);
74 EXPECT_NE(callBackStub.OnSendDtmfResponseInner(data, reply), TELEPHONY_SUCCESS);
75 EXPECT_NE(callBackStub.OnStopDtmfResponseInner(data, reply), TELEPHONY_SUCCESS);
76 EXPECT_EQ(callBackStub.OnCallStateChangeReportInner(data, reply), TELEPHONY_SUCCESS);
77 EXPECT_NE(callBackStub.OnSetImsSwitchResponseInner(data, reply), TELEPHONY_SUCCESS);
78 EXPECT_EQ(callBackStub.OnGetImsSwitchResponseInner(data, reply), TELEPHONY_SUCCESS);
79 EXPECT_EQ(callBackStub.OnGetImsCallsDataResponseInner(data, reply), TELEPHONY_SUCCESS);
80 EXPECT_NE(callBackStub.OnSetMuteResponseInner(data, reply), TELEPHONY_SUCCESS);
81 EXPECT_NE(callBackStub.OnCallRingBackReportInner(data, reply), TELEPHONY_SUCCESS);
82 EXPECT_EQ(callBackStub.OnLastCallFailReasonResponseInner(data, reply), TELEPHONY_SUCCESS);
83 EXPECT_EQ(callBackStub.OnSetClipResponseInner(data, reply), TELEPHONY_SUCCESS);
84 EXPECT_EQ(callBackStub.OnGetClipResponseInner(data, reply), TELEPHONY_SUCCESS);
85 EXPECT_EQ(callBackStub.OnSetClirResponseInner(data, reply), TELEPHONY_SUCCESS);
86 EXPECT_EQ(callBackStub.OnGetClirResponseInner(data, reply), TELEPHONY_SUCCESS);
87 EXPECT_EQ(callBackStub.OnGetCallTransferResponseInner(data, reply), TELEPHONY_SUCCESS);
88 EXPECT_EQ(callBackStub.OnSetCallTransferResponseInner(data, reply), TELEPHONY_SUCCESS);
89 EXPECT_EQ(callBackStub.OnGetCallRestrictionResponseInner(data, reply), TELEPHONY_SUCCESS);
90 EXPECT_EQ(callBackStub.OnSetCallRestrictionResponseInner(data, reply), TELEPHONY_SUCCESS);
91 EXPECT_EQ(callBackStub.OnGetCallWaitingResponseInner(data, reply), TELEPHONY_SUCCESS);
92 EXPECT_EQ(callBackStub.OnSetCallWaitingResponseInner(data, reply), TELEPHONY_SUCCESS);
93 EXPECT_EQ(callBackStub.OnSetColrResponseInner(data, reply), TELEPHONY_SUCCESS);
94 EXPECT_EQ(callBackStub.OnGetColrResponseInner(data, reply), TELEPHONY_SUCCESS);
95 EXPECT_EQ(callBackStub.OnSetColpResponseInner(data, reply), TELEPHONY_SUCCESS);
96 EXPECT_EQ(callBackStub.OnGetColpResponseInner(data, reply), TELEPHONY_SUCCESS);
97 EXPECT_EQ(callBackStub.OnNvCfgFinishedInner(data, reply), TELEPHONY_SUCCESS);
98 }
99
100 /**
101 * @tc.number Telephony_ImsCallCallbackStubTest_0002
102 * @tc.name Test ImsCallCallbackStub
103 * @tc.desc Function test
104 */
105 HWTEST_F(ImsCallCallbackStubTest, ImsCallCallbackStubTest_0002, Function | MediumTest | Level1)
106 {
107 ImsCallCallbackStub callBackStub;
108 int32_t slotId = 0;
109 MessageParcel data;
110 MessageParcel reply;
111 RadioResponseInfo rilRadioResponse;
112 rilRadioResponse.error = ErrType::ERR_GENERIC_FAILURE;
113 data.WriteInt32(slotId);
114 data.WriteRawData((const void *)&rilRadioResponse, sizeof(RadioResponseInfo));
115 EXPECT_EQ(callBackStub.OnCombineConferenceResponseInner(data, reply), TELEPHONY_SUCCESS);
116 EXPECT_NE(callBackStub.OnInviteToConferenceResponseInner(data, reply), TELEPHONY_SUCCESS);
117 EXPECT_NE(callBackStub.OnReceiveUpdateCallMediaModeRequestInner(data, reply), TELEPHONY_SUCCESS);
118 EXPECT_NE(callBackStub.OnReceiveUpdateCallMediaModeResponseInner(data, reply), TELEPHONY_SUCCESS);
119 EXPECT_NE(callBackStub.OnCallSessionEventChangedInner(data, reply), TELEPHONY_SUCCESS);
120 EXPECT_NE(callBackStub.OnPeerDimensionsChangedInner(data, reply), TELEPHONY_SUCCESS);
121 EXPECT_NE(callBackStub.OnCallDataUsageChangedInner(data, reply), TELEPHONY_SUCCESS);
122 EXPECT_NE(callBackStub.OnCameraCapabilitiesChangedInner(data, reply), TELEPHONY_SUCCESS);
123 callBackStub.DialResponse(slotId, rilRadioResponse);
124 callBackStub.HangUpResponse(slotId, rilRadioResponse);
125 callBackStub.RejectWithReasonResponse(slotId, rilRadioResponse);
126 callBackStub.AnswerResponse(slotId, rilRadioResponse);
127 callBackStub.HoldCallResponse(slotId, rilRadioResponse);
128 callBackStub.UnHoldCallResponse(slotId, rilRadioResponse);
129 callBackStub.SwitchCallResponse(slotId, rilRadioResponse);
130 callBackStub.StartDtmfResponse(slotId, rilRadioResponse);
131 callBackStub.StopDtmfResponse(slotId, rilRadioResponse);
132 callBackStub.SetImsSwitchResponse(slotId, rilRadioResponse);
133 callBackStub.GetImsSwitchResponse(slotId, rilRadioResponse);
134 callBackStub.CombineConferenceResponse(slotId, rilRadioResponse);
135 callBackStub.InviteToConferenceResponse(slotId, rilRadioResponse);
136 callBackStub.GetImsCallsDataResponse(slotId, rilRadioResponse);
137 int32_t callIndex = 0;
138 callBackStub.SendDtmfResponse(slotId, rilRadioResponse, callIndex);
139 callBackStub.CallStateChangeReport(slotId);
140 ImsCurrentCallList callList;
141 callBackStub.GetImsCallsDataResponse(slotId, callList);
142 ImsCallModeReceiveInfo callModeResponse;
143 callBackStub.ReceiveUpdateCallMediaModeRequest(slotId, callModeResponse);
144 callBackStub.ReceiveUpdateCallMediaModeResponse(slotId, callModeResponse);
145 MuteControlResponse response;
146 EXPECT_EQ(callBackStub.SetMuteResponse(slotId, response), TELEPHONY_SUCCESS);
147
148 slotId = -100;
149 EXPECT_EQ(callBackStub.SwitchCallResponse(slotId, rilRadioResponse), TELEPHONY_ERR_LOCAL_PTR_NULL);
150 EXPECT_EQ(callBackStub.SendDtmfResponse(slotId, rilRadioResponse, callIndex), TELEPHONY_ERR_LOCAL_PTR_NULL);
151 EXPECT_EQ(callBackStub.CallStateChangeReport(slotId), TELEPHONY_ERR_LOCAL_PTR_NULL);
152 EXPECT_EQ(callBackStub.GetImsCallsDataResponse(slotId, callList), TELEPHONY_ERR_LOCAL_PTR_NULL);
153 }
154
155 /**
156 * @tc.number Telephony_ImsCallCallbackStubTest_0003
157 * @tc.name Test ImsCallCallbackStub
158 * @tc.desc Function test
159 */
160 HWTEST_F(ImsCallCallbackStubTest, ImsCallCallbackStubTest_0003, Function | MediumTest | Level1)
161 {
162 ImsCallCallbackStub callBackStub;
163 int32_t slotId = 0;
164 int32_t active = 0;
165 callBackStub.GetImsSwitchResponse(slotId, active);
166
167 RingbackVoice info;
168 callBackStub.CallRingBackReport(slotId, info);
169 DisconnectedDetails details;
170 callBackStub.LastCallFailReasonResponse(slotId, details);
171 SsBaseResult baseResult;
172 callBackStub.SetClipResponse(slotId, baseResult);
173 GetClipResult clipResult;
174 callBackStub.GetClipResponse(slotId, clipResult);
175 GetClirResult clirResult;
176 callBackStub.GetClirResponse(slotId, clirResult);
177 callBackStub.SetClirResponse(slotId, baseResult);
178 CallForwardQueryInfoList cFQueryList;
179 callBackStub.GetCallTransferResponse(slotId, cFQueryList);
180 callBackStub.SetCallTransferResponse(slotId, baseResult);
181 CallRestrictionResult callRestriResult;
182 callBackStub.GetCallRestrictionResponse(slotId, callRestriResult);
183 callBackStub.SetCallTransferResponse(slotId, baseResult);
184 CallWaitResult waitResult;
185 callBackStub.GetCallWaitingResponse(slotId, waitResult);
186 callBackStub.SetCallWaitingResponse(slotId, baseResult);
187 GetColrResult colrResult;
188 callBackStub.GetColrResponse(slotId, colrResult);
189 callBackStub.SetColrResponse(slotId, baseResult);
190 GetColpResult colpResult;
191 callBackStub.GetColpResponse(slotId, colpResult);
192 callBackStub.SetColpResponse(slotId, baseResult);
193 ImsCallSessionEventInfo callSessionEventInfo;
194 callBackStub.CallSessionEventChanged(slotId, callSessionEventInfo);
195
196 slotId = -100;
197 EXPECT_EQ(callBackStub.GetImsSwitchResponse(slotId, active), TELEPHONY_ERR_LOCAL_PTR_NULL);
198 EXPECT_EQ(callBackStub.CallRingBackReport(slotId, info), TELEPHONY_ERR_LOCAL_PTR_NULL);
199 EXPECT_EQ(callBackStub.LastCallFailReasonResponse(slotId, details), TELEPHONY_ERR_LOCAL_PTR_NULL);
200 EXPECT_EQ(callBackStub.GetClipResponse(slotId, clipResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
201 EXPECT_EQ(callBackStub.GetClirResponse(slotId, clirResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
202 EXPECT_EQ(callBackStub.GetCallTransferResponse(slotId, cFQueryList), TELEPHONY_ERR_LOCAL_PTR_NULL);
203 EXPECT_EQ(callBackStub.GetCallRestrictionResponse(slotId, callRestriResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
204 EXPECT_EQ(callBackStub.GetCallWaitingResponse(slotId, waitResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
205 EXPECT_EQ(callBackStub.GetColrResponse(slotId, colrResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
206 EXPECT_EQ(callBackStub.GetColpResponse(slotId, colpResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
207 EXPECT_EQ(callBackStub.CallSessionEventChanged(slotId, callSessionEventInfo), TELEPHONY_ERR_LOCAL_PTR_NULL);
208 }
209
210 /**
211 * @tc.number Telephony_ImsCallCallbackStubTest_0004
212 * @tc.name Test ImsCallCallbackStub
213 * @tc.desc Function test
214 */
215 HWTEST_F(ImsCallCallbackStubTest, ImsCallCallbackStubTest_0004, Function | MediumTest | Level1)
216 {
217 ImsCallCallbackStub callBackStub;
218 int32_t slotId = 0;
219
220 ImsCallPeerDimensionsInfo callPeerDimensionsInfo;
221 callBackStub.PeerDimensionsChanged(slotId, callPeerDimensionsInfo);
222
223 ImsCallDataUsageInfo callDataUsageInfo;
224 callBackStub.CallDataUsageChanged(slotId, callDataUsageInfo);
225
226 CameraCapabilitiesInfo cameraCapabilitiesInfo;
227 callBackStub.CameraCapabilitiesChanged(slotId, cameraCapabilitiesInfo);
228
229 SsRequestCommand ss;
230 int32_t index = 0;
231 callBackStub.GetSsRequestCommand(slotId, index, ss);
232
233 CallForwardQueryInfoList cFQueryList;
234 CallForwardQueryInfoList cFQueryResultList;
235 callBackStub.BuildCallForwardInfo(cFQueryList, cFQueryResultList);
236
237 int32_t eventId = 0;
238 RadioResponseInfo rilRadioResponse;
239 rilRadioResponse.error = ErrType::ERR_GENERIC_FAILURE;
240 callBackStub.SendEvent(slotId, eventId, rilRadioResponse);
241
242 SsBaseResult baseResult;
243 callBackStub.SendEvent(slotId, eventId, baseResult);
244
245 ImsCallModeReceiveInfo callModeInfo;
246 callBackStub.SendEvent(slotId, eventId, callModeInfo);
247
248 callBackStub.CallNvCfgFinishedIndication(slotId);
249
250 slotId = -100;
251 EXPECT_EQ(callBackStub.PeerDimensionsChanged(slotId, callPeerDimensionsInfo), TELEPHONY_ERR_LOCAL_PTR_NULL);
252 EXPECT_EQ(callBackStub.CallDataUsageChanged(slotId, callDataUsageInfo), TELEPHONY_ERR_LOCAL_PTR_NULL);
253 EXPECT_EQ(callBackStub.CameraCapabilitiesChanged(slotId, cameraCapabilitiesInfo), TELEPHONY_ERR_LOCAL_PTR_NULL);
254 EXPECT_EQ(callBackStub.GetSsRequestCommand(slotId, index, ss), TELEPHONY_ERR_LOCAL_PTR_NULL);
255 EXPECT_EQ(callBackStub.SendEvent(slotId, eventId, rilRadioResponse), TELEPHONY_ERR_LOCAL_PTR_NULL);
256 EXPECT_EQ(callBackStub.SendEvent(slotId, eventId, baseResult), TELEPHONY_ERR_LOCAL_PTR_NULL);
257 EXPECT_EQ(callBackStub.SendEvent(slotId, eventId, callModeInfo), TELEPHONY_ERR_LOCAL_PTR_NULL);
258 EXPECT_EQ(callBackStub.CallNvCfgFinishedIndication(slotId), TELEPHONY_ERR_LOCAL_PTR_NULL);
259 }
260
261 } // namespace Telephony
262 } // namespace OHOS