• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "full_ime_info_manager.h"
18 #undef private
19 #include <gtest/gtest.h>
20 #include <sys/time.h>
21 #include <unistd.h>
22 
23 #include <string>
24 #include <vector>
25 
26 #include "global.h"
27 #include "ime_info_inquirer.h"
28 
29 using namespace testing::ext;
30 namespace OHOS {
31 namespace MiscServices {
32 class FullImeInfoManagerTest : public testing::Test {
33 public:
34     static void SetUpTestCase(void);
35     static void TearDownTestCase(void);
36     void SetUp();
37     void TearDown();
38 };
39 
SetUpTestCase(void)40 void FullImeInfoManagerTest::SetUpTestCase(void)
41 {
42     IMSA_HILOGI("FullImeInfoManagerTest::SetUpTestCase");
43 }
44 
TearDownTestCase(void)45 void FullImeInfoManagerTest::TearDownTestCase(void)
46 {
47     IMSA_HILOGI("FullImeInfoManagerTest::TearDownTestCase");
48     FullImeInfoManager::GetInstance().fullImeInfos_.clear();
49 }
50 
SetUp(void)51 void FullImeInfoManagerTest::SetUp(void)
52 {
53     IMSA_HILOGI("FullImeInfoManagerTest::SetUp");
54     FullImeInfoManager::GetInstance().fullImeInfos_.clear();
55 }
56 
TearDown(void)57 void FullImeInfoManagerTest::TearDown(void)
58 {
59     IMSA_HILOGI("FullImeInfoManagerTest::TearDown");
60 }
61 
62 /**
63  * @tc.name: test_Init_001
64  * @tc.desc: test Init that QueryFullImeInfo failed.
65  * @tc.type: FUNC
66  */
67 HWTEST_F(FullImeInfoManagerTest, test_Init_001, TestSize.Level0)
68 {
69     IMSA_HILOGI("test_Init_001 start");
70     // QueryFullImeInfo failed
71     std::vector<std::pair<int32_t, std::vector<FullImeInfo>>> fullImeInfos;
72     ImeInfoInquirer::GetInstance().SetFullImeInfo(false, fullImeInfos);
73     auto ret = FullImeInfoManager::GetInstance().Init();
74     EXPECT_EQ(ret, ErrorCode::ERROR_PACKAGE_MANAGER);
75 }
76 
77 /**
78  * @tc.name: test_Init_002
79  * @tc.desc: test Init succeed.
80  * @tc.type: FUNC
81  */
82 HWTEST_F(FullImeInfoManagerTest, test_Init_002, TestSize.Level0)
83 {
84     IMSA_HILOGI("test_Init_002 start");
85     int32_t userId = 100;
86     bool isNewIme = false;
87     uint32_t tokenId = 2;
88     std::string appId = "appId";
89     uint32_t versionCode = 11;
90     Property prop { "bundleName" };
91     std::vector<FullImeInfo> imeInfos;
92     imeInfos.push_back({ isNewIme, tokenId, appId, versionCode, prop });
93     std::vector<std::pair<int32_t, std::vector<FullImeInfo>>> fullImeInfos;
94     fullImeInfos.emplace_back(std::make_pair(userId, imeInfos));
95     ImeInfoInquirer::GetInstance().SetFullImeInfo(true, fullImeInfos);
96     auto ret = FullImeInfoManager::GetInstance().Init();
97     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
98     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
99     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
100     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
101     ASSERT_EQ(it->second.size(), 1);
102     auto imeInfo = it->second[0];
103     EXPECT_EQ(imeInfo.isNewIme, isNewIme);
104     EXPECT_EQ(imeInfo.tokenId, tokenId);
105     EXPECT_EQ(imeInfo.appId, appId);
106     EXPECT_EQ(imeInfo.versionCode, versionCode);
107     EXPECT_EQ(imeInfo.prop.name, prop.name);
108 }
109 
110 /**
111  * @tc.name: test_Add_001
112  * @tc.desc: test Add in user added that the userId exists
113  * @tc.type: FUNC
114  */
115 HWTEST_F(FullImeInfoManagerTest, test_Add_001, TestSize.Level0)
116 {
117     IMSA_HILOGI("test_Add_001 start");
118     int32_t userId = 100;
119     std::vector<FullImeInfo> imeInfos;
120     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
121     auto ret = FullImeInfoManager::GetInstance().Add(userId);
122     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
123 }
124 
125 /**
126  * @tc.name: test_Add_002
127  * @tc.desc: test Add in user added that QueryFullImeInfo failed
128  * @tc.type: FUNC
129  */
130 HWTEST_F(FullImeInfoManagerTest, test_Add_002, TestSize.Level0)
131 {
132     IMSA_HILOGI("test_Add_002 start");
133     int32_t userId = 100;
134     std::vector<FullImeInfo> imeInfos;
135     ImeInfoInquirer::GetInstance().SetFullImeInfo(false, imeInfos);
136     auto ret = FullImeInfoManager::GetInstance().Add(userId);
137     EXPECT_EQ(ret, ErrorCode::ERROR_PACKAGE_MANAGER);
138 }
139 
140 /**
141  * @tc.name: test_Add_003
142  * @tc.desc: test Add in user added succeed
143  * @tc.type: FUNC
144  */
145 HWTEST_F(FullImeInfoManagerTest, test_Add_003, TestSize.Level0)
146 {
147     IMSA_HILOGI("test_Add_003 start");
148     int32_t userId = 100;
149     std::vector<FullImeInfo> imeInfos;
150     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
151 
152     bool isNewIme = false;
153     uint32_t tokenId = 2;
154     std::string appId = "appId";
155     uint32_t versionCode = 11;
156     Property prop { "bundleName" };
157     FullImeInfo imeInfo { isNewIme, tokenId, appId, versionCode, prop };
158     uint32_t tokenId1 = 2;
159     std::string appId1 = "appId1";
160     Property prop1 { "bundleName1" };
161     FullImeInfo imeInfo1 { isNewIme, tokenId1, appId1, versionCode, prop1 };
162     imeInfos.push_back(imeInfo);
163     imeInfos.push_back(imeInfo1);
164     ImeInfoInquirer::GetInstance().SetFullImeInfo(true, imeInfos);
165 
166     int32_t userId1 = 101;
167     auto ret = FullImeInfoManager::GetInstance().Add(userId1);
168     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
169     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 2);
170     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId1);
171     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
172     ASSERT_EQ(it->second.size(), 2);
173     EXPECT_EQ(it->second[0].isNewIme, isNewIme);
174     EXPECT_EQ(it->second[0].tokenId, tokenId);
175     EXPECT_EQ(it->second[0].appId, appId);
176     EXPECT_EQ(it->second[0].versionCode, versionCode);
177     EXPECT_EQ(it->second[0].prop.name, prop.name);
178     EXPECT_EQ(it->second[1].isNewIme, isNewIme);
179     EXPECT_EQ(it->second[1].tokenId, tokenId1);
180     EXPECT_EQ(it->second[1].appId, appId1);
181     EXPECT_EQ(it->second[1].versionCode, versionCode);
182     EXPECT_EQ(it->second[1].prop.name, prop1.name);
183 }
184 
185 /**
186  * @tc.name: test_Add_004
187  * @tc.desc: test Add in package added that GetFullImeInfo failed
188  * @tc.type: FUNC
189  */
190 HWTEST_F(FullImeInfoManagerTest, test_Add_004, TestSize.Level0)
191 {
192     IMSA_HILOGI("test_Add_004 start");
193     FullImeInfo imeInfo;
194     ImeInfoInquirer::GetInstance().SetFullImeInfo(false, imeInfo);
195     int32_t userId = 100;
196     std::string bundleName = "bundleName";
197     auto ret = FullImeInfoManager::GetInstance().Add(userId, bundleName);
198     EXPECT_EQ(ret, ErrorCode::ERROR_PACKAGE_MANAGER);
199 }
200 
201 /**
202  * @tc.name: test_Add_005
203  * @tc.desc: test Add in package added that userId does not exist;
204  * @tc.type: FUNC
205  */
206 HWTEST_F(FullImeInfoManagerTest, test_Add_005, TestSize.Level0)
207 {
208     IMSA_HILOGI("test_Add_005 start");
209     FullImeInfo imeInfo;
210     ImeInfoInquirer::GetInstance().SetFullImeInfo(true, imeInfo);
211     int32_t userId = 100;
212     std::string bundleName = "bundleName";
213     auto ret = FullImeInfoManager::GetInstance().Add(userId, bundleName);
214     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
215     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
216     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
217     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
218     EXPECT_EQ(it->second.size(), 1);
219 }
220 
221 /**
222  * @tc.name: test_Add_006
223  * @tc.desc: test Add in package added that bundleName does not exist;
224  * @tc.type: FUNC
225  */
226 HWTEST_F(FullImeInfoManagerTest, test_Add_006, TestSize.Level0)
227 {
228     IMSA_HILOGI("test_Add_006 start");
229     int32_t userId = 100;
230     std::vector<FullImeInfo> imeInfos;
231     FullImeInfo imeInfo;
232     imeInfo.prop.name = "bundleName";
233     imeInfos.push_back(imeInfo);
234     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
235 
236     FullImeInfo imeInfo1;
237     imeInfo1.prop.name = "bundleName1";
238     ImeInfoInquirer::GetInstance().SetFullImeInfo(true, imeInfo1);
239 
240     std::string bundleName = "bundleName1";
241     auto ret = FullImeInfoManager::GetInstance().Add(userId, bundleName);
242     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
243     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
244     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
245     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
246     ASSERT_EQ(it->second.size(), 2);
247     EXPECT_EQ(it->second[0].prop.name, imeInfo.prop.name);
248     EXPECT_EQ(it->second[1].prop.name, imeInfo1.prop.name);
249 }
250 
251 /**
252  * @tc.name: test_Add_007
253  * @tc.desc: test Add in package added that bundleName exists;
254  * @tc.type: FUNC
255  */
256 HWTEST_F(FullImeInfoManagerTest, test_Add_007, TestSize.Level0)
257 {
258     IMSA_HILOGI("test_Add_007 start");
259     int32_t userId = 100;
260     std::vector<FullImeInfo> imeInfos;
261     FullImeInfo imeInfo;
262     imeInfo.isNewIme = true;
263     imeInfo.prop.name = "bundleName";
264     imeInfos.push_back(imeInfo);
265     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
266 
267     FullImeInfo imeInfo1;
268     imeInfo1.isNewIme = false;
269     imeInfo1.prop.name = "bundleName";
270     ImeInfoInquirer::GetInstance().SetFullImeInfo(true, imeInfo1);
271 
272     std::string bundleName = "bundleName";
273     auto ret = FullImeInfoManager::GetInstance().Add(userId, bundleName);
274     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
275     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
276     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
277     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
278     ASSERT_EQ(it->second.size(), 1);
279     EXPECT_FALSE(it->second[0].isNewIme);
280 }
281 
282 /**
283  * @tc.name: test_Update_001
284  * @tc.desc: test Update in language change that Init failed
285  * @tc.type: FUNC
286  */
287 HWTEST_F(FullImeInfoManagerTest, test_Update_001, TestSize.Level0)
288 {
289     IMSA_HILOGI("test_Update_001 start");
290     int32_t userId = 100;
291     std::vector<FullImeInfo> imeInfos;
292     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
293 
294     std::vector<std::pair<int32_t, std::vector<FullImeInfo>>> fullImeInfos;
295     ImeInfoInquirer::GetInstance().SetFullImeInfo(false, fullImeInfos);
296     auto ret = FullImeInfoManager::GetInstance().Update();
297     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
298     EXPECT_TRUE(FullImeInfoManager::GetInstance().fullImeInfos_.empty());
299 }
300 
301 /**
302  * @tc.name: test_Update_002
303  * @tc.desc: test Update in language change succeed
304  * @tc.type: FUNC
305  */
306 HWTEST_F(FullImeInfoManagerTest, test_Update_002, TestSize.Level0)
307 {
308     IMSA_HILOGI("test_Update_002 start");
309     int32_t userId = 100;
310     std::vector<FullImeInfo> imeInfos;
311     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
312 
313     int32_t userId1 = 101;
314     std::vector<FullImeInfo> imeInfos1;
315     int32_t userId2 = 102;
316     std::vector<FullImeInfo> imeInfos2;
317     std::vector<std::pair<int32_t, std::vector<FullImeInfo>>> fullImeInfos;
318     fullImeInfos.emplace_back(std::make_pair(userId1, imeInfos1));
319     fullImeInfos.emplace_back(std::make_pair(userId2, imeInfos2));
320     ImeInfoInquirer::GetInstance().SetFullImeInfo(true, fullImeInfos);
321 
322     auto ret = FullImeInfoManager::GetInstance().Update();
323     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
324     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 2);
325     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
326     ASSERT_EQ(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
327     auto it1 = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId1);
328     ASSERT_NE(it1, FullImeInfoManager::GetInstance().fullImeInfos_.end());
329     auto it2 = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId2);
330     ASSERT_NE(it2, FullImeInfoManager::GetInstance().fullImeInfos_.end());
331 }
332 
333 /**
334  * @tc.name: test_Delete_001
335  * @tc.desc: test Delete in user removed that userId does not exist
336  * @tc.type: FUNC
337  */
338 HWTEST_F(FullImeInfoManagerTest, test_Delete_001, TestSize.Level0)
339 {
340     IMSA_HILOGI("test_Delete_001 start");
341     int32_t userId = 100;
342     std::vector<FullImeInfo> imeInfos;
343     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
344 
345     int32_t userId1 = 101;
346     auto ret = FullImeInfoManager::GetInstance().Delete(userId1);
347     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
348     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
349     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
350     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
351 }
352 
353 /**
354  * @tc.name: test_Delete_002
355  * @tc.desc: test Delete in user removed that userId exists
356  * @tc.type: FUNC
357  */
358 HWTEST_F(FullImeInfoManagerTest, test_Delete_002, TestSize.Level0)
359 {
360     IMSA_HILOGI("test_Delete_002 start");
361     int32_t userId = 100;
362     std::vector<FullImeInfo> imeInfos;
363     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
364 
365     auto ret = FullImeInfoManager::GetInstance().Delete(userId);
366     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
367     ASSERT_TRUE(FullImeInfoManager::GetInstance().fullImeInfos_.empty());
368 
369     int32_t userId1 = 101;
370     std::vector<FullImeInfo> imeInfos1;
371     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId1, imeInfos1);
372     int32_t userId2 = 102;
373     std::vector<FullImeInfo> imeInfos2;
374     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId2, imeInfos2);
375     ret = FullImeInfoManager::GetInstance().Delete(userId2);
376     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
377     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
378     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId2);
379     ASSERT_EQ(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
380 }
381 
382 /**
383  * @tc.name: test_Delete_003
384  * @tc.desc: test Delete in package removed that userId does not exist
385  * @tc.type: FUNC
386  */
387 HWTEST_F(FullImeInfoManagerTest, test_Delete_003, TestSize.Level0)
388 {
389     IMSA_HILOGI("test_Delete_003 start");
390     int32_t userId = 100;
391     std::vector<FullImeInfo> imeInfos;
392     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
393 
394     int32_t userId1 = 101;
395     std::string bundleName = "bundleName";
396     auto ret = FullImeInfoManager::GetInstance().Delete(userId1, bundleName);
397     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
398     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
399     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
400     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
401 }
402 
403 /**
404  * @tc.name: test_Delete_004
405  * @tc.desc: test Delete in package removed that bundleName does not exist
406  * @tc.type: FUNC
407  */
408 HWTEST_F(FullImeInfoManagerTest, test_Delete_004, TestSize.Level0)
409 {
410     IMSA_HILOGI("test_Delete_004 start");
411     int32_t userId = 100;
412     std::vector<FullImeInfo> imeInfos;
413     FullImeInfo imeInfo;
414     imeInfo.prop.name = "bundleName";
415     imeInfos.push_back(imeInfo);
416     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
417 
418     std::string bundleName = "bundleName1";
419     auto ret = FullImeInfoManager::GetInstance().Delete(userId, bundleName);
420     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
421     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
422     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
423     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
424     ASSERT_EQ(it->second.size(), 1);
425     EXPECT_EQ(it->second[0].prop.name, imeInfo.prop.name);
426 }
427 
428 /**
429  * @tc.name: test_Delete_005
430  * @tc.desc: test Delete in package removed that bundleName exist
431  * @tc.type: FUNC
432  */
433 HWTEST_F(FullImeInfoManagerTest, test_Delete_005, TestSize.Level0)
434 {
435     IMSA_HILOGI("test_Delete_005 start");
436     int32_t userId = 100;
437     std::vector<FullImeInfo> imeInfos;
438     FullImeInfo imeInfo;
439     imeInfo.prop.name = "bundleName";
440     imeInfos.push_back(imeInfo);
441     FullImeInfo imeInfo1;
442     imeInfo1.prop.name = "bundleName1";
443     imeInfos.push_back(imeInfo1);
444     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
445 
446     std::string bundleName1 = "bundleName1";
447     auto ret = FullImeInfoManager::GetInstance().Delete(userId, bundleName1);
448     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
449     EXPECT_EQ(FullImeInfoManager::GetInstance().fullImeInfos_.size(), 1);
450     auto it = FullImeInfoManager::GetInstance().fullImeInfos_.find(userId);
451     ASSERT_NE(it, FullImeInfoManager::GetInstance().fullImeInfos_.end());
452     ASSERT_EQ(it->second.size(), 1);
453     EXPECT_EQ(it->second[0].prop.name, imeInfo.prop.name);
454 
455     std::string bundleName = "bundleName";
456     ret = FullImeInfoManager::GetInstance().Delete(userId, bundleName);
457     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
458     EXPECT_TRUE(FullImeInfoManager::GetInstance().fullImeInfos_.empty());
459 }
460 
461 /**
462  * @tc.name: test_Get_001
463  * @tc.desc: test Get that by userId that userId does not exist
464  * @tc.type: FUNC
465  */
466 HWTEST_F(FullImeInfoManagerTest, test_Get_001, TestSize.Level0)
467 {
468     IMSA_HILOGI("test_Get_001 start");
469     int32_t userId = 100;
470     std::vector<FullImeInfo> imeInfos;
471     FullImeInfo info;
472     imeInfos.push_back(info);
473     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
474 
475     int32_t userId1 = 101;
476     auto ret = FullImeInfoManager::GetInstance().Get(userId1);
477     EXPECT_TRUE(ret.empty());
478 }
479 
480 /**
481  * @tc.name: test_Get_002
482  * @tc.desc: test Get that by userId that userId exist
483  * @tc.type: FUNC
484  */
485 HWTEST_F(FullImeInfoManagerTest, test_Get_002, TestSize.Level0)
486 {
487     IMSA_HILOGI("test_Get_002 start");
488     int32_t userId = 100;
489     std::vector<FullImeInfo> imeInfos;
490     FullImeInfo info;
491     imeInfos.push_back(info);
492     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
493 
494     auto ret = FullImeInfoManager::GetInstance().Get(userId);
495     EXPECT_EQ(ret.size(), 1);
496 }
497 
498 /**
499  * @tc.name: test_Get_003
500  * @tc.desc: test Get that by userId and bundleName that userId does not exist
501  * @tc.type: FUNC
502  */
503 HWTEST_F(FullImeInfoManagerTest, test_Get_003, TestSize.Level0)
504 {
505     IMSA_HILOGI("test_Get_003 start");
506     int32_t userId = 100;
507     std::vector<FullImeInfo> imeInfos;
508     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
509 
510     int32_t userId1 = 101;
511     std::string bundleName = "bundleName";
512     FullImeInfo info;
513     auto ret = FullImeInfoManager::GetInstance().Get(bundleName, userId1, info);
514     EXPECT_FALSE(ret);
515 }
516 
517 /**
518  * @tc.name: test_Get_004
519  * @tc.desc: test Get that by userId and bundleName that bundleName does not exist
520  * @tc.type: FUNC
521  */
522 HWTEST_F(FullImeInfoManagerTest, test_Get_004, TestSize.Level0)
523 {
524     IMSA_HILOGI("test_Get_004 start");
525     int32_t userId = 100;
526     std::vector<FullImeInfo> imeInfos;
527     FullImeInfo info;
528     info.prop.name = "bundleName1";
529     imeInfos.push_back(info);
530     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
531 
532     int32_t userId1 = 100;
533     std::string bundleName = "bundleName";
534     FullImeInfo infoRet;
535     auto ret = FullImeInfoManager::GetInstance().Get(bundleName, userId1, infoRet);
536     EXPECT_FALSE(ret);
537 }
538 
539 /**
540  * @tc.name: test_Get_005
541  * @tc.desc: test Get that by userId and bundleName succeed
542  * @tc.type: FUNC
543  */
544 HWTEST_F(FullImeInfoManagerTest, test_Get_005, TestSize.Level0)
545 {
546     IMSA_HILOGI("test_Get_005 start");
547     int32_t userId = 100;
548     std::vector<FullImeInfo> imeInfos;
549     FullImeInfo info;
550     info.prop.name = "bundleName1";
551     imeInfos.push_back(info);
552     FullImeInfoManager::GetInstance().fullImeInfos_.insert_or_assign(userId, imeInfos);
553 
554     int32_t userId1 = 100;
555     std::string bundleName = "bundleName1";
556     FullImeInfo infoRet;
557     auto ret = FullImeInfoManager::GetInstance().Get(bundleName, userId1, infoRet);
558     EXPECT_TRUE(ret);
559     EXPECT_EQ(infoRet.prop.name, info.prop.name);
560 }
561 } // namespace MiscServices
562 } // namespace OHOS