1 /*
2 * Copyright (C) 2024 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 <string>
19 #include <unistd.h>
20
21 #include "asn1_node.h"
22 #include "common_event_manager.h"
23 #include "common_event_support.h"
24 #include "esim_file.h"
25 #include "icc_file.h"
26 #include "sim_file_manager.h"
27 #include "sim_constant.h"
28 #include "sim_file_manager.h"
29 #include "tel_ril_manager.h"
30 #include "telephony_tag_def.h"
31 #include "esim_state_type.h"
32 #include "gtest/gtest.h"
33
34 namespace OHOS {
35 namespace Telephony {
36 using namespace testing::ext;
37 class EsimTest : public testing::Test {
38 public:
39 static void SetUpTestCase();
40 static void TearDownTestCase();
41 void SetUp();
42 void TearDown();
43 };
44
TearDownTestCase()45 void EsimTest::TearDownTestCase() {}
46
SetUp()47 void EsimTest::SetUp() {}
48
TearDown()49 void EsimTest::TearDown() {}
50
SetUpTestCase()51 void EsimTest::SetUpTestCase() {}
52
53 static const std::string bppCombineHexStr = "BF3781ADBF27678008D14FE1DE62C340D7BF2F3480024C66810207800C1E31302E313"
54 "02E31322E3136342F64702D706C75732D696E746572666163655A0A98680010203040506080060388370AA21FA01D4F10A000000559101"
55 "0FFFFFFFF890000120004093007A00530038001005F3740B354AE39D08ACD7EDD7D2D01C73378621F623B832DFA3243489C5B42C90F220"
56 "14E6C928130D78EE561982EF412AC3D94C04B56F37657DA84FD7BB24DD5634E89";
57
58 static const std::string boundProfilePackage = "vzaCFPW/I4GjggEBgAiX"
59 "eXu/pVhILaYNgAGIgQEQhAURIjNEVV9JQQR+7Z54dnOSpmXRSRn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mY5MThjNDI2ZTZkZThiN2UyM2ExYTMwMA==";
187
188 HWTEST_F(EsimTest, SyncOpenChannel_001, Function | MediumTest | Level2)
189 {
190 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
191 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
192 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
193 esimFile->currentChannelId_ = 2;
194 esimFile->ObtainChannelSuccessExclusive();
195 EXPECT_TRUE(esimFile->IsLogicChannelOpen());
196 }
197
198 HWTEST_F(EsimTest, SyncOpenChannel_002, Function | MediumTest | Level2)
199 {
200 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
201 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
202 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
203 std::u16string aid = Str8ToStr16("123");
204 esimFile->currentChannelId_ = 2;
205 esimFile->ObtainChannelSuccessAlllowSameAidReuse(aid);
206 EXPECT_TRUE(esimFile->IsLogicChannelOpen());
207 }
208
209 HWTEST_F(EsimTest, SyncCloseChannel_001, Function | MediumTest | Level2)
210 {
211 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
212 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
213 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
214 esimFile->currentChannelId_ = 0;
215 esimFile->SyncCloseChannel();
216 EXPECT_FALSE(esimFile->IsLogicChannelOpen());
217 }
218
219 HWTEST_F(EsimTest, SyncCloseChannel_002, Function | MediumTest | Level2)
220 {
221 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
222 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
223 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
224 esimFile->currentChannelId_ = 0;
225 esimFile->SyncCloseChannel();
226 EXPECT_FALSE(esimFile->IsLogicChannelOpen());
227 }
228
229 HWTEST_F(EsimTest, ObtainEid_001, Function | MediumTest | Level2)
230 {
231 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
232 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
233 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
234 esimFile->currentChannelId_ = 0;
235 EXPECT_EQ("", esimFile->ObtainEid());
236 int32_t slotId = 0;
237 esimFile->currentChannelId_ = 2;
238 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
239 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
240 EXPECT_EQ("", esimFile->ObtainEid());
241 }
242
243 HWTEST_F(EsimTest, ProcessObtainEid_001, Function | MediumTest | Level2)
244 {
245 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
246 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
247 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
248 AppExecFwk::InnerEvent::Pointer eventGetEid = esimFile->BuildCallerInfo(MSG_ESIM_OBTAIN_EID_DONE);
249 int32_t slotId = 0;
250 esimFile->currentChannelId_ = 0;
251 EXPECT_EQ(esimFile->ProcessObtainEid(slotId, eventGetEid), false);
252 esimFile->currentChannelId_ = 2;
253 EXPECT_EQ(esimFile->ProcessObtainEid(slotId, eventGetEid), true);
254 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
255 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
256 EXPECT_EQ(esimFile->ProcessObtainEid(slotId, eventGetEid), true);
257 }
258
259 HWTEST_F(EsimTest, ProcessObtainEidDone_001, Function | MediumTest | Level2)
260 {
261 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
262 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
263 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
264 std::shared_ptr<IccControllerHolder> holder = nullptr;
265 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
266 rcvMsg->fileData.resultData = "BF3E125A1089086030202200000024000070951319";
267 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
268 EXPECT_TRUE(esimFile->ProcessObtainEidDone(event));
269 auto eventGetEid = AppExecFwk::InnerEvent::Get(0);
270 EXPECT_EQ(esimFile->ProcessObtainEidDone(eventGetEid), false);
271 eventGetEid = nullptr;
272 EXPECT_EQ(esimFile->ProcessObtainEidDone(eventGetEid), false);
273 }
274
275 HWTEST_F(EsimTest, GetEuiccProfileInfoList_001, Function | MediumTest | Level2)
276 {
277 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
278 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
279 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
280 esimFile->currentChannelId_ = 0;
281 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_OPEN_FAILED),
282 esimFile->GetEuiccProfileInfoList().result_);
283 int32_t slotId = 0;
284 esimFile->currentChannelId_ = 2;
285 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
286 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
287 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_IN_USE),
288 esimFile->GetEuiccProfileInfoList().result_);
289 }
290
291 HWTEST_F(EsimTest, ProcessRequestAllProfiles_001, Function | MediumTest | Level2)
292 {
293 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
294 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
295 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
296 int slotId = 0;
297 AppExecFwk::InnerEvent::Pointer eventRequestAllProfiles = esimFile->BuildCallerInfo(MSG_ESIM_REQUEST_ALL_PROFILES);
298 esimFile->currentChannelId_ = 0;
299 EXPECT_FALSE(esimFile->ProcessRequestAllProfiles(slotId, eventRequestAllProfiles));
300 esimFile->currentChannelId_ = 2;
301 EXPECT_TRUE(esimFile->ProcessRequestAllProfiles(slotId, eventRequestAllProfiles));
302 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
303 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
304 EXPECT_TRUE(esimFile->ProcessRequestAllProfiles(slotId, eventRequestAllProfiles));
305 }
306
307 HWTEST_F(EsimTest, ProcessRequestAllProfilesDone_001, Function | MediumTest | Level2)
308 {
309 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
310 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
311 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
312 std::shared_ptr<IccControllerHolder> holder = nullptr;
313 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
314 rcvMsg->fileData.resultData = "BF2D25A023E3215A0A986800102030405060809F7001019105736D617274950102B705800364F007";
315 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
316 EXPECT_FALSE(esimFile->ProcessRequestAllProfilesDone(event));
317 auto eventRequestAllProfiles = AppExecFwk::InnerEvent::Get(0);
318 EXPECT_EQ(esimFile->ProcessRequestAllProfilesDone(eventRequestAllProfiles), false);
319 eventRequestAllProfiles = nullptr;
320 EXPECT_EQ(esimFile->ProcessRequestAllProfilesDone(eventRequestAllProfiles), false);
321 }
322
323 HWTEST_F(EsimTest, GetEuiccInfo_001, Function | MediumTest | Level2)
324 {
325 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
326 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
327 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
328 EuiccInfo eUiccInfo_;
329 esimFile->currentChannelId_ = 0;
330 EXPECT_EQ(eUiccInfo_.osVersion_, esimFile->GetEuiccInfo().osVersion_);
331 int32_t slotId = 0;
332 esimFile->currentChannelId_ = 2;
333 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
334 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
335 EXPECT_EQ(eUiccInfo_.osVersion_, esimFile->GetEuiccInfo().osVersion_);
336 }
337
338 HWTEST_F(EsimTest, CommBuildOneApduReqInfo_001, Function | MediumTest | Level2)
339 {
340 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
341 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
342 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
343 ApduSimIORequestInfo reqInfo;
344 std::shared_ptr<Asn1Builder> builder = std::make_shared<Asn1Builder>(TAG_ESIM_GET_RAT);
345 esimFile->CommBuildOneApduReqInfo(reqInfo, builder);
346 EXPECT_NE(esimFile->nextSerialId_, -1);
347 }
348
349 HWTEST_F(EsimTest, ProcessObtainEuiccInfo1_001, Function | MediumTest | Level2)
350 {
351 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
352 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
353 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
354 int slotId = 0;
355 AppExecFwk::InnerEvent::Pointer eventEUICCInfo1 = esimFile->BuildCallerInfo(MSG_ESIM_OBTAIN_EUICC_INFO_1_DONE);
356 esimFile->currentChannelId_ = 0;
357 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1(slotId, eventEUICCInfo1), false);
358 esimFile->currentChannelId_ = 2;
359 EXPECT_NE(esimFile->ProcessObtainEuiccInfo1(slotId, eventEUICCInfo1), false);
360 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
361 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
362 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1(slotId, eventEUICCInfo1), true);
363 }
364
365 HWTEST_F(EsimTest, ProcessObtainEuiccInfo1Done_001, Function | MediumTest | Level2)
366 {
367 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
368 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
369 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
370 std::shared_ptr<IccControllerHolder> holder = nullptr;
371 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
372 rcvMsg->fileData.resultData = "BF20618203020202A92C0414F54172BDF98A95D65CBEB88A38A1C11D800A85C30414C0BC70BA369"
373 "29D43B467FF57570530E57AB8FCD8AA2C0414F54172BDF98A95D65CBEB88A38A1C11D800A85C30414C0BC70BA36929D43B467FF575"
374 "70530E57AB8FCD8";
375 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
376 EXPECT_TRUE(esimFile->ProcessObtainEuiccInfo1Done(event));
377 auto event1 = AppExecFwk::InnerEvent::Get(0);
378 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1Done(event), false);
379 event1 = nullptr;
380 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1Done(event1), false);
381 }
382
383 HWTEST_F(EsimTest, ProcessEsimOpenChannel_001, Function | MediumTest | Level2)
384 {
385 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
386 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
387 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
388 std::u16string aid = Str8ToStr16("123");
389 int32_t slotId = 0;
390 esimFile->ProcessEsimOpenChannel(aid);
391 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
392 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
393 esimFile->ProcessEsimOpenChannel(aid);
394 EXPECT_NE(telRilManager, nullptr);
395 }
396
397 HWTEST_F(EsimTest, ProcessEsimOpenChannelDone_001, Function | MediumTest | Level2)
398 {
399 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
400 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
401 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
402 auto event = AppExecFwk::InnerEvent::Get(0);
403 EXPECT_EQ(false, esimFile->ProcessEsimOpenChannelDone(event));
404 event = nullptr;
405 EXPECT_EQ(false, esimFile->ProcessEsimOpenChannelDone(event));
406 }
407
408 HWTEST_F(EsimTest, ProcessEsimCloseChannel_001, Function | MediumTest | Level2)
409 {
410 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
411 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
412 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
413 int32_t slotId = 0;
414 esimFile->ProcessEsimCloseChannel();
415 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
416 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
417 esimFile->ProcessEsimCloseChannel();
418 EXPECT_NE(telRilManager, nullptr);
419 }
420
421 HWTEST_F(EsimTest, ProcessEsimCloseChannelDone_001, Function | MediumTest | Level2)
422 {
423 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
424 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
425 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
426 AppExecFwk::InnerEvent::Pointer event = esimFile->BuildCallerInfo(MSG_ESIM_CLOSE_CHANNEL_DONE);
427 EXPECT_EQ(true, esimFile->ProcessEsimCloseChannelDone(event));
428 }
429
430 HWTEST_F(EsimTest, ObtainEuiccInfo1ParseTagCtx2_001, Function | MediumTest | Level2)
431 {
432 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
433 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
434 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
435 int32_t tag = 0;
436 std::vector<uint8_t> src;
437 std::shared_ptr<Asn1Node> asn1Node = std::make_shared<Asn1Node>(tag, src, 0, 0);
438 asn1Node->constructed_ = false;
439 bool ret = esimFile->ObtainEuiccInfo1ParseTagCtx2(asn1Node);
440 EXPECT_EQ(ret, false);
441 }
442
443 HWTEST_F(EsimTest, ProcessEvent_001, Function | MediumTest | Level2)
444 {
445 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
446 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
447 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
448 auto event = AppExecFwk::InnerEvent::Get(0);
449 esimFile->ProcessEvent(event);
450 event = nullptr;
451 esimFile->ProcessEvent(event);
452 event =esimFile->BuildCallerInfo(MSG_ESIM_REQUEST_ALL_PROFILES);
453 esimFile->ProcessEvent(event);
454 ASSERT_TRUE(esimFile != nullptr);
455 }
456
457 HWTEST_F(EsimTest, InitMemberFunc_001, Function | MediumTest | Level2)
458 {
459 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
460 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
461 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
462 esimFile->InitMemberFunc();
463 bool ret = esimFile->memberFuncMap_.empty();
464 EXPECT_FALSE(ret);
465 }
466
467 HWTEST_F(EsimTest, DisableProfile_001, Function | MediumTest | Level2)
468 {
469 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
470 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
471 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
472 int32_t portIndex = 0;
473 std::u16string iccId = Str8ToStr16("5A0A89670000000000452301");
474 int32_t disableProfileResult = static_cast<int32_t>(EsimResultCode::RESULT_SGP_22_OTHER);
475 esimFile->currentChannelId_ = 0;
476 EXPECT_NE(disableProfileResult, esimFile->DisableProfile(portIndex, iccId));
477 int32_t slotId = 0;
478 esimFile->currentChannelId_ = 2;
479 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
480 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
481 EXPECT_NE(disableProfileResult, esimFile->DisableProfile(portIndex, iccId));
482 esimFile->currentChannelId_ = 2;
483 EXPECT_NE(disableProfileResult, esimFile->DisableProfile(portIndex, iccId));
484 }
485
486 HWTEST_F(EsimTest, ProcessDisableProfile_001, Function | MediumTest | Level2)
487 {
488 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
489 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
490 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
491 int slotId = 0;
492 AppExecFwk::InnerEvent::Pointer eventGetProfile = esimFile->BuildCallerInfo(MSG_ESIM_DISABLE_PROFILE);
493 esimFile->currentChannelId_ = 0;
494 EXPECT_FALSE(esimFile->ProcessDisableProfile(slotId, eventGetProfile));
495 esimFile->currentChannelId_ = 2;
496 std::string iccIdStr = "ABCDEFG";
497 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdStr);
498 EXPECT_TRUE(esimFile->ProcessDisableProfile(slotId, eventGetProfile));
499 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
500 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
501 EXPECT_TRUE(esimFile->ProcessDisableProfile(slotId, eventGetProfile));
502 std::string str = "ABCDEFGG";
503 esimFile->esimProfile_.iccId = Str8ToStr16(str);
504 EXPECT_TRUE(esimFile->ProcessDisableProfile(slotId, eventGetProfile));
505 }
506
507 HWTEST_F(EsimTest, ProcessDisableProfileDone_001, Function | MediumTest | Level2)
508 {
509 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
510 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
511 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
512 std::shared_ptr<IccControllerHolder> holder = nullptr;
513 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
514 rcvMsg->fileData.resultData = "BF32038001009000";
515 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
516 EXPECT_TRUE(esimFile->ProcessDisableProfileDone(event));
517 auto eventDisableProfile = AppExecFwk::InnerEvent::Get(0);
518 EXPECT_EQ(esimFile->ProcessDisableProfileDone(eventDisableProfile), false);
519 eventDisableProfile = nullptr;
520 EXPECT_EQ(esimFile->ProcessDisableProfileDone(eventDisableProfile), false);
521 }
522
523 HWTEST_F(EsimTest, ObtainSmdsAddress_001, Function | MediumTest | Level2)
524 {
525 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
526 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
527 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
528 int32_t portIndex = 0;
529 std::string smdsAddress = "";
530 esimFile->currentChannelId_ = 0;
531 EXPECT_EQ(smdsAddress, esimFile->ObtainSmdsAddress(portIndex));
532 int32_t slotId = 0;
533 esimFile->currentChannelId_ = 2;
534 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
535 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
536 EXPECT_EQ(smdsAddress, esimFile->ObtainSmdsAddress(portIndex));
537 }
538
539 HWTEST_F(EsimTest, ObtainRulesAuthTable_001, Function | MediumTest | Level2)
540 {
541 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
542 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
543 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
544 int32_t portIndex = 0;
545 EuiccRulesAuthTable eUiccRulesAuthTable;
546 esimFile->currentChannelId_ = 0;
547 EXPECT_EQ(eUiccRulesAuthTable.position_, (esimFile->ObtainRulesAuthTable(portIndex)).position_);
548 int32_t slotId = 0;
549 esimFile->currentChannelId_ = 2;
550 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
551 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
552 EXPECT_EQ(eUiccRulesAuthTable.position_, (esimFile->ObtainRulesAuthTable(portIndex)).position_);
553 }
554
555 HWTEST_F(EsimTest, ObtainEuiccChallenge_001, Function | MediumTest | Level2)
556 {
557 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
558 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
559 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
560 int32_t portIndex = 0;
561 esimFile->currentChannelId_ = 0;
562 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_OPEN_FAILED),
563 (esimFile->ObtainEuiccChallenge(portIndex)).resultCode_);
564 int32_t slotId = 0;
565 esimFile->currentChannelId_ = 2;
566 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
567 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
568 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_IN_USE),
569 (esimFile->ObtainEuiccChallenge(portIndex)).resultCode_);
570 }
571
572 HWTEST_F(EsimTest, RequestRulesAuthTableParseTagCtxComp0_001, Function | MediumTest | Level2)
573 {
574 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
575 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
576 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
577
578 std::string resultData = "BF434B"
579 "A0233021"
580 "800206C0"
581 "A118"
582 "B70A800312F3458103010203"
583 "B70A800312F3458203040506"
584 "820108"
585 "A0243022"
586 "80020780"
587 "A118"
588 "B70A800312E3458103010203"
589 "B70A8003EEEE458203040506"
590 "82020780"
591 "9000";
592 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
593 uint32_t byteLen = responseByte.size();
594 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
595 EXPECT_TRUE(esimFile->RequestRulesAuthTableParseTagCtxComp0(root));
596 byteLen = 0;
597 EXPECT_TRUE(esimFile->RequestRulesAuthTableParseTagCtxComp0(root));
598 }
599
600 HWTEST_F(EsimTest, ProcessRequestRulesAuthTableDone_001, Function | MediumTest | Level2)
601 {
602 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
603 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
604 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
605 AppExecFwk::InnerEvent::Pointer eventRequestRulesAuthTable =
606 esimFile->BuildCallerInfo(MSG_ESIM_REQUEST_RULES_AUTH_TABLE);
607 std::shared_ptr<IccControllerHolder> holder = nullptr;
608 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
609 rcvMsg->fileData.resultData = "BF434B"
610 "A0233021"
611 "800206C0"
612 "A118"
613 "B70A800312F3458103010203"
614 "B70A800312F3458203040506"
615 "820108"
616 "A0243022"
617 "80020780"
618 "A118"
619 "B70A800312E3458103010203"
620 "B70A8003EEEE458203040506"
621 "82020780"
622 "9000";
623 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
624 EXPECT_TRUE(esimFile->ProcessRequestRulesAuthTableDone(event));
625 auto event1 = AppExecFwk::InnerEvent::Get(0);
626 EXPECT_EQ(esimFile->ProcessRequestRulesAuthTableDone(event1), false);
627 event1 = nullptr;
628 EXPECT_EQ(esimFile->ProcessRequestRulesAuthTableDone(event1), false);
629 }
630
631 HWTEST_F(EsimTest, ProcessRequestRulesAuthTable_001, Function | MediumTest | Level2)
632 {
633 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
634 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
635 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
636 int slotId = 0;
637 AppExecFwk::InnerEvent::Pointer eventRequestRulesAuthTable =
638 esimFile->BuildCallerInfo(MSG_ESIM_REQUEST_RULES_AUTH_TABLE);
639 esimFile->currentChannelId_ = 1;
640 EXPECT_TRUE(esimFile->ProcessRequestRulesAuthTable(slotId, eventRequestRulesAuthTable));
641 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
642 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
643 EXPECT_TRUE(esimFile->ProcessRequestRulesAuthTable(slotId, eventRequestRulesAuthTable));
644 esimFile->currentChannelId_ = 0;
645 EXPECT_FALSE(esimFile->ProcessRequestRulesAuthTable(slotId, eventRequestRulesAuthTable));
646 }
647
648 HWTEST_F(EsimTest, ProcessObtainSmdsAddressDone_001, Function | MediumTest | Level2)
649 {
650 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
651 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
652 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
653 std::shared_ptr<IccControllerHolder> holder = nullptr;
654 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
655 rcvMsg->fileData.resultData = "BF3C148008534D44502E434F4D8108736D64732E636F6D9000";
656 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
657 EXPECT_TRUE(esimFile->ProcessObtainSmdsAddressDone(event));
658 auto event1 = AppExecFwk::InnerEvent::Get(0);
659 EXPECT_FALSE(esimFile->ProcessObtainSmdsAddressDone(event));
660 event1 = nullptr;
661 EXPECT_FALSE(esimFile->ProcessObtainSmdsAddressDone(event));
662 }
663
664 HWTEST_F(EsimTest, ProcessObtainSmdsAddress_001, Function | MediumTest | Level2)
665 {
666 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
667 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
668 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
669 int slotId = 0;
670 AppExecFwk::InnerEvent::Pointer eventObtainSmdsAddress = esimFile->BuildCallerInfo(MSG_ESIM_OBTAIN_SMDS_ADDRESS);
671 esimFile->currentChannelId_ = 0;
672 EXPECT_FALSE(esimFile->ProcessObtainSmdsAddress(slotId, eventObtainSmdsAddress));
673 esimFile->currentChannelId_ = 2;
674 EXPECT_TRUE(esimFile->ProcessObtainSmdsAddress(slotId, eventObtainSmdsAddress));
675 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
676 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
677 EXPECT_TRUE(esimFile->ProcessObtainSmdsAddress(slotId, eventObtainSmdsAddress));
678 }
679
680 HWTEST_F(EsimTest, ProcessObtainEuiccChallenge_001, Function | MediumTest | Level2)
681 {
682 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
683 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
684 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
685 int slotId = 0;
686 AppExecFwk::InnerEvent::Pointer eventEUICCChanllenge =
687 esimFile->BuildCallerInfo(MSG_ESIM_OBTAIN_EUICC_CHALLENGE_DONE);
688 esimFile->currentChannelId_ = 0;
689 EXPECT_EQ(esimFile->ProcessObtainEuiccChallenge(slotId, eventEUICCChanllenge), false);
690 esimFile->currentChannelId_ = 2;
691 EXPECT_NE(esimFile->ProcessObtainEuiccChallenge(slotId, eventEUICCChanllenge), false);
692 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
693 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
694 EXPECT_EQ(esimFile->ProcessObtainEuiccChallenge(slotId, eventEUICCChanllenge), true);
695 }
696
697 HWTEST_F(EsimTest, ProcessObtainEuiccChallengeDone_001, Function | MediumTest | Level2)
698 {
699 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
700 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
701 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
702 std::shared_ptr<IccControllerHolder> holder = nullptr;
703 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
704 rcvMsg->fileData.resultData = "BF2E1280105DAD74D9F1734CF96CDE5C78FDB0565B";
705 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
706 EXPECT_TRUE(esimFile->ProcessObtainEuiccChallengeDone(event));
707 auto eventEUICCChanllenge = AppExecFwk::InnerEvent::Get(0);
708 EXPECT_EQ(esimFile->ProcessObtainEuiccChallengeDone(eventEUICCChanllenge), false);
709 eventEUICCChanllenge = nullptr;
710 EXPECT_EQ(esimFile->ProcessObtainEuiccChallengeDone(eventEUICCChanllenge), false);
711 }
712
713 HWTEST_F(EsimTest, ObtainDefaultSmdpAddress_001, Function | MediumTest | Level2)
714 {
715 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
716 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
717 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
718 std::string defaultDpAddress_ = "";
719 esimFile->currentChannelId_ = 0;
720 EXPECT_EQ(defaultDpAddress_, esimFile->ObtainDefaultSmdpAddress());
721 int32_t slotId = 0;
722 esimFile->currentChannelId_ = 2;
723 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
724 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
725 EXPECT_EQ(defaultDpAddress_, esimFile->ObtainDefaultSmdpAddress());
726 }
727
728 HWTEST_F(EsimTest, CancelSession_001, Function | MediumTest | Level2)
729 {
730 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
731 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
732 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
733 std::u16string transactionId = Str8ToStr16("A1B2C3");
734 const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
735 esimFile->currentChannelId_ = 0;
736 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_OPEN_FAILED),
737 (esimFile->CancelSession(transactionId, cancelReason)).resultCode_);
738 int32_t slotId = 0;
739 esimFile->currentChannelId_ = 2;
740 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
741 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
742 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_IN_USE),
743 (esimFile->CancelSession(transactionId, cancelReason)).resultCode_);
744 }
745
746 HWTEST_F(EsimTest, ObtainProfile_001, Function | MediumTest | Level2)
747 {
748 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
749 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
750 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
751 int32_t portIndex = 0;
752 std::u16string iccId = Str8ToStr16("5A0A89670000000000216954");
753 EuiccProfile eUiccProfile;
754 esimFile->currentChannelId_ = 0;
755 EXPECT_EQ(eUiccProfile.state_, (esimFile->ObtainProfile(portIndex, iccId)).state_);
756 int32_t slotId = 0;
757 esimFile->currentChannelId_ = 2;
758 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
759 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
760 EXPECT_EQ(eUiccProfile.state_, (esimFile->ObtainProfile(portIndex, iccId)).state_);
761 }
762
763 HWTEST_F(EsimTest, ProcessObtainDefaultSmdpAddress_001, Function | MediumTest | Level2)
764 {
765 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
766 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
767 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
768 int slotId = 0;
769 AppExecFwk::InnerEvent::Pointer eventSmdpAddress =
770 esimFile->BuildCallerInfo(MSG_ESIM_OBTAIN_DEFAULT_SMDP_ADDRESS_DONE);
771 esimFile->currentChannelId_ = 0;
772 EXPECT_FALSE(esimFile->ProcessObtainDefaultSmdpAddress(slotId, eventSmdpAddress));
773 esimFile->currentChannelId_ = 2;
774 EXPECT_TRUE(esimFile->ProcessObtainDefaultSmdpAddress(slotId, eventSmdpAddress));
775 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
776 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
777 EXPECT_TRUE(esimFile->ProcessObtainDefaultSmdpAddress(slotId, eventSmdpAddress));
778 }
779
780 HWTEST_F(EsimTest, ProcessObtainDefaultSmdpAddressDone_001, Function | MediumTest | Level2)
781 {
782 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
783 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
784 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
785 std::shared_ptr<IccControllerHolder> holder = nullptr;
786 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
787 rcvMsg->fileData.resultData = "BF3C148008534D44502E434F4D8108736D64732E58225F9000";
788 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
789 EXPECT_TRUE(esimFile->ProcessObtainDefaultSmdpAddressDone(event));
790 auto event1 = AppExecFwk::InnerEvent::Get(0);
791 EXPECT_FALSE(esimFile->ProcessObtainDefaultSmdpAddressDone(event1));
792 event1 = nullptr;
793 EXPECT_FALSE(esimFile->ProcessObtainDefaultSmdpAddressDone(event1));
794 }
795
796 HWTEST_F(EsimTest, ProcessCancelSession_001, Function | MediumTest | Level2)
797 {
798 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
799 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
800 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
801 int slotId = 0;
802 AppExecFwk::InnerEvent::Pointer eventCancelSession = esimFile->BuildCallerInfo(MSG_ESIM_CANCEL_SESSION);
803 esimFile->currentChannelId_ = 0;
804 EXPECT_FALSE(esimFile->ProcessCancelSession(slotId, eventCancelSession));
805 esimFile->currentChannelId_ = 2;
806 EXPECT_TRUE(esimFile->ProcessCancelSession(slotId, eventCancelSession));
807 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
808 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
809 EXPECT_TRUE(esimFile->ProcessCancelSession(slotId, eventCancelSession));
810 }
811
812 HWTEST_F(EsimTest, ProcessCancelSessionDone_001, Function | MediumTest | Level2)
813 {
814 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
815 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
816 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
817 std::shared_ptr<IccControllerHolder> holder = nullptr;
818 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
819 rcvMsg->fileData.resultData = "BF41009000";
820 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
821 EXPECT_TRUE(esimFile->ProcessCancelSessionDone(event));
822 std::shared_ptr<IccControllerHolder> holder1 = nullptr;
823 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg1 = std::make_unique<Telephony::IccFromRilMsg>(holder1);
824 rcvMsg1->fileData.resultData = "BF4106810456362523";
825 event = AppExecFwk::InnerEvent::Get(0, rcvMsg1);
826 EXPECT_TRUE(esimFile->ProcessCancelSessionDone(event));
827 auto event1 = AppExecFwk::InnerEvent::Get(0);
828 EXPECT_FALSE(esimFile->ProcessCancelSessionDone(event1));
829 event1 = nullptr;
830 EXPECT_FALSE(esimFile->ProcessCancelSessionDone(event1));
831 }
832
833 HWTEST_F(EsimTest, ProcessGetProfile_001, Function | MediumTest | Level2)
834 {
835 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
836 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
837 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
838 int slotId = 0;
839 AppExecFwk::InnerEvent::Pointer eventGetProfile = esimFile->BuildCallerInfo(MSG_ESIM_GET_PROFILE);
840 const int32_t CHANEL_ID_ZERO = 0;
841 esimFile->currentChannelId_ = CHANEL_ID_ZERO;
842 EXPECT_FALSE(esimFile->ProcessGetProfile(slotId, eventGetProfile));
843 const int32_t CHANEL_ID_TWO = 0;
844 esimFile->currentChannelId_ = CHANEL_ID_TWO;
845 std::string str = "ABCDEFG";
846 esimFile->esimProfile_.iccId = Str8ToStr16(str);
847 EXPECT_FALSE(esimFile->ProcessGetProfile(slotId, eventGetProfile));
848 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
849 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
850 EXPECT_FALSE(esimFile->ProcessGetProfile(slotId, eventGetProfile));
851 std::string iccIdstr = "ABCDEFGG";
852 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdstr);
853 EXPECT_FALSE(esimFile->ProcessGetProfile(slotId, eventGetProfile));
854 }
855
856 HWTEST_F(EsimTest, ProcessGetProfileDone_002, Function | MediumTest | Level2)
857 {
858 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
859 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
860 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
861 std::shared_ptr<IccControllerHolder> holder = nullptr;
862 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
863 rcvMsg->fileData.resultData = "BF2D";
864 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
865 EXPECT_FALSE(esimFile->ProcessGetProfileDone(event));
866 }
867
868 HWTEST_F(EsimTest, ResetMemory_001, Function | MediumTest | Level2)
869 {
870 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
871 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
872 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
873 ResetOption resetOption = ResetOption::DELETE_FIELD_LOADED_TEST_PROFILES;
874 int32_t resetResult = static_cast<int32_t>(EsimResultCode::RESULT_SGP_22_OTHER);
875 esimFile->currentChannelId_ = 0;
876 EXPECT_NE(resetResult, esimFile->ResetMemory(resetOption));
877 int32_t slotId = 0;
878 esimFile->currentChannelId_ = 2;
879 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
880 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
881 EXPECT_NE(resetResult, esimFile->ResetMemory(resetOption));
882 }
883
884 HWTEST_F(EsimTest, ProcessResetMemory_001, Function | MediumTest | Level2)
885 {
886 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
887 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
888 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
889 int slotId = 0;
890 AppExecFwk::InnerEvent::Pointer eventResetMemory = esimFile->BuildCallerInfo(MSG_ESIM_RESET_MEMORY);
891 esimFile->currentChannelId_ = 0;
892 EXPECT_EQ(esimFile->ProcessResetMemory(slotId, eventResetMemory), false);
893 esimFile->currentChannelId_ = 2;
894 EXPECT_NE(esimFile->ProcessResetMemory(slotId, eventResetMemory), false);
895 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
896 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
897 EXPECT_EQ(esimFile->ProcessResetMemory(slotId, eventResetMemory), true);
898 }
899
900 HWTEST_F(EsimTest, ProcessResetMemoryDone_001, Function | MediumTest | Level2)
901 {
902 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
903 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
904 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
905 std::shared_ptr<IccControllerHolder> holder = nullptr;
906 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
907 rcvMsg->fileData.resultData = "BF34038001009000";
908 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
909 EXPECT_TRUE(esimFile->ProcessResetMemoryDone(event));
910 auto eventResetMemory = AppExecFwk::InnerEvent::Get(0);
911 EXPECT_EQ(esimFile->ProcessResetMemoryDone(eventResetMemory), false);
912 eventResetMemory = nullptr;
913 EXPECT_EQ(esimFile->ProcessResetMemoryDone(eventResetMemory), false);
914 }
915
916 HWTEST_F(EsimTest, ProcessSendApduDataDone_001, Function | MediumTest | Level2)
917 {
918 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
919 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
920 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
921 std::shared_ptr<IccControllerHolder> holder = nullptr;
922 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
923 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
924 EXPECT_TRUE(esimFile->ProcessSendApduDataDone(event));
925 auto event1 = AppExecFwk::InnerEvent::Get(0);
926 EXPECT_EQ(esimFile->ProcessSendApduDataDone(event1), false);
927 event1 = nullptr;
928 EXPECT_EQ(esimFile->ProcessSendApduDataDone(event1), false);
929 }
930
931 HWTEST_F(EsimTest, ProcessSendApduData_001, Function | MediumTest | Level2)
932 {
933 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
934 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
935 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
936 int slotId = 0;
937 AppExecFwk::InnerEvent::Pointer eventSendApduData = esimFile->BuildCallerInfo(MSG_ESIM_SEND_APUD_DATA);
938 esimFile->currentChannelId_ = 1;
939 EXPECT_TRUE(esimFile->ProcessSendApduData(slotId, eventSendApduData));
940 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
941 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
942 EXPECT_TRUE(esimFile->ProcessSendApduData(slotId, eventSendApduData));
943 esimFile->currentChannelId_ = 0;
944 EXPECT_FALSE(esimFile->ProcessSendApduData(slotId, eventSendApduData));
945 }
946
947 HWTEST_F(EsimTest, ObtainPrepareDownload_001, Function | MediumTest | Level2)
948 {
949 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
950 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
951 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
952 DownLoadConfigInfo downLoadConfigInfo;
953 esimFile->currentChannelId_ = 0;
954 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_OPEN_FAILED),
955 (esimFile->ObtainPrepareDownload(downLoadConfigInfo)).resultCode_);
956 int32_t slotId = 0;
957 esimFile->currentChannelId_ = 2;
958 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
959 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
960 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_IN_USE),
961 (esimFile->ObtainPrepareDownload(downLoadConfigInfo)).resultCode_);
962 }
963
964 HWTEST_F(EsimTest, ObtainLoadBoundProfilePackage_001, Function | MediumTest | Level2)
965 {
966 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
967 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
968 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
969 int32_t portIndex = 0;
970 std::u16string boundProfilePackageStr;
971 esimFile->currentChannelId_ = 0;
972 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_OPEN_FAILED),
973 (esimFile->ObtainLoadBoundProfilePackage(portIndex, boundProfilePackageStr)).resultCode_);
974 int32_t slotId = 0;
975 esimFile->currentChannelId_ = 2;
976 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
977 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
978 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_IN_USE),
979 (esimFile->ObtainLoadBoundProfilePackage(portIndex, boundProfilePackageStr)).resultCode_);
980 }
981
982 HWTEST_F(EsimTest, ListNotifications_001, Function | MediumTest | Level2)
983 {
984 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
985 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
986 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
987 int32_t portIndex = 0;
988 EsimEvent events = EsimEvent::EVENT_DONOTHING;
989 esimFile->currentChannelId_ = 0;
990 EXPECT_TRUE((esimFile->ListNotifications(portIndex, events)).euiccNotification_.empty());
991 int32_t slotId = 0;
992 esimFile->currentChannelId_ = 2;
993 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
994 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
995 EXPECT_TRUE((esimFile->ListNotifications(portIndex, events)).euiccNotification_.empty());
996 }
997
998 HWTEST_F(EsimTest, ProcessPrepareDownload_001, Function | MediumTest | Level2)
999 {
1000 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1001 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1002 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1003
1004 int slotId = 0;
1005 esimFile->currentChannelId_ = 0;
1006 EXPECT_FALSE(esimFile->ProcessPrepareDownload(slotId));
1007
1008 esimFile->currentChannelId_ = 2;
1009 EXPECT_TRUE(esimFile->ProcessPrepareDownload(slotId));
1010
1011 std::u16string str = u"hashCctest";
1012 esimFile->esimProfile_.hashCc = str;
1013 EXPECT_TRUE(esimFile->ProcessPrepareDownload(slotId));
1014
1015 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1016 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1017 EXPECT_TRUE(esimFile->ProcessPrepareDownload(slotId));
1018 }
1019
1020
1021 HWTEST_F(EsimTest, DecodeBoundProfilePackage_001, Function | MediumTest | Level2)
1022 {
1023 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1024 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1025 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1026 std::shared_ptr<Asn1Node> bppNode = nullptr;
1027 std::string boundProfilePackageStr = "some_decode_data";
1028 EXPECT_FALSE(esimFile->DecodeBoundProfilePackage(boundProfilePackageStr, bppNode));
1029 }
1030
1031 HWTEST_F(EsimTest, BuildApduForInitSecureChannel_001, Function | MediumTest | Level2)
1032 {
1033 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1034 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1035 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1036 std::shared_ptr<Asn1Node> bppNode = nullptr;
1037 esimFile->DecodeBoundProfilePackage(boundProfilePackage, bppNode);
1038 int32_t currentChannelId_ = 1;
1039 RequestApduBuild codec(currentChannelId_);
1040 std::shared_ptr<Asn1Node> initSecureChannelReq = bppNode->Asn1GetChild(TAG_ESIM_INITIALISE_SECURE_CHANNEL);
1041 esimFile->BuildApduForInitSecureChannel(codec, bppNode, initSecureChannelReq);
1042 bool bRet = codec.GetCommands().size() != 0 ? true : false;
1043 EXPECT_TRUE(bRet);
1044 }
1045
1046 HWTEST_F(EsimTest, BuildApduForFirstSequenceOf87_001, Function | MediumTest | Level2)
1047 {
1048 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1049 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1050 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1051 std::shared_ptr<Asn1Node> bppNode = nullptr;
1052 esimFile->DecodeBoundProfilePackage(boundProfilePackage, bppNode);
1053 int32_t currentChannelId_ = 1;
1054 RequestApduBuild codec(currentChannelId_);
1055 std::shared_ptr<Asn1Node> firstSequenceOf87 = bppNode->Asn1GetChild(TAG_ESIM_CTX_COMP_0);
1056 esimFile->BuildApduForFirstSequenceOf87(codec, firstSequenceOf87);
1057 bool bRet = codec.GetCommands().size() != 0 ? true : false;
1058 EXPECT_TRUE(bRet);
1059 }
1060
1061 HWTEST_F(EsimTest, BuildApduForSequenceOf88_001, Function | MediumTest | Level2)
1062 {
1063 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1064 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1065 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1066 std::shared_ptr<Asn1Node> bppNode = nullptr;
1067 esimFile->DecodeBoundProfilePackage(boundProfilePackage, bppNode);
1068 int32_t currentChannelId_ = 1;
1069 RequestApduBuild codec(currentChannelId_);
1070 std::shared_ptr<Asn1Node> sequenceOf88 = bppNode->Asn1GetChild(TAG_ESIM_CTX_COMP_1);
1071 esimFile->BuildApduForSequenceOf88(codec, sequenceOf88);
1072 bool bRet = codec.GetCommands().size() != 0 ? true : false;
1073 EXPECT_TRUE(bRet);
1074 }
1075
1076 HWTEST_F(EsimTest, BuildApduForSequenceOf86_001, Function | MediumTest | Level2)
1077 {
1078 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1079 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1080 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1081 std::shared_ptr<Asn1Node> bppNode = nullptr;
1082 esimFile->DecodeBoundProfilePackage(boundProfilePackage, bppNode);
1083 int32_t currentChannelId_ = 1;
1084 RequestApduBuild codec(currentChannelId_);
1085 std::shared_ptr<Asn1Node> sequenceOf86 = bppNode->Asn1GetChild(TAG_ESIM_CTX_COMP_3);
1086 esimFile->BuildApduForSequenceOf86(codec, bppNode, sequenceOf86);
1087 bool bRet = codec.GetCommands().size() != 0 ? true : false;
1088 EXPECT_TRUE(bRet);
1089 }
1090
1091 HWTEST_F(EsimTest, ProcessLoadBoundProfilePackage_001, Function | MediumTest | Level2)
1092 {
1093 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1094 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1095 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1096 int slotId = 0;
1097 AppExecFwk::InnerEvent::Pointer eventGetProfile = esimFile->BuildCallerInfo(MSG_ESIM_GET_PROFILE);
1098 esimFile->currentChannelId_ = 0;
1099 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1100 esimFile->currentChannelId_ = 2;
1101 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1102 esimFile->esimProfile_.boundProfilePackage = Str8ToStr16(boundProfilePackage);
1103 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1104 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1105 EXPECT_TRUE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1106 }
1107
1108 HWTEST_F(EsimTest, ProcessLoadBoundProfilePackage_002, Function | MediumTest | Level2)
1109 {
1110 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1111 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1112 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1113 int slotId = 0;
1114 AppExecFwk::InnerEvent::Pointer eventGetProfile = esimFile->BuildCallerInfo(MSG_ESIM_GET_PROFILE);
1115 esimFile->currentChannelId_ = 0;
1116 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1117 esimFile->currentChannelId_ = 1;
1118 esimFile->esimProfile_.boundProfilePackage = Str8ToStr16(BOUND_PROFILE_PACKAGE_GET_BPP_LOAD_ERROR_A300);
1119 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1120 esimFile->currentChannelId_ = 2;
1121 esimFile->esimProfile_.boundProfilePackage = Str8ToStr16(BOUND_PROFILE_PACKAGE_GET_BPP_LOAD_ERROR_NULLPTR);
1122 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1123 esimFile->currentChannelId_ = 3;
1124 esimFile->esimProfile_.boundProfilePackage = Str8ToStr16(boundProfilePackage);
1125 EXPECT_TRUE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1126 esimFile->esimProfile_.boundProfilePackage = Str8ToStr16(BOUND_PROFILE_PACKAGE_UNKNOWN_BPP);
1127 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1128 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1129 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1130 }
1131
1132 HWTEST_F(EsimTest, ProcessLoadBoundProfilePackageDone_001, Function | MediumTest | Level2)
1133 {
1134 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1135 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1136 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1137
1138 std::shared_ptr<IccControllerHolder> holder = nullptr;
1139 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1140 rcvMsg->fileData.resultData = "BF3781ADBF27678008D14FE1DE62C340D7BF2F3480024C66810207800C1E31302E31302E31322E"
1141 "3136342F64702D706C75732D696E746572666163655A0A98680010203040506080060388370AA21FA01D4F10A0000005591010FFF"
1142 "FFFFF890000120004093007A00530038001005F3740B354AE39D08ACD7EDD7D2D01C73378621F623B832DFA3243489C5B42C90F22"
1143 "014E6C928130D78EE561982EF412AC3D94C04B56F37657DA84FD7BB24D15C4783F";
1144 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1145 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackageDone(event));
1146 auto event1 = AppExecFwk::InnerEvent::Get(0);
1147 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackageDone(event1));
1148 event1 = nullptr;
1149 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackageDone(event1));
1150 }
1151
1152 HWTEST_F(EsimTest, LoadBoundProfilePackageParseNotificationMetadata_001, Function | MediumTest | Level2)
1153 {
1154 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1155 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1156 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1157 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(bppCombineHexStr);
1158 uint32_t byteLen = responseByte.size();
1159 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1160 std::shared_ptr<Asn1Node> nodeNotificationMetadata =
1161 esimFile->LoadBoundProfilePackageParseProfileInstallResult(root);
1162 EXPECT_TRUE(esimFile->LoadBoundProfilePackageParseNotificationMetadata(nodeNotificationMetadata));
1163 }
1164
1165 HWTEST_F(EsimTest, RealProcessLoadBoundProfilePackageDone_001, Function | MediumTest | Level2)
1166 {
1167 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1168 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1169 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1170 EXPECT_FALSE(esimFile->RealProcessLoadBoundProfilePackageDone());
1171 }
1172
1173 HWTEST_F(EsimTest, ProcessListNotifications_001, Function | MediumTest | Level2)
1174 {
1175 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1176 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1177 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1178 int slotId = 0;
1179 AppExecFwk::InnerEvent::Pointer eventListNotif = esimFile->BuildCallerInfo(MSG_ESIM_LIST_NOTIFICATION);
1180 esimFile->currentChannelId_ =0 ;
1181 EXPECT_FALSE(esimFile->ProcessListNotifications(slotId, EsimEvent::EVENT_ENABLE, eventListNotif));
1182 esimFile->currentChannelId_ =2 ;
1183 EXPECT_TRUE(esimFile->ProcessListNotifications(slotId, EsimEvent::EVENT_ENABLE, eventListNotif));
1184 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1185 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1186 EXPECT_TRUE(esimFile->ProcessListNotifications(slotId, EsimEvent::EVENT_ENABLE, eventListNotif));
1187 }
1188
1189 HWTEST_F(EsimTest, CreateNotification_001, Function | MediumTest | Level2)
1190 {
1191 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1192 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1193 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1194 std::string resultData = "BF2F118001010C08736D64702E636F6D81020508";
1195 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData.c_str());
1196 uint32_t byteLen = responseByte.size();
1197 std::shared_ptr<Asn1Node> node = esimFile->Asn1ParseResponse(responseByte, byteLen);
1198 EuiccNotification euicc;
1199 esimFile->CreateNotification(node, euicc);
1200 bool bRet = euicc.targetAddr_.empty() ? false : true;
1201 EXPECT_TRUE(bRet);
1202 }
1203
1204 HWTEST_F(EsimTest, CreateNotification_002, Function | MediumTest | Level2)
1205 {
1206 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1207 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1208 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1209
1210 std::string resultData = "BF282BA029BF2F118001010C00736D64702E636F6C820";
1211 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData.c_str());
1212 uint32_t byteLen = responseByte.size();
1213 std::shared_ptr<Asn1Node> node = esimFile->Asn1ParseResponse(responseByte, byteLen);
1214 EuiccNotification euicc;
1215 esimFile->CreateNotification(node, euicc);
1216 bool bRet = euicc.targetAddr_.empty() ? false : true;
1217 EXPECT_TRUE(!bRet);
1218 }
1219
1220 HWTEST_F(EsimTest, CreateNotification_003, Function | MediumTest | Level2)
1221 {
1222 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1223 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1224 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1225 std::string resultData = "BF2F118001010C08736D64702E636F6D81020603";
1226 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData.c_str());
1227 uint32_t byteLen = responseByte.size();
1228 std::shared_ptr<Asn1Node> node = esimFile->Asn1ParseResponse(responseByte, byteLen);
1229 EuiccNotification euicc;
1230 esimFile->CreateNotification(node, euicc);
1231 bool bRet = euicc.targetAddr_.empty() ? false : true;
1232 EXPECT_TRUE(bRet);
1233 }
1234
1235 HWTEST_F(EsimTest, ProcessListNotificationsAsn1Response_001, Function | MediumTest | Level2)
1236 {
1237 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1238 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1239 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1240
1241 std::string resultData =
1242 "BF282BA029BF2F118001010C08736D64702E636F6D81020410BF2F128001020C09736D6470322E636F6D810205309000";
1243 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1244 uint32_t byteLen = responseByte.size();
1245
1246 std::shared_ptr<Asn1Node> profileNode = esimFile->Asn1ParseResponse(responseByte, byteLen);
1247 EXPECT_EQ(esimFile->ProcessListNotificationsAsn1Response(profileNode), true);
1248 }
1249
1250 HWTEST_F(EsimTest, ProcessListNotificationsAsn1Response_002, Function | MediumTest | Level2)
1251 {
1252 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1253 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1254 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1255
1256 std::string resultData = "BF2803810106";
1257 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1258 uint32_t byteLen = responseByte.size();
1259
1260 std::shared_ptr<Asn1Node> profileNode = esimFile->Asn1ParseResponse(responseByte, byteLen);
1261 EXPECT_EQ(esimFile->ProcessListNotificationsAsn1Response(profileNode), false);
1262 }
1263
1264 HWTEST_F(EsimTest, ProcessListNotificationsAsn1Response_003, Function | MediumTest | Level2)
1265 {
1266 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1267 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1268 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1269
1270 std::string resultData = "BF2803A00106";
1271 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1272 uint32_t byteLen = responseByte.size();
1273
1274 std::shared_ptr<Asn1Node> profileNode = esimFile->Asn1ParseResponse(responseByte, byteLen);
1275 EXPECT_EQ(esimFile->ProcessListNotificationsAsn1Response(profileNode), true);
1276 }
1277
1278 HWTEST_F(EsimTest, RetrieveNotificationList_001, Function | MediumTest | Level2)
1279 {
1280 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1281 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1282 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1283 int32_t portIndex = 0;
1284 EsimEvent events = EsimEvent::EVENT_DONOTHING;
1285 esimFile->currentChannelId_ = 0;
1286 EXPECT_TRUE((esimFile->RetrieveNotificationList(portIndex, events)).euiccNotification_.empty());
1287
1288 int32_t slotId = 0;
1289 esimFile->currentChannelId_ = 2;
1290 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1291 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1292 EXPECT_TRUE((esimFile->RetrieveNotificationList(portIndex, events)).euiccNotification_.empty());
1293 }
1294
1295 HWTEST_F(EsimTest, ObtainRetrieveNotification_001, Function | MediumTest | Level2)
1296 {
1297 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1298 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1299 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1300 int32_t portIndex = 0;
1301 int32_t seqNumber = 5;
1302 EuiccNotification notification;
1303 esimFile->currentChannelId_ = 0;
1304 EXPECT_EQ(notification.seq_, (esimFile->ObtainRetrieveNotification(portIndex, seqNumber)).seq_);
1305 int32_t slotId = 0;
1306 esimFile->currentChannelId_ = 2;
1307 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1308 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1309 EXPECT_EQ(notification.seq_, (esimFile->ObtainRetrieveNotification(portIndex, seqNumber)).seq_);
1310 }
1311
1312 HWTEST_F(EsimTest, RemoveNotificationFromList_001, Function | MediumTest | Level2)
1313 {
1314 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1315 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1316 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1317 int32_t portIndex = 0;
1318 int32_t seqNumber = 5;
1319 esimFile->currentChannelId_ = 0;
1320 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_OPEN_FAILED),
1321 esimFile->RemoveNotificationFromList(portIndex, seqNumber));
1322 int32_t slotId = 0;
1323 esimFile->currentChannelId_ = 2;
1324 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1325 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1326 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_IN_USE),
1327 esimFile->RemoveNotificationFromList(portIndex, seqNumber));
1328 }
1329
1330 HWTEST_F(EsimTest, ProcessRemoveNotification_001, Function | MediumTest | Level2)
1331 {
1332 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1333 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1334 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1335 int slotId = 0;
1336 AppExecFwk::InnerEvent::Pointer eventRemoveNotif = esimFile->BuildCallerInfo(MSG_ESIM_REMOVE_NOTIFICATION);
1337 esimFile->currentChannelId_ = 0;
1338 EXPECT_FALSE(esimFile->ProcessRemoveNotification(slotId, eventRemoveNotif));
1339 esimFile->currentChannelId_ = 2;
1340 EXPECT_TRUE(esimFile->ProcessRemoveNotification(slotId, eventRemoveNotif));
1341 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1342 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1343 EXPECT_TRUE(esimFile->ProcessRemoveNotification(slotId, eventRemoveNotif));
1344 }
1345
1346 HWTEST_F(EsimTest, ProcessRemoveNotificationDone_001, Function | MediumTest | Level2)
1347 {
1348 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1349 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1350 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1351 std::shared_ptr<IccControllerHolder> holder = nullptr;
1352 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1353 rcvMsg->fileData.resultData = "BF3003800100";
1354 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1355 EXPECT_TRUE(esimFile->ProcessRemoveNotificationDone(event));
1356 auto eventRemoveNotif = AppExecFwk::InnerEvent::Get(0);
1357 EXPECT_EQ(esimFile->ProcessRemoveNotificationDone(eventRemoveNotif), false);
1358 eventRemoveNotif = nullptr;
1359 EXPECT_EQ(esimFile->ProcessRemoveNotificationDone(eventRemoveNotif), false);
1360 }
1361
1362 HWTEST_F(EsimTest, ProcessRetrieveNotification_001, Function | MediumTest | Level2)
1363 {
1364 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1365 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1366 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1367 int slotId = 0;
1368 AppExecFwk::InnerEvent::Pointer eventRetrieveNotification =
1369 esimFile->BuildCallerInfo(MSG_ESIM_RETRIEVE_NOTIFICATION_DONE);
1370 esimFile->currentChannelId_ = 0;
1371 EXPECT_FALSE(esimFile->ProcessRetrieveNotification(slotId, eventRetrieveNotification));
1372 esimFile->currentChannelId_ = 2;
1373 EXPECT_TRUE(esimFile->ProcessRetrieveNotification(slotId, eventRetrieveNotification));
1374 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1375 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1376 EXPECT_TRUE(esimFile->ProcessRetrieveNotification(slotId, eventRetrieveNotification));
1377 }
1378
1379 HWTEST_F(EsimTest, ProcessRetrieveNotificationList_001, Function | MediumTest | Level2)
1380 {
1381 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1382 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1383 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1384 int slotId = 0;
1385 AppExecFwk::InnerEvent::Pointer eventRetrieveListNotif =
1386 esimFile->BuildCallerInfo(MSG_ESIM_RETRIEVE_NOTIFICATION_LIST);
1387 EsimEvent events = EsimEvent::EVENT_ENABLE;
1388 esimFile->currentChannelId_ = 1;
1389 EXPECT_TRUE(esimFile->ProcessRetrieveNotificationList(slotId, events, eventRetrieveListNotif));
1390 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1391 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1392 EXPECT_TRUE(esimFile->ProcessRetrieveNotificationList(slotId, events, eventRetrieveListNotif));
1393 esimFile->currentChannelId_ = 0;
1394 EXPECT_FALSE(esimFile->ProcessRetrieveNotificationList(slotId, events, eventRetrieveListNotif));
1395 }
1396
1397 HWTEST_F(EsimTest, ProcessRetrieveNotificationListDone_001, Function | MediumTest | Level2)
1398 {
1399 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1400 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1401 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1402 std::shared_ptr<IccControllerHolder> holder = nullptr;
1403 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1404 rcvMsg->fileData.resultData =
1405 "BF2B2FA02D3014BF2F118001010C08736D64702E636F6D810204103015BF2F128001020C09736D6470322E636F6D810205109000";
1406 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1407 EXPECT_TRUE(esimFile->ProcessRetrieveNotificationListDone(event));
1408 auto event1 = AppExecFwk::InnerEvent::Get(0);
1409 EXPECT_EQ(esimFile->ProcessRetrieveNotificationListDone(event1), false);
1410 event1 = nullptr;
1411 EXPECT_EQ(esimFile->ProcessRetrieveNotificationListDone(event1), false);
1412 }
1413
1414 HWTEST_F(EsimTest, RetrieveNotificationParseCompTag_001, Function | MediumTest | Level2)
1415 {
1416 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1417 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1418 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1419 std::shared_ptr<IccControllerHolder> holder = nullptr;
1420 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1421 rcvMsg->fileData.resultData =
1422 "BF2B2FA02D3014BF2F118001010C08736D64702E636F6D810204103015BF2F128001020C09736D6470322E636F6D810205109000";
1423 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(rcvMsg->fileData.resultData);
1424 uint32_t byteLen = responseByte.size();
1425 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1426 EXPECT_TRUE(esimFile->RetrieveNotificationParseCompTag(root));
1427 }
1428
1429 HWTEST_F(EsimTest, DeleteProfile_001, Function | MediumTest | Level2)
1430 {
1431 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1432 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1433 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1434
1435 std::u16string iccId;
1436 int32_t disableProfileResult = static_cast<int32_t>(EsimResultCode::RESULT_SGP_22_OTHER);
1437 esimFile->currentChannelId_ = 0;
1438 EXPECT_NE(disableProfileResult, esimFile->DeleteProfile(iccId));
1439
1440 int32_t slotId = 0;
1441 esimFile->currentChannelId_ = 2;
1442 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1443 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1444 EXPECT_NE(disableProfileResult, esimFile->DeleteProfile(iccId));
1445 }
1446
1447 HWTEST_F(EsimTest, SwitchToProfile_001, Function | MediumTest | Level2)
1448 {
1449 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1450 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1451 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1452
1453 int32_t portIndex = 0;
1454 std::u16string iccId;
1455 bool forceDisableProfile = false;
1456 int32_t switchResult = static_cast<int32_t>(EsimResultCode::RESULT_SGP_22_OTHER);
1457 esimFile->currentChannelId_ = 0;
1458 EXPECT_NE(switchResult, esimFile->SwitchToProfile(portIndex, iccId, forceDisableProfile));
1459
1460 int32_t slotId = 0;
1461 esimFile->currentChannelId_ = 2;
1462 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1463 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1464 EXPECT_NE(switchResult, esimFile->SwitchToProfile(portIndex, iccId, forceDisableProfile));
1465 }
1466
1467 HWTEST_F(EsimTest, SetProfileNickname_001, Function | MediumTest | Level2)
1468 {
1469 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1470 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1471 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1472
1473 std::u16string iccId = Str8ToStr16("98760000000000543210");
1474 std::u16string nickname = Str8ToStr16("nick");
1475 int32_t updateNicknameResult = static_cast<int32_t>(EsimResultCode::RESULT_SGP_22_OTHER);
1476 esimFile->currentChannelId_ = 0;
1477 EXPECT_NE(updateNicknameResult, esimFile->SetProfileNickname(iccId, nickname));
1478
1479 int32_t slotId = 0;
1480 esimFile->currentChannelId_ = 2;
1481 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1482 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1483 EXPECT_NE(updateNicknameResult, esimFile->SetProfileNickname(iccId, nickname));
1484 }
1485
1486 HWTEST_F(EsimTest, ProcessDeleteProfile_001, Function | MediumTest | Level2)
1487 {
1488 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1489 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1490 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1491
1492 int slotId = 0;
1493 AppExecFwk::InnerEvent::Pointer eventDeleteProfile = esimFile->BuildCallerInfo(MSG_ESIM_DELETE_PROFILE);
1494 esimFile->currentChannelId_ = 0;
1495 EXPECT_FALSE(esimFile->ProcessDeleteProfile(slotId, eventDeleteProfile));
1496
1497 esimFile->currentChannelId_ = 2;
1498 std::string iccIdStr = "ABCDEFG";
1499 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdStr);
1500 EXPECT_TRUE(esimFile->ProcessDeleteProfile(slotId, eventDeleteProfile));
1501
1502 std::string str = "ABCDEFGG";
1503 esimFile->esimProfile_.iccId = Str8ToStr16(str);
1504 EXPECT_TRUE(esimFile->ProcessDeleteProfile(slotId, eventDeleteProfile));
1505 }
1506
1507 HWTEST_F(EsimTest, ProcessDeleteProfileDone_001, Function | MediumTest | Level2)
1508 {
1509 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1510 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1511 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1512 std::shared_ptr<IccControllerHolder> holder = nullptr;
1513 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1514 rcvMsg->fileData.resultData = "BF33038001009000";
1515 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1516 EXPECT_TRUE(esimFile->ProcessDeleteProfileDone(event));
1517
1518 auto event1 = AppExecFwk::InnerEvent::Get(0);
1519 EXPECT_FALSE(esimFile->ProcessDeleteProfileDone(event1));
1520
1521 event1 = nullptr;
1522 EXPECT_FALSE(esimFile->ProcessDeleteProfileDone(event1));
1523 }
1524
1525 HWTEST_F(EsimTest, ProcessSwitchToProfile_001, Function | MediumTest | Level2)
1526 {
1527 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1528 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1529 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1530
1531 int slotId = 0;
1532 AppExecFwk::InnerEvent::Pointer eventSwitchToProfile = esimFile->BuildCallerInfo(MSG_ESIM_SWITCH_PROFILE);
1533 esimFile->currentChannelId_ = 0;
1534 EXPECT_FALSE(esimFile->ProcessSwitchToProfile(slotId, eventSwitchToProfile));
1535
1536 esimFile->currentChannelId_ = 2;
1537 std::string iccIdStr = "ABCDEFG";
1538 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdStr);
1539 EXPECT_TRUE(esimFile->ProcessSwitchToProfile(slotId, eventSwitchToProfile));
1540
1541 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1542 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1543 EXPECT_TRUE(esimFile->ProcessSwitchToProfile(slotId, eventSwitchToProfile));
1544
1545 std::string str = "ABCDEFGG";
1546 esimFile->esimProfile_.iccId = Str8ToStr16(str);
1547 EXPECT_TRUE(esimFile->ProcessSwitchToProfile(slotId, eventSwitchToProfile));
1548 }
1549
1550 HWTEST_F(EsimTest, ProcessSwitchToProfileDone_001, Function | MediumTest | Level2)
1551 {
1552 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1553 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1554 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1555 std::shared_ptr<IccControllerHolder> holder = nullptr;
1556 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1557 rcvMsg->fileData.resultData = "BF3103800100";
1558 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1559 EXPECT_TRUE(esimFile->ProcessSwitchToProfileDone(event));
1560
1561 auto event1 = AppExecFwk::InnerEvent::Get(0);
1562 EXPECT_FALSE(esimFile->ProcessSwitchToProfileDone(event1));
1563
1564 event1 = nullptr;
1565 EXPECT_FALSE(esimFile->ProcessSwitchToProfileDone(event1));
1566 }
1567
1568 HWTEST_F(EsimTest, ProcessSetNickname_001, Function | MediumTest | Level2)
1569 {
1570 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1571 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1572 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1573
1574 int slotId = 0;
1575 AppExecFwk::InnerEvent::Pointer eventSetNickName = esimFile->BuildCallerInfo(MSG_ESIM_SET_NICK_NAME);
1576 esimFile->currentChannelId_ = 0;
1577 EXPECT_FALSE(esimFile->ProcessSetNickname(slotId, eventSetNickName));
1578
1579 esimFile->currentChannelId_ = 2;
1580 std::string iccIdStr = "ABCDEFG";
1581 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdStr);
1582 EXPECT_TRUE(esimFile->ProcessSetNickname(slotId, eventSetNickName));
1583
1584 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1585 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1586 EXPECT_TRUE(esimFile->ProcessSetNickname(slotId, eventSetNickName));
1587
1588 std::string str = "ABCDEFGG";
1589 esimFile->esimProfile_.iccId = Str8ToStr16(str);
1590 EXPECT_TRUE(esimFile->ProcessSetNickname(slotId, eventSetNickName));
1591 }
1592
1593 HWTEST_F(EsimTest, ProcessSetNicknameDone_001, Function | MediumTest | Level2)
1594 {
1595 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1596 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1597 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1598 std::shared_ptr<IccControllerHolder> holder = nullptr;
1599 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1600 rcvMsg->fileData.resultData = "BF31038001009000";
1601 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1602 EXPECT_TRUE(esimFile->ProcessSetNicknameDone(event));
1603
1604 auto event1 = AppExecFwk::InnerEvent::Get(0);
1605 EXPECT_FALSE(esimFile->ProcessSetNicknameDone(event1));
1606
1607 event1 = nullptr;
1608 EXPECT_FALSE(esimFile->ProcessSetNicknameDone(event1));
1609 }
1610
1611 HWTEST_F(EsimTest, ProcessAuthenticateServer_001, Function | MediumTest | Level2)
1612 {
1613 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1614 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1615 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1616 int32_t slotId = 0;
1617 esimFile->currentChannelId_ = 0;
1618 EXPECT_FALSE(esimFile->ProcessAuthenticateServer(slotId));
1619 esimFile->currentChannelId_ = 2;
1620 EXPECT_TRUE(esimFile->ProcessAuthenticateServer(slotId));
1621 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1622 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1623 EXPECT_TRUE(esimFile->ProcessAuthenticateServer(slotId));
1624 }
1625
1626 HWTEST_F(EsimTest, ProcessAuthenticateServerDone_001, Function | MediumTest | Level2)
1627 {
1628 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1629 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1630 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1631 std::shared_ptr<IccControllerHolder> holder = nullptr;
1632 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1633 rcvMsg->fileData.sw1 = 90;
1634 rcvMsg->fileData.sw2 = 00;
1635 rcvMsg->fileData.resultData = "BF388205E5A08205E13082011C8008D14FE1DE62C340D7831E31302E31302E31322E3136342F647"
1636 "02D706C75732D696E746572666163658410F31F2690404C42718528B2301082A071BF2281A68103020301820302020283030402008"
1637 "40D81010082040007AE2E83022F378505067F32F7C08603090200870302030088020490A92C0414F54172BDF98A95D65CBEB88A38A"
1638 "1C11D800A85C30414C0BC70BA36929D43B467FF57570530E57AB8FCD8AA2C0414F54172BDF98A95D65CBEB88A38A1C11D800A85C30"
1639 "414C0BC70BA36929D43B467FF57570530E57AB8FCD88B010004030100000C0D45442D5A492D55502D30383234A0348017503658313"
1640 "72D3833594C332D52345230592D4E56523332A119800468396860A10F80030B000081030B000085030B000082005F3740B939AD87D"
1641 "29B5505CB5C00ACAABD3E156C680EF9A15B99D8C4361A9B4CA59C112D9CC649463515A860F534A1822536F537F7D422651F9D19A40"
1642 "384C90A2FFCCC308201FE308201A5A0030201020209020000000000000001300A06082A8648CE3D0403023037310B3009060355040"
1643 "61302455331153013060355040A0C0C52535020546573742045554D3111300F06035504030C0845554D20546573743020170D32303"
1644 "03430313039343835385A180F37343936303132343039343835385A3064310B300906035504061302455331153013060355040A0C0"
1645 "C52535020546573742045554D312930270603550405132038393038363033303230323230303030303032343030303037303935313"
1646 "331393113301106035504030C0A546573742065554943433059301306072A8648CE3D020106082A8648CE3D030107034200046DB3F"
1647 "53ADC87DC2FF10C7BFCD87AD13AE97009AFA065A6757EE571B3F2EBB18F46C1D68F3EDEB0E74B2E5D542051E7D27F50952028605AF"
1648 "DEF79FE9FFFD03959A36B3069301F0603551D23041830168014DD3DA24D350C1CC5D0AF0965F40EC34C5EE409F1301D0603551D0E0"
1649 "4160414A52476AF5D50AA376437CCB1DA2172EF45F484F0300E0603551D0F0101FF04040302078030170603551D200101FF040D300"
1650 "B3009060767811201020101300A06082A8648CE3D040302034700304402200858D232D4649A8BDA7B9441C1215854B1BC48AB52D24"
1651 "1CF57BA7D6FA0EB5191022009ED2C93F2184ECD34F2E42FD64B1DC68CF38EAB6CDBA9ADDDBD0139629C55CC308202783082021FA00"
1652 "3020102020412345678300A06082A8648CE3D04030230443110300E06035504030C07546573742043493111300F060355040B0C085"
1653 "4455354434552543110300E060355040A0C0752535054455354310B30090603550406130249543020170D323030343031303932383"
1654 "3375A180F32303534303332343039323833375A3037310B300906035504061302455331153013060355040A0C0C525350205465737"
1655 "42045554D3111300F06035504030C0845554D20546573743059301306072A8648CE3D020106082A8648CE3D030107034200041330D"
1656 "59256AC0CB50BD928D0F4C68007C485FE3F42988AD3EE3875AE33F4983AB23B4DD4C31340D676DD8E11F9C5CBA1B11EB694EED0994"
1657 "DB529285E632C8906A382010830820104301F0603551D23041830168014F54172BDF98A95D65CBEB88A38A1C11D800A85C3301D060"
1658 "3551D0E04160414DD3DA24D350C1CC5D0AF0965F40EC34C5EE409F1300E0603551D0F0101FF04040302020430170603551D200101F"
1659 "F040D300B3009060767811201020102300E0603551D1104073005880388370530120603551D130101FF040830060101FF020100303"
1660 "50603551D1F042E302C302AA028A0268624687474703A2F2F63692E746573742E6578616D706C652E636F6D2F43524C2D422E63726"
1661 "C303E0603551D1E0101FF04343032A030302EA42C302A31153013060355040A0C0C52535020546573742045554D3111300F0603550"
1662 "40513083839303439303332300A06082A8648CE3D040302034700304402200C567BF01E45244863AD7A4613F7572EEF3439F698B47"
1663 "11AA397AEEFC5445CE702206E993AA0A505F260B0EEF62CC30A2BBE453B0E8248218FD53304EF7FAABBCCDD";
1664 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1665 EXPECT_FALSE(esimFile->ProcessAuthenticateServerDone(event));
1666 auto event1 = AppExecFwk::InnerEvent::Get(0);
1667 EXPECT_FALSE(esimFile->ProcessAuthenticateServerDone(event1));
1668 event1 = nullptr;
1669 EXPECT_FALSE(esimFile->ProcessAuthenticateServerDone(event1));
1670 }
1671
1672 HWTEST_F(EsimTest, ConvertAuthInputParaFromApiStru_001, Function | MediumTest | Level2)
1673 {
1674 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1675 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1676 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1677 Es9PlusInitAuthResp bytes;
1678 esimFile->ConvertAuthInputParaFromApiStru(bytes, esimFile->esimProfile_);
1679 bool bRet = bytes.imei.empty() ? false : true;
1680 EXPECT_TRUE(!bRet);
1681 }
1682
1683 HWTEST_F(EsimTest, ObtainEuiccInfo2_001, Function | MediumTest | Level2)
1684 {
1685 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1686 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1687 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1688 int32_t portIndex = 0;
1689 EuiccInfo2 EuiccInfo2;
1690 esimFile->currentChannelId_ = 0;
1691 EXPECT_EQ(EuiccInfo2.svn_, (esimFile->ObtainEuiccInfo2(portIndex)).svn_);
1692 int32_t slotId = 0;
1693 esimFile->currentChannelId_ = 2;
1694 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1695 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1696 EXPECT_EQ(EuiccInfo2.svn_, (esimFile->ObtainEuiccInfo2(portIndex)).svn_);
1697 }
1698
1699 HWTEST_F(EsimTest, ProcessObtainEUICCInfo2_001, Function | MediumTest | Level2)
1700 {
1701 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1702 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1703 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1704 int32_t slotId = 0;
1705 AppExecFwk::InnerEvent::Pointer eventEUICCInfo2 = esimFile->BuildCallerInfo(MSG_ESIM_OBTAIN_EUICC_INFO2_DONE);
1706 esimFile->currentChannelId_ = 0;
1707 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo2(slotId, eventEUICCInfo2), false);
1708 esimFile->currentChannelId_ = 2;
1709 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo2(slotId, eventEUICCInfo2), true);
1710 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1711 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1712 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo2(slotId, eventEUICCInfo2), true);
1713 }
1714
1715 HWTEST_F(EsimTest, EuiccInfo2ParseProfileVersion_001, Function | MediumTest | Level2)
1716 {
1717 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1718 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1719 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1720 EuiccInfo2 euiccInfo2;
1721 std::string resultData =
1722 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1723 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1724 uint32_t byteLen = responseByte.size();
1725 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1726 esimFile->EuiccInfo2ParseProfileVersion(euiccInfo2, root);
1727 bool bRet = euiccInfo2.profileVersion_.empty() ? false : true;
1728 EXPECT_TRUE(!bRet);
1729 }
1730
1731 HWTEST_F(EsimTest, EuiccInfo2ParseEuiccFirmwareVer_001, Function | MediumTest | Level2)
1732 {
1733 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1734 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1735 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1736 EuiccInfo2 euiccInfo2;
1737 std::string resultData =
1738 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1739 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1740 uint32_t byteLen = responseByte.size();
1741 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1742 esimFile->EuiccInfo2ParseEuiccFirmwareVer(euiccInfo2, root);
1743 bool bRet = euiccInfo2.globalPlatformVersion_.empty() ? false : true;
1744 EXPECT_TRUE(!bRet);
1745 }
1746
1747 HWTEST_F(EsimTest, EuiccInfo2ParseExtCardResource_001, Function | MediumTest | Level2)
1748 {
1749 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1750 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1751 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1752 EuiccInfo2 euiccInfo2;
1753 std::string resultData =
1754 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1755 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1756 uint32_t byteLen = responseByte.size();
1757 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1758 esimFile->EuiccInfo2ParseExtCardResource(euiccInfo2, root);
1759 bool bRet = euiccInfo2.extCardResource_.empty() ? false : true;
1760 EXPECT_TRUE(!bRet);
1761 }
1762
1763 HWTEST_F(EsimTest, EuiccInfo2ParseUiccCapability_001, Function | MediumTest | Level2)
1764 {
1765 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1766 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1767 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1768 EuiccInfo2 euiccInfo2;
1769 std::string resultData =
1770 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1771 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1772 uint32_t byteLen = responseByte.size();
1773 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1774 esimFile->EuiccInfo2ParseUiccCapability(euiccInfo2, root);
1775 bool bRet = euiccInfo2.uiccCapability_.empty() ? false : true;
1776 EXPECT_TRUE(!bRet);
1777 }
1778
1779 HWTEST_F(EsimTest, EuiccInfo2ParseTs102241Version_001, Function | MediumTest | Level2)
1780 {
1781 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1782 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1783 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1784 EuiccInfo2 euiccInfo2;
1785 std::string resultData =
1786 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1787 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1788 uint32_t byteLen = responseByte.size();
1789 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1790 esimFile->EuiccInfo2ParseTs102241Version(euiccInfo2, root);
1791 bool bRet = euiccInfo2.ts102241Version_.empty() ? false : true;
1792 EXPECT_TRUE(!bRet);
1793 }
1794
1795 HWTEST_F(EsimTest, EuiccInfo2ParseGlobalPlatformVersion_001, Function | MediumTest | Level2)
1796 {
1797 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1798 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1799 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1800 EuiccInfo2 euiccInfo2;
1801 std::string resultData =
1802 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1803 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1804 uint32_t byteLen = responseByte.size();
1805 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1806 esimFile->EuiccInfo2ParseGlobalPlatformVersion(euiccInfo2, root);
1807 bool bRet = euiccInfo2.globalPlatformVersion_.empty() ? false : true;
1808 EXPECT_TRUE(!bRet);
1809 }
1810
1811 HWTEST_F(EsimTest, EuiccInfo2ParseRspCapability_001, Function | MediumTest | Level2)
1812 {
1813 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1814 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1815 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1816 EuiccInfo2 euiccInfo2;
1817 std::string resultData =
1818 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1819 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1820 uint32_t byteLen = responseByte.size();
1821 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1822 esimFile->EuiccInfo2ParseRspCapability(euiccInfo2, root);
1823 bool bRet = euiccInfo2.rspCapability_.empty() ? false : true;
1824 EXPECT_TRUE(!bRet);
1825 }
1826
1827 HWTEST_F(EsimTest, EuiccInfo2ParseEuiccCiPKIdListForVerification_001, Function | MediumTest | Level2)
1828 {
1829 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1830 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1831 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1832 EuiccInfo2 euiccInfo2;
1833 std::string resultData =
1834 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1835 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1836 uint32_t byteLen = responseByte.size();
1837 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1838 esimFile->EuiccInfo2ParseEuiccCiPKIdListForVerification(euiccInfo2, root);
1839 bool bRet = euiccInfo2.euiccCiPKIdListForVerification_.empty() ? false : true;
1840 EXPECT_TRUE(!bRet);
1841 }
1842
1843 HWTEST_F(EsimTest, EuiccInfo2ParseEuiccCiPKIdListForSigning_001, Function | MediumTest | Level2)
1844 {
1845 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1846 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1847 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1848 EuiccInfo2 euiccInfo2;
1849 std::string resultData =
1850 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1851 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1852 uint32_t byteLen = responseByte.size();
1853 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1854 esimFile->EuiccInfo2ParseEuiccCiPKIdListForSigning(euiccInfo2, root);
1855 bool bRet = euiccInfo2.euiccCiPKIdListForSigning_.empty() ? false : true;
1856 EXPECT_TRUE(!bRet);
1857 }
1858
1859 HWTEST_F(EsimTest, EuiccInfo2ParseEuiccCategory_001, Function | MediumTest | Level2)
1860 {
1861 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1862 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1863 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1864 EuiccInfo2 euiccInfo2;
1865 std::string resultData =
1866 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1867 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1868 uint32_t byteLen = responseByte.size();
1869 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1870 esimFile->EuiccInfo2ParseEuiccCategory(euiccInfo2, root);
1871 bool bRet = euiccInfo2.euiccCategory_ == 0 ? false : true;
1872 EXPECT_TRUE(!bRet);
1873 }
1874
1875 HWTEST_F(EsimTest, EuiccInfo2ParsePpVersion_001, Function | MediumTest | Level2)
1876 {
1877 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1878 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1879 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1880 EuiccInfo2 euiccInfo2;
1881 std::string resultData =
1882 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1883 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1884 uint32_t byteLen = responseByte.size();
1885 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1886 esimFile->EuiccInfo2ParsePpVersion(euiccInfo2, root);
1887 bool bRet = euiccInfo2.ppVersion_.empty() ? false : true;
1888 EXPECT_TRUE(!bRet);
1889 }
1890
1891 HWTEST_F(EsimTest, AuthenticateServer_001, Function | MediumTest | Level2)
1892 {
1893 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1894 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1895 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1896 AuthenticateConfigInfo authenticateConfigInfo;
1897 esimFile->currentChannelId_ = 0;
1898 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_OPEN_FAILED),
1899 (esimFile->AuthenticateServer(authenticateConfigInfo)).resultCode_);
1900 int32_t slotId = 0;
1901 esimFile->currentChannelId_ = 2;
1902 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1903 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1904 EXPECT_EQ(static_cast<int32_t>(ResultInnerCode::RESULT_EUICC_CARD_CHANNEL_IN_USE),
1905 (esimFile->AuthenticateServer(authenticateConfigInfo)).resultCode_);
1906 }
1907
1908 HWTEST_F(EsimTest, GetContractInfo_001, Function | MediumTest | Level2)
1909 {
1910 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1911 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1912 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1913
1914 GetContractInfoRequest getContractInfoRequest;
1915 getContractInfoRequest.euiccCiPkidToBeUsed = u"16B5D16048E3EA02BD4B606E5F77A4BF20808D83";
1916 getContractInfoRequest.mapMetaData.nonce = u"A9ACE9E6EC018F45C834FB7AC2E22B0E";
1917 getContractInfoRequest.mapMetaData.imei = u"123456787654321";
1918 getContractInfoRequest.mapMetaData.imei2 = u"723456787654327";
1919 getContractInfoRequest.mapMetaData.timestamp = u"2025-07-09T09:47:18+08:00";
1920 getContractInfoRequest.ePkPosHpke =
1921 u"04193c786771e820ab133de09c1ee6c8215fadab2bd2541c436d6b042c03c70a9a0fd9bcd50781da090a2c68fc1aaa7b1ed184d36927"
1922 "0f1fdc1da3261c38af1496";
1923 std::string resultStr = "";
1924 esimFile->currentChannelId_ = 0;
1925 EXPECT_EQ(resultStr, esimFile->GetContractInfo(getContractInfoRequest));
1926 int32_t slotId = 0;
1927 esimFile->currentChannelId_ = 2;
1928 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1929 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1930 EXPECT_EQ(resultStr, esimFile->GetContractInfo(getContractInfoRequest));
1931 }
1932
1933 HWTEST_F(EsimTest, ProcessGetContractInfo_001, Function | MediumTest | Level2)
1934 {
1935 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1936 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1937 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(telRilManager);
1938 AppExecFwk::InnerEvent::Pointer eventGetContractInfo = esimFile->BuildCallerInfo(MSG_ESIM_CANCEL_SESSION);
1939 int32_t slotId = 0;
1940 esimFile->currentChannelId_ = 0;
1941 EXPECT_FALSE(esimFile->ProcessGetContractInfo(eventGetContractInfo));
1942 esimFile->currentChannelId_ = 2;
1943 EXPECT_TRUE(esimFile->ProcessGetContractInfo(eventGetContractInfo));
1944 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1945 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1946 EXPECT_TRUE(esimFile->ProcessGetContractInfo(eventGetContractInfo));
1947 }
1948 } // namespace Telephony
1949 } // namespace OHOS