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 "gtest/gtest.h"
32
33 namespace OHOS {
34 namespace Telephony {
35 using namespace testing::ext;
36 class EsimTest : public testing::Test {
37 public:
38 static void SetUpTestCase();
39 static void TearDownTestCase();
40 void SetUp();
41 void TearDown();
42 };
43
TearDownTestCase()44 void EsimTest::TearDownTestCase() {}
45
SetUp()46 void EsimTest::SetUp() {}
47
TearDown()48 void EsimTest::TearDown() {}
49
SetUpTestCase()50 void EsimTest::SetUpTestCase() {}
51
52 static const std::string bppCombineHexStr = "BF3781ADBF27678008D14FE1DE62C340D7BF2F3480024C66810207800C1E31302E313"
53 "02E31322E3136342F64702D706C75732D696E746572666163655A0A98680010203040506080060388370AA21FA01D4F10A000000559101"
54 "0FFFFFFFF890000120004093007A00530038001005F3740B354AE39D08ACD7EDD7D2D01C73378621F623B832DFA3243489C5B42C90F220"
55 "14E6C928130D78EE561982EF412AC3D94C04B56F37657DA84FD7BB24DD5634E89";
56
57 static const std::string boundProfilePackage = "vzaCFPW/I4GjggEBgAiX"
58 "eXu/pVhILaYNgAGIgQEQhAURIjNEVV9JQQR+7Z54dnOSpmXRSRnS/dgZEoPkCNaLCyTpgJ8wSrEsBUj2+BzS0YB0bucZUYQRGEcd5cbYvJGiV8"
59 "e5SKNcRHwlXzdAsXrBYvUtRoF94nq56/+wm60AXC0w5/1rUwpZqEhgu+G5Yof1Bb1e/uKWQNicUmNMDJNKi/7keRhJBItkYTjBnaAahxjfW3PZ"
60 "gTC0L4zP/odnrg0orSDX3nb1etmhVIhSvyVHWgqYaAAQIDBAUGCAkQVzbWFydJIAlQECtiYwJIACBPCBHjEwLjEwLjEyLjE2NC9kcC1wbHVzLW"
61 "ludGVyZmFjZbcFgANk8AdYBUS7Ycw9VqJKh0ibFgbfrAUr8C1h1o6Ma4CHo3wKtDM/GsDqnR3jIh2F1pjgtt8n056NDtwJvLogxbqOCLl6ebpb"
62 "H5GIP9r5SnNpvexqohtDtcyjghOMhoID+NsF50pgD/CZKe3pTpzqDmIW0U0mr+97YAC1aTrSBraPI/a2M1400vGM8ZRrQq1QGrP1Exk474Ngis"
63 "yrznc8aHW1TVfVz2JHh1yQiXcNX5wIVsIeUBKIRai31fGgYrdeQrn4ZJGNkaWQtil+TtVaxBbBwBr/Uskxsyh+Qw/a0HumkP4zUf6mjSz0LXlu"
64 "rHio50PhvIbP/JEdjDbyMxXDhok3Lw1V4eOq1HSAYE3F+6mLIC/rLG/um43yROoPtlz6yOJ9aUXea4f3+ZaAHR6jQ70sobb+VSy3dbnO3fP+rx"
65 "ZzZMK29Res9ehcmnKG/JRicjIbagsx9ch39m/qdFqqHDBPscOmnI9MeE40Pnt9FiifyAJUD+54DRrB77uXhhN0k31Kou8KMzpfcqKF/NwyjpeA"
66 "pDi394+g3N2Zep/F/+DgkaiV8CDHFrIUwv3ofqBr9qABXc5IZRxVSqPi+cQptYK6Oyg1WT2JY+hTrMNoLZyn7LY/N79lSUrWT6ltHp5yWyKTCl"
67 "hNzcYEOT/xwxdg1qiCuwqHkR558Gn1yMHsqUdGB2tDgf7J6DbvVewnjv2RyVILRFNsJrijvLtdruWSzIIxbuhYTd6fmbdC4YpY9JZ2e/ZlrYay"
68 "YCshjDOCH42870HQfqYjVdrkJAStmnbANeGtibAWfv6ICFLiToum3K38vsZfupHZ9+qOBeKxETsejugkv9UFHYmN3c5tqnLDtm4ex23Uh30b4Y"
69 "RkypKCg68r5MIaP6FQkL/L3Ew1VeFlQ+H+tNyLipdIx6FOLgqfugZPF3w9MxdbGWhZwmHqH3AGcHS6vG2GdAVv53dxI+Wl/Gb21I39cT0gLjQ2"
70 "lM9ux2gPfazxvqcEE0GOjUN3Y9ATGmiXK+/ObwvP8OjUUCXLq0Tqostgukp/rLSe+9uIsipqa8gB0zA4f0hD5JqkojE7xVO6FmFOO+/kGzlpSa"
71 "X5NVBJm47p/haAGWJX7aTNkNJQEs51qtwTCKDFSAXNQdB7IJ2+ndj8X34mI+DIDiupT/9lj1eefj9O0yIQeYaUmjjor6F4TDcYZi7pknW43arz"
72 "zI+lsbvfkQXhsvyoNXsIDHxWV1zttBwTQ3GeEyYW7aINgyglbfdHliU+v/X5tnIxgH7oGZaVVfrKZW+0GUIBA512YxV3jUMzZmEa9Qv8infThE"
73 "j9pLGhAWJtqFjzk1ppCO1EAjDkCqQlpXQsrOqXCNQiK70m6I8BayQiogn7zlPMB3mA43e+PZpWPrKZNl15eNf/INJ0p/Lzdv5xKB0HMMmkS10k"
74 "7Lqzv0zb3x48ve70hM1lgq+3cv2wEL4DWA6vjhb5Qn39beWl7FbPHGaQJnvwdKnDX3uihoID+BEsRW2hoBVl8MaduL4qJfqn9/WfHkQny7JAsb"
75 "Ya/JSwMB2g+LHkcuZq0goj3/5BfHyEJw/fmbcXDm2OYqf1erpITtSAaCCK6a/7zVAXiYZWUPeN/9uOhL4pPWF0Y0niw3NIqS4seRmiwwBgU3mB"
76 "hpi3RRyPmjE3sO0KEXiKiwzGTCTNbItl7omm37vvEwny/C9088+euiTHJr5+5l71Iol+tq/d5mdpEgln4kq/AkDyjExBJD7yLyOQzu/WVi4gdx"
77 "f2uI4uwcWajC9Pih657rp5rVVrHX9jqgTbi8OcufOoISHh2LyDcedRYsxF6Ucv0fsvQvhGnjAIIwv4yrKfdCuAE9SLm/d3YlOaTOQy+NhTFocS"
78 "C5NaIsvIvMDcRhWrrkSPiymkXGLABnzPvZTe46zSo4XopjPktfYdrRFqRPQ3Og36UlBGeCnQ/tEdpHjwwSx+ykT3oZcCvMedukhAAt1NCYNSlN"
79 "B6Pyk9JVfOsEBAM42S4aCZkVsK5rFVyGdOOMo2AUuujrXzJUc64LEfGHHrjOSkwHryobnJKaPRfJ1e+X4yJyjXDCZWAuF930lEDLjoySCvR+4r"
80 "xSp7b8gO0dnxWif1RMnSeVvNrn68LZC/jVEFtdxGD9lR5Ie0GiOtBvz7o6TYrOztUn4YFE+vEQgW2trGmBAoJ24401/RqbvuRYVkc3RDxYzOa7"
81 "vidHR1r+38ITdgkwRusw8J0ytx0M4H+R+2KG3d7c6Zkylau9qb6bOxAo1Cm+gay2ZclEL2aHbGlVBeabuITZ7f1mu7y6BXK04rmo+8Ml6yr/2b"
82 "sdF2KKWsSHUfc2tGT9ZqiNdy/QWBUwCiy4dOcuX7hUdTOGYLAQqzlctmVaJrKC0DQQBmSHaPnX3/vWQXBjaGbhvYmqb0IQSguxTS6dNl9T+99E"
83 "LYNPzwYTr/AuyXDkaUq1vcsaatmMuB35hXDB5cqaWHY1tG+8j0NC8hokw3ANhv5AnQBO2DvcRi61vcjER/OvlVEkMhmbF53jzO1ePLh8bJQEZD"
84 "k6B+i7k+KehnX2tg21yEcUjkaWZO55xZiiUHM/1CjmTEvk0x+S7RWrP2gwTJdZI7sHgN1TNcfBdq5YmVTFq6Sdtmfa9uzLownyYo2ohosa/FJQ"
85 "aIUpYmpRUElVNXhafPDHb1FJDjBzivulqyKK0LrYEUEWsb1TltBHDkBQD9AKjBBGsxDqrax1rqXu1QV1ZRugD05ppgsShAvz0/a3ubc7VX53Lp"
86 "GIK0qzOIM8zLTYIekc47r1yk+MbxyNA4aZipcFgsB8Oq6a+6bDNcZnm1JTpa5N0COJq5IcTo1hZuOgGtQi5jGJ8nEuNJesaTPaIkH05xpTx4ho"
87 "ID+DEdZylkGaIAbxdAWDpXKh4Jf0qIGKOYqcZ5gtV1Q0xf+EVhw7XgIBsbRkWt1miiIGyzFu9nDEBPJ6fjeyyV9PJDfTnTKUyLMk6O3ug+SdeQ"
88 "cyq5FnoIb5uc0+dYI7FXW8LWo+ubVnZottNCQvmkWgmKNGpZV4+POeMsUfD2OaXWluWeHfB9zlbiRq3W5/BsG8JWWjM6dkoL7D4lpq4zY9ggiv"
89 "N8Mu7DhFaBjJRwBJ8sD1RleC5J0KulgBoDhzMJtmOsLDtDiv6JhgIYcwbkeZsLeSEg3AdEOIMKiWyzlcigaEuOF4ArzHZ2/E4rsJCHUEZjGCWu"
90 "1Yf8O5NLc1bKd30hlLioSr87R8Bpz/MHnZc1YlrDBsYg06Xf5p4/cxDCqyNtP1RbNFXAZff1gRHXTHG9gC66MgBZmpgnexFEOOd4PTNvagd4Z8"
91 "51+VJOsmv955o5vrzyzuFQMTJiS9umgeAyCOY6tLiVR1EZQX6JTOSEKXNOVRXQuNNgMTsXJhAh5NEx4HrTkwxhiwK9hMA4XeAHuIYo02R4ORNf"
92 "0BionT5bBTIJNFwc+Y6IU9s5Ixt9ypvNnxvclk0i5KqSTa1hwBHW3Golec3DyMxLpbo0piTcIImqGz2RQzcFTYxkmdB5I/PzYk0L+dJmz/XPQD"
93 "bYU4M9CspqlgmDRQwf98PI+w/JvMTzoGI9W7hG0J89SXYfpE9Uj55oYXGIv/lnvJL8kfOBj04Ogj+XD9CBhOGhi8zIIbPn57hk6RKr7OZdsHgf"
94 "nrOTPJsKX3+TGKoQyisqHeDPh5pfY7ruIKWjAenz8h/uwEqtOfjAR+FFtdLkd6qEP30puBi925o1b2or3IGh9otP3V45CugQJhJkBQbU3yAirK"
95 "fob/6nnJRBeWrJKJISrHzwC1jtZvYXnqUY4Cb2Qprx8MursAwIOJg9kEiNypyOuFlqbzrdGffwVwPA5MUcf9/+bRTUVAek7R0I8joFCqFOAPAh"
96 "Q+ZrLdpaIVc+LFSoosBS1vy8L9kr6A7uY2Ux3WUebcRKSqHhZhdKMUBRLWDjEqlcniYSfP50Z4SkW2dbBmQC83LWMc7Ihz6OVJImaaA5afdlMy"
97 "Wv+ImVn5FBdiG96IQS8y3CdjFqE2e6OXHRonyvZLtMVgBpisvwoWbaZTwHdC9o74+Cf9XGJ0W4/ZGJe8ySHlzeEhQJJEbOufQmSh64mgls+IuH"
98 "WF7QVwEtd3hJ8ZJ5N5JFkd+HUvN2t4Vy88YjmthtnBwoyNgDfNOlT+uxOJ8BBUMKZ6/AOEBxLxkbaJdpngR/x6X1i+GNCBtOUtSDXSnwEnlbbw"
99 "4HTQxF1ZJ1AdpwDql3vHAjM8P5SG8Q1TMOFgcKhoID+LMQzo9+MdjzA7Tbv4k6/3CnHNjvXA+ZIoYzXbdrCSvlLo/s28k9DJ+onbgDVsSL//PL"
100 "0qxc3Qg9Ez62i6tgTyj577AAM7dn+Z4MNd8guw78CIq6c80ewCEg7cKhmBmZFK4tDxx4vNOF3jGjVECOcs48mplTvgF1937/MlAUnhbS7oN1Zf"
101 "of8c1i17gv69Ugj1N4aT9FXlbtCRsclh5Tzfcp81+Epi7vSsyyGWGkD9TD9K4OuEykGOqdPl1xLKXDLmkBctPrkd16W4cDQbSKqsItXarJueZN"
102 "eE5Vo2ZXCamuuX8t2teTd9iNCfQI4b1OYC5PNIGwbgSmYcxRxWkoGiTecGLLZoz+Un6LdggOuUp0iQ6fvSr3idBYILcrpA1eBwTzDiKQgp4H3Y"
103 "TBvFrV9lSLdqtANCGNYwvTWBxkwk55hV3HrGyyTZTctyTrWS5uaPcEe/T72/vtYF9QcUaDEG4VcRMlPJw6s2NYHI9SqHT+SDfjJxq1AQs9M3H1"
104 "8a12B4ov3BKQfCjlnR7Y9JGsyw83pEINABo55k8zaCPlRVo+BwcmNvaOhJVwOcKmAoBTEvMXw02DkBwDKd1ZdPPokVAyE8w+B1QFq4pV92/2kV"
105 "W6GayQIt0kPbWMs046vxga6Vafv6vbkPpuXCnz55nMGRIdDZF6qf9bNhoq+X8byjyKE4bq3s+3901oaWUCwzvMFoA1Zyapl/GV8ZYzgEFjoXfM"
106 "Ckq6es6yfijUMe2aiJUxQplw6+b4eDNm/C0K8ROSkl1UmYTRo17uiM/JL808N/K7pUAyiBQGZZxsxGv1I1yCSurDuDrnNstw3aVJjAFj3QLn6+"
107 "Sj/0nb+Ln10+iNA5S4a0r0XJx0Fvurquj+OKcrLt2d4vMKlSWW8+m0wJE9stZmNt61144EKPMzljPIgfyoq2u8OMMGuXn9ufeHgXB6H/Lzdh4X"
108 "iJITNNjffkk+aQOMFL7kEwAXYhrg82TRR6VKEvR/nWZKFbeRQlGrGNDgn0XWT3PbnnRwpUzIdtW0TDjNA3fEcGPG6kBOjagtHYow46oIr1stau"
109 "L3388hzhrf1BEOuT2uhxjstjrJWLTp40kfMjeopD5lCoCwZnAhDv53mr8b1TnVV+wZ6SpS7+TfEEJemSGv5kVZc/1xx4lrq4N28DYsKSJN30kQ"
110 "vBZvXhqGVvTVHw+coshBrRt2iBMkE5uFInIfduMphYJ4/u2V3FiGzE1GZ8yiCnSYQbrsBb1hqHgeZkKDIzOUTdJFIKDtplh9z1PtIfghv/+Yv1"
111 "DovpleCjn6XYZkw6xIhwyRk4Mni4CArlOsOX0szh9V/EJkWwmlI0IvsR06mW2xp6zkhIo1IfuXuhw7hoIDmHvO33Z4Fh/L7eNQh/Rhm3aeefZ4"
112 "GJr7G92cRwf+SJ/o8hw/x0IWvC/LHJ1Pui47f5zqlJtkKL9JqRdOvgSDGvrRibnWyGS1LVYys76DWCNDK3EVHIMrsXm4RiNJsOdmojfmD8t5br"
113 "WBsxIVC8HUMxi80yknMsiId97kG5qIr3Ws6AK0pHGXbnjtBSIXmgfWW2+f0+At1AMC0WCkLDnmXsnVqIMwKH787ponG7FYDfoE/suUGB19RrL8"
114 "u9mD1baKfkh978NbA1DmSoH6PQsZUe6t8l/e8iNYpvjBWVU/N9Ivz4rLAVtmGgT3Ay1CDuKslDyOqbVkHta+oD3KjmikR3PAwUMuRe0uMI48PP"
115 "JK8Lx5enYwFTHHH/lnRh2yq69Ag1v37LbshyDwhaxmQ7JSQWYplVNcNyfUwQTNbcRxCrBYBcOCCxIcueGGwDEDZjiOEarCCXVNTVEQn6LWf7UE"
116 "OzKLrjL+bY0zLhsrjZk8ij3oOJdhPnhAfncnqNy7LUp3N5/XSUjmWfh9TK8C9nnbNFrY2TlUkpMqeCcna6irHsQX1oHFzF6wMTHINoMZJOk4bm"
117 "rmIk7QZzRULZhgV8u3H47aMeESViEJvqQ1X0LlOM2d7xTMfTF2D+oIkusheJ6WCxxMxBmF7i4pBAJsvWtG/2mDqT3xHFrVqMP+ybOmFwPLcfEu"
118 "x2StoNL5+TzcLtDaNx825aAZ/QwQRfL96hQbCtKmiM17Dwiwl/PajJv5YKdR5iBNg155vmASRoXvP+j45e/IGgV2JzXeMEXCrwgCRU0FdU/rjl"
119 "JTWlhZNe4gLGrVmrbxPG/2lXdtb3JnH9iAfzPxbsJLDiDiVzb6JM2U8I0cplmFX5IxYFcVUUCg4ZNQuXXZdMklwSHN+QQdBqh2F6Z+ot1KJmGL"
120 "4zkrn60C0IqQ/Io55/nDNLyJIc8ogkvAVIy1O8GFZVvUcahyFmWxkSRVsj/6j1n+RmMpbbJsvfsCa93+09gNszKKYaIR30r51SzrPEckjcRdc/"
121 "aZNW6UFYPg/BK6SuCJTMxL9OkDmh7II/n7vOnOum3xMwLGO5Ls/JXje5stKLdBBrdGf1AZx2OFo04O96AuXtM+wwUgPIHmLsg8ftOz/oBPhfgc"
122 "F6N9SucIgpUkjlxdM61S5KyvxEVgFKyb1tWfc8QaMq5hSwjtD/Rdg1KHei5aWNxLFovBcwk3JDLH5I3TZrlBGcJYxE16AkvXz4G3";
123
124 HWTEST_F(EsimTest, SyncOpenChannel_001, Function | MediumTest | Level2)
125 {
126 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
127 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
128 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
129 esimFile->currentChannelId_ = 2;
130 esimFile->ObtainChannelSuccessExclusive();
131 EXPECT_TRUE(esimFile->IsLogicChannelOpen());
132 }
133
134 HWTEST_F(EsimTest, SyncOpenChannel_002, Function | MediumTest | Level2)
135 {
136 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
137 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
138 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
139 std::u16string aid = Str8ToStr16("123");
140 esimFile->currentChannelId_ = 2;
141 esimFile->ObtainChannelSuccessAlllowSameAidReuse(aid);
142 EXPECT_TRUE(esimFile->IsLogicChannelOpen());
143 }
144
145 HWTEST_F(EsimTest, SyncCloseChannel_001, Function | MediumTest | Level2)
146 {
147 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
148 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
149 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
150 esimFile->currentChannelId_ = 0;
151 esimFile->SyncCloseChannel();
152 EXPECT_FALSE(esimFile->IsLogicChannelOpen());
153 }
154
155 HWTEST_F(EsimTest, SyncCloseChannel_002, Function | MediumTest | Level2)
156 {
157 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
158 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
159 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
160 esimFile->currentChannelId_ = 0;
161 esimFile->SyncCloseChannel();
162 EXPECT_TRUE(esimFile->IsLogicChannelOpen());
163 }
164
165 HWTEST_F(EsimTest, ObtainEid_001, Function | MediumTest | Level2)
166 {
167 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
168 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
169 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
170 esimFile->currentChannelId_ = 0;
171 EXPECT_EQ("", esimFile->ObtainEid());
172 int32_t slotId = 0;
173 esimFile->currentChannelId_ = 2;
174 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
175 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
176 esimFile->SetRilAndFileController(telRilManager, file, handler);
177 EXPECT_EQ("", esimFile->ObtainEid());
178 }
179
180 HWTEST_F(EsimTest, ProcessObtainEid_001, Function | MediumTest | Level2)
181 {
182 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
183 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
184 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
185 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
186 AppExecFwk::InnerEvent::Pointer eventGetEid = iccFile->BuildCallerInfo(MSG_ESIM_OBTAIN_EID_DONE);
187 int32_t slotId = 0;
188 esimFile->currentChannelId_ = 0;
189 EXPECT_EQ(esimFile->ProcessObtainEid(slotId, eventGetEid), false);
190 esimFile->currentChannelId_ = 2;
191 EXPECT_EQ(esimFile->ProcessObtainEid(slotId, eventGetEid), false);
192 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
193 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
194 esimFile->SetRilAndFileController(telRilManager, file, handler);
195 EXPECT_EQ(esimFile->ProcessObtainEid(slotId, eventGetEid), true);
196 }
197
198 HWTEST_F(EsimTest, ProcessObtainEidDone_001, 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>(simStateManager);
203 std::shared_ptr<IccControllerHolder> holder = nullptr;
204 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
205 rcvMsg->fileData.resultData = "BF3E125A1089086030202200000024000070951319";
206 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
207 EXPECT_TRUE(esimFile->ProcessObtainEidDone(event));
208 auto eventGetEid = AppExecFwk::InnerEvent::Get(0);
209 EXPECT_EQ(esimFile->ProcessObtainEidDone(eventGetEid), false);
210 eventGetEid = nullptr;
211 EXPECT_EQ(esimFile->ProcessObtainEidDone(eventGetEid), false);
212 }
213
214 HWTEST_F(EsimTest, GetEuiccProfileInfoList_001, Function | MediumTest | Level2)
215 {
216 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
217 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
218 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
219 esimFile->currentChannelId_ = 0;
220 GetEuiccProfileInfoListResult euiccProfileInfoList_;
221 EXPECT_EQ(static_cast<int32_t>(euiccProfileInfoList_.result_), esimFile->GetEuiccProfileInfoList().result_);
222 int32_t slotId = 0;
223 esimFile->currentChannelId_ = 2;
224 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
225 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
226 esimFile->SetRilAndFileController(telRilManager, file, handler);
227 EXPECT_EQ(static_cast<int32_t>(euiccProfileInfoList_.result_), esimFile->GetEuiccProfileInfoList().result_);
228 }
229
230 HWTEST_F(EsimTest, ProcessRequestAllProfiles_001, Function | MediumTest | Level2)
231 {
232 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
233 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
234 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
235 int slotId = 0;
236 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
237 AppExecFwk::InnerEvent::Pointer eventRequestAllProfiles = iccFile->BuildCallerInfo(MSG_ESIM_REQUEST_ALL_PROFILES);
238 esimFile->currentChannelId_ = 0;
239 EXPECT_FALSE(esimFile->ProcessRequestAllProfiles(slotId, eventRequestAllProfiles));
240 esimFile->currentChannelId_ = 2;
241 EXPECT_FALSE(esimFile->ProcessRequestAllProfiles(slotId, eventRequestAllProfiles));
242 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
243 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
244 esimFile->SetRilAndFileController(telRilManager, file, handler);
245 EXPECT_TRUE(esimFile->ProcessRequestAllProfiles(slotId, eventRequestAllProfiles));
246 }
247
248 HWTEST_F(EsimTest, ProcessRequestAllProfilesDone_001, Function | MediumTest | Level2)
249 {
250 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
251 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
252 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
253 std::shared_ptr<IccControllerHolder> holder = nullptr;
254 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
255 rcvMsg->fileData.resultData = "BF2D25A023E3215A0A986800102030405060809F7001019105736D617274950102B705800364F007";
256 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
257 EXPECT_TRUE(esimFile->ProcessRequestAllProfilesDone(event));
258 auto eventRequestAllProfiles = AppExecFwk::InnerEvent::Get(0);
259 EXPECT_EQ(esimFile->ProcessRequestAllProfilesDone(eventRequestAllProfiles), false);
260 eventRequestAllProfiles = nullptr;
261 EXPECT_EQ(esimFile->ProcessRequestAllProfilesDone(eventRequestAllProfiles), false);
262 }
263
264 HWTEST_F(EsimTest, GetEuiccInfo_001, Function | MediumTest | Level2)
265 {
266 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
267 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
268 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
269 EuiccInfo eUiccInfo_;
270 esimFile->currentChannelId_ = 0;
271 EXPECT_EQ(eUiccInfo_.osVersion_, esimFile->GetEuiccInfo().osVersion_);
272 int32_t slotId = 0;
273 esimFile->currentChannelId_ = 2;
274 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
275 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
276 esimFile->SetRilAndFileController(telRilManager, file, handler);
277 EXPECT_EQ(eUiccInfo_.osVersion_, esimFile->GetEuiccInfo().osVersion_);
278 }
279
280 HWTEST_F(EsimTest, CommBuildOneApduReqInfo_001, Function | MediumTest | Level2)
281 {
282 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
283 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
284 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
285 ApduSimIORequestInfo reqInfo;
286 std::shared_ptr<Asn1Builder> builder = std::make_shared<Asn1Builder>(TAG_ESIM_GET_RAT);
287 esimFile->CommBuildOneApduReqInfo(reqInfo, builder);
288 EXPECT_NE(esimFile->nextSerialId_, -1);
289 }
290
291 HWTEST_F(EsimTest, ProcessObtainEuiccInfo1_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>(simStateManager);
296 int slotId = 0;
297 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
298 AppExecFwk::InnerEvent::Pointer eventEUICCInfo1 = iccFile->BuildCallerInfo(MSG_ESIM_OBTAIN_EUICC_INFO_1_DONE);
299 esimFile->currentChannelId_ = 0;
300 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1(slotId, eventEUICCInfo1), false);
301 esimFile->currentChannelId_ = 2;
302 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1(slotId, eventEUICCInfo1), false);
303 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
304 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
305 esimFile->SetRilAndFileController(telRilManager, file, handler);
306 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1(slotId, eventEUICCInfo1), true);
307 }
308
309 HWTEST_F(EsimTest, ProcessObtainEuiccInfo1Done_001, Function | MediumTest | Level2)
310 {
311 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
312 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
313 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
314 std::shared_ptr<IccControllerHolder> holder = nullptr;
315 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
316 rcvMsg->fileData.resultData = "BF20618203020202A92C0414F54172BDF98A95D65CBEB88A38A1C11D800A85C30414C0BC70BA369"
317 "29D43B467FF57570530E57AB8FCD8AA2C0414F54172BDF98A95D65CBEB88A38A1C11D800A85C30414C0BC70BA36929D43B467FF575"
318 "70530E57AB8FCD8";
319 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
320 EXPECT_TRUE(esimFile->ProcessObtainEuiccInfo1Done(event));
321 auto event1 = AppExecFwk::InnerEvent::Get(0);
322 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1Done(event), false);
323 event1 = nullptr;
324 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo1Done(event1), false);
325 }
326
327 HWTEST_F(EsimTest, ProcessEsimOpenChannel_001, Function | MediumTest | Level2)
328 {
329 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
330 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
331 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
332 std::u16string aid = Str8ToStr16("123");
333 int32_t slotId = 0;
334 esimFile->ProcessEsimOpenChannel(aid);
335 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
336 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
337 esimFile->SetRilAndFileController(telRilManager, file, handler);
338 esimFile->ProcessEsimOpenChannel(aid);
339 EXPECT_NE(telRilManager, nullptr);
340 }
341
342 HWTEST_F(EsimTest, ProcessEsimOpenChannelDone_001, Function | MediumTest | Level2)
343 {
344 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
345 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
346 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
347 auto event = AppExecFwk::InnerEvent::Get(0);
348 EXPECT_EQ(false, esimFile->ProcessEsimOpenChannelDone(event));
349 event = nullptr;
350 EXPECT_EQ(false, esimFile->ProcessEsimOpenChannelDone(event));
351 }
352
353 HWTEST_F(EsimTest, ProcessEsimCloseChannel_001, Function | MediumTest | Level2)
354 {
355 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
356 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
357 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
358 int32_t slotId = 0;
359 esimFile->ProcessEsimCloseChannel();
360 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
361 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
362 esimFile->SetRilAndFileController(telRilManager, file, handler);
363 esimFile->ProcessEsimCloseChannel();
364 EXPECT_NE(telRilManager, nullptr);
365 }
366
367 HWTEST_F(EsimTest, ProcessEsimCloseChannelDone_001, Function | MediumTest | Level2)
368 {
369 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
370 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
371 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
372 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
373 AppExecFwk::InnerEvent::Pointer event = iccFile->BuildCallerInfo(MSG_ESIM_CLOSE_CHANNEL_DONE);
374 EXPECT_EQ(true, esimFile->ProcessEsimCloseChannelDone(event));
375 }
376
377 HWTEST_F(EsimTest, ObtainEuiccInfo1ParseTagCtx2_001, Function | MediumTest | Level2)
378 {
379 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
380 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
381 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
382 int32_t tag = 0;
383 std::vector<uint8_t> src;
384 std::shared_ptr<Asn1Node> asn1Node = std::make_shared<Asn1Node>(tag, src, 0, 0);
385 asn1Node->constructed_ = false;
386 bool ret = esimFile->ObtainEuiccInfo1ParseTagCtx2(asn1Node);
387 EXPECT_EQ(ret, false);
388 }
389
390 HWTEST_F(EsimTest, RequestAllProfilesParseProfileInfo_001, Function | MediumTest | Level2)
391 {
392 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
393 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
394 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
395 std::string resultData =
396 "BF282BA029BF2F118001010C08736D64702E636F6081020410BF2F128001020C09736D6470322E636F60810204209000";
397 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
398 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, responseByte.size());
399 EXPECT_EQ(esimFile->RequestAllProfilesParseProfileInfo(root), true);
400 }
401
402 HWTEST_F(EsimTest, ProcessEvent_001, Function | MediumTest | Level2)
403 {
404 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
405 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
406 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
407 auto event = AppExecFwk::InnerEvent::Get(0);
408 esimFile->ProcessEvent(event);
409 event = nullptr;
410 esimFile->ProcessEvent(event);
411 event =esimFile->BuildCallerInfo(MSG_ESIM_REQUEST_ALL_PROFILES);
412 esimFile->ProcessEvent(event);
413 EXPECT_EQ(event, nullptr);
414 }
415
416 HWTEST_F(EsimTest, ObtainSpnCondition_001, Function | MediumTest | Level2)
417 {
418 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
419 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
420 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
421 bool roaming = false;
422 std::string str = "abc";
423 int res = esimFile->ObtainSpnCondition(roaming, str);
424 EXPECT_EQ(res, 0);
425 }
426
427 HWTEST_F(EsimTest, ProcessIccReady_001, Function | MediumTest | Level2)
428 {
429 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
430 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
431 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
432 auto event = AppExecFwk::InnerEvent::Get(0);
433 int res = esimFile->ProcessIccReady(event);
434 EXPECT_EQ(res, false);
435 }
436
437 HWTEST_F(EsimTest, UpdateVoiceMail_001, Function | MediumTest | Level2)
438 {
439 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
440 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
441 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
442 std::string mailName = "wang";
443 std::string mailNumber = "123456";
444 int res = esimFile->UpdateVoiceMail(mailName, mailNumber);
445 EXPECT_EQ(res, false);
446 }
447
448 HWTEST_F(EsimTest, SetVoiceMailCount_001, Function | MediumTest | Level2)
449 {
450 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
451 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
452 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
453 int32_t voiceMailCount = 0;
454 int res = esimFile->SetVoiceMailCount(voiceMailCount);
455 EXPECT_EQ(res, false);
456 }
457
458 HWTEST_F(EsimTest, SetVoiceCallForwarding_001, Function | MediumTest | Level2)
459 {
460 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
461 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
462 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
463 bool enable = false;
464 std::string number = "123";
465 int res = esimFile->SetVoiceCallForwarding(enable, number);
466 EXPECT_EQ(res, false);
467 }
468
469 HWTEST_F(EsimTest, GetVoiceMailNumber_001, Function | MediumTest | Level2)
470 {
471 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
472 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
473 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
474 std::string res = esimFile->GetVoiceMailNumber();
475 EXPECT_EQ(res, "");
476 }
477
478 HWTEST_F(EsimTest, InitMemberFunc_001, Function | MediumTest | Level2)
479 {
480 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
481 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
482 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
483 esimFile->InitMemberFunc();
484 bool ret = esimFile->memberFuncMap_.empty();
485 EXPECT_FALSE(ret);
486 }
487
488 HWTEST_F(EsimTest, DisableProfile_001, Function | MediumTest | Level2)
489 {
490 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
491 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
492 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
493 int32_t portIndex = 0;
494 std::u16string iccId = Str8ToStr16("5A0A89670000000000452301");
495 int32_t disableProfileResult = static_cast<int32_t>(ResultCode::RESULT_SGP_22_OTHER);
496 esimFile->currentChannelId_ = 0;
497 EXPECT_NE(disableProfileResult, esimFile->DisableProfile(portIndex, iccId));
498 int32_t slotId = 0;
499 esimFile->currentChannelId_ = 2;
500 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
501 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
502 esimFile->SetRilAndFileController(telRilManager, file, handler);
503 EXPECT_NE(disableProfileResult, esimFile->DisableProfile(portIndex, iccId));
504 esimFile->currentChannelId_ = 2;
505 EXPECT_NE(disableProfileResult, esimFile->DisableProfile(portIndex, iccId));
506 }
507
508 HWTEST_F(EsimTest, ProcessDisableProfile_001, Function | MediumTest | Level2)
509 {
510 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
511 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
512 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
513 int slotId = 0;
514 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
515 AppExecFwk::InnerEvent::Pointer eventGetProfile = iccFile->BuildCallerInfo(MSG_ESIM_DISABLE_PROFILE);
516 esimFile->currentChannelId_ = 0;
517 EXPECT_FALSE(esimFile->ProcessDisableProfile(slotId, eventGetProfile));
518 esimFile->currentChannelId_ = 2;
519 std::string iccIdStr = "ABCDEFG";
520 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdStr);
521 EXPECT_FALSE(esimFile->ProcessDisableProfile(slotId, eventGetProfile));
522 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
523 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
524 esimFile->SetRilAndFileController(telRilManager, file, handler);
525 EXPECT_TRUE(esimFile->ProcessDisableProfile(slotId, eventGetProfile));
526 std::string str = "ABCDEFGG";
527 esimFile->esimProfile_.iccId = Str8ToStr16(str);
528 EXPECT_TRUE(esimFile->ProcessDisableProfile(slotId, eventGetProfile));
529 }
530
531 HWTEST_F(EsimTest, ProcessDisableProfileDone_001, Function | MediumTest | Level2)
532 {
533 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
534 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
535 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
536 std::shared_ptr<IccControllerHolder> holder = nullptr;
537 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
538 rcvMsg->fileData.resultData = "BF32038001009000";
539 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
540 EXPECT_TRUE(esimFile->ProcessDisableProfileDone(event));
541 auto eventDisableProfile = AppExecFwk::InnerEvent::Get(0);
542 EXPECT_EQ(esimFile->ProcessDisableProfileDone(eventDisableProfile), false);
543 eventDisableProfile = nullptr;
544 EXPECT_EQ(esimFile->ProcessDisableProfileDone(eventDisableProfile), false);
545 }
546
547 HWTEST_F(EsimTest, ObtainSmdsAddress_001, Function | MediumTest | Level2)
548 {
549 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
550 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
551 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
552 int32_t portIndex = 0;
553 std::string smdsAddress = "";
554 esimFile->currentChannelId_ = 0;
555 EXPECT_EQ(smdsAddress, esimFile->ObtainSmdsAddress(portIndex));
556 int32_t slotId = 0;
557 esimFile->currentChannelId_ = 2;
558 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
559 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
560 esimFile->SetRilAndFileController(telRilManager, file, handler);
561 EXPECT_EQ(smdsAddress, esimFile->ObtainSmdsAddress(portIndex));
562 }
563
564 HWTEST_F(EsimTest, ObtainRulesAuthTable_001, Function | MediumTest | Level2)
565 {
566 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
567 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
568 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
569 int32_t portIndex = 0;
570 EuiccRulesAuthTable eUiccRulesAuthTable;
571 esimFile->currentChannelId_ = 0;
572 EXPECT_EQ(eUiccRulesAuthTable.position_, (esimFile->ObtainRulesAuthTable(portIndex)).position_);
573 int32_t slotId = 0;
574 esimFile->currentChannelId_ = 2;
575 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
576 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
577 esimFile->SetRilAndFileController(telRilManager, file, handler);
578 EXPECT_EQ(eUiccRulesAuthTable.position_, (esimFile->ObtainRulesAuthTable(portIndex)).position_);
579 }
580
581 HWTEST_F(EsimTest, ObtainEuiccChallenge_001, Function | MediumTest | Level2)
582 {
583 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
584 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
585 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
586 int32_t portIndex = 0;
587 ResponseEsimResult responseChallengeResult;
588 esimFile->currentChannelId_ = 0;
589 EXPECT_EQ(static_cast<int32_t>(responseChallengeResult.resultCode_),
590 (esimFile->ObtainEuiccChallenge(portIndex)).resultCode_);
591 int32_t slotId = 0;
592 esimFile->currentChannelId_ = 2;
593 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
594 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
595 esimFile->SetRilAndFileController(telRilManager, file, handler);
596 EXPECT_EQ(static_cast<int32_t>(responseChallengeResult.resultCode_),
597 (esimFile->ObtainEuiccChallenge(portIndex)).resultCode_);
598 }
599
600 HWTEST_F(EsimTest, RequestRulesAuthTableParseTagCtxComp0_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>(simStateManager);
605
606 std::string resultData = "BF434B"
607 "A0233021"
608 "800206C0"
609 "A118"
610 "B70A800312F3458103010203"
611 "B70A800312F3458203040506"
612 "820108"
613 "A0243022"
614 "80020780"
615 "A118"
616 "B70A800312E3458103010203"
617 "B70A8003EEEE458203040506"
618 "82020780"
619 "9000";
620 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
621 uint32_t byteLen = responseByte.size();
622 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
623 EXPECT_TRUE(esimFile->RequestRulesAuthTableParseTagCtxComp0(root));
624 byteLen = 0;
625 EXPECT_TRUE(esimFile->RequestRulesAuthTableParseTagCtxComp0(root));
626 }
627
628 HWTEST_F(EsimTest, ProcessRequestRulesAuthTableDone_001, Function | MediumTest | Level2)
629 {
630 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
631 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
632 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
633 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
634 AppExecFwk::InnerEvent::Pointer eventRequestRulesAuthTable =
635 iccFile->BuildCallerInfo(MSG_ESIM_REQUEST_RULES_AUTH_TABLE);
636 std::shared_ptr<IccControllerHolder> holder = nullptr;
637 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
638 rcvMsg->fileData.resultData = "BF434B"
639 "A0233021"
640 "800206C0"
641 "A118"
642 "B70A800312F3458103010203"
643 "B70A800312F3458203040506"
644 "820108"
645 "A0243022"
646 "80020780"
647 "A118"
648 "B70A800312E3458103010203"
649 "B70A8003EEEE458203040506"
650 "82020780"
651 "9000";
652 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
653 EXPECT_TRUE(esimFile->ProcessRequestRulesAuthTableDone(event));
654 auto event1 = AppExecFwk::InnerEvent::Get(0);
655 EXPECT_EQ(esimFile->ProcessRequestRulesAuthTableDone(event1), true);
656 event1 = nullptr;
657 EXPECT_EQ(esimFile->ProcessRequestRulesAuthTableDone(event1), true);
658 }
659
660 HWTEST_F(EsimTest, ProcessRequestRulesAuthTable_001, Function | MediumTest | Level2)
661 {
662 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
663 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
664 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
665 int slotId = 0;
666 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
667 AppExecFwk::InnerEvent::Pointer eventRequestRulesAuthTable =
668 iccFile->BuildCallerInfo(MSG_ESIM_REQUEST_RULES_AUTH_TABLE);
669 esimFile->currentChannelId_ = 1;
670 EXPECT_FALSE(esimFile->ProcessRequestRulesAuthTable(slotId, eventRequestRulesAuthTable));
671 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
672 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
673 esimFile->SetRilAndFileController(telRilManager, file, handler);
674 EXPECT_TRUE(esimFile->ProcessRequestRulesAuthTable(slotId, eventRequestRulesAuthTable));
675 esimFile->currentChannelId_ = 0;
676 EXPECT_FALSE(esimFile->ProcessRequestRulesAuthTable(slotId, eventRequestRulesAuthTable));
677 }
678
679 HWTEST_F(EsimTest, ProcessObtainSmdsAddressDone_001, Function | MediumTest | Level2)
680 {
681 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
682 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
683 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
684 std::shared_ptr<IccControllerHolder> holder = nullptr;
685 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
686 rcvMsg->fileData.resultData = "BF3C148008534D44502E434F4D8108736D64732E636F6D9000";
687 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
688 EXPECT_TRUE(esimFile->ProcessObtainSmdsAddressDone(event));
689 auto event1 = AppExecFwk::InnerEvent::Get(0);
690 EXPECT_FALSE(esimFile->ProcessObtainSmdsAddressDone(event));
691 event1 = nullptr;
692 EXPECT_FALSE(esimFile->ProcessObtainSmdsAddressDone(event));
693 }
694
695 HWTEST_F(EsimTest, ProcessObtainSmdsAddress_001, Function | MediumTest | Level2)
696 {
697 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
698 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
699 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
700 int slotId = 0;
701 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
702 AppExecFwk::InnerEvent::Pointer eventObtainSmdsAddress = iccFile->BuildCallerInfo(MSG_ESIM_OBTAIN_SMDS_ADDRESS);
703 esimFile->currentChannelId_ = 0;
704 EXPECT_FALSE(esimFile->ProcessObtainSmdsAddress(slotId, eventObtainSmdsAddress));
705 esimFile->currentChannelId_ = 2;
706 EXPECT_FALSE(esimFile->ProcessObtainSmdsAddress(slotId, eventObtainSmdsAddress));
707 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
708 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
709 esimFile->SetRilAndFileController(telRilManager, file, handler);
710 EXPECT_TRUE(esimFile->ProcessObtainSmdsAddress(slotId, eventObtainSmdsAddress));
711 }
712
713 HWTEST_F(EsimTest, ProcessObtainEuiccChallenge_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>(simStateManager);
718 int slotId = 0;
719 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
720 AppExecFwk::InnerEvent::Pointer eventEUICCChanllenge =
721 iccFile->BuildCallerInfo(MSG_ESIM_OBTAIN_EUICC_CHALLENGE_DONE);
722 esimFile->currentChannelId_ = 0;
723 EXPECT_EQ(esimFile->ProcessObtainEuiccChallenge(slotId, eventEUICCChanllenge), false);
724 esimFile->currentChannelId_ = 2;
725 EXPECT_EQ(esimFile->ProcessObtainEuiccChallenge(slotId, eventEUICCChanllenge), false);
726 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
727 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
728 esimFile->SetRilAndFileController(telRilManager, file, handler);
729 EXPECT_EQ(esimFile->ProcessObtainEuiccChallenge(slotId, eventEUICCChanllenge), true);
730 }
731
732 HWTEST_F(EsimTest, ProcessObtainEuiccChallengeDone_001, Function | MediumTest | Level2)
733 {
734 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
735 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
736 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
737 std::shared_ptr<IccControllerHolder> holder = nullptr;
738 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
739 rcvMsg->fileData.resultData = "BF2E1280105DAD74D9F1734CF96CDE5C78FDB0565B";
740 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
741 EXPECT_TRUE(esimFile->ProcessObtainEuiccChallengeDone(event));
742 auto eventEUICCChanllenge = AppExecFwk::InnerEvent::Get(0);
743 EXPECT_EQ(esimFile->ProcessObtainEuiccChallengeDone(eventEUICCChanllenge), false);
744 eventEUICCChanllenge = nullptr;
745 EXPECT_EQ(esimFile->ProcessObtainEuiccChallengeDone(eventEUICCChanllenge), false);
746 }
747
748 HWTEST_F(EsimTest, ObtainDefaultSmdpAddress_001, Function | MediumTest | Level2)
749 {
750 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
751 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
752 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
753 std::string defaultDpAddress_ = "";
754 esimFile->currentChannelId_ = 0;
755 EXPECT_EQ(defaultDpAddress_, esimFile->ObtainDefaultSmdpAddress());
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 esimFile->SetRilAndFileController(telRilManager, file, handler);
761 EXPECT_EQ(defaultDpAddress_, esimFile->ObtainDefaultSmdpAddress());
762 }
763
764 HWTEST_F(EsimTest, CancelSession_001, Function | MediumTest | Level2)
765 {
766 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
767 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
768 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
769 std::u16string transactionId = Str8ToStr16("A1B2C3");
770 const CancelReason cancelReason = CancelReason::CANCEL_REASON_POSTPONED;
771 ResponseEsimResult responseResult;
772 esimFile->currentChannelId_ = 0;
773 EXPECT_EQ(static_cast<int32_t>(responseResult.resultCode_),
774 (esimFile->CancelSession(transactionId, cancelReason)).resultCode_);
775 int32_t slotId = 0;
776 esimFile->currentChannelId_ = 2;
777 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
778 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
779 esimFile->SetRilAndFileController(telRilManager, file, handler);
780 EXPECT_EQ(static_cast<int32_t>(responseResult.resultCode_),
781 (esimFile->CancelSession(transactionId, cancelReason)).resultCode_);
782 }
783
784 HWTEST_F(EsimTest, ObtainProfile_001, Function | MediumTest | Level2)
785 {
786 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
787 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
788 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
789 int32_t portIndex = 0;
790 std::u16string iccId = Str8ToStr16("5A0A89670000000000216954");
791 EuiccProfile eUiccProfile;
792 esimFile->currentChannelId_ = 0;
793 EXPECT_EQ(eUiccProfile.state_, (esimFile->ObtainProfile(portIndex, iccId)).state_);
794 int32_t slotId = 0;
795 esimFile->currentChannelId_ = 2;
796 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
797 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
798 esimFile->SetRilAndFileController(telRilManager, file, handler);
799 EXPECT_EQ(eUiccProfile.state_, (esimFile->ObtainProfile(portIndex, iccId)).state_);
800 }
801
802 HWTEST_F(EsimTest, ProcessObtainDefaultSmdpAddress_001, Function | MediumTest | Level2)
803 {
804 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
805 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
806 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
807 int slotId = 0;
808 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
809 AppExecFwk::InnerEvent::Pointer eventSmdpAddress =
810 iccFile->BuildCallerInfo(MSG_ESIM_OBTAIN_DEFAULT_SMDP_ADDRESS_DONE);
811 esimFile->currentChannelId_ = 0;
812 EXPECT_FALSE(esimFile->ProcessObtainDefaultSmdpAddress(slotId, eventSmdpAddress));
813 esimFile->currentChannelId_ = 2;
814 EXPECT_FALSE(esimFile->ProcessObtainDefaultSmdpAddress(slotId, eventSmdpAddress));
815 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
816 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
817 esimFile->SetRilAndFileController(telRilManager, file, handler);
818 EXPECT_TRUE(esimFile->ProcessObtainDefaultSmdpAddress(slotId, eventSmdpAddress));
819 }
820
821 HWTEST_F(EsimTest, ProcessObtainDefaultSmdpAddressDone_001, Function | MediumTest | Level2)
822 {
823 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
824 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
825 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
826 std::shared_ptr<IccControllerHolder> holder = nullptr;
827 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
828 rcvMsg->fileData.resultData = "BF3C148008534D44502E434F4D8108736D64732E58225F9000";
829 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
830 EXPECT_TRUE(esimFile->ProcessObtainDefaultSmdpAddressDone(event));
831 auto event1 = AppExecFwk::InnerEvent::Get(0);
832 EXPECT_FALSE(esimFile->ProcessObtainDefaultSmdpAddressDone(event1));
833 event1 = nullptr;
834 EXPECT_FALSE(esimFile->ProcessObtainDefaultSmdpAddressDone(event1));
835 }
836
837 HWTEST_F(EsimTest, ProcessCancelSession_001, Function | MediumTest | Level2)
838 {
839 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
840 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
841 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
842 int slotId = 0;
843 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
844 AppExecFwk::InnerEvent::Pointer eventCancelSession = iccFile->BuildCallerInfo(MSG_ESIM_CANCEL_SESSION);
845 esimFile->currentChannelId_ = 0;
846 EXPECT_FALSE(esimFile->ProcessCancelSession(slotId, eventCancelSession));
847 esimFile->currentChannelId_ = 2;
848 EXPECT_FALSE(esimFile->ProcessCancelSession(slotId, eventCancelSession));
849 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
850 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
851 esimFile->SetRilAndFileController(telRilManager, file, handler);
852 EXPECT_TRUE(esimFile->ProcessCancelSession(slotId, eventCancelSession));
853 }
854
855 HWTEST_F(EsimTest, ProcessCancelSessionDone_001, Function | MediumTest | Level2)
856 {
857 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
858 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
859 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
860 std::shared_ptr<IccControllerHolder> holder = nullptr;
861 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
862 rcvMsg->fileData.resultData = "BF41009000";
863 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
864 EXPECT_TRUE(esimFile->ProcessCancelSessionDone(event));
865 std::shared_ptr<IccControllerHolder> holder1 = nullptr;
866 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg1 = std::make_unique<Telephony::IccFromRilMsg>(holder1);
867 rcvMsg1->fileData.resultData = "BF4106810456362523";
868 event = AppExecFwk::InnerEvent::Get(0, rcvMsg1);
869 EXPECT_FALSE(esimFile->ProcessCancelSessionDone(event));
870 auto event1 = AppExecFwk::InnerEvent::Get(0);
871 EXPECT_FALSE(esimFile->ProcessCancelSessionDone(event1));
872 event1 = nullptr;
873 EXPECT_FALSE(esimFile->ProcessCancelSessionDone(event1));
874 }
875
876 HWTEST_F(EsimTest, ProcessGetProfile_001, Function | MediumTest | Level2)
877 {
878 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
879 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
880 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
881 int slotId = 0;
882 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
883 AppExecFwk::InnerEvent::Pointer eventGetProfile = iccFile->BuildCallerInfo(MSG_ESIM_GET_PROFILE);
884 const int32_t CHANEL_ID_ZERO = 0;
885 esimFile->currentChannelId_ = CHANEL_ID_ZERO;
886 EXPECT_FALSE(esimFile->ProcessGetProfile(slotId, eventGetProfile));
887 const int32_t CHANEL_ID_TWO = 0;
888 esimFile->currentChannelId_ = CHANEL_ID_TWO;
889 std::string str = "ABCDEFG";
890 esimFile->esimProfile_.iccId = Str8ToStr16(str);
891 EXPECT_FALSE(esimFile->ProcessGetProfile(slotId, eventGetProfile));
892 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
893 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
894 esimFile->SetRilAndFileController(telRilManager, file, handler);
895 EXPECT_TRUE(esimFile->ProcessGetProfile(slotId, eventGetProfile));
896 std::string iccIdstr = "ABCDEFGG";
897 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdstr);
898 EXPECT_TRUE(esimFile->ProcessGetProfile(slotId, eventGetProfile));
899 }
900
901 HWTEST_F(EsimTest, ProcessGetProfileDone_002, Function | MediumTest | Level2)
902 {
903 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
904 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
905 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
906 std::shared_ptr<IccControllerHolder> holder = nullptr;
907 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
908 rcvMsg->fileData.resultData = "BF2D";
909 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
910 EXPECT_FALSE(esimFile->ProcessGetProfileDone(event));
911 }
912
913 HWTEST_F(EsimTest, ResetMemory_001, Function | MediumTest | Level2)
914 {
915 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
916 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
917 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
918 ResetOption resetOption = ResetOption::DELETE_FIELD_LOADED_TEST_PROFILES;
919 int32_t resetResult = static_cast<int32_t>(ResultCode::RESULT_SGP_22_OTHER);
920 esimFile->currentChannelId_ = 0;
921 EXPECT_NE(resetResult, esimFile->ResetMemory(resetOption));
922 int32_t slotId = 0;
923 esimFile->currentChannelId_ = 2;
924 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
925 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
926 esimFile->SetRilAndFileController(telRilManager, file, handler);
927 EXPECT_NE(resetResult, esimFile->ResetMemory(resetOption));
928 }
929
930 HWTEST_F(EsimTest, ProcessResetMemory_001, Function | MediumTest | Level2)
931 {
932 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
933 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
934 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
935 int slotId = 0;
936 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
937 AppExecFwk::InnerEvent::Pointer eventResetMemory = iccFile->BuildCallerInfo(MSG_ESIM_RESET_MEMORY);
938 esimFile->currentChannelId_ = 0;
939 EXPECT_EQ(esimFile->ProcessResetMemory(slotId, eventResetMemory), false);
940 esimFile->currentChannelId_ = 2;
941 EXPECT_EQ(esimFile->ProcessResetMemory(slotId, eventResetMemory), false);
942 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
943 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
944 esimFile->SetRilAndFileController(telRilManager, file, handler);
945 EXPECT_EQ(esimFile->ProcessResetMemory(slotId, eventResetMemory), true);
946 }
947
948 HWTEST_F(EsimTest, ProcessResetMemoryDone_001, Function | MediumTest | Level2)
949 {
950 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
951 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
952 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
953 std::shared_ptr<IccControllerHolder> holder = nullptr;
954 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
955 rcvMsg->fileData.resultData = "BF34038001009000";
956 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
957 EXPECT_TRUE(esimFile->ProcessResetMemoryDone(event));
958 auto eventResetMemory = AppExecFwk::InnerEvent::Get(0);
959 EXPECT_EQ(esimFile->ProcessResetMemoryDone(eventResetMemory), false);
960 eventResetMemory = nullptr;
961 EXPECT_EQ(esimFile->ProcessResetMemoryDone(eventResetMemory), false);
962 }
963
964 HWTEST_F(EsimTest, ProcessSendApduDataDone_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>(simStateManager);
969 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
970 std::shared_ptr<IccControllerHolder> holder = nullptr;
971 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
972 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
973 EXPECT_TRUE(esimFile->ProcessSendApduDataDone(event));
974 auto event1 = AppExecFwk::InnerEvent::Get(0);
975 EXPECT_EQ(esimFile->ProcessSendApduDataDone(event1), false);
976 event1 = nullptr;
977 EXPECT_EQ(esimFile->ProcessSendApduDataDone(event1), false);
978 }
979
980 HWTEST_F(EsimTest, ProcessSendApduData_001, Function | MediumTest | Level2)
981 {
982 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
983 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
984 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
985 int slotId = 0;
986 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
987 AppExecFwk::InnerEvent::Pointer eventSendApduData = iccFile->BuildCallerInfo(MSG_ESIM_SEND_APUD_DATA);
988 esimFile->currentChannelId_ = 1;
989 EXPECT_FALSE(esimFile->ProcessSendApduData(slotId, eventSendApduData));
990 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
991 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
992 esimFile->SetRilAndFileController(telRilManager, file, handler);
993 EXPECT_TRUE(esimFile->ProcessSendApduData(slotId, eventSendApduData));
994 esimFile->currentChannelId_ = 0;
995 EXPECT_FALSE(esimFile->ProcessSendApduData(slotId, eventSendApduData));
996 }
997
998 HWTEST_F(EsimTest, ObtainPrepareDownload_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>(simStateManager);
1003 DownLoadConfigInfo downLoadConfigInfo;
1004 ResponseEsimResult preDownloadResult;
1005 esimFile->currentChannelId_ = 0;
1006 EXPECT_EQ(static_cast<int32_t>(preDownloadResult.resultCode_),
1007 (esimFile->ObtainPrepareDownload(downLoadConfigInfo)).resultCode_);
1008 int32_t slotId = 0;
1009 esimFile->currentChannelId_ = 2;
1010 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1011 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1012 esimFile->SetRilAndFileController(telRilManager, file, handler);
1013 EXPECT_EQ(static_cast<int32_t>(preDownloadResult.resultCode_),
1014 (esimFile->ObtainPrepareDownload(downLoadConfigInfo)).resultCode_);
1015 }
1016
1017 HWTEST_F(EsimTest, ObtainLoadBoundProfilePackage_001, Function | MediumTest | Level2)
1018 {
1019 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1020 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1021 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1022 int32_t portIndex = 0;
1023 std::u16string boundProfilePackageStr;
1024 ResponseEsimBppResult loadBPPResult;
1025 esimFile->currentChannelId_ = 0;
1026 EXPECT_EQ(static_cast<int32_t>(loadBPPResult.resultCode_), (esimFile->ObtainLoadBoundProfilePackage(
1027 portIndex, boundProfilePackageStr)).resultCode_);
1028 int32_t slotId = 0;
1029 esimFile->currentChannelId_ = 2;
1030 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1031 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1032 esimFile->SetRilAndFileController(telRilManager, file, handler);
1033 EXPECT_EQ(static_cast<int32_t>(loadBPPResult.resultCode_), (esimFile->ObtainLoadBoundProfilePackage(
1034 portIndex, boundProfilePackageStr)).resultCode_);
1035 }
1036
1037 HWTEST_F(EsimTest, ListNotifications_001, Function | MediumTest | Level2)
1038 {
1039 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1040 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1041 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1042 int32_t portIndex = 0;
1043 Event events = Event::EVENT_DONOTHING;
1044 esimFile->currentChannelId_ = 0;
1045 EXPECT_TRUE((esimFile->ListNotifications(portIndex, events)).euiccNotification_.empty());
1046 int32_t slotId = 0;
1047 esimFile->currentChannelId_ = 2;
1048 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1049 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1050 esimFile->SetRilAndFileController(telRilManager, file, handler);
1051 EXPECT_TRUE((esimFile->ListNotifications(portIndex, events)).euiccNotification_.empty());
1052 }
1053
1054 HWTEST_F(EsimTest, ProcessPrepareDownload_001, Function | MediumTest | Level2)
1055 {
1056 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1057 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1058 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1059
1060 int slotId = 0;
1061 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1062 esimFile->currentChannelId_ = 0;
1063 EXPECT_FALSE(esimFile->ProcessPrepareDownload(slotId));
1064
1065 esimFile->currentChannelId_ = 2;
1066 EXPECT_TRUE(esimFile->ProcessPrepareDownload(slotId));
1067
1068 std::u16string str = u"hashCctest";
1069 esimFile->esimProfile_.hashCc = str;
1070 EXPECT_TRUE(esimFile->ProcessPrepareDownload(slotId));
1071
1072 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1073 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1074 esimFile->SetRilAndFileController(telRilManager, file, handler);
1075 EXPECT_TRUE(esimFile->ProcessPrepareDownload(slotId));
1076 }
1077
1078
1079 HWTEST_F(EsimTest, DecodeBoundProfilePackage_001, Function | MediumTest | Level2)
1080 {
1081 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1082 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1083 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1084 std::shared_ptr<Asn1Node> bppNode = nullptr;
1085 std::string boundProfilePackageStr = "some_decode_data";
1086 EXPECT_FALSE(esimFile->DecodeBoundProfilePackage(boundProfilePackageStr, bppNode));
1087 }
1088
1089 HWTEST_F(EsimTest, BuildApduForInitSecureChannel_001, Function | MediumTest | Level2)
1090 {
1091 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1092 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1093 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1094 std::shared_ptr<Asn1Node> bppNode = nullptr;
1095 esimFile->DecodeBoundProfilePackage(boundProfilePackage, bppNode);
1096 int32_t currentChannelId_ = 1;
1097 RequestApduBuild codec(currentChannelId_);
1098 std::shared_ptr<Asn1Node> initSecureChannelReq = bppNode->Asn1GetChild(TAG_ESIM_INITIALISE_SECURE_CHANNEL);
1099 esimFile->BuildApduForInitSecureChannel(codec, bppNode, initSecureChannelReq);
1100 bool bRet = codec.GetCommands().size() != 0 ? true : false;
1101 EXPECT_TRUE(bRet);
1102 }
1103
1104 HWTEST_F(EsimTest, BuildApduForFirstSequenceOf87_001, Function | MediumTest | Level2)
1105 {
1106 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1107 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1108 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1109 std::shared_ptr<Asn1Node> bppNode = nullptr;
1110 esimFile->DecodeBoundProfilePackage(boundProfilePackage, bppNode);
1111 int32_t currentChannelId_ = 1;
1112 RequestApduBuild codec(currentChannelId_);
1113 std::shared_ptr<Asn1Node> firstSequenceOf87 = bppNode->Asn1GetChild(TAG_ESIM_CTX_COMP_0);
1114 esimFile->BuildApduForFirstSequenceOf87(codec, firstSequenceOf87);
1115 bool bRet = codec.GetCommands().size() != 0 ? true : false;
1116 EXPECT_TRUE(bRet);
1117 }
1118
1119 HWTEST_F(EsimTest, BuildApduForSequenceOf88_001, Function | MediumTest | Level2)
1120 {
1121 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1122 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1123 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1124 std::shared_ptr<Asn1Node> bppNode = nullptr;
1125 esimFile->DecodeBoundProfilePackage(boundProfilePackage, bppNode);
1126 int32_t currentChannelId_ = 1;
1127 RequestApduBuild codec(currentChannelId_);
1128 std::shared_ptr<Asn1Node> sequenceOf88 = bppNode->Asn1GetChild(TAG_ESIM_CTX_COMP_1);
1129 esimFile->BuildApduForSequenceOf88(codec, sequenceOf88);
1130 bool bRet = codec.GetCommands().size() != 0 ? true : false;
1131 EXPECT_TRUE(bRet);
1132 }
1133
1134 HWTEST_F(EsimTest, BuildApduForSequenceOf86_001, Function | MediumTest | Level2)
1135 {
1136 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1137 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1138 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1139 std::shared_ptr<Asn1Node> bppNode = nullptr;
1140 esimFile->DecodeBoundProfilePackage(boundProfilePackage, bppNode);
1141 int32_t currentChannelId_ = 1;
1142 RequestApduBuild codec(currentChannelId_);
1143 std::shared_ptr<Asn1Node> sequenceOf86 = bppNode->Asn1GetChild(TAG_ESIM_CTX_COMP_3);
1144 esimFile->BuildApduForSequenceOf86(codec, bppNode, sequenceOf86);
1145 bool bRet = codec.GetCommands().size() != 0 ? true : false;
1146 EXPECT_TRUE(bRet);
1147 }
1148
1149 HWTEST_F(EsimTest, ProcessLoadBoundProfilePackage_001, Function | MediumTest | Level2)
1150 {
1151 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1152 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1153 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1154 int slotId = 0;
1155 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1156 AppExecFwk::InnerEvent::Pointer eventGetProfile = iccFile->BuildCallerInfo(MSG_ESIM_GET_PROFILE);
1157 esimFile->currentChannelId_ = 0;
1158 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1159 esimFile->currentChannelId_ = 2;
1160 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1161 esimFile->esimProfile_.boundProfilePackage = Str8ToStr16(boundProfilePackage);
1162 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1163 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1164 esimFile->SetRilAndFileController(telRilManager, file, handler);
1165 EXPECT_TRUE(esimFile->ProcessLoadBoundProfilePackage(slotId));
1166 }
1167
1168 HWTEST_F(EsimTest, ProcessLoadBoundProfilePackageDone_001, Function | MediumTest | Level2)
1169 {
1170 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1171 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1172 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1173
1174 std::shared_ptr<IccControllerHolder> holder = nullptr;
1175 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1176 rcvMsg->fileData.resultData = "BF3781ADBF27678008D14FE1DE62C340D7BF2F3480024C66810207800C1E31302E31302E31322E"
1177 "3136342F64702D706C75732D696E746572666163655A0A98680010203040506080060388370AA21FA01D4F10A0000005591010FFF"
1178 "FFFFF890000120004093007A00530038001005F3740B354AE39D08ACD7EDD7D2D01C73378621F623B832DFA3243489C5B42C90F22"
1179 "014E6C928130D78EE561982EF412AC3D94C04B56F37657DA84FD7BB24D15C4783F";
1180 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1181 EXPECT_TRUE(esimFile->ProcessLoadBoundProfilePackageDone(event));
1182 auto event1 = AppExecFwk::InnerEvent::Get(0);
1183 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackageDone(event1));
1184 event1 = nullptr;
1185 EXPECT_FALSE(esimFile->ProcessLoadBoundProfilePackageDone(event1));
1186 }
1187
1188 HWTEST_F(EsimTest, LoadBoundProfilePackageParseNotificationMetadata_001, Function | MediumTest | Level2)
1189 {
1190 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1191 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1192 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1193 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(bppCombineHexStr);
1194 uint32_t byteLen = responseByte.size();
1195 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1196 std::shared_ptr<Asn1Node> nodeNotificationMetadata =
1197 esimFile->LoadBoundProfilePackageParseProfileInstallResult(root);
1198 EXPECT_TRUE(esimFile->LoadBoundProfilePackageParseNotificationMetadata(nodeNotificationMetadata));
1199 }
1200
1201 HWTEST_F(EsimTest, RealProcessLoadBoundProfilePackageDone_001, Function | MediumTest | Level2)
1202 {
1203 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1204 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1205 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1206 EXPECT_TRUE(esimFile->RealProcessLoadBoundProfilePackageDone(bppCombineHexStr));
1207 }
1208
1209 HWTEST_F(EsimTest, ProcessListNotifications_001, Function | MediumTest | Level2)
1210 {
1211 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1212 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1213 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1214 int slotId = 0;
1215 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1216 AppExecFwk::InnerEvent::Pointer eventListNotif = iccFile->BuildCallerInfo(MSG_ESIM_LIST_NOTIFICATION);
1217 esimFile->currentChannelId_ =0 ;
1218 EXPECT_FALSE(esimFile->ProcessListNotifications(slotId, Event::EVENT_ENABLE, eventListNotif));
1219 esimFile->currentChannelId_ =2 ;
1220 EXPECT_FALSE(esimFile->ProcessListNotifications(slotId, Event::EVENT_ENABLE, eventListNotif));
1221 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1222 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1223 esimFile->SetRilAndFileController(telRilManager, file, handler);
1224 EXPECT_TRUE(esimFile->ProcessListNotifications(slotId, Event::EVENT_ENABLE, eventListNotif));
1225 }
1226
1227 HWTEST_F(EsimTest, createNotification_001, Function | MediumTest | Level2)
1228 {
1229 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1230 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1231 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1232 std::string resultData = "BF2F118001010C08736D64702E636F6D81020508";
1233 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData.c_str());
1234 uint32_t byteLen = responseByte.size();
1235 std::shared_ptr<Asn1Node> node = esimFile->Asn1ParseResponse(responseByte, byteLen);
1236 EuiccNotification euicc;
1237 esimFile->createNotification(node, euicc);
1238 bool bRet = euicc.targetAddr_.empty() ? false : true;
1239 EXPECT_TRUE(bRet);
1240 }
1241
1242 HWTEST_F(EsimTest, createNotification_002, Function | MediumTest | Level2)
1243 {
1244 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1245 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1246 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1247
1248 std::string resultData = "BF282BA029BF2F118001010C00736D64702E636F6C820";
1249 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData.c_str());
1250 uint32_t byteLen = responseByte.size();
1251 std::shared_ptr<Asn1Node> node = esimFile->Asn1ParseResponse(responseByte, byteLen);
1252 EuiccNotification euicc;
1253 esimFile->createNotification(node, euicc);
1254 bool bRet = euicc.targetAddr_.empty() ? false : true;
1255 EXPECT_TRUE(bRet);
1256 }
1257
1258 HWTEST_F(EsimTest, createNotification_003, Function | MediumTest | Level2)
1259 {
1260 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1261 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1262 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1263 std::string resultData = "BF2F118001010C08736D64702E636F6D81020603";
1264 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData.c_str());
1265 uint32_t byteLen = responseByte.size();
1266 std::shared_ptr<Asn1Node> node = esimFile->Asn1ParseResponse(responseByte, byteLen);
1267 EuiccNotification euicc;
1268 esimFile->createNotification(node, euicc);
1269 bool bRet = euicc.targetAddr_.empty() ? false : true;
1270 EXPECT_TRUE(bRet);
1271 }
1272
1273 HWTEST_F(EsimTest, ProcessListNotificationsAsn1Response_001, Function | MediumTest | Level2)
1274 {
1275 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1276 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1277 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1278
1279 std::string resultData =
1280 "BF282BA029BF2F118001010C08736D64702E636F6D81020410BF2F128001020C09736D6470322E636F6D810205309000";
1281 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1282 uint32_t byteLen = responseByte.size();
1283
1284 std::shared_ptr<Asn1Node> profileNode = esimFile->Asn1ParseResponse(responseByte, byteLen);
1285 EXPECT_EQ(esimFile->ProcessListNotificationsAsn1Response(profileNode), false);
1286 }
1287
1288 HWTEST_F(EsimTest, ProcessListNotificationsAsn1Response_002, Function | MediumTest | Level2)
1289 {
1290 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1291 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1292 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1293
1294 std::string resultData = "BF2803810106";
1295 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1296 uint32_t byteLen = responseByte.size();
1297
1298 std::shared_ptr<Asn1Node> profileNode = esimFile->Asn1ParseResponse(responseByte, byteLen);
1299 EXPECT_EQ(esimFile->ProcessListNotificationsAsn1Response(profileNode), false);
1300 }
1301
1302 HWTEST_F(EsimTest, ProcessListNotificationsAsn1Response_003, Function | MediumTest | Level2)
1303 {
1304 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1305 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1306 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1307
1308 std::string resultData = "BF2803A00106";
1309 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1310 uint32_t byteLen = responseByte.size();
1311
1312 std::shared_ptr<Asn1Node> profileNode = esimFile->Asn1ParseResponse(responseByte, byteLen);
1313 EXPECT_EQ(esimFile->ProcessListNotificationsAsn1Response(profileNode), false);
1314 }
1315
1316 HWTEST_F(EsimTest, RetrieveNotificationList_001, Function | MediumTest | Level2)
1317 {
1318 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1319 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1320 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1321 int32_t portIndex = 0;
1322 Event events = Event::EVENT_DONOTHING;
1323 esimFile->currentChannelId_ = 0;
1324 EXPECT_TRUE((esimFile->RetrieveNotificationList(portIndex, events)).euiccNotification_.empty());
1325
1326 int32_t slotId = 0;
1327 esimFile->currentChannelId_ = 2;
1328 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1329 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1330 esimFile->SetRilAndFileController(telRilManager, file, handler);
1331 EXPECT_TRUE((esimFile->RetrieveNotificationList(portIndex, events)).euiccNotification_.empty());
1332 }
1333
1334 HWTEST_F(EsimTest, ObtainRetrieveNotification_001, Function | MediumTest | Level2)
1335 {
1336 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1337 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1338 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1339 int32_t portIndex = 0;
1340 int32_t seqNumber = 5;
1341 EuiccNotification notification;
1342 esimFile->currentChannelId_ = 0;
1343 EXPECT_EQ(notification.seq_, (esimFile->ObtainRetrieveNotification(portIndex, seqNumber)).seq_);
1344 int32_t slotId = 0;
1345 esimFile->currentChannelId_ = 2;
1346 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1347 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1348 esimFile->SetRilAndFileController(telRilManager, file, handler);
1349 EXPECT_EQ(notification.seq_, (esimFile->ObtainRetrieveNotification(portIndex, seqNumber)).seq_);
1350 }
1351
1352 HWTEST_F(EsimTest, RemoveNotificationFromList_001, Function | MediumTest | Level2)
1353 {
1354 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1355 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1356 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1357 int32_t portIndex = 0;
1358 int32_t seqNumber = 5;
1359 int32_t removeNotifResult = static_cast<int32_t>(ResultCode::RESULT_SGP_22_OTHER);
1360 esimFile->currentChannelId_ = 0;
1361 EXPECT_EQ(removeNotifResult, esimFile->RemoveNotificationFromList(portIndex, seqNumber));
1362 int32_t slotId = 0;
1363 esimFile->currentChannelId_ = 2;
1364 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1365 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1366 esimFile->SetRilAndFileController(telRilManager, file, handler);
1367 EXPECT_EQ(removeNotifResult, esimFile->RemoveNotificationFromList(portIndex, seqNumber));
1368 }
1369
1370 HWTEST_F(EsimTest, ProcessRemoveNotification_001, Function | MediumTest | Level2)
1371 {
1372 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1373 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1374 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1375 int slotId = 0;
1376 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1377 AppExecFwk::InnerEvent::Pointer eventRemoveNotif = iccFile->BuildCallerInfo(MSG_ESIM_REMOVE_NOTIFICATION);
1378 esimFile->currentChannelId_ = 0;
1379 EXPECT_FALSE(esimFile->ProcessRemoveNotification(slotId, eventRemoveNotif));
1380 esimFile->currentChannelId_ = 2;
1381 EXPECT_FALSE(esimFile->ProcessRemoveNotification(slotId, eventRemoveNotif));
1382 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1383 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1384 esimFile->SetRilAndFileController(telRilManager, file, handler);
1385 EXPECT_TRUE(esimFile->ProcessRemoveNotification(slotId, eventRemoveNotif));
1386 }
1387
1388 HWTEST_F(EsimTest, ProcessRemoveNotificationDone_001, Function | MediumTest | Level2)
1389 {
1390 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1391 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1392 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1393 std::shared_ptr<IccControllerHolder> holder = nullptr;
1394 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1395 rcvMsg->fileData.resultData = "BF3003800100";
1396 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1397 EXPECT_TRUE(esimFile->ProcessRemoveNotificationDone(event));
1398 auto eventRemoveNotif = AppExecFwk::InnerEvent::Get(0);
1399 EXPECT_EQ(esimFile->ProcessRemoveNotificationDone(eventRemoveNotif), false);
1400 eventRemoveNotif = nullptr;
1401 EXPECT_EQ(esimFile->ProcessRemoveNotificationDone(eventRemoveNotif), false);
1402 }
1403
1404 HWTEST_F(EsimTest, ProcessRetrieveNotification_001, Function | MediumTest | Level2)
1405 {
1406 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1407 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1408 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1409 int slotId = 0;
1410 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1411 AppExecFwk::InnerEvent::Pointer eventRetrieveNotification =
1412 iccFile->BuildCallerInfo(MSG_ESIM_RETRIEVE_NOTIFICATION_DONE);
1413 esimFile->currentChannelId_ = 0;
1414 EXPECT_FALSE(esimFile->ProcessRetrieveNotification(slotId, eventRetrieveNotification));
1415 esimFile->currentChannelId_ = 2;
1416 EXPECT_FALSE(esimFile->ProcessRetrieveNotification(slotId, eventRetrieveNotification));
1417 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1418 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1419 esimFile->SetRilAndFileController(telRilManager, file, handler);
1420 EXPECT_TRUE(esimFile->ProcessRetrieveNotification(slotId, eventRetrieveNotification));
1421 }
1422
1423 HWTEST_F(EsimTest, ProcessRetrieveNotificationList_001, Function | MediumTest | Level2)
1424 {
1425 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1426 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1427 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1428 int slotId = 0;
1429 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1430 AppExecFwk::InnerEvent::Pointer eventRetrieveListNotif =
1431 iccFile->BuildCallerInfo(MSG_ESIM_RETRIEVE_NOTIFICATION_LIST);
1432 Event events = Event::EVENT_ENABLE;
1433 esimFile->currentChannelId_ = 1;
1434 EXPECT_FALSE(esimFile->ProcessRetrieveNotificationList(slotId, events, eventRetrieveListNotif));
1435 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1436 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1437 esimFile->SetRilAndFileController(telRilManager, file, handler);
1438 EXPECT_TRUE(esimFile->ProcessRetrieveNotificationList(slotId, events, eventRetrieveListNotif));
1439 esimFile->currentChannelId_ = 0;
1440 EXPECT_FALSE(esimFile->ProcessRetrieveNotificationList(slotId, events, eventRetrieveListNotif));
1441 }
1442
1443 HWTEST_F(EsimTest, ProcessRetrieveNotificationListDone_001, Function | MediumTest | Level2)
1444 {
1445 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1446 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1447 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1448 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1449 std::shared_ptr<IccControllerHolder> holder = nullptr;
1450 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1451 rcvMsg->fileData.resultData =
1452 "BF2B2FA02D3014BF2F118001010C08736D64702E636F6D810204103015BF2F128001020C09736D6470322E636F6D810205109000";
1453 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1454 EXPECT_TRUE(esimFile->ProcessRetrieveNotificationListDone(event));
1455 auto event1 = AppExecFwk::InnerEvent::Get(0);
1456 EXPECT_EQ(esimFile->ProcessRetrieveNotificationListDone(event1), false);
1457 event1 = nullptr;
1458 EXPECT_EQ(esimFile->ProcessRetrieveNotificationListDone(event1), false);
1459 }
1460
1461 HWTEST_F(EsimTest, RetrieveNotificationParseCompTag_001, Function | MediumTest | Level2)
1462 {
1463 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1464 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1465 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1466 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1467 std::shared_ptr<IccControllerHolder> holder = nullptr;
1468 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1469 rcvMsg->fileData.resultData =
1470 "BF2B2FA02D3014BF2F118001010C08736D64702E636F6D810204103015BF2F128001020C09736D6470322E636F6D810205109000";
1471 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(rcvMsg->fileData.resultData);
1472 uint32_t byteLen = responseByte.size();
1473 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1474 EXPECT_TRUE(esimFile->RetrieveNotificationParseCompTag(root));
1475 }
1476
1477 HWTEST_F(EsimTest, DeleteProfile_001, Function | MediumTest | Level2)
1478 {
1479 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1480 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1481 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1482
1483 std::u16string iccId;
1484 int32_t disableProfileResult = static_cast<int32_t>(ResultCode::RESULT_SGP_22_OTHER);
1485 esimFile->currentChannelId_ = 0;
1486 EXPECT_NE(disableProfileResult, esimFile->DeleteProfile(iccId));
1487
1488 int32_t slotId = 0;
1489 esimFile->currentChannelId_ = 2;
1490 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1491 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1492 esimFile->SetRilAndFileController(telRilManager, file, handler);
1493 EXPECT_NE(disableProfileResult, esimFile->DeleteProfile(iccId));
1494 }
1495
1496 HWTEST_F(EsimTest, SwitchToProfile_001, Function | MediumTest | Level2)
1497 {
1498 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1499 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1500 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1501
1502 int32_t portIndex = 0;
1503 std::u16string iccId;
1504 bool forceDisableProfile = false;
1505 int32_t switchResult = static_cast<int32_t>(ResultCode::RESULT_SGP_22_OTHER);
1506 esimFile->currentChannelId_ = 0;
1507 EXPECT_NE(switchResult, esimFile->SwitchToProfile(portIndex, iccId, forceDisableProfile));
1508
1509 int32_t slotId = 0;
1510 esimFile->currentChannelId_ = 2;
1511 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1512 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1513 esimFile->SetRilAndFileController(telRilManager, file, handler);
1514 EXPECT_NE(switchResult, esimFile->SwitchToProfile(portIndex, iccId, forceDisableProfile));
1515 }
1516
1517 HWTEST_F(EsimTest, SetProfileNickname_001, Function | MediumTest | Level2)
1518 {
1519 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1520 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1521 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1522
1523 std::u16string iccId = Str8ToStr16("98760000000000543210");
1524 std::u16string nickname = Str8ToStr16("nick");
1525 int32_t updateNicknameResult = static_cast<int32_t>(ResultCode::RESULT_SGP_22_OTHER);
1526 esimFile->currentChannelId_ = 0;
1527 EXPECT_NE(updateNicknameResult, esimFile->SetProfileNickname(iccId, nickname));
1528
1529 int32_t slotId = 0;
1530 esimFile->currentChannelId_ = 2;
1531 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1532 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1533 esimFile->SetRilAndFileController(telRilManager, file, handler);
1534 EXPECT_NE(updateNicknameResult, esimFile->SetProfileNickname(iccId, nickname));
1535 }
1536
1537 HWTEST_F(EsimTest, ProcessDeleteProfile_001, Function | MediumTest | Level2)
1538 {
1539 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1540 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1541 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1542
1543 int slotId = 0;
1544 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1545 AppExecFwk::InnerEvent::Pointer eventDeleteProfile = iccFile->BuildCallerInfo(MSG_ESIM_DELETE_PROFILE);
1546 esimFile->currentChannelId_ = 0;
1547 EXPECT_FALSE(esimFile->ProcessDeleteProfile(slotId, eventDeleteProfile));
1548
1549 esimFile->currentChannelId_ = 2;
1550 std::string iccIdStr = "ABCDEFG";
1551 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdStr);
1552 EXPECT_FALSE(esimFile->ProcessDeleteProfile(slotId, eventDeleteProfile));
1553
1554 std::string str = "ABCDEFGG";
1555 esimFile->esimProfile_.iccId = Str8ToStr16(str);
1556 EXPECT_FALSE(esimFile->ProcessDeleteProfile(slotId, eventDeleteProfile));
1557 }
1558
1559 HWTEST_F(EsimTest, ProcessDeleteProfileDone_001, Function | MediumTest | Level2)
1560 {
1561 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1562 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1563 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1564 std::shared_ptr<IccControllerHolder> holder = nullptr;
1565 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1566 rcvMsg->fileData.resultData = "BF33038001009000";
1567 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1568 EXPECT_TRUE(esimFile->ProcessDeleteProfileDone(event));
1569
1570 auto event1 = AppExecFwk::InnerEvent::Get(0);
1571 EXPECT_FALSE(esimFile->ProcessDeleteProfileDone(event1));
1572
1573 event1 = nullptr;
1574 EXPECT_FALSE(esimFile->ProcessDeleteProfileDone(event1));
1575 }
1576
1577 HWTEST_F(EsimTest, ProcessSwitchToProfile_001, Function | MediumTest | Level2)
1578 {
1579 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1580 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1581 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1582
1583 int slotId = 0;
1584 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1585 AppExecFwk::InnerEvent::Pointer eventSwitchToProfile = iccFile->BuildCallerInfo(MSG_ESIM_SWITCH_PROFILE);
1586 esimFile->currentChannelId_ = 0;
1587 EXPECT_FALSE(esimFile->ProcessSwitchToProfile(slotId, eventSwitchToProfile));
1588
1589 esimFile->currentChannelId_ = 2;
1590 std::string iccIdStr = "ABCDEFG";
1591 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdStr);
1592 EXPECT_FALSE(esimFile->ProcessSwitchToProfile(slotId, eventSwitchToProfile));
1593
1594 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1595 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1596 esimFile->SetRilAndFileController(telRilManager, file, handler);
1597 EXPECT_TRUE(esimFile->ProcessSwitchToProfile(slotId, eventSwitchToProfile));
1598
1599 std::string str = "ABCDEFGG";
1600 esimFile->esimProfile_.iccId = Str8ToStr16(str);
1601 EXPECT_TRUE(esimFile->ProcessSwitchToProfile(slotId, eventSwitchToProfile));
1602 }
1603
1604 HWTEST_F(EsimTest, ProcessSwitchToProfileDone_001, Function | MediumTest | Level2)
1605 {
1606 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1607 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1608 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1609 std::shared_ptr<IccControllerHolder> holder = nullptr;
1610 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1611 rcvMsg->fileData.resultData = "BF3103800100";
1612 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1613 EXPECT_TRUE(esimFile->ProcessSwitchToProfileDone(event));
1614
1615 auto event1 = AppExecFwk::InnerEvent::Get(0);
1616 EXPECT_FALSE(esimFile->ProcessSwitchToProfileDone(event1));
1617
1618 event1 = nullptr;
1619 EXPECT_FALSE(esimFile->ProcessSwitchToProfileDone(event1));
1620 }
1621
1622 HWTEST_F(EsimTest, ProcessSetNickname_001, Function | MediumTest | Level2)
1623 {
1624 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1625 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1626 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1627
1628 int slotId = 0;
1629 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1630 AppExecFwk::InnerEvent::Pointer eventSetNickName = iccFile->BuildCallerInfo(MSG_ESIM_SET_NICK_NAME);
1631 esimFile->currentChannelId_ = 0;
1632 EXPECT_FALSE(esimFile->ProcessSetNickname(slotId, eventSetNickName));
1633
1634 esimFile->currentChannelId_ = 2;
1635 std::string iccIdStr = "ABCDEFG";
1636 esimFile->esimProfile_.iccId = Str8ToStr16(iccIdStr);
1637 EXPECT_FALSE(esimFile->ProcessSetNickname(slotId, eventSetNickName));
1638
1639 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1640 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1641 esimFile->SetRilAndFileController(telRilManager, file, handler);
1642 EXPECT_TRUE(esimFile->ProcessSetNickname(slotId, eventSetNickName));
1643
1644 std::string str = "ABCDEFGG";
1645 esimFile->esimProfile_.iccId = Str8ToStr16(str);
1646 EXPECT_TRUE(esimFile->ProcessSetNickname(slotId, eventSetNickName));
1647 }
1648
1649 HWTEST_F(EsimTest, ProcessSetNicknameDone_001, Function | MediumTest | Level2)
1650 {
1651 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1652 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1653 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1654 std::shared_ptr<IccControllerHolder> holder = nullptr;
1655 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1656 rcvMsg->fileData.resultData = "BF31038001009000";
1657 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1658 EXPECT_TRUE(esimFile->ProcessSetNicknameDone(event));
1659
1660 auto event1 = AppExecFwk::InnerEvent::Get(0);
1661 EXPECT_FALSE(esimFile->ProcessSetNicknameDone(event1));
1662
1663 event1 = nullptr;
1664 EXPECT_FALSE(esimFile->ProcessSetNicknameDone(event1));
1665 }
1666
1667 HWTEST_F(EsimTest, ProcessAuthenticateServer_001, Function | MediumTest | Level2)
1668 {
1669 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1670 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1671 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1672 int32_t slotId = 0;
1673 esimFile->currentChannelId_ = 0;
1674 EXPECT_FALSE(esimFile->ProcessAuthenticateServer(slotId));
1675 esimFile->currentChannelId_ = 2;
1676 EXPECT_TRUE(esimFile->ProcessAuthenticateServer(slotId));
1677 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1678 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1679 esimFile->SetRilAndFileController(telRilManager, file, handler);
1680 EXPECT_TRUE(esimFile->ProcessAuthenticateServer(slotId));
1681 }
1682
1683 HWTEST_F(EsimTest, ProcessAuthenticateServerDone_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>(simStateManager);
1688 std::shared_ptr<IccControllerHolder> holder = nullptr;
1689 std::unique_ptr<Telephony::IccFromRilMsg> rcvMsg = std::make_unique<Telephony::IccFromRilMsg>(holder);
1690 rcvMsg->fileData.sw1 = 90;
1691 rcvMsg->fileData.sw2 = 00;
1692 rcvMsg->fileData.resultData = "BF388205E5A08205E13082011C8008D14FE1DE62C340D7831E31302E31302E31322E3136342F647"
1693 "02D706C75732D696E746572666163658410F31F2690404C42718528B2301082A071BF2281A68103020301820302020283030402008"
1694 "40D81010082040007AE2E83022F378505067F32F7C08603090200870302030088020490A92C0414F54172BDF98A95D65CBEB88A38A"
1695 "1C11D800A85C30414C0BC70BA36929D43B467FF57570530E57AB8FCD8AA2C0414F54172BDF98A95D65CBEB88A38A1C11D800A85C30"
1696 "414C0BC70BA36929D43B467FF57570530E57AB8FCD88B010004030100000C0D45442D5A492D55502D30383234A0348017503658313"
1697 "72D3833594C332D52345230592D4E56523332A119800468396860A10F80030B000081030B000085030B000082005F3740B939AD87D"
1698 "29B5505CB5C00ACAABD3E156C680EF9A15B99D8C4361A9B4CA59C112D9CC649463515A860F534A1822536F537F7D422651F9D19A40"
1699 "384C90A2FFCCC308201FE308201A5A0030201020209020000000000000001300A06082A8648CE3D0403023037310B3009060355040"
1700 "61302455331153013060355040A0C0C52535020546573742045554D3111300F06035504030C0845554D20546573743020170D32303"
1701 "03430313039343835385A180F37343936303132343039343835385A3064310B300906035504061302455331153013060355040A0C0"
1702 "C52535020546573742045554D312930270603550405132038393038363033303230323230303030303032343030303037303935313"
1703 "331393113301106035504030C0A546573742065554943433059301306072A8648CE3D020106082A8648CE3D030107034200046DB3F"
1704 "53ADC87DC2FF10C7BFCD87AD13AE97009AFA065A6757EE571B3F2EBB18F46C1D68F3EDEB0E74B2E5D542051E7D27F50952028605AF"
1705 "DEF79FE9FFFD03959A36B3069301F0603551D23041830168014DD3DA24D350C1CC5D0AF0965F40EC34C5EE409F1301D0603551D0E0"
1706 "4160414A52476AF5D50AA376437CCB1DA2172EF45F484F0300E0603551D0F0101FF04040302078030170603551D200101FF040D300"
1707 "B3009060767811201020101300A06082A8648CE3D040302034700304402200858D232D4649A8BDA7B9441C1215854B1BC48AB52D24"
1708 "1CF57BA7D6FA0EB5191022009ED2C93F2184ECD34F2E42FD64B1DC68CF38EAB6CDBA9ADDDBD0139629C55CC308202783082021FA00"
1709 "3020102020412345678300A06082A8648CE3D04030230443110300E06035504030C07546573742043493111300F060355040B0C085"
1710 "4455354434552543110300E060355040A0C0752535054455354310B30090603550406130249543020170D323030343031303932383"
1711 "3375A180F32303534303332343039323833375A3037310B300906035504061302455331153013060355040A0C0C525350205465737"
1712 "42045554D3111300F06035504030C0845554D20546573743059301306072A8648CE3D020106082A8648CE3D030107034200041330D"
1713 "59256AC0CB50BD928D0F4C68007C485FE3F42988AD3EE3875AE33F4983AB23B4DD4C31340D676DD8E11F9C5CBA1B11EB694EED0994"
1714 "DB529285E632C8906A382010830820104301F0603551D23041830168014F54172BDF98A95D65CBEB88A38A1C11D800A85C3301D060"
1715 "3551D0E04160414DD3DA24D350C1CC5D0AF0965F40EC34C5EE409F1300E0603551D0F0101FF04040302020430170603551D200101F"
1716 "F040D300B3009060767811201020102300E0603551D1104073005880388370530120603551D130101FF040830060101FF020100303"
1717 "50603551D1F042E302C302AA028A0268624687474703A2F2F63692E746573742E6578616D706C652E636F6D2F43524C2D422E63726"
1718 "C303E0603551D1E0101FF04343032A030302EA42C302A31153013060355040A0C0C52535020546573742045554D3111300F0603550"
1719 "40513083839303439303332300A06082A8648CE3D040302034700304402200C567BF01E45244863AD7A4613F7572EEF3439F698B47"
1720 "11AA397AEEFC5445CE702206E993AA0A505F260B0EEF62CC30A2BBE453B0E8248218FD53304EF7FAABBCCDD";
1721 auto event = AppExecFwk::InnerEvent::Get(0, rcvMsg);
1722 EXPECT_TRUE(esimFile->ProcessAuthenticateServerDone(event));
1723 auto event1 = AppExecFwk::InnerEvent::Get(0);
1724 EXPECT_FALSE(esimFile->ProcessAuthenticateServerDone(event1));
1725 event1 = nullptr;
1726 EXPECT_FALSE(esimFile->ProcessAuthenticateServerDone(event1));
1727 }
1728
1729 HWTEST_F(EsimTest, ConvertAuthInputParaFromApiStru_001, Function | MediumTest | Level2)
1730 {
1731 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1732 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1733 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1734 Es9PlusInitAuthResp bytes;
1735 esimFile->ConvertAuthInputParaFromApiStru(bytes, esimFile->esimProfile_);
1736 bool bRet = bytes.imei.empty() ? false : true;
1737 EXPECT_TRUE(bRet);
1738 }
1739
1740 HWTEST_F(EsimTest, ObtainEuiccInfo2_001, Function | MediumTest | Level2)
1741 {
1742 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1743 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1744 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1745 int32_t portIndex = 0;
1746 EuiccInfo2 EuiccInfo2;
1747 esimFile->currentChannelId_ = 0;
1748 EXPECT_EQ(EuiccInfo2.svn_, (esimFile->ObtainEuiccInfo2(portIndex)).svn_);
1749 int32_t slotId = 0;
1750 esimFile->currentChannelId_ = 2;
1751 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1752 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1753 esimFile->SetRilAndFileController(telRilManager, file, handler);
1754 EXPECT_EQ(EuiccInfo2.svn_, (esimFile->ObtainEuiccInfo2(portIndex)).svn_);
1755 }
1756
1757 HWTEST_F(EsimTest, ProcessObtainEUICCInfo2_001, Function | MediumTest | Level2)
1758 {
1759 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1760 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1761 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1762 int32_t slotId = 0;
1763 std::shared_ptr<Telephony::IccFile> iccFile = std::make_shared<EsimFile>(simStateManager);
1764 AppExecFwk::InnerEvent::Pointer eventEUICCInfo2 = iccFile->BuildCallerInfo(MSG_ESIM_OBTAIN_EUICC_INFO2_DONE);
1765 esimFile->currentChannelId_ = 0;
1766 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo2(slotId, eventEUICCInfo2), false);
1767 esimFile->currentChannelId_ = 2;
1768 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo2(slotId, eventEUICCInfo2), false);
1769 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1770 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1771 esimFile->SetRilAndFileController(telRilManager, file, handler);
1772 EXPECT_EQ(esimFile->ProcessObtainEuiccInfo2(slotId, eventEUICCInfo2), true);
1773 }
1774
1775 HWTEST_F(EsimTest, EuiccInfo2ParseProfileVersion_001, Function | MediumTest | Level2)
1776 {
1777 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1778 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1779 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1780 EuiccInfo2 euiccInfo2;
1781 std::string resultData =
1782 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1783 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1784 uint32_t byteLen = responseByte.size();
1785 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1786 esimFile->EuiccInfo2ParseProfileVersion(euiccInfo2, root);
1787 bool bRet = euiccInfo2.profileVersion_.empty() ? false : true;
1788 EXPECT_TRUE(bRet);
1789 }
1790
1791 HWTEST_F(EsimTest, EuiccInfo2ParseEuiccFirmwareVer_001, Function | MediumTest | Level2)
1792 {
1793 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1794 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1795 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1796 EuiccInfo2 euiccInfo2;
1797 std::string resultData =
1798 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1799 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1800 uint32_t byteLen = responseByte.size();
1801 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1802 esimFile->EuiccInfo2ParseEuiccFirmwareVer(euiccInfo2, root);
1803 bool bRet = euiccInfo2.globalPlatformVersion_.empty() ? false : true;
1804 EXPECT_TRUE(bRet);
1805 }
1806
1807 HWTEST_F(EsimTest, EuiccInfo2ParseExtCardResource_001, Function | MediumTest | Level2)
1808 {
1809 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1810 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1811 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1812 EuiccInfo2 euiccInfo2;
1813 std::string resultData =
1814 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1815 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1816 uint32_t byteLen = responseByte.size();
1817 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1818 esimFile->EuiccInfo2ParseExtCardResource(euiccInfo2, root);
1819 bool bRet = euiccInfo2.extCardResource_.empty() ? false : true;
1820 EXPECT_TRUE(bRet);
1821 }
1822
1823 HWTEST_F(EsimTest, EuiccInfo2ParseUiccCapability_001, Function | MediumTest | Level2)
1824 {
1825 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1826 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1827 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1828 EuiccInfo2 euiccInfo2;
1829 std::string resultData =
1830 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1831 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1832 uint32_t byteLen = responseByte.size();
1833 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1834 esimFile->EuiccInfo2ParseUiccCapability(euiccInfo2, root);
1835 bool bRet = euiccInfo2.uiccCapability_.empty() ? false : true;
1836 EXPECT_TRUE(bRet);
1837 }
1838
1839 HWTEST_F(EsimTest, EuiccInfo2ParseTs102241Version_001, Function | MediumTest | Level2)
1840 {
1841 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1842 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1843 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1844 EuiccInfo2 euiccInfo2;
1845 std::string resultData =
1846 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1847 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1848 uint32_t byteLen = responseByte.size();
1849 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1850 esimFile->EuiccInfo2ParseTs102241Version(euiccInfo2, root);
1851 bool bRet = euiccInfo2.ts102241Version_.empty() ? false : true;
1852 EXPECT_TRUE(bRet);
1853 }
1854
1855 HWTEST_F(EsimTest, EuiccInfo2ParseGlobalPlatformVersion_001, Function | MediumTest | Level2)
1856 {
1857 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1858 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1859 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1860 EuiccInfo2 euiccInfo2;
1861 std::string resultData =
1862 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1863 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1864 uint32_t byteLen = responseByte.size();
1865 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1866 esimFile->EuiccInfo2ParseGlobalPlatformVersion(euiccInfo2, root);
1867 bool bRet = euiccInfo2.globalPlatformVersion_.empty() ? false : true;
1868 EXPECT_TRUE(bRet);
1869 }
1870
1871 HWTEST_F(EsimTest, EuiccInfo2ParseRspCapability_001, Function | MediumTest | Level2)
1872 {
1873 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1874 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1875 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1876 EuiccInfo2 euiccInfo2;
1877 std::string resultData =
1878 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1879 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1880 uint32_t byteLen = responseByte.size();
1881 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1882 esimFile->EuiccInfo2ParseRspCapability(euiccInfo2, root);
1883 bool bRet = euiccInfo2.rspCapability_.empty() ? false : true;
1884 EXPECT_TRUE(bRet);
1885 }
1886
1887 HWTEST_F(EsimTest, EuiccInfo2ParseEuiccCiPKIdListForVerification_001, Function | MediumTest | Level2)
1888 {
1889 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1890 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1891 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1892 EuiccInfo2 euiccInfo2;
1893 std::string resultData =
1894 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1895 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1896 uint32_t byteLen = responseByte.size();
1897 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1898 esimFile->EuiccInfo2ParseEuiccCiPKIdListForVerification(euiccInfo2, root);
1899 bool bRet = euiccInfo2.euiccCiPKIdListForVerification_.empty() ? false : true;
1900 EXPECT_TRUE(bRet);
1901 }
1902
1903 HWTEST_F(EsimTest, EuiccInfo2ParseEuiccCiPKIdListForSigning_001, Function | MediumTest | Level2)
1904 {
1905 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1906 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1907 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1908 EuiccInfo2 euiccInfo2;
1909 std::string resultData =
1910 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1911 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1912 uint32_t byteLen = responseByte.size();
1913 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1914 esimFile->EuiccInfo2ParseEuiccCiPKIdListForSigning(euiccInfo2, root);
1915 bool bRet = euiccInfo2.euiccCiPKIdListForSigning_.empty() ? false : true;
1916 EXPECT_TRUE(bRet);
1917 }
1918
1919 HWTEST_F(EsimTest, EuiccInfo2ParseEuiccCategory_001, Function | MediumTest | Level2)
1920 {
1921 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1922 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1923 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1924 EuiccInfo2 euiccInfo2;
1925 std::string resultData =
1926 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1927 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1928 uint32_t byteLen = responseByte.size();
1929 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1930 esimFile->EuiccInfo2ParseEuiccCategory(euiccInfo2, root);
1931 bool bRet = euiccInfo2.euiccCategory_ == 0 ? false : true;
1932 EXPECT_TRUE(bRet);
1933 }
1934
1935 HWTEST_F(EsimTest, EuiccInfo2ParsePpVersion_001, Function | MediumTest | Level2)
1936 {
1937 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1938 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1939 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1940 EuiccInfo2 euiccInfo2;
1941 std::string resultData =
1942 "BF282BA029BF2F118001010C08736D64702E636F6081020136BF2F128001020C09736D6470322E636F608102AABB9000";
1943 std::vector<uint8_t> responseByte = Asn1Utils::HexStrToBytes(resultData);
1944 uint32_t byteLen = responseByte.size();
1945 std::shared_ptr<Asn1Node> root = esimFile->Asn1ParseResponse(responseByte, byteLen);
1946 esimFile->EuiccInfo2ParsePpVersion(euiccInfo2, root);
1947 bool bRet = euiccInfo2.ppVersion_.empty() ? false : true;
1948 EXPECT_TRUE(bRet);
1949 }
1950
1951 HWTEST_F(EsimTest, AuthenticateServer_001, Function | MediumTest | Level2)
1952 {
1953 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
1954 std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
1955 std::shared_ptr<Telephony::EsimFile> esimFile = std::make_shared<EsimFile>(simStateManager);
1956 AuthenticateConfigInfo authenticateConfigInfo;
1957 ResponseEsimResult responseAuthenticateResult;
1958 esimFile->currentChannelId_ = 0;
1959 EXPECT_EQ(static_cast<int32_t>(responseAuthenticateResult.resultCode_),
1960 (esimFile->AuthenticateServer(authenticateConfigInfo)).resultCode_);
1961 int32_t slotId = 0;
1962 esimFile->currentChannelId_ = 2;
1963 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
1964 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
1965 esimFile->SetRilAndFileController(telRilManager, file, handler);
1966 EXPECT_EQ(static_cast<int32_t>(responseAuthenticateResult.resultCode_),
1967 (esimFile->AuthenticateServer(authenticateConfigInfo)).resultCode_);
1968 }
1969 } // namespace Telephony
1970 } // namespace OHOS