• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 #include <gtest/gtest.h>
18 #include <thread>
19 
20 #include "esim_manager.h"
21 #include "string_ex.h"
22 #include "tel_ril_manager.h"
23 
24 namespace OHOS {
25 namespace Telephony {
26 using namespace testing::ext;
27 class EsimManagerTest : public testing::Test {
28 public:
29     static void SetUpTestCase();
30     static void TearDownTestCase();
31     void SetUp();
32     void TearDown();
33 
34     std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
35     std::shared_ptr<EsimManager> esimManager = std::make_shared<EsimManager>(telRilManager);
36 };
37 
SetUpTestCase()38 void EsimManagerTest::SetUpTestCase() {}
39 
TearDownTestCase()40 void EsimManagerTest::TearDownTestCase() {}
41 
SetUp()42 void EsimManagerTest::SetUp()
43 {
44     esimManager->esimFiles_.resize(ESIM_MAX_SLOT_COUNT);
45     esimManager->esimFiles_[0] = std::make_shared<EsimFile>(telRilManager);
46     esimManager->esimFiles_[1] = nullptr;
47 }
48 
TearDown()49 void EsimManagerTest::TearDown() {}
50 
51 #ifdef CORE_SERVICE_SUPPORT_ESIM
52 HWTEST_F(EsimManagerTest, OnInit_001, Function | MediumTest | Level1)
53 {
54     int32_t slotCount = 4;
55     bool ret = esimManager->OnInit(slotCount);
56     EXPECT_FALSE(ret);
57 
58     slotCount = -1;
59     ret = esimManager->OnInit(slotCount);
60     EXPECT_FALSE(ret);
61 
62     slotCount = 0;
63     ret = esimManager->OnInit(slotCount);
64     EXPECT_TRUE(ret);
65 }
66 
67 HWTEST_F(EsimManagerTest, GetEid_001, Function | MediumTest | Level1)
68 {
69     int32_t slotId = -1;
70     std::u16string eId;
71     int32_t ret = esimManager->GetEid(slotId, eId);
72     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
73 
74     slotId = 1;
75     ret = esimManager->GetEid(slotId, eId);
76     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
77 
78     slotId = 0;
79     ret = esimManager->GetEid(slotId, eId);
80     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
81 }
82 
83 HWTEST_F(EsimManagerTest, GetEuiccProfileInfoList_001, Function | MediumTest | Level1)
84 {
85     int32_t slotId = -1;
86     GetEuiccProfileInfoListInnerResult result;
87     int32_t ret = esimManager->GetEuiccProfileInfoList(slotId, result);
88     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
89 
90     slotId = 1;
91     ret = esimManager->GetEuiccProfileInfoList(slotId, result);
92     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
93 
94     slotId = 0;
95     ret = esimManager->GetEuiccProfileInfoList(slotId, result);
96     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
97 }
98 
99 HWTEST_F(EsimManagerTest, GetEuiccInfo_001, Function | MediumTest | Level1)
100 {
101     int32_t slotId = -1;
102     EuiccInfo result;
103     int32_t ret = esimManager->GetEuiccInfo(slotId, result);
104     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
105 
106     slotId = 1;
107     ret = esimManager->GetEuiccInfo(slotId, result);
108     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
109 
110     slotId = 0;
111     ret = esimManager->GetEuiccInfo(slotId, result);
112     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
113 }
114 
115 HWTEST_F(EsimManagerTest, DisableProfile_001, Function | MediumTest | Level1)
116 {
117     int32_t slotId = -1;
118     int32_t portIndex = 0;
119     std::u16string iccId = Str8ToStr16("98760000000000543210");
120     bool refresh = true;
121     int32_t enumResult;
122     int32_t ret = esimManager->DisableProfile(slotId, portIndex, iccId, refresh, enumResult);
123     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
124 
125     slotId = 1;
126     ret = esimManager->DisableProfile(slotId, portIndex, iccId, refresh, enumResult);
127     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
128 
129     slotId = 0;
130     ret = esimManager->DisableProfile(slotId, portIndex, iccId, refresh, enumResult);
131     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
132 }
133 
134 HWTEST_F(EsimManagerTest, GetSmdsAddress_001, Function | MediumTest | Level1)
135 {
136     int32_t slotId = -1;
137     int32_t portIndex = 0;
138     std::u16string smdsAddress;
139     int32_t ret = esimManager->GetSmdsAddress(slotId, portIndex, smdsAddress);
140     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
141 
142     slotId = 1;
143     ret = esimManager->GetSmdsAddress(slotId, portIndex, smdsAddress);
144     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
145 
146     slotId = 0;
147     ret = esimManager->GetSmdsAddress(slotId, portIndex, smdsAddress);
148     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
149 }
150 
151 HWTEST_F(EsimManagerTest, GetRulesAuthTable_001, Function | MediumTest | Level1)
152 {
153     int32_t slotId = -1;
154     int32_t portIndex = 0;
155     EuiccRulesAuthTable eUiccRulesAuthTable;
156     int32_t ret = esimManager->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
157     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
158 
159     slotId = 1;
160     ret = esimManager->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
161     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
162 
163     slotId = 0;
164     ret = esimManager->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
165     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
166 }
167 
168 HWTEST_F(EsimManagerTest, GetEuiccChallenge_001, Function | MediumTest | Level1)
169 {
170     int32_t slotId = -1;
171     int32_t portIndex = 0;
172     ResponseEsimInnerResult result;
173     int32_t ret = esimManager->GetEuiccChallenge(slotId, portIndex, result);
174     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
175 
176     slotId = 1;
177     ret = esimManager->GetEuiccChallenge(slotId, portIndex, result);
178     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
179 
180     slotId = 0;
181     ret = esimManager->GetEuiccChallenge(slotId, portIndex, result);
182     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
183 }
184 
185 HWTEST_F(EsimManagerTest, GetDefaultSmdpAddress_001, Function | MediumTest | Level1)
186 {
187     int32_t slotId = -1;
188     std::u16string defaultSmdpAddress;
189     int32_t ret = esimManager->GetDefaultSmdpAddress(slotId, defaultSmdpAddress);
190     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
191 
192     slotId = 1;
193     ret = esimManager->GetDefaultSmdpAddress(slotId, defaultSmdpAddress);
194     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
195 
196     slotId = 0;
197     ret = esimManager->GetDefaultSmdpAddress(slotId, defaultSmdpAddress);
198     EXPECT_EQ(ret, TELEPHONY_ERR_FAIL);
199 }
200 
201 HWTEST_F(EsimManagerTest, CancelSession_001, Function | MediumTest | Level1)
202 {
203     int32_t slotId = -1;
204     std::u16string transactionId = Str8ToStr16("A1B2C3");
205     CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
206     ResponseEsimInnerResult responseResult;
207     int32_t ret = esimManager->CancelSession(slotId, transactionId, cancelReason, responseResult);
208     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
209 
210     slotId = 1;
211     ret = esimManager->CancelSession(slotId, transactionId, cancelReason, responseResult);
212     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
213 
214     slotId = 0;
215     ret = esimManager->CancelSession(slotId, transactionId, cancelReason, responseResult);
216     EXPECT_EQ(ret, TELEPHONY_ERR_FAIL);
217 }
218 
219 HWTEST_F(EsimManagerTest, GetProfile_001, Function | MediumTest | Level1)
220 {
221     int32_t slotId = -1;
222     int32_t portIndex = 0;
223     std::u16string iccId = Str8ToStr16("5A0A89670000000000216954");
224     EuiccProfile eUiccProfile;
225     int32_t ret = esimManager->GetProfile(slotId, portIndex, iccId, eUiccProfile);
226     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
227 
228     slotId = 1;
229     ret = esimManager->GetProfile(slotId, portIndex, iccId, eUiccProfile);
230     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
231 
232     slotId = 0;
233     ret = esimManager->GetProfile(slotId, portIndex, iccId, eUiccProfile);
234     EXPECT_EQ(ret, TELEPHONY_ERR_FAIL);
235 }
236 
237 HWTEST_F(EsimManagerTest, ResetMemory_001, Function | MediumTest | Level1)
238 {
239     int32_t slotId = -1;
240     int32_t resetMemoryResult;
241     const ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
242     int32_t ret = esimManager->ResetMemory(slotId, resetOption, resetMemoryResult);
243     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
244 
245     slotId = 1;
246     ret = esimManager->ResetMemory(slotId, resetOption, resetMemoryResult);
247     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
248 
249     slotId = 0;
250     ret = esimManager->ResetMemory(slotId, resetOption, resetMemoryResult);
251     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
252 }
253 
254 HWTEST_F(EsimManagerTest, SetDefaultSmdpAddress_001, Function | MediumTest | Level1)
255 {
256     int32_t slotId = -1;
257     std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
258     int32_t setAddressResult;
259     int32_t ret = esimManager->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, setAddressResult);
260     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
261 
262     slotId = 1;
263     ret = esimManager->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, setAddressResult);
264     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
265 
266     slotId = 0;
267     ret = esimManager->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, setAddressResult);
268     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
269 }
270 
271 HWTEST_F(EsimManagerTest, IsSupported_001, Function | MediumTest | Level1)
272 {
273     int32_t slotId = -1;
274     bool ret = esimManager->IsSupported(slotId);
275     EXPECT_EQ(ret, false);
276 
277     slotId = 1;
278     ret = esimManager->IsSupported(slotId);
279     EXPECT_EQ(ret, false);
280 
281     slotId = 0;
282     ret = esimManager->IsSupported(slotId);
283     EXPECT_EQ(ret, false);
284 }
285 
286 HWTEST_F(EsimManagerTest, SendApduData_001, Function | MediumTest | Level1)
287 {
288     int32_t slotId = -1;
289     std::u16string aid = Str8ToStr16("aid test");
290     EsimApduData apduData;
291     ResponseEsimInnerResult responseResult;
292     int32_t ret = esimManager->SendApduData(slotId, aid, apduData, responseResult);
293     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
294 
295     slotId = 1;
296     ret = esimManager->SendApduData(slotId, aid, apduData, responseResult);
297     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
298 
299     slotId = 0;
300     ret = esimManager->SendApduData(slotId, aid, apduData, responseResult);
301     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
302 }
303 
304 HWTEST_F(EsimManagerTest, PrepareDownload_001, Function | MediumTest | Level1)
305 {
306     int32_t slotId = -1;
307     DownLoadConfigInfo downLoadConfigInfo;
308     downLoadConfigInfo.portIndex_ = 0;
309     downLoadConfigInfo.hashCc_ = Str8ToStr16("4131423243332D583459355A36");
310     ResponseEsimInnerResult responseResult;
311     int32_t ret = esimManager->PrepareDownload(slotId, downLoadConfigInfo, responseResult);
312     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
313 
314     slotId = 1;
315     ret = esimManager->PrepareDownload(slotId, downLoadConfigInfo, responseResult);
316     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
317 
318     slotId = 0;
319     ret = esimManager->PrepareDownload(slotId, downLoadConfigInfo, responseResult);
320     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
321 }
322 
323 HWTEST_F(EsimManagerTest, LoadBoundProfilePackage_001, Function | MediumTest | Level1)
324 {
325     int32_t slotId = -1;
326     int32_t portIndex = 0;
327     std::u16string boundProfilePackage;
328     ResponseEsimBppResult responseResult;
329     int32_t ret = esimManager->LoadBoundProfilePackage(slotId, portIndex, boundProfilePackage, responseResult);
330     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
331 
332     slotId = 1;
333     ret = esimManager->LoadBoundProfilePackage(slotId, portIndex, boundProfilePackage, responseResult);
334     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
335 
336     slotId = 0;
337     ret = esimManager->LoadBoundProfilePackage(slotId, portIndex, boundProfilePackage, responseResult);
338     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
339 }
340 
341 HWTEST_F(EsimManagerTest, ListNotifications_001, Function | MediumTest | Level1)
342 {
343     int32_t slotId = -1;
344     int32_t portIndex = 0;
345     const EsimEvent events = EsimEvent::EVENT_DELETE;
346     EuiccNotificationList notificationList;
347     int32_t ret = esimManager->ListNotifications(slotId, portIndex, events, notificationList);
348     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
349 
350     slotId = 1;
351     ret = esimManager->ListNotifications(slotId, portIndex, events, notificationList);
352     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
353 
354     slotId = 0;
355     ret = esimManager->ListNotifications(slotId, portIndex, events, notificationList);
356     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
357 }
358 
359 HWTEST_F(EsimManagerTest, RetrieveNotificationList_001, Function | MediumTest | Level1)
360 {
361     int32_t slotId = -1;
362     int32_t portIndex = 0;
363     const EsimEvent events = EsimEvent::EVENT_DISABLE;
364     EuiccNotificationList notificationList;
365     int32_t ret = esimManager->RetrieveNotificationList(slotId, portIndex, events, notificationList);
366     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
367 
368     slotId = 1;
369     ret = esimManager->RetrieveNotificationList(slotId, portIndex, events, notificationList);
370     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
371 
372     slotId = 0;
373     ret = esimManager->RetrieveNotificationList(slotId, portIndex, events, notificationList);
374     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
375 }
376 
377 HWTEST_F(EsimManagerTest, RetrieveNotification_001, Function | MediumTest | Level1)
378 {
379     int32_t slotId = -1;
380     int32_t portIndex = 0;
381     int32_t seqNumber = 5;
382     EuiccNotification notification;
383     int32_t ret = esimManager->RetrieveNotification(slotId, portIndex, seqNumber, notification);
384     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
385 
386     slotId = 1;
387     ret = esimManager->RetrieveNotification(slotId, portIndex, seqNumber, notification);
388     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
389 
390     slotId = 0;
391     ret = esimManager->RetrieveNotification(slotId, portIndex, seqNumber, notification);
392     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
393 }
394 
395 HWTEST_F(EsimManagerTest, RemoveNotificationFromList_001, Function | MediumTest | Level1)
396 {
397     int32_t slotId = -1;
398     int32_t portIndex = 0;
399     int32_t seqNumber = 5;
400     int32_t enumResult;
401     int32_t ret = esimManager->RemoveNotificationFromList(slotId, portIndex, seqNumber, enumResult);
402     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
403 
404     slotId = 1;
405     ret = esimManager->RemoveNotificationFromList(slotId, portIndex, seqNumber, enumResult);
406     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
407 
408     slotId = 0;
409     ret = esimManager->RemoveNotificationFromList(slotId, portIndex, seqNumber, enumResult);
410     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
411 }
412 
413 HWTEST_F(EsimManagerTest, DeleteProfile_001, Function | MediumTest | Level1)
414 {
415     int32_t slotId = -1;
416     std::u16string iccId = Str8ToStr16("98760000000000543210");
417     int32_t deleteProfileResult;
418     int32_t ret = esimManager->DeleteProfile(slotId, iccId, deleteProfileResult);
419     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
420 
421     slotId = 1;
422     ret = esimManager->DeleteProfile(slotId, iccId, deleteProfileResult);
423     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
424 
425     slotId = 0;
426     ret = esimManager->DeleteProfile(slotId, iccId, deleteProfileResult);
427     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
428 }
429 
430 HWTEST_F(EsimManagerTest, SwitchToProfile_001, Function | MediumTest | Level1)
431 {
432     int32_t slotId = -1;
433     int32_t portIndex = 1;
434     std::u16string iccId = Str8ToStr16("98760000000000543210");
435     bool forceDisableProfile = true;
436     int32_t switchProfileResult;
437     int32_t ret = esimManager->SwitchToProfile(slotId, portIndex, iccId, forceDisableProfile, switchProfileResult);
438     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
439 
440     slotId = 1;
441     ret = esimManager->SwitchToProfile(slotId, portIndex, iccId, forceDisableProfile, switchProfileResult);
442     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
443 
444     slotId = 0;
445     ret = esimManager->SwitchToProfile(slotId, portIndex, iccId, forceDisableProfile, switchProfileResult);
446     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
447 }
448 
449 HWTEST_F(EsimManagerTest, SetProfileNickname_001, Function | MediumTest | Level1)
450 {
451     int32_t slotId = -1;
452     std::u16string iccId = Str8ToStr16("98760000000000543210");
453     std::u16string nickname = Str8ToStr16("nick");
454     int32_t updateResult;
455     int32_t ret = esimManager->SetProfileNickname(slotId, iccId, nickname, updateResult);
456     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
457 
458     slotId = 1;
459     ret = esimManager->SetProfileNickname(slotId, iccId, nickname, updateResult);
460     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
461 
462     slotId = 0;
463     ret = esimManager->SetProfileNickname(slotId, iccId, nickname, updateResult);
464     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
465 }
466 
467 HWTEST_F(EsimManagerTest, GetEuiccInfo2_001, Function | MediumTest | Level1)
468 {
469     int32_t slotId = -1;
470     int32_t portIndex = 0;
471     EuiccInfo2 euiccInfo2;
472     int32_t ret = esimManager->GetEuiccInfo2(slotId, portIndex, euiccInfo2);
473     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
474 
475     slotId = 1;
476     ret = esimManager->GetEuiccInfo2(slotId, portIndex, euiccInfo2);
477     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
478 
479     slotId = 0;
480     ret = esimManager->GetEuiccInfo2(slotId, portIndex, euiccInfo2);
481     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
482 }
483 
484 HWTEST_F(EsimManagerTest, AuthenticateServer_001, Function | MediumTest | Level1)
485 {
486     int32_t slotId = -1;
487     AuthenticateConfigInfo authenticateConfigInfo;
488     authenticateConfigInfo.matchingId_ = Str8ToStr16("4131423243332D583459355A36");
489     ResponseEsimInnerResult responseResult;
490     int32_t ret = esimManager->AuthenticateServer(slotId, authenticateConfigInfo, responseResult);
491     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
492 
493     slotId = 1;
494     ret = esimManager->AuthenticateServer(slotId, authenticateConfigInfo, responseResult);
495     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
496 
497     slotId = 0;
498     ret = esimManager->AuthenticateServer(slotId, authenticateConfigInfo, responseResult);
499     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
500 }
501 
502 HWTEST_F(EsimManagerTest, GetContractInfo_001, Function | MediumTest | Level1)
503 {
504     int32_t slotId = -1;
505     GetContractInfoRequest request;
506     std::string response = "";
507     int32_t ret = esimManager->GetContractInfo(slotId, request, response);
508     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
509 
510     slotId = 1;
511     ret = esimManager->GetContractInfo(slotId, request, response);
512     EXPECT_EQ(ret, TELEPHONY_ERR_LOCAL_PTR_NULL);
513 
514     slotId = 0;
515     ret = esimManager->GetContractInfo(slotId, request, response);
516     EXPECT_EQ(ret, TELEPHONY_ERR_SUCCESS);
517 }
518 #else
519 HWTEST_F(EsimManagerTest, OnInit_002, Function | MediumTest | Level1)
520 {
521     int32_t slotCount = 4;
522     bool ret = esimManager->OnInit(slotCount);
523     EXPECT_FALSE(ret);
524 }
525 
526 HWTEST_F(EsimManagerTest, GetEid_002, Function | MediumTest | Level1)
527 {
528     int32_t slotId = -1;
529     std::u16string eId;
530     int32_t ret = esimManager->GetEid(slotId, eId);
531     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
532 }
533 
534 HWTEST_F(EsimManagerTest, GetEuiccProfileInfoList_002, Function | MediumTest | Level1)
535 {
536     int32_t slotId = -1;
537     GetEuiccProfileInfoListInnerResult result;
538     int32_t ret = esimManager->GetEuiccProfileInfoList(slotId, result);
539     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
540 }
541 
542 HWTEST_F(EsimManagerTest, GetEuiccInfo_002, Function | MediumTest | Level1)
543 {
544     int32_t slotId = -1;
545     EuiccInfo result;
546     int32_t ret = esimManager->GetEuiccInfo(slotId, result);
547     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
548 }
549 
550 HWTEST_F(EsimManagerTest, DisableProfile_002, Function | MediumTest | Level1)
551 {
552     int32_t slotId = -1;
553     int32_t portIndex = 0;
554     std::u16string iccId = Str8ToStr16("98760000000000543210");
555     bool refresh = true;
556     int32_t enumResult;
557     int32_t ret = esimManager->DisableProfile(slotId, portIndex, iccId, refresh, enumResult);
558     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
559 }
560 
561 HWTEST_F(EsimManagerTest, GetSmdsAddress_002, Function | MediumTest | Level1)
562 {
563     int32_t slotId = -1;
564     int32_t portIndex = 0;
565     std::u16string smdsAddress;
566     int32_t ret = esimManager->GetSmdsAddress(slotId, portIndex, smdsAddress);
567     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
568 }
569 
570 HWTEST_F(EsimManagerTest, GetRulesAuthTable_002, Function | MediumTest | Level1)
571 {
572     int32_t slotId = -1;
573     int32_t portIndex = 0;
574     EuiccRulesAuthTable eUiccRulesAuthTable;
575     int32_t ret = esimManager->GetRulesAuthTable(slotId, portIndex, eUiccRulesAuthTable);
576     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
577 }
578 
579 HWTEST_F(EsimManagerTest, GetEuiccChallenge_002, Function | MediumTest | Level1)
580 {
581     int32_t slotId = -1;
582     int32_t portIndex = 0;
583     ResponseEsimInnerResult result;
584     int32_t ret = esimManager->GetEuiccChallenge(slotId, portIndex, result);
585     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
586 }
587 
588 HWTEST_F(EsimManagerTest, GetDefaultSmdpAddress_002, Function | MediumTest | Level1)
589 {
590     int32_t slotId = -1;
591     std::u16string defaultSmdpAddress;
592     int32_t ret = esimManager->GetDefaultSmdpAddress(slotId, defaultSmdpAddress);
593     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
594 }
595 
596 HWTEST_F(EsimManagerTest, CancelSession_002, Function | MediumTest | Level1)
597 {
598     int32_t slotId = -1;
599     std::u16string transactionId = Str8ToStr16("A1B2C3");
600     CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
601     ResponseEsimInnerResult responseResult;
602     int32_t ret = esimManager->CancelSession(slotId, transactionId, cancelReason, responseResult);
603     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
604 }
605 
606 HWTEST_F(EsimManagerTest, GetProfile_002, Function | MediumTest | Level1)
607 {
608     int32_t slotId = -1;
609     int32_t portIndex = 0;
610     std::u16string iccId = Str8ToStr16("5A0A89670000000000216954");
611     EuiccProfile eUiccProfile;
612     int32_t ret = esimManager->GetProfile(slotId, portIndex, iccId, eUiccProfile);
613     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
614 }
615 
616 HWTEST_F(EsimManagerTest, ResetMemory_002, Function | MediumTest | Level1)
617 {
618     int32_t slotId = -1;
619     int32_t resetMemoryResult;
620     ResetOption resetOption = ResetOption::DELETE_OPERATIONAL_PROFILES;
621     int32_t ret = esimManager->ResetMemory(slotId, resetOption, resetMemoryResult);
622     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
623 }
624 
625 HWTEST_F(EsimManagerTest, SetDefaultSmdpAddress_002, Function | MediumTest | Level1)
626 {
627     int32_t slotId = -1;
628     std::u16string defaultSmdpAddress = Str8ToStr16("test.com");
629     int32_t setAddressResult;
630     int32_t ret = esimManager->SetDefaultSmdpAddress(slotId, defaultSmdpAddress, setAddressResult);
631     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
632 }
633 
634 HWTEST_F(EsimManagerTest, IsSupported_002, Function | MediumTest | Level1)
635 {
636     int32_t slotId = -1;
637     bool ret = esimManager->IsSupported(slotId);
638     EXPECT_EQ(ret, false);
639 }
640 
641 HWTEST_F(EsimManagerTest, SendApduData_002, Function | MediumTest | Level1)
642 {
643     int32_t slotId = -1;
644     std::u16string aid = Str8ToStr16("aid test");
645     EsimApduData apduData;
646     ResponseEsimInnerResult responseResult;
647     int32_t ret = esimManager->SendApduData(slotId, aid, apduData, responseResult);
648     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
649 }
650 
651 HWTEST_F(EsimManagerTest, PrepareDownload_002, Function | MediumTest | Level1)
652 {
653     int32_t slotId = -1;
654     DownLoadConfigInfo downLoadConfigInfo;
655     downLoadConfigInfo.portIndex_ = 0;
656     downLoadConfigInfo.hashCc_ = Str8ToStr16("4131423243332D583459355A36");
657     ResponseEsimInnerResult responseResult;
658     int32_t ret = esimManager->PrepareDownload(slotId, downLoadConfigInfo, responseResult);
659     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
660 }
661 
662 HWTEST_F(EsimManagerTest, LoadBoundProfilePackage_002, Function | MediumTest | Level1)
663 {
664     int32_t slotId = -1;
665     int32_t portIndex = 0;
666     std::u16string boundProfilePackage;
667     ResponseEsimBppResult responseResult;
668     int32_t ret = esimManager->LoadBoundProfilePackage(slotId, portIndex, boundProfilePackage, responseResult);
669     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
670 }
671 
672 HWTEST_F(EsimManagerTest, ListNotifications_002, Function | MediumTest | Level1)
673 {
674     int32_t slotId = -1;
675     int32_t portIndex = 0;
676     const EsimEvent events = EsimEvent::EVENT_DELETE;
677     EuiccNotificationList notificationList;
678     int32_t ret = esimManager->ListNotifications(slotId, portIndex, events, notificationList);
679     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
680 }
681 
682 HWTEST_F(EsimManagerTest, RetrieveNotificationList_002, Function | MediumTest | Level1)
683 {
684     int32_t slotId = -1;
685     int32_t portIndex = 0;
686     const EsimEvent events = EsimEvent::EVENT_DISABLE;
687     EuiccNotificationList notificationList;
688     int32_t ret = esimManager->RetrieveNotificationList(slotId, portIndex, events, notificationList);
689     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
690 }
691 
692 HWTEST_F(EsimManagerTest, RetrieveNotification_002, Function | MediumTest | Level1)
693 {
694     int32_t slotId = -1;
695     int32_t portIndex = 0;
696     int32_t seqNumber = 5;
697     EuiccNotification notification;
698     int32_t ret = esimManager->RetrieveNotification(slotId, portIndex, seqNumber, notification);
699     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
700 }
701 
702 HWTEST_F(EsimManagerTest, RemoveNotificationFromList_002, Function | MediumTest | Level1)
703 {
704     int32_t slotId = -1;
705     int32_t portIndex = 0;
706     int32_t seqNumber = 5;
707     int32_t enumResult;
708     int32_t ret = esimManager->RemoveNotificationFromList(slotId, portIndex, seqNumber, enumResult);
709     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
710 }
711 
712 HWTEST_F(EsimManagerTest, DeleteProfile_002, Function | MediumTest | Level1)
713 {
714     int32_t slotId = -1;
715     std::u16string iccId = Str8ToStr16("98760000000000543210");
716     int32_t deleteProfileResult;
717     int32_t ret = esimManager->DeleteProfile(slotId, iccId, deleteProfileResult);
718     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
719 }
720 
721 HWTEST_F(EsimManagerTest, SwitchToProfile_002, Function | MediumTest | Level1)
722 {
723     int32_t slotId = -1;
724     int32_t portIndex = 1;
725     std::u16string iccId = Str8ToStr16("98760000000000543210");
726     bool forceDisableProfile = true;
727     int32_t switchProfileResult;
728     int32_t ret = esimManager->SwitchToProfile(slotId, portIndex, iccId, forceDisableProfile, switchProfileResult);
729     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
730 }
731 
732 HWTEST_F(EsimManagerTest, SetProfileNickname_002, Function | MediumTest | Level1)
733 {
734     int32_t slotId = -1;
735     std::u16string iccId = Str8ToStr16("98760000000000543210");
736     std::u16string nickname = Str8ToStr16("nick");
737     int32_t updateResult;
738     int32_t ret = esimManager->esimManager->SetProfileNickname(slotId, iccId, nickname, updateResult);
739     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
740 }
741 
742 HWTEST_F(EsimManagerTest, GetEuiccInfo2_002, Function | MediumTest | Level1)
743 {
744     int32_t slotId = -1;
745     int32_t portIndex = 0;
746     EuiccInfo2 euiccInfo2;
747     int32_t ret = esimManager->GetEuiccInfo2(slotId, portIndex, euiccInfo2);
748     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
749 }
750 
751 HWTEST_F(EsimManagerTest, AuthenticateServer_002, Function | MediumTest | Level1)
752 {
753     int32_t slotId = -1;
754     AuthenticateConfigInfo authenticateConfigInfo;
755     authenticateConfigInfo.matchingId_ = Str8ToStr16("4131423243332D583459355A36");
756     ResponseEsimInnerResult responseResult;
757     int32_t ret = esimManager->AuthenticateServer(slotId, authenticateConfigInfo, responseResult);
758     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
759 }
760 
761 HWTEST_F(EsimManagerTest, GetContractInfo_002, Function | MediumTest | Level1)
762 {
763     int32_t slotId = -1;
764     GetContractInfoRequest request;
765     std::string response = "";
766     int32_t ret = esimManager->GetContractInfo(slotId, request, response);
767     EXPECT_EQ(ret, TELEPHONY_ERR_CORE_SERVICE_NOT_SUPPORTED_ESIM);
768 }
769 #endif
770 } // Telephony
771 } // OHOS