• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <gtest/gtest.h>
16 #include <memory>
17 #include "form_caller_mgr.h"
18 #define private public
19 #define protected public
20 #include "form_mgr.h"
21 #include "form_errors.h"
22 #include "iservice_registry.h"
23 #undef private
24 #undef protected
25 #include "form_mgr_errors.h"
26 #include "mock_form_provider_client.h"
27 #include "gmock/gmock.h"
28 #include "mock_form_mgr_proxy.h"
29 #include "mock_form_token.h"
30 #include "if_system_ability_manager.h"
31 #include "mock_system_ability_manager.h"
32 
33 
34 using namespace testing::ext;
35 using namespace OHOS;
36 using namespace OHOS::AppExecFwk;
37 
38 using ::testing::Return;
39 using ::testing::SetArgReferee;
40 using ::testing::ContainerEq;
41 using ::testing::_;
42 using ::testing::DoAll;
43 
44 // overload operator for ContainerEq
45 namespace OHOS::AppExecFwk {
operator ==(const FormInfo & lhs,const FormInfo & rhs)46     bool operator==(const FormInfo& lhs, const FormInfo& rhs)
47     {
48         if (lhs.bundleName != rhs.bundleName) {
49             return false;
50         }
51         if (lhs.moduleName != rhs.moduleName) {
52             return false;
53         }
54         if (lhs.name != rhs.name) {
55             return false;
56         }
57         // to be continued...
58         return true;
59     }
60 }
61 
62 namespace {
63 class FormMgrTest : public testing::Test {
64 public:
65     // TestSuite setup has to be static
SetUpTestCase()66     static void SetUpTestCase()
67     {
68         if (mockProxy == nullptr) {
69             GTEST_LOG_(INFO) << "SetUpTestCase";
70             sptr<IRemoteObject> impl = nullptr;
71             mockProxy = new (std::nothrow) MockFormMgrProxy(impl);
72             FormMgr::GetInstance().SetFormMgrService(mockProxy);
73         }
74     }
75     // TearDown is unnecessary.
76     // TestSuite setup has to be static
77     static sptr<MockFormMgrProxy> mockProxy;
78 };
79 // initialize static variable.
80 sptr<MockFormMgrProxy> FormMgrTest::mockProxy = nullptr;
81 
82 /**
83  * @tc.name: FormMgrTest_0001
84  * @tc.desc: Verify GetFormsInfo
85  * @tc.type: FUNC
86  * @tc.require: #I59O23
87  */
88 HWTEST_F(FormMgrTest, FormMgrTest_0001, TestSize.Level1) {
89     GTEST_LOG_(INFO) << "FormMgrTest_0001 starts";
90     // initialize input parameters.
91     FormInfoFilter filter;
92     filter.moduleName = "";
93     std::vector<FormInfo> formInfos;
94     // setup expectations.
95     std::vector<FormInfo> expectFormInfos;
96     FormInfo formInfo = {};
97     formInfo.bundleName = "ohos.samples.FormApplication";
98     expectFormInfos.push_back(formInfo);
99     EXPECT_CALL(*mockProxy, GetFormsInfo(_, _))
100         .Times(1)
101         .WillOnce(DoAll(SetArgReferee<1>(expectFormInfos), Return(ERR_OK)));
102     // test.
103     FormMgr::GetInstance().GetFormsInfo(filter, formInfos);
104     // expect result.
105     EXPECT_THAT(formInfos, ContainerEq(expectFormInfos));
106     // FormMgr is a singleton, therefore, deleteing it will cause segfault for other invocations.
107     testing::Mock::AllowLeak(mockProxy);
108     GTEST_LOG_(INFO) << "FormMgrTest_0001 test ends";
109 }
110 
111 /**
112  * @tc.name: FormMgrTest_0002
113  * @tc.desc: Verify GetFormsInfo
114  * @tc.type: FUNC
115  * @tc.require: #I59O23
116  */
117 HWTEST_F(FormMgrTest, FormMgrTest_0002, TestSize.Level1) {
118     GTEST_LOG_(INFO) << "FormMgrTest_0002 starts";
119     // initialize input parameters.
120     FormInfoFilter filter;
121     filter.moduleName = "empty";
122     std::vector<FormInfo> formInfos;
123     // setup expectations.
124     std::vector<FormInfo> expectFormInfos;
125     FormInfo formInfo = {};
126     formInfo.bundleName = "ohos.samples.FormApplication";
127     formInfo.moduleName = "entry";
128     expectFormInfos.push_back(formInfo);
129     EXPECT_CALL(*mockProxy, GetFormsInfo(_, _))
130         .Times(1)
131         .WillOnce(Return(ERR_OK));
132     // test.
133     FormMgr::GetInstance().GetFormsInfo(filter, formInfos);
134     // expect result.
135     EXPECT_EQ(formInfos.size(), 0);
136     testing::Mock::AllowLeak(mockProxy);
137     GTEST_LOG_(INFO) << "FormMgrTest_0002 test ends";
138 }
139 
140 /**
141  * @tc.name: FormMgrTest_0003
142  * @tc.desc: Verify IsRequestPublishFormSupported
143  * @tc.type: FUNC
144  * @tc.require: #I58Y0A
145  */
146 HWTEST_F(FormMgrTest, FormMgrTest_0003, TestSize.Level1) {
147     GTEST_LOG_(INFO) << "FormMgrTest_0003 starts";
148     EXPECT_CALL(*mockProxy, IsRequestPublishFormSupported())
149         .Times(1)
150         .WillOnce(Return(false));
151     bool result = FormMgr::GetInstance().IsRequestPublishFormSupported();
152     EXPECT_EQ(result, false);
153     GTEST_LOG_(INFO) << "FormMgrTest_0003 test ends";
154 }
155 
156 /**
157  * @tc.name: FormMgrTest_0004
158  * @tc.desc: Verify StartAbility
159  * @tc.type: FUNC
160  * @tc.require: #I5EFDX
161  */
162 HWTEST_F(FormMgrTest, FormMgrTest_0004, TestSize.Level1) {
163     GTEST_LOG_(INFO) << "FormMgrTest_0004 starts";
164     EXPECT_CALL(*mockProxy, StartAbility(_, _))
165         .Times(1)
166         .WillOnce(Return(0));
167     Want want;
168     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
169     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
170     int32_t result = FormMgr::GetInstance().StartAbility(want, token);
171     EXPECT_EQ(result, 0);
172     GTEST_LOG_(INFO) << "FormMgrTest_0004 test ends";
173 }
174 
175 /**
176  * @tc.name: FormMgrTest_0005
177  * @tc.desc: Verify UpdateForm
178  * @tc.type: FUNC
179  * @tc.require: issueI5PFT9
180  */
181 HWTEST_F(FormMgrTest, FormMgrTest_0005, TestSize.Level1) {
182     GTEST_LOG_(INFO) << "FormMgrTest_0005 starts";
183     EXPECT_CALL(*mockProxy, UpdateForm(_, _))
184         .Times(1)
185         .WillOnce(Return(0));
186     FormJsInfo formJsInfo;
187     formJsInfo.formId = 1;
188     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
189     sptr<IRemoteObject> providerToken = new (std::nothrow) MockFormProviderClient();
190     FormCallerMgr::GetInstance().AddFormHostCaller(formJsInfo, providerToken);
191     FormProviderData formProviderData = FormProviderData(std::string("{\"city\": \"beijing001\"}"));
192     int32_t result = FormMgr::GetInstance().UpdateForm(formJsInfo.formId, formProviderData);
193     EXPECT_EQ(result, 0);
194     GTEST_LOG_(INFO) << "FormMgrTest_0005 test ends";
195 }
196 
197 /**
198  * @tc.name: FormMgrTest_0006
199  * @tc.desc: Verify RequestForm
200  * @tc.type: FUNC
201  * @tc.require: issueI5Q8IU
202  */
203 HWTEST_F(FormMgrTest, FormMgrTest_0006, TestSize.Level1) {
204     GTEST_LOG_(INFO) << "FormMgrTest_0006 starts";
205     EXPECT_CALL(*mockProxy, RequestForm(_, _, _))
206         .Times(1)
207         .WillOnce(Return(0));
208     Want want;
209     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
210     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
211     FormJsInfo formJsInfo;
212     formJsInfo.formId = 1;
213     sptr<IRemoteObject> providerToken = new (std::nothrow) MockFormProviderClient();
214     FormCallerMgr::GetInstance().AddFormHostCaller(formJsInfo, providerToken);
215     int32_t result = FormMgr::GetInstance().RequestForm(formJsInfo.formId, token, want);
216     EXPECT_EQ(result, 0);
217     GTEST_LOG_(INFO) << "FormMgrTest_0006 test ends";
218 }
219 
220 /**
221  * @tc.name: FormMgrTest_0007
222  * @tc.desc: Verify MessageEvent
223  * @tc.type: FUNC
224  * @tc.require: issueI5QGMS
225  */
226 HWTEST_F(FormMgrTest, FormMgrTest_0007, TestSize.Level1) {
227     GTEST_LOG_(INFO) << "FormMgrTest_0007 starts";
228     EXPECT_CALL(*mockProxy, MessageEvent(_, _, _))
229         .Times(1)
230         .WillOnce(Return(0));
231     Want want;
232     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
233     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
234     FormJsInfo formJsInfo;
235     sptr<IRemoteObject> providerToken = new (std::nothrow) MockFormProviderClient();
236     FormCallerMgr::GetInstance().AddFormHostCaller(formJsInfo, providerToken);
237     int32_t result = FormMgr::GetInstance().MessageEvent(formJsInfo.formId, want, token);
238     EXPECT_EQ(result, 0);
239     GTEST_LOG_(INFO) << "FormMgrTest_0007 test ends";
240 }
241 
242 /**
243  * @tc.name: FormMgrTest_0005
244  * @tc.desc: Verify NotifyFormsPrivacyProtected
245  * @tc.type: FUNC
246  * @tc.require: I5ST27
247  */
248 HWTEST_F(FormMgrTest, FormMgrTest_0008, TestSize.Level1) {
249     GTEST_LOG_(INFO) << "FormMgrTest_0008 starts";
250     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
251         .Times(1)
252         .WillOnce(Return(0));
253     // initialize input parameters.
254     int64_t formId = 1;
255     std::vector<int64_t> formIds;
256     formIds.push_back(formId);
257     bool isProtected = false;
258     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
259     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
260     // expect result.
261     EXPECT_EQ(result, 0);
262     GTEST_LOG_(INFO) << "FormMgrTest_0008 test ends";
263 }
264 
265 /**
266  * @tc.name: FormMgrTest_0006
267  * @tc.desc: Verify NotifyFormsPrivacyProtected
268  * @tc.type: FUNC
269  * @tc.require: I5ST27
270  */
271 HWTEST_F(FormMgrTest, FormMgrTest_0009, TestSize.Level1) {
272     GTEST_LOG_(INFO) << "FormMgrTest_0009 starts";
273     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
274         .Times(1)
275         .WillOnce(Return(0));
276     // initialize input parameters.
277     int64_t formId = 2;
278     std::vector<int64_t> formIds;
279     formIds.push_back(formId);
280     bool isProtected = true;
281     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
282     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
283     // expect result.
284     EXPECT_EQ(result, 0);
285     GTEST_LOG_(INFO) << "FormMgrTest_0009 test ends";
286 }
287 
288 /**
289  * @tc.name: FormMgrTest_0007
290  * @tc.desc: Verify NotifyFormsPrivacyProtected
291  * @tc.type: FUNC
292  * @tc.require: I5ST27
293  */
294 HWTEST_F(FormMgrTest, FormMgrTest_0010, TestSize.Level1) {
295     GTEST_LOG_(INFO) << "FormMgrTest_0010 starts";
296     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
297         .Times(1)
298         .WillOnce(Return(0));
299     // initialize input parameters.
300     int64_t formId1 = 3;
301     int64_t formId2 = 4;
302     std::vector<int64_t> formIds;
303     formIds.push_back(formId1);
304     formIds.push_back(formId2);
305     bool isProtected = false;
306     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
307     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
308     // expect result.
309     EXPECT_EQ(result, 0);
310     GTEST_LOG_(INFO) << "FormMgrTest_0010 test ends";
311 }
312 
313 /**
314  * @tc.name: FormMgrTest_0011
315  * @tc.desc: Verify NotifyFormsPrivacyProtected
316  * @tc.type: FUNC
317  * @tc.require: I5ST27
318  */
319 HWTEST_F(FormMgrTest, FormMgrTest_0011, TestSize.Level1) {
320     GTEST_LOG_(INFO) << "FormMgrTest_0008 starts";
321     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
322         .Times(1)
323         .WillOnce(Return(0));
324     // initialize input parameters.
325     int64_t formId1 = 5;
326     int64_t formId2 = 6;
327     std::vector<int64_t> formIds;
328     formIds.push_back(formId1);
329     formIds.push_back(formId2);
330     bool isProtected = true;
331     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
332     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
333     // expect result.
334     EXPECT_EQ(result, 0);
335     GTEST_LOG_(INFO) << "FormMgrTest_0011 test ends";
336 }
337 
338 /**
339  * @tc.name: FormMgrTest_0012
340  * @tc.desc: Verify GetErrorMsg
341  * @tc.type: FUNC
342  */
343 HWTEST_F(FormMgrTest, FormMgrTest_0012, TestSize.Level1) {
344     GTEST_LOG_(INFO) << "FormMgrTest_0012 starts";
345     int errorCode = 0;
346     auto result = FormMgr::GetInstance().GetErrorMsg(errorCode);
347 
348     EXPECT_EQ(result, "unknown error");
349     GTEST_LOG_(INFO) << "FormMgrTest_0012 test ends";
350 }
351 
352 /**
353  * @tc.name: FormMgrTest_0013
354  * @tc.desc: Verify DumpStorageFormInfos
355  * @tc.type: FUNC
356  */
357 HWTEST_F(FormMgrTest, FormMgrTest_0013, TestSize.Level1) {
358     GTEST_LOG_(INFO) << "FormMgrTest_0013 starts";
359     EXPECT_CALL(*mockProxy, DumpStorageFormInfos(_))
360     .Times(1)
361     .WillOnce(Return(0));
362     std::string formInfos = "a";
363     auto result = FormMgr::GetInstance().DumpStorageFormInfos(formInfos);
364 
365     EXPECT_EQ(result, 0);
366     GTEST_LOG_(INFO) << "FormMgrTest_0013 test ends";
367 }
368 
369 /**
370  * @tc.name: FormMgrTest_0014
371  * @tc.desc: Verify DumpFormInfoByFormId
372  * @tc.type: FUNC
373  */
374 HWTEST_F(FormMgrTest, FormMgrTest_0014, TestSize.Level1) {
375     GTEST_LOG_(INFO) << "FormMgrTest_0014 starts";
376     EXPECT_CALL(*mockProxy, DumpFormInfoByFormId(_, _))
377     .Times(1)
378     .WillOnce(Return(0));
379     std::string formInfos = "a";
380     std::int64_t formId = 3;
381     auto result = FormMgr::GetInstance().DumpFormInfoByFormId(formId, formInfos);
382 
383     EXPECT_EQ(result, 0);
384     GTEST_LOG_(INFO) << "FormMgrTest_0014 test ends";
385 }
386 
387 /**
388  * @tc.name: FormMgrTest_0015
389  * @tc.desc: Verify DumpFormTimerByFormId
390  * @tc.type: FUNC
391  */
392 HWTEST_F(FormMgrTest, FormMgrTest_0015, TestSize.Level1) {
393     GTEST_LOG_(INFO) << "FormMgrTest_0015 starts";
394     EXPECT_CALL(*mockProxy, DumpFormTimerByFormId(_, _))
395     .Times(1)
396     .WillOnce(Return(0));
397     std::string isTimingService = "b";
398     std::int64_t formId = 3;
399     auto result = FormMgr::GetInstance().DumpFormTimerByFormId(formId, isTimingService);
400 
401     EXPECT_EQ(result, 0);
402     GTEST_LOG_(INFO) << "FormMgrTest_0015 test ends";
403 }
404 
405 /**
406  * @tc.name: FormMgrTest_0016
407  * @tc.desc: Verify RouterEvent
408  * @tc.type: FUNC
409  */
410 HWTEST_F(FormMgrTest, FormMgrTest_0016, TestSize.Level1) {
411     GTEST_LOG_(INFO) << "FormMgrTest_0016 starts";
412     EXPECT_CALL(*mockProxy, RouterEvent(_, _, _))
413         .Times(1)
414         .WillOnce(Return(0));
415     Want want;
416     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
417     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
418     FormJsInfo formJsInfo;
419     sptr<IRemoteObject> providerToken = new (std::nothrow) MockFormProviderClient();
420     FormCallerMgr::GetInstance().AddFormHostCaller(formJsInfo, providerToken);
421     int32_t result = FormMgr::GetInstance().RouterEvent(formJsInfo.formId, want, token);
422 
423     EXPECT_EQ(result, 0);
424     GTEST_LOG_(INFO) << "FormMgrTest_0016 test ends";
425 }
426 
427 /**
428  * @tc.name: FormMgrTest_0017
429  * @tc.desc: Verify SetNextRefreshTime
430  * @tc.type: FUNC
431  */
432 HWTEST_F(FormMgrTest, FormMgrTest_0017, TestSize.Level1) {
433     GTEST_LOG_(INFO) << "FormMgrTest_0017 starts";
434     int64_t formId = 1;
435     int64_t nextTime = 2;
436     auto result = FormMgr::GetInstance().SetNextRefreshTime(formId, nextTime);
437 
438     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_REFRESH_TIME);
439     GTEST_LOG_(INFO) << "FormMgrTest_0017 test ends";
440 }
441 
442 /**
443  * @tc.name: FormMgrTest_0018
444  * @tc.desc: Verify GetErrorMessage
445  * @tc.type: FUNC
446  */
447 HWTEST_F(FormMgrTest, FormMgrTest_0018, TestSize.Level1) {
448     GTEST_LOG_(INFO) << "FormMgrTest_0018 starts";
449     FormErrors::GetInstance().InitErrorMessageMap();
450     int errCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
451     auto result = FormMgr::GetInstance().GetErrorMessage(errCode);
452 
453     EXPECT_EQ(result, "check permission deny, need to request ohos.permission.REQUIRE_FORM.");
454     GTEST_LOG_(INFO) << "FormMgrTest_0018 test ends";
455 }
456 
457 /**
458  * @tc.name: FormMgrTest_0019
459  * @tc.desc: Verify DeleteInvalidForms
460  * @tc.type: FUNC
461  */
462 HWTEST_F(FormMgrTest, FormMgrTest_0019, TestSize.Level1) {
463     GTEST_LOG_(INFO) << "FormMgrTest_0019 starts";
464     EXPECT_CALL(*mockProxy, DeleteInvalidForms(_, _, _))
465     .Times(1)
466     .WillOnce(Return(0));
467     std::vector<int64_t> formInfos;
468     formInfos.push_back(1);
469     formInfos.push_back(2);
470     FormJsInfo formJsInfo;
471     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
472     int32_t numFormsDeleted = 2;
473     auto result = FormMgr::GetInstance().DeleteInvalidForms(formInfos, token, numFormsDeleted);
474 
475     EXPECT_EQ(result, 0);
476     GTEST_LOG_(INFO) << "FormMgrTest_0019 test ends";
477 }
478 
479 /**
480  * @tc.name: FormMgrTest_0020
481  * @tc.desc: Verify DumpStorageFormInfos
482  * @tc.type: FUNC
483  */
484 HWTEST_F(FormMgrTest, FormMgrTest_0020, TestSize.Level1) {
485     GTEST_LOG_(INFO) << "FormMgrTest_0020 starts";
486     EXPECT_CALL(*mockProxy, NotifyFormsVisible(_, _, _))
487         .Times(1)
488         .WillOnce(Return(0));
489     int64_t formId1 = 5;
490     int64_t formId2 = 6;
491     std::vector<int64_t> formIds;
492     formIds.push_back(formId1);
493     formIds.push_back(formId2);
494     bool isProtected = true;
495     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
496     int32_t result = FormMgr::GetInstance().NotifyFormsVisible(formIds, isProtected, token);
497 
498     EXPECT_EQ(result, 0);
499     GTEST_LOG_(INFO) << "FormMgrTest_0020 test ends";
500 }
501 
502 /**
503  * @tc.name: FormMgrTest_0021
504  * @tc.desc: Verify NotifyFormsEnableUpdate
505  * @tc.type: FUNC
506  */
507 HWTEST_F(FormMgrTest, FormMgrTest_0021, TestSize.Level1) {
508     GTEST_LOG_(INFO) << "FormMgrTest_0021 starts";
509     EXPECT_CALL(*mockProxy, NotifyFormsEnableUpdate(_, _, _))
510         .Times(1)
511         .WillOnce(Return(0));
512     int64_t formId1 = 3;
513     int64_t formId2 = 4;
514     std::vector<int64_t> formIds;
515     formIds.push_back(formId1);
516     formIds.push_back(formId2);
517     bool isProtected = true;
518     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
519     int32_t result = FormMgr::GetInstance().NotifyFormsEnableUpdate(formIds, isProtected, token);
520 
521     EXPECT_EQ(result, 0);
522     GTEST_LOG_(INFO) << "FormMgrTest_0021 test ends";
523 }
524 
525 /**
526  * @tc.name: FormMgrTest_0022
527  * @tc.desc: Verify  GetAllFormsInfo
528  * @tc.type: FUNC
529  */
530 HWTEST_F(FormMgrTest, FormMgrTest_0022, TestSize.Level1) {
531     GTEST_LOG_(INFO) << "FormMgrTest_0022 starts";
532     EXPECT_CALL(*mockProxy, GetAllFormsInfo(_))
533     .Times(1)
534     .WillOnce(Return(0));
535     std::vector<FormInfo> formInfos;
536     std::vector<FormInfo> expectFormInfos;
537     FormInfo formInfo = {};
538     formInfo.bundleName = "ohos.samples.FormApplication";
539     formInfo.moduleName = "entry";
540     expectFormInfos.push_back(formInfo);
541     auto result = FormMgr::GetInstance().GetAllFormsInfo(formInfos);
542 
543     EXPECT_EQ(result, 0);
544     GTEST_LOG_(INFO) << "FormMgrTest_0022 test ends";
545 }
546 
547 /**
548  * @tc.name: FormMgrTest_0023
549  * @tc.desc: Verify GetFormsInfoByApp
550  * @tc.type: FUNC
551  */
552 HWTEST_F(FormMgrTest, FormMgrTest_0023, TestSize.Level1) {
553     GTEST_LOG_(INFO) << "FormMgrTest_0023 starts";
554     EXPECT_CALL(*mockProxy, GetFormsInfoByApp(_, _))
555     .Times(1)
556     .WillOnce(Return(0));
557     std::vector<FormInfo> formInfos;
558     std::vector<FormInfo> expectFormInfos;
559     FormInfo formInfo = {};
560     formInfo.bundleName = "ohos.samples.FormApplication";
561     formInfo.moduleName = "entry";
562     expectFormInfos.push_back(formInfo);
563     std::string bundleName = "a";
564     auto result = FormMgr::GetInstance().GetFormsInfoByApp(bundleName, formInfos);
565 
566     EXPECT_EQ(result, 0);
567     GTEST_LOG_(INFO) << "FormMgrTest_0023 test ends";
568 }
569 
570 /**
571  * @tc.name: FormMgrTest_0024
572  * @tc.desc: Verify GetFormsInfoByModule
573  * @tc.type: FUNC
574  */
575 HWTEST_F(FormMgrTest, FormMgrTest_0024, TestSize.Level1) {
576     GTEST_LOG_(INFO) << "FormMgrTest_0024 starts";
577     EXPECT_CALL(*mockProxy, GetFormsInfoByModule(_, _, _))
578     .Times(1)
579     .WillOnce(Return(0));
580     std::vector<FormInfo> formInfos;
581     std::vector<FormInfo> expectFormInfos;
582     FormInfo formInfo = {};
583     formInfo.bundleName = "ohos.samples.FormApplication";
584     formInfo.moduleName = "entry";
585     expectFormInfos.push_back(formInfo);
586     std::string bundleName = "a";
587     std::string moduleName = "A";
588     auto result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
589 
590     EXPECT_EQ(result, 0);
591     GTEST_LOG_(INFO) << "FormMgrTest_0024 test ends";
592 }
593 
594 /**
595  * @tc.name: FormMgrTest_0025
596  * @tc.desc: Verify CheckFMSReady
597  * @tc.type: FUNC
598  */
599 HWTEST_F(FormMgrTest, FormMgrTest_0025, TestSize.Level1) {
600     GTEST_LOG_(INFO) << "FormMgrTest_0025 starts";
601     sptr<MockSystemAbilityManager> mockSamgr = new (std::nothrow) MockSystemAbilityManager();
602     sptr<ISystemAbilityManager> backupSamgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
603     SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = mockSamgr;
604 
605     auto result = FormMgr::GetInstance().CheckFMSReady();
606 
607     EXPECT_TRUE(result);
608     GTEST_LOG_(INFO) << "FormMgrTest_0025 test ends";
609 }
610 
611 /**
612  * @tc.name: FormMgrTest_0026
613  * @tc.desc: Verify DumpFormInfoByBundleName
614  * @tc.type: FUNC
615  */
616 HWTEST_F(FormMgrTest, FormMgrTest_0026, TestSize.Level1) {
617     GTEST_LOG_(INFO) << "FormMgrTest_0026 starts";
618     EXPECT_CALL(*mockProxy, DumpFormInfoByBundleName(_, _))
619     .Times(1)
620     .WillOnce(Return(0));
621     std::string bundleName = "b";
622     std::string formInfos = "a";
623     auto result = FormMgr::GetInstance().DumpFormInfoByBundleName(bundleName, formInfos);
624 
625     EXPECT_EQ(result, 0);
626     GTEST_LOG_(INFO) << "FormMgrTest_0026 test ends";
627 }
628 
629 /**
630  * @tc.name: FormMgrTest_0027
631  * @tc.desc: Verify AcquireFormState
632  * @tc.type: FUNC
633  */
634 HWTEST_F(FormMgrTest, FormMgrTest_0027, TestSize.Level1) {
635     GTEST_LOG_(INFO) << "FormMgrTest_0027 starts";
636     EXPECT_CALL(*mockProxy, AcquireFormState(_, _, _))
637     .Times(1)
638     .WillOnce(Return(0));
639     Want want;
640     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
641     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
642     FormStateInfo stateInfo;
643     auto result = FormMgr::GetInstance().AcquireFormState(want, token, stateInfo);
644 
645     EXPECT_EQ(result, 0);
646     GTEST_LOG_(INFO) << "FormMgrTest_0027 test ends";
647 }
648 
649 /**
650  * @tc.name: FormMgrTest_0028
651  * @tc.desc: Verify DeleteForm
652  * @tc.type: FUNC
653  * @tc.require: issueI63OQL
654  */
655 HWTEST_F(FormMgrTest, FormMgrTest_0028, TestSize.Level1) {
656     GTEST_LOG_(INFO) << "FormMgrTest_0028 starts";
657     int64_t formId = 1;
658     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
659     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
660     int result = FormMgr::GetInstance().DeleteForm(formId, token);
661 
662     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
663     GTEST_LOG_(INFO) << "FormMgrTest_0028 test ends";
664 }
665 
666 /**
667  * @tc.name: FormMgrTest_0029
668  * @tc.desc: Verify ReleaseForm
669  * @tc.type: FUNC
670  * @tc.require: issueI63OQL
671  */
672 HWTEST_F(FormMgrTest, FormMgrTest_0029, TestSize.Level1) {
673     GTEST_LOG_(INFO) << "FormMgrTest_0029 starts";
674     int64_t formId = 1;
675     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
676     bool delCache = true;
677     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
678     int result = FormMgr::GetInstance().ReleaseForm(formId, token, delCache);
679 
680     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
681     GTEST_LOG_(INFO) << "FormMgrTest_0029 test ends";
682 }
683 
684 /**
685  * @tc.name: FormMgrTest_0030
686  * @tc.desc: Verify ReleaseForm
687  * @tc.type: FUNC
688  * @tc.require: issueI63OQL
689  */
690 HWTEST_F(FormMgrTest, FormMgrTest_0030, TestSize.Level1) {
691     GTEST_LOG_(INFO) << "FormMgrTest_0030 starts";
692     int64_t formId = -1;
693     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
694     bool delCache = true;
695     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
696     int result = FormMgr::GetInstance().ReleaseForm(formId, token, delCache);
697 
698     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
699     GTEST_LOG_(INFO) << "FormMgrTest_0030 test ends";
700 }
701 
702 /**
703  * @tc.name: FormMgrTest_0031
704  * @tc.desc: Verify UpdateForm
705  * @tc.type: FUNC
706  * @tc.require: issueI63OQL
707  */
708 HWTEST_F(FormMgrTest, FormMgrTest_0031, TestSize.Level1) {
709     GTEST_LOG_(INFO) << "FormMgrTest_0031 starts";
710     int64_t formId = 1;
711     FormProviderData formBindingData;
712     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
713     int result = FormMgr::GetInstance().UpdateForm(formId, formBindingData);
714 
715     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
716     GTEST_LOG_(INFO) << "FormMgrTest_0031 test ends";
717 }
718 
719 /**
720  * @tc.name: FormMgrTest_0032
721  * @tc.desc: Verify UpdateForm
722  * @tc.type: FUNC
723  * @tc.require: issueI63OQL
724  */
725 HWTEST_F(FormMgrTest, FormMgrTest_0032, TestSize.Level1) {
726     GTEST_LOG_(INFO) << "FormMgrTest_0032 starts";
727     int64_t formId = -1;
728     FormProviderData formBindingData;
729     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
730     int result = FormMgr::GetInstance().UpdateForm(formId, formBindingData);
731 
732     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
733     GTEST_LOG_(INFO) << "FormMgrTest_0032 test ends";
734 }
735 
736 /**
737  * @tc.name: FormMgrTest_0033
738  * @tc.desc: Verify UpdateForm
739  * @tc.type: FUNC
740  * @tc.require: issueI63OQL
741  */
742 HWTEST_F(FormMgrTest, FormMgrTest_0033, TestSize.Level1) {
743     GTEST_LOG_(INFO) << "FormMgrTest_0033 starts";
744     int64_t formId = 1;
745     FormProviderData formBindingData;
746     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
747     int result = FormMgr::GetInstance().UpdateForm(formId, formBindingData);
748 
749     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_PROVIDER_DATA_EMPTY);
750     GTEST_LOG_(INFO) << "FormMgrTest_0033 test ends";
751 }
752 
753 /**
754  * @tc.name: FormMgrTest_0034
755  * @tc.desc: Verify RequestForm
756  * @tc.type: FUNC
757  * @tc.require: issueI63OQL
758  */
759 HWTEST_F(FormMgrTest, FormMgrTest_0034, TestSize.Level1) {
760     GTEST_LOG_(INFO) << "FormMgrTest_0034 starts";
761     int64_t formId = 1;
762     Want want;
763     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
764     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
765     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
766     int result = FormMgr::GetInstance().RequestForm(formId, token, want);
767 
768     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
769     GTEST_LOG_(INFO) << "FormMgrTest_0034 test ends";
770 }
771 
772 /**
773  * @tc.name: FormMgrTest_0035
774  * @tc.desc: Verify RequestForm
775  * @tc.type: FUNC
776  * @tc.require: issueI63OQL
777  */
778 HWTEST_F(FormMgrTest, FormMgrTest_0035, TestSize.Level1) {
779     GTEST_LOG_(INFO) << "FormMgrTest_0035 starts";
780     int64_t formId = -1;
781     Want want;
782     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
783     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
784     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
785     int result = FormMgr::GetInstance().RequestForm(formId, token, want);
786 
787     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
788     GTEST_LOG_(INFO) << "FormMgrTest_0035 test ends";
789 }
790 
791 /**
792  * @tc.name: FormMgrTest_0036
793  * @tc.desc: Verify NotifyWhetherVisibleForms
794  * @tc.type: FUNC
795  * @tc.require: issueI63OQL
796  */
797 HWTEST_F(FormMgrTest, FormMgrTest_0036, TestSize.Level1) {
798     GTEST_LOG_(INFO) << "FormMgrTest_0036 starts";
799     std::vector<int64_t> formIds;
800     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
801     int32_t formVisibleType = 1;
802     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
803     int result = FormMgr::GetInstance().NotifyWhetherVisibleForms(formIds, token, formVisibleType);
804 
805     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
806     GTEST_LOG_(INFO) << "FormMgrTest_0036 test ends";
807 }
808 
809 /**
810  * @tc.name: FormMgrTest_0037
811  * @tc.desc: Verify NotifyWhetherVisibleForms
812  * @tc.type: FUNC
813  * @tc.require: issueI63OQL
814  */
815 HWTEST_F(FormMgrTest, FormMgrTest_0037, TestSize.Level1) {
816     GTEST_LOG_(INFO) << "FormMgrTest_0037 starts";
817     std::vector<int64_t> formIds;
818     int64_t formId = 1;
819     formIds.emplace_back(formId);
820     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
821     int32_t formVisibleType = 1;
822     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
823     int result = FormMgr::GetInstance().NotifyWhetherVisibleForms(formIds, token, formVisibleType);
824 
825     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
826     GTEST_LOG_(INFO) << "FormMgrTest_0037 test ends";
827 }
828 
829 /**
830  * @tc.name: FormMgrTest_0038
831  * @tc.desc: Verify SetNextRefreshTime
832  * @tc.type: FUNC
833  * @tc.require: issueI63OQL
834  */
835 HWTEST_F(FormMgrTest, FormMgrTest_0038, TestSize.Level1) {
836     GTEST_LOG_(INFO) << "FormMgrTest_0038 starts";
837     int64_t formId = 10;
838     int64_t nextTime = 50;
839     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
840     int result = FormMgr::GetInstance().SetNextRefreshTime(formId, nextTime);
841 
842     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
843     GTEST_LOG_(INFO) << "FormMgrTest_0038 test ends";
844 }
845 
846 /**
847  * @tc.name: FormMgrTest_0039
848  * @tc.desc: Verify LifecycleUpdate
849  * @tc.type: FUNC
850  * @tc.require: issueI63OQL
851  */
852 HWTEST_F(FormMgrTest, FormMgrTest_0039, TestSize.Level1) {
853     GTEST_LOG_(INFO) << "FormMgrTest_0039 starts";
854     std::vector<int64_t> formIds;
855     int64_t formId = 1;
856     formIds.emplace_back(formId);
857     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
858     bool updateType = true;
859     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
860     int result = FormMgr::GetInstance().LifecycleUpdate(formIds, token, updateType);
861 
862     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
863     GTEST_LOG_(INFO) << "FormMgrTest_0039 test ends";
864 }
865 
866 /**
867  * @tc.name: FormMgrTest_0040
868  * @tc.desc: Verify RegisterDeathCallback
869  * @tc.type: FUNC
870  * @tc.require: issueI63OQL
871  */
872 HWTEST_F(FormMgrTest, FormMgrTest_0040, TestSize.Level1) {
873     GTEST_LOG_(INFO) << "FormMgrTest_0040 starts";
874     FormMgr::GetInstance().RegisterDeathCallback(nullptr);
875     FormMgr::GetInstance().UnRegisterDeathCallback(nullptr);
876     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
877     GTEST_LOG_(INFO) << "FormMgrTest_0040 test ends";
878 }
879 
880 /**
881  * @tc.name: FormMgrTest_0041
882  * @tc.desc: Verify DeleteInvalidForms
883  * @tc.type: FUNC
884  * @tc.require: issueI63OQL
885  */
886 HWTEST_F(FormMgrTest, FormMgrTest_0041, TestSize.Level1) {
887     GTEST_LOG_(INFO) << "FormMgrTest_0041 starts";
888     std::vector<int64_t> formIds;
889     int64_t formId = 1;
890     formIds.emplace_back(formId);
891     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
892     int32_t numFormsDeleted = 2;
893     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
894     int result = FormMgr::GetInstance().DeleteInvalidForms(formIds, token, numFormsDeleted);
895 
896     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
897     GTEST_LOG_(INFO) << "FormMgrTest_0041 test ends";
898 }
899 
900 /**
901  * @tc.name: FormMgrTest_0042
902  * @tc.desc: Verify AcquireFormState
903  * @tc.type: FUNC
904  * @tc.require: issueI63OQL
905  */
906 HWTEST_F(FormMgrTest, FormMgrTest_0042, TestSize.Level1) {
907     GTEST_LOG_(INFO) << "FormMgrTest_0042 starts";
908     Want want;
909     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
910     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
911     FormStateInfo stateInfo;
912     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
913     int result = FormMgr::GetInstance().AcquireFormState(want, token, stateInfo);
914 
915     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
916     GTEST_LOG_(INFO) << "FormMgrTest_0042 test ends";
917 }
918 
919 /**
920  * @tc.name: FormMgrTest_0043
921  * @tc.desc: Verify NotifyFormsVisible
922  * @tc.type: FUNC
923  * @tc.require: issueI63OQL
924  */
925 HWTEST_F(FormMgrTest, FormMgrTest_0043, TestSize.Level1) {
926     GTEST_LOG_(INFO) << "FormMgrTest_0043 starts";
927     std::vector<int64_t> formIds;
928     int64_t formId = 1;
929     formIds.emplace_back(formId);
930     bool isVisible = true;
931     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
932     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
933     int result = FormMgr::GetInstance().NotifyFormsVisible(formIds, isVisible, token);
934 
935     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
936     GTEST_LOG_(INFO) << "FormMgrTest_0043 test ends";
937 }
938 
939 /**
940  * @tc.name: FormMgrTest_0044
941  * @tc.desc: Verify NotifyFormsPrivacyProtected
942  * @tc.type: FUNC
943  * @tc.require: issueI63OQL
944  */
945 HWTEST_F(FormMgrTest, FormMgrTest_0044, TestSize.Level1) {
946     GTEST_LOG_(INFO) << "FormMgrTest_0044 starts";
947     std::vector<int64_t> formIds;
948     int64_t formId = 1;
949     formIds.emplace_back(formId);
950     bool isProtected = true;
951     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
952     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
953     int result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
954 
955     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
956     GTEST_LOG_(INFO) << "FormMgrTest_0044 test ends";
957 }
958 
959 /**
960  * @tc.name: FormMgrTest_0045
961  * @tc.desc: Verify NotifyFormsEnableUpdate
962  * @tc.type: FUNC
963  * @tc.require: issueI63OQL
964  */
965 HWTEST_F(FormMgrTest, FormMgrTest_0045, TestSize.Level1) {
966     GTEST_LOG_(INFO) << "FormMgrTest_0045 starts";
967     std::vector<int64_t> formIds;
968     int64_t formId = 1;
969     formIds.emplace_back(formId);
970     bool isEnableUpdate = true;
971     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
972     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
973     int result = FormMgr::GetInstance().NotifyFormsEnableUpdate(formIds, isEnableUpdate, token);
974 
975     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
976     GTEST_LOG_(INFO) << "FormMgrTest_0045 test ends";
977 }
978 
979 /**
980  * @tc.name: FormMgrTest_0046
981  * @tc.desc: Verify GetAllFormsInfo
982  * @tc.type: FUNC
983  * @tc.require: issueI63OQL
984  */
985 HWTEST_F(FormMgrTest, FormMgrTest_0046, TestSize.Level1) {
986     GTEST_LOG_(INFO) << "FormMgrTest_0046 starts";
987     std::vector<FormInfo> formInfos;
988     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
989     int result = FormMgr::GetInstance().GetAllFormsInfo(formInfos);
990 
991     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
992     GTEST_LOG_(INFO) << "FormMgrTest_0046 test ends";
993 }
994 
995 /**
996  * @tc.name: FormMgrTest_0047
997  * @tc.desc: Verify GetFormsInfoByApp
998  * @tc.type: FUNC
999  * @tc.require: issueI63OQL
1000  */
1001 HWTEST_F(FormMgrTest, FormMgrTest_0047, TestSize.Level1) {
1002     GTEST_LOG_(INFO) << "FormMgrTest_0047 starts";
1003     std::string bundleName = "this is bundleName";
1004     std::vector<FormInfo> formInfos;
1005     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1006     int result = FormMgr::GetInstance().GetFormsInfoByApp(bundleName, formInfos);
1007 
1008     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
1009     GTEST_LOG_(INFO) << "FormMgrTest_0047 test ends";
1010 }
1011 
1012 /**
1013  * @tc.name: FormMgrTest_0048
1014  * @tc.desc: Verify GetFormsInfoByApp
1015  * @tc.type: FUNC
1016  * @tc.require: issueI63OQL
1017  */
1018 HWTEST_F(FormMgrTest, FormMgrTest_0048, TestSize.Level1) {
1019     GTEST_LOG_(INFO) << "FormMgrTest_0048 starts";
1020     std::string bundleName = "";
1021     std::vector<FormInfo> formInfos;
1022     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1023     int result = FormMgr::GetInstance().GetFormsInfoByApp(bundleName, formInfos);
1024 
1025     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_BUNDLENAME);
1026     GTEST_LOG_(INFO) << "FormMgrTest_0048 test ends";
1027 }
1028 
1029 /**
1030  * @tc.name: FormMgrTest_0050
1031  * @tc.desc: Verify GetFormsInfoByModule
1032  * @tc.type: FUNC
1033  * @tc.require: issueI63OQL
1034  */
1035 HWTEST_F(FormMgrTest, FormMgrTest_0050, TestSize.Level1) {
1036     GTEST_LOG_(INFO) << "FormMgrTest_0050 starts";
1037     std::string bundleName = "";
1038     std::string moduleName = "this is moduleName";
1039     std::vector<FormInfo> formInfos;
1040     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1041     int result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
1042 
1043     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_BUNDLENAME);
1044     GTEST_LOG_(INFO) << "FormMgrTest_0050 test ends";
1045 }
1046 
1047 /**
1048  * @tc.name: FormMgrTest_0051
1049  * @tc.desc: Verify GetFormsInfoByModule
1050  * @tc.type: FUNC
1051  * @tc.require: issueI63OQL
1052  */
1053 HWTEST_F(FormMgrTest, FormMgrTest_0051, TestSize.Level1) {
1054     GTEST_LOG_(INFO) << "FormMgrTest_0051 starts";
1055     std::string bundleName = "this is bundleName";
1056     std::string moduleName = "";
1057     std::vector<FormInfo> formInfos;
1058     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1059     int result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
1060 
1061     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_MODULENAME);
1062     GTEST_LOG_(INFO) << "FormMgrTest_0051 test ends";
1063 }
1064 
1065 /**
1066  * @tc.name: FormMgrTest_0052
1067  * @tc.desc: Verify GetFormsInfoByModule
1068  * @tc.type: FUNC
1069  * @tc.require: issueI63OQL
1070  */
1071 HWTEST_F(FormMgrTest, FormMgrTest_0052, TestSize.Level1) {
1072     GTEST_LOG_(INFO) << "FormMgrTest_0052 starts";
1073     std::string bundleName = "this is bundleName";
1074     std::string moduleName = "this is moduleName";
1075     std::vector<FormInfo> formInfos;
1076     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1077     int result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
1078 
1079     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
1080     GTEST_LOG_(INFO) << "FormMgrTest_0052 test ends";
1081 }
1082 } // namespace