• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 using namespace testing::ext;
34 using namespace OHOS;
35 using namespace OHOS::AppExecFwk;
36 
37 using ::testing::Return;
38 using ::testing::SetArgReferee;
39 using ::testing::ContainerEq;
40 using ::testing::_;
41 using ::testing::DoAll;
42 
43 // overload operator for ContainerEq
44 namespace OHOS::AppExecFwk {
operator ==(const FormInfo & lhs,const FormInfo & rhs)45     bool operator==(const FormInfo& lhs, const FormInfo& rhs)
46     {
47         if (lhs.bundleName != rhs.bundleName) {
48             return false;
49         }
50         if (lhs.moduleName != rhs.moduleName) {
51             return false;
52         }
53         if (lhs.name != rhs.name) {
54             return false;
55         }
56         // to be continued...
57         return true;
58     }
59 }
60 
61 namespace {
62 const std::int32_t ERROR_NUM = 2293778;
63 const std::int32_t ERROR_NUMS = 8388610;
64 const std::int32_t NEGATIVE_NUM = -1;
65 const std::int32_t POSITIVE_NUM = 1;
66 class FormMgrTest : public testing::Test {
67 public:
68     // TestSuite setup has to be static
SetUpTestCase()69     static void SetUpTestCase()
70     {
71         if (mockProxy == nullptr) {
72             GTEST_LOG_(INFO) << "SetUpTestCase";
73             sptr<IRemoteObject> impl = nullptr;
74             mockProxy = new (std::nothrow) MockFormMgrProxy(impl);
75             FormMgr::GetInstance().SetFormMgrService(mockProxy);
76         }
77     }
78     // TearDown is unnecessary.
79     // TestSuite setup has to be static
80     static sptr<MockFormMgrProxy> mockProxy;
81 };
82 // initialize static variable.
83 sptr<MockFormMgrProxy> FormMgrTest::mockProxy = nullptr;
84 
85 /**
86  * @tc.name: FormMgrTest_0001
87  * @tc.desc: Verify GetFormsInfo
88  * @tc.type: FUNC
89  * @tc.require: #I59O23
90  */
91 HWTEST_F(FormMgrTest, FormMgrTest_0001, TestSize.Level1) {
92     GTEST_LOG_(INFO) << "FormMgrTest_0001 starts";
93     // initialize input parameters.
94     FormInfoFilter filter;
95     filter.moduleName = "";
96     std::vector<FormInfo> formInfos;
97     // setup expectations.
98     std::vector<FormInfo> expectFormInfos;
99     FormInfo formInfo = {};
100     formInfo.bundleName = "ohos.samples.FormApplication";
101     expectFormInfos.push_back(formInfo);
102     EXPECT_CALL(*mockProxy, GetFormsInfo(_, _))
103         .Times(1)
104         .WillOnce(DoAll(SetArgReferee<1>(expectFormInfos), Return(ERR_OK)));
105     // test.
106     FormMgr::GetInstance().GetFormsInfo(filter, formInfos);
107     // expect result.
108     EXPECT_THAT(formInfos, ContainerEq(expectFormInfos));
109     // FormMgr is a singleton, therefore, deleteing it will cause segfault for other invocations.
110     testing::Mock::AllowLeak(mockProxy);
111     GTEST_LOG_(INFO) << "FormMgrTest_0001 test ends";
112 }
113 
114 /**
115  * @tc.name: FormMgrTest_0002
116  * @tc.desc: Verify GetFormsInfo
117  * @tc.type: FUNC
118  * @tc.require: #I59O23
119  */
120 HWTEST_F(FormMgrTest, FormMgrTest_0002, TestSize.Level1) {
121     GTEST_LOG_(INFO) << "FormMgrTest_0002 starts";
122     // initialize input parameters.
123     FormInfoFilter filter;
124     filter.moduleName = "empty";
125     std::vector<FormInfo> formInfos;
126     // setup expectations.
127     std::vector<FormInfo> expectFormInfos;
128     FormInfo formInfo = {};
129     formInfo.bundleName = "ohos.samples.FormApplication";
130     formInfo.moduleName = "entry";
131     expectFormInfos.push_back(formInfo);
132     EXPECT_CALL(*mockProxy, GetFormsInfo(_, _))
133         .Times(1)
134         .WillOnce(Return(ERR_OK));
135     // test.
136     FormMgr::GetInstance().GetFormsInfo(filter, formInfos);
137     // expect result.
138     EXPECT_EQ(formInfos.size(), 0);
139     testing::Mock::AllowLeak(mockProxy);
140     GTEST_LOG_(INFO) << "FormMgrTest_0002 test ends";
141 }
142 
143 /**
144  * @tc.name: FormMgrTest_0003
145  * @tc.desc: Verify IsRequestPublishFormSupported
146  * @tc.type: FUNC
147  * @tc.require: #I58Y0A
148  */
149 HWTEST_F(FormMgrTest, FormMgrTest_0003, TestSize.Level1) {
150     GTEST_LOG_(INFO) << "FormMgrTest_0003 starts";
151     EXPECT_CALL(*mockProxy, IsRequestPublishFormSupported())
152         .Times(1)
153         .WillOnce(Return(false));
154     bool result = FormMgr::GetInstance().IsRequestPublishFormSupported();
155     EXPECT_EQ(result, false);
156     GTEST_LOG_(INFO) << "FormMgrTest_0003 test ends";
157 }
158 
159 /**
160  * @tc.name: FormMgrTest_0004
161  * @tc.desc: Verify StartAbility
162  * @tc.type: FUNC
163  * @tc.require: #I5EFDX
164  */
165 HWTEST_F(FormMgrTest, FormMgrTest_0004, TestSize.Level1) {
166     GTEST_LOG_(INFO) << "FormMgrTest_0004 starts";
167     EXPECT_CALL(*mockProxy, StartAbility(_, _))
168         .Times(1)
169         .WillOnce(Return(0));
170     Want want;
171     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
172     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
173     int32_t result = FormMgr::GetInstance().StartAbility(want, token);
174     EXPECT_EQ(result, 0);
175     GTEST_LOG_(INFO) << "FormMgrTest_0004 test ends";
176 }
177 
178 /**
179  * @tc.name: FormMgrTest_0005
180  * @tc.desc: Verify UpdateForm
181  * @tc.type: FUNC
182  * @tc.require: issueI5PFT9
183  */
184 HWTEST_F(FormMgrTest, FormMgrTest_0005, TestSize.Level1) {
185     GTEST_LOG_(INFO) << "FormMgrTest_0005 starts";
186     EXPECT_CALL(*mockProxy, UpdateForm(_, _))
187         .Times(1)
188         .WillOnce(Return(0));
189     FormJsInfo formJsInfo;
190     formJsInfo.formId = 1;
191     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
192     sptr<IRemoteObject> providerToken = new (std::nothrow) MockFormProviderClient();
193     FormCallerMgr::GetInstance().AddFormHostCaller(formJsInfo, providerToken);
194     FormProviderData formProviderData = FormProviderData(std::string("{\"city\": \"beijing001\"}"));
195     int32_t result = FormMgr::GetInstance().UpdateForm(formJsInfo.formId, formProviderData);
196     EXPECT_EQ(result, 0);
197     GTEST_LOG_(INFO) << "FormMgrTest_0005 test ends";
198 }
199 
200 /**
201  * @tc.name: FormMgrTest_0006
202  * @tc.desc: Verify RequestForm
203  * @tc.type: FUNC
204  * @tc.require: issueI5Q8IU
205  */
206 HWTEST_F(FormMgrTest, FormMgrTest_0006, TestSize.Level1) {
207     GTEST_LOG_(INFO) << "FormMgrTest_0006 starts";
208     EXPECT_CALL(*mockProxy, RequestForm(_, _, _))
209         .Times(1)
210         .WillOnce(Return(0));
211     Want want;
212     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
213     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
214     FormJsInfo formJsInfo;
215     formJsInfo.formId = 1;
216     sptr<IRemoteObject> providerToken = new (std::nothrow) MockFormProviderClient();
217     FormCallerMgr::GetInstance().AddFormHostCaller(formJsInfo, providerToken);
218     int32_t result = FormMgr::GetInstance().RequestForm(formJsInfo.formId, token, want);
219     EXPECT_EQ(result, 0);
220     GTEST_LOG_(INFO) << "FormMgrTest_0006 test ends";
221 }
222 
223 /**
224  * @tc.name: FormMgrTest_0007
225  * @tc.desc: Verify MessageEvent
226  * @tc.type: FUNC
227  * @tc.require: issueI5QGMS
228  */
229 HWTEST_F(FormMgrTest, FormMgrTest_0007, TestSize.Level1) {
230     GTEST_LOG_(INFO) << "FormMgrTest_0007 starts";
231     EXPECT_CALL(*mockProxy, MessageEvent(_, _, _))
232         .Times(1)
233         .WillOnce(Return(0));
234     Want want;
235     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
236     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
237     FormJsInfo formJsInfo;
238     sptr<IRemoteObject> providerToken = new (std::nothrow) MockFormProviderClient();
239     FormCallerMgr::GetInstance().AddFormHostCaller(formJsInfo, providerToken);
240     int32_t result = FormMgr::GetInstance().MessageEvent(formJsInfo.formId, want, token);
241     EXPECT_EQ(result, 0);
242     GTEST_LOG_(INFO) << "FormMgrTest_0007 test ends";
243 }
244 
245 /**
246  * @tc.name: FormMgrTest_0005
247  * @tc.desc: Verify NotifyFormsPrivacyProtected
248  * @tc.type: FUNC
249  * @tc.require: I5ST27
250  */
251 HWTEST_F(FormMgrTest, FormMgrTest_0008, TestSize.Level1) {
252     GTEST_LOG_(INFO) << "FormMgrTest_0008 starts";
253     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
254         .Times(1)
255         .WillOnce(Return(0));
256     // initialize input parameters.
257     int64_t formId = 1;
258     std::vector<int64_t> formIds;
259     formIds.push_back(formId);
260     bool isProtected = false;
261     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
262     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
263     // expect result.
264     EXPECT_EQ(result, 0);
265     GTEST_LOG_(INFO) << "FormMgrTest_0008 test ends";
266 }
267 
268 /**
269  * @tc.name: FormMgrTest_0006
270  * @tc.desc: Verify NotifyFormsPrivacyProtected
271  * @tc.type: FUNC
272  * @tc.require: I5ST27
273  */
274 HWTEST_F(FormMgrTest, FormMgrTest_0009, TestSize.Level1) {
275     GTEST_LOG_(INFO) << "FormMgrTest_0009 starts";
276     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
277         .Times(1)
278         .WillOnce(Return(0));
279     // initialize input parameters.
280     int64_t formId = 2;
281     std::vector<int64_t> formIds;
282     formIds.push_back(formId);
283     bool isProtected = true;
284     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
285     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
286     // expect result.
287     EXPECT_EQ(result, 0);
288     GTEST_LOG_(INFO) << "FormMgrTest_0009 test ends";
289 }
290 
291 /**
292  * @tc.name: FormMgrTest_0007
293  * @tc.desc: Verify NotifyFormsPrivacyProtected
294  * @tc.type: FUNC
295  * @tc.require: I5ST27
296  */
297 HWTEST_F(FormMgrTest, FormMgrTest_0010, TestSize.Level1) {
298     GTEST_LOG_(INFO) << "FormMgrTest_0010 starts";
299     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
300         .Times(1)
301         .WillOnce(Return(0));
302     // initialize input parameters.
303     int64_t formId1 = 3;
304     int64_t formId2 = 4;
305     std::vector<int64_t> formIds;
306     formIds.push_back(formId1);
307     formIds.push_back(formId2);
308     bool isProtected = false;
309     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
310     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
311     // expect result.
312     EXPECT_EQ(result, 0);
313     GTEST_LOG_(INFO) << "FormMgrTest_0010 test ends";
314 }
315 
316 /**
317  * @tc.name: FormMgrTest_0011
318  * @tc.desc: Verify NotifyFormsPrivacyProtected
319  * @tc.type: FUNC
320  * @tc.require: I5ST27
321  */
322 HWTEST_F(FormMgrTest, FormMgrTest_0011, TestSize.Level1) {
323     GTEST_LOG_(INFO) << "FormMgrTest_0008 starts";
324     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
325         .Times(1)
326         .WillOnce(Return(0));
327     // initialize input parameters.
328     int64_t formId1 = 5;
329     int64_t formId2 = 6;
330     std::vector<int64_t> formIds;
331     formIds.push_back(formId1);
332     formIds.push_back(formId2);
333     bool isProtected = true;
334     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
335     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
336     // expect result.
337     EXPECT_EQ(result, 0);
338     GTEST_LOG_(INFO) << "FormMgrTest_0011 test ends";
339 }
340 
341 /**
342  * @tc.name: FormMgrTest_0012
343  * @tc.desc: Verify GetErrorMsg
344  * @tc.type: FUNC
345  */
346 HWTEST_F(FormMgrTest, FormMgrTest_0012, TestSize.Level1) {
347     GTEST_LOG_(INFO) << "FormMgrTest_0012 starts";
348     int errorCode = 0;
349     auto result = FormMgr::GetInstance().GetErrorMsg(errorCode);
350 
351     EXPECT_EQ(result, "unknown error");
352     GTEST_LOG_(INFO) << "FormMgrTest_0012 test ends";
353 }
354 
355 /**
356  * @tc.name: FormMgrTest_0013
357  * @tc.desc: Verify DumpStorageFormInfos
358  * @tc.type: FUNC
359  */
360 HWTEST_F(FormMgrTest, FormMgrTest_0013, TestSize.Level1) {
361     GTEST_LOG_(INFO) << "FormMgrTest_0013 starts";
362     EXPECT_CALL(*mockProxy, DumpStorageFormInfos(_))
363     .Times(1)
364     .WillOnce(Return(0));
365     std::string formInfos = "a";
366     auto result = FormMgr::GetInstance().DumpStorageFormInfos(formInfos);
367 
368     EXPECT_EQ(result, 0);
369     GTEST_LOG_(INFO) << "FormMgrTest_0013 test ends";
370 }
371 
372 /**
373  * @tc.name: FormMgrTest_0014
374  * @tc.desc: Verify DumpFormInfoByFormId
375  * @tc.type: FUNC
376  */
377 HWTEST_F(FormMgrTest, FormMgrTest_0014, TestSize.Level1) {
378     GTEST_LOG_(INFO) << "FormMgrTest_0014 starts";
379     EXPECT_CALL(*mockProxy, DumpFormInfoByFormId(_, _))
380     .Times(1)
381     .WillOnce(Return(0));
382     std::string formInfos = "a";
383     std::int64_t formId = 3;
384     auto result = FormMgr::GetInstance().DumpFormInfoByFormId(formId, formInfos);
385 
386     EXPECT_EQ(result, 0);
387     GTEST_LOG_(INFO) << "FormMgrTest_0014 test ends";
388 }
389 
390 /**
391  * @tc.name: FormMgrTest_0015
392  * @tc.desc: Verify DumpFormTimerByFormId
393  * @tc.type: FUNC
394  */
395 HWTEST_F(FormMgrTest, FormMgrTest_0015, TestSize.Level1) {
396     GTEST_LOG_(INFO) << "FormMgrTest_0015 starts";
397     EXPECT_CALL(*mockProxy, DumpFormTimerByFormId(_, _))
398     .Times(1)
399     .WillOnce(Return(0));
400     std::string isTimingService = "b";
401     std::int64_t formId = 3;
402     auto result = FormMgr::GetInstance().DumpFormTimerByFormId(formId, isTimingService);
403 
404     EXPECT_EQ(result, 0);
405     GTEST_LOG_(INFO) << "FormMgrTest_0015 test ends";
406 }
407 
408 /**
409  * @tc.name: FormMgrTest_0016
410  * @tc.desc: Verify RouterEvent
411  * @tc.type: FUNC
412  */
413 HWTEST_F(FormMgrTest, FormMgrTest_0016, TestSize.Level1) {
414     GTEST_LOG_(INFO) << "FormMgrTest_0016 starts";
415     EXPECT_CALL(*mockProxy, RouterEvent(_, _, _))
416         .Times(1)
417         .WillOnce(Return(0));
418     Want want;
419     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
420     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
421     FormJsInfo formJsInfo;
422     sptr<IRemoteObject> providerToken = new (std::nothrow) MockFormProviderClient();
423     FormCallerMgr::GetInstance().AddFormHostCaller(formJsInfo, providerToken);
424     int32_t result = FormMgr::GetInstance().RouterEvent(formJsInfo.formId, want, token);
425 
426     EXPECT_EQ(result, 0);
427     GTEST_LOG_(INFO) << "FormMgrTest_0016 test ends";
428 }
429 
430 /**
431  * @tc.name: FormMgrTest_0017
432  * @tc.desc: Verify SetNextRefreshTime
433  * @tc.type: FUNC
434  */
435 HWTEST_F(FormMgrTest, FormMgrTest_0017, TestSize.Level1) {
436     GTEST_LOG_(INFO) << "FormMgrTest_0017 starts";
437     int64_t formId = 1;
438     int64_t nextTime = 2;
439     auto result = FormMgr::GetInstance().SetNextRefreshTime(formId, nextTime);
440 
441     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_REFRESH_TIME);
442     GTEST_LOG_(INFO) << "FormMgrTest_0017 test ends";
443 }
444 
445 /**
446  * @tc.name: FormMgrTest_0018
447  * @tc.desc: Verify GetErrorMessage
448  * @tc.type: FUNC
449  */
450 HWTEST_F(FormMgrTest, FormMgrTest_0018, TestSize.Level1) {
451     GTEST_LOG_(INFO) << "FormMgrTest_0018 starts";
452     FormErrors::GetInstance().InitErrorMessageMap();
453     int errCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
454     auto result = FormMgr::GetInstance().GetErrorMessage(errCode);
455 
456     EXPECT_EQ(result, "check permission deny, need to request ohos.permission.REQUIRE_FORM "
457         "or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS.");
458     GTEST_LOG_(INFO) << "FormMgrTest_0018 test ends";
459 }
460 
461 /**
462  * @tc.name: FormMgrTest_0019
463  * @tc.desc: Verify DeleteInvalidForms
464  * @tc.type: FUNC
465  */
466 HWTEST_F(FormMgrTest, FormMgrTest_0019, TestSize.Level1) {
467     GTEST_LOG_(INFO) << "FormMgrTest_0019 starts";
468     EXPECT_CALL(*mockProxy, DeleteInvalidForms(_, _, _))
469     .Times(1)
470     .WillOnce(Return(0));
471     std::vector<int64_t> formInfos;
472     formInfos.push_back(1);
473     formInfos.push_back(2);
474     FormJsInfo formJsInfo;
475     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
476     int32_t numFormsDeleted = 2;
477     auto result = FormMgr::GetInstance().DeleteInvalidForms(formInfos, token, numFormsDeleted);
478 
479     EXPECT_EQ(result, 0);
480     GTEST_LOG_(INFO) << "FormMgrTest_0019 test ends";
481 }
482 
483 /**
484  * @tc.name: FormMgrTest_0020
485  * @tc.desc: Verify DumpStorageFormInfos
486  * @tc.type: FUNC
487  */
488 HWTEST_F(FormMgrTest, FormMgrTest_0020, TestSize.Level1) {
489     GTEST_LOG_(INFO) << "FormMgrTest_0020 starts";
490     EXPECT_CALL(*mockProxy, NotifyFormsVisible(_, _, _))
491         .Times(1)
492         .WillOnce(Return(0));
493     int64_t formId1 = 5;
494     int64_t formId2 = 6;
495     std::vector<int64_t> formIds;
496     formIds.push_back(formId1);
497     formIds.push_back(formId2);
498     bool isProtected = true;
499     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
500     int32_t result = FormMgr::GetInstance().NotifyFormsVisible(formIds, isProtected, token);
501 
502     EXPECT_EQ(result, 0);
503     GTEST_LOG_(INFO) << "FormMgrTest_0020 test ends";
504 }
505 
506 /**
507  * @tc.name: FormMgrTest_0021
508  * @tc.desc: Verify NotifyFormsEnableUpdate
509  * @tc.type: FUNC
510  */
511 HWTEST_F(FormMgrTest, FormMgrTest_0021, TestSize.Level1) {
512     GTEST_LOG_(INFO) << "FormMgrTest_0021 starts";
513     EXPECT_CALL(*mockProxy, NotifyFormsEnableUpdate(_, _, _))
514         .Times(1)
515         .WillOnce(Return(0));
516     int64_t formId1 = 3;
517     int64_t formId2 = 4;
518     std::vector<int64_t> formIds;
519     formIds.push_back(formId1);
520     formIds.push_back(formId2);
521     bool isProtected = true;
522     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
523     int32_t result = FormMgr::GetInstance().NotifyFormsEnableUpdate(formIds, isProtected, token);
524 
525     EXPECT_EQ(result, 0);
526     GTEST_LOG_(INFO) << "FormMgrTest_0021 test ends";
527 }
528 
529 /**
530  * @tc.name: FormMgrTest_0022
531  * @tc.desc: Verify  GetAllFormsInfo
532  * @tc.type: FUNC
533  */
534 HWTEST_F(FormMgrTest, FormMgrTest_0022, TestSize.Level1) {
535     GTEST_LOG_(INFO) << "FormMgrTest_0022 starts";
536     EXPECT_CALL(*mockProxy, GetAllFormsInfo(_))
537     .Times(1)
538     .WillOnce(Return(0));
539     std::vector<FormInfo> formInfos;
540     std::vector<FormInfo> expectFormInfos;
541     FormInfo formInfo = {};
542     formInfo.bundleName = "ohos.samples.FormApplication";
543     formInfo.moduleName = "entry";
544     expectFormInfos.push_back(formInfo);
545     auto result = FormMgr::GetInstance().GetAllFormsInfo(formInfos);
546 
547     EXPECT_EQ(result, 0);
548     GTEST_LOG_(INFO) << "FormMgrTest_0022 test ends";
549 }
550 
551 /**
552  * @tc.name: FormMgrTest_0023
553  * @tc.desc: Verify GetFormsInfoByApp
554  * @tc.type: FUNC
555  */
556 HWTEST_F(FormMgrTest, FormMgrTest_0023, TestSize.Level1) {
557     GTEST_LOG_(INFO) << "FormMgrTest_0023 starts";
558     EXPECT_CALL(*mockProxy, GetFormsInfoByApp(_, _))
559     .Times(1)
560     .WillOnce(Return(0));
561     std::vector<FormInfo> formInfos;
562     std::vector<FormInfo> expectFormInfos;
563     FormInfo formInfo = {};
564     formInfo.bundleName = "ohos.samples.FormApplication";
565     formInfo.moduleName = "entry";
566     expectFormInfos.push_back(formInfo);
567     std::string bundleName = "a";
568     auto result = FormMgr::GetInstance().GetFormsInfoByApp(bundleName, formInfos);
569 
570     EXPECT_EQ(result, 0);
571     GTEST_LOG_(INFO) << "FormMgrTest_0023 test ends";
572 }
573 
574 /**
575  * @tc.name: FormMgrTest_0024
576  * @tc.desc: Verify GetFormsInfoByModule
577  * @tc.type: FUNC
578  */
579 HWTEST_F(FormMgrTest, FormMgrTest_0024, TestSize.Level1) {
580     GTEST_LOG_(INFO) << "FormMgrTest_0024 starts";
581     EXPECT_CALL(*mockProxy, GetFormsInfoByModule(_, _, _))
582     .Times(1)
583     .WillOnce(Return(0));
584     std::vector<FormInfo> formInfos;
585     std::vector<FormInfo> expectFormInfos;
586     FormInfo formInfo = {};
587     formInfo.bundleName = "ohos.samples.FormApplication";
588     formInfo.moduleName = "entry";
589     expectFormInfos.push_back(formInfo);
590     std::string bundleName = "a";
591     std::string moduleName = "A";
592     auto result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
593 
594     EXPECT_EQ(result, 0);
595     GTEST_LOG_(INFO) << "FormMgrTest_0024 test ends";
596 }
597 
598 /**
599  * @tc.name: FormMgrTest_0025
600  * @tc.desc: Verify CheckFMSReady
601  * @tc.type: FUNC
602  */
603 HWTEST_F(FormMgrTest, FormMgrTest_0025, TestSize.Level1) {
604     GTEST_LOG_(INFO) << "FormMgrTest_0025 starts";
605     sptr<MockSystemAbilityManager> mockSamgr = new (std::nothrow) MockSystemAbilityManager();
606     sptr<ISystemAbilityManager> backupSamgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
607     SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = mockSamgr;
608 
609     auto result = FormMgr::GetInstance().CheckFMSReady();
610 
611     EXPECT_TRUE(result);
612     GTEST_LOG_(INFO) << "FormMgrTest_0025 test ends";
613 }
614 
615 /**
616  * @tc.name: FormMgrTest_0026
617  * @tc.desc: Verify DumpFormInfoByBundleName
618  * @tc.type: FUNC
619  */
620 HWTEST_F(FormMgrTest, FormMgrTest_0026, TestSize.Level1) {
621     GTEST_LOG_(INFO) << "FormMgrTest_0026 starts";
622     EXPECT_CALL(*mockProxy, DumpFormInfoByBundleName(_, _))
623     .Times(1)
624     .WillOnce(Return(0));
625     std::string bundleName = "b";
626     std::string formInfos = "a";
627     auto result = FormMgr::GetInstance().DumpFormInfoByBundleName(bundleName, formInfos);
628 
629     EXPECT_EQ(result, 0);
630     GTEST_LOG_(INFO) << "FormMgrTest_0026 test ends";
631 }
632 
633 /**
634  * @tc.name: FormMgrTest_0027
635  * @tc.desc: Verify AcquireFormState
636  * @tc.type: FUNC
637  */
638 HWTEST_F(FormMgrTest, FormMgrTest_0027, TestSize.Level1) {
639     GTEST_LOG_(INFO) << "FormMgrTest_0027 starts";
640     EXPECT_CALL(*mockProxy, AcquireFormState(_, _, _))
641     .Times(1)
642     .WillOnce(Return(0));
643     Want want;
644     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
645     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
646     FormStateInfo stateInfo;
647     auto result = FormMgr::GetInstance().AcquireFormState(want, token, stateInfo);
648 
649     EXPECT_EQ(result, 0);
650     GTEST_LOG_(INFO) << "FormMgrTest_0027 test ends";
651 }
652 
653 /**
654  * @tc.name: FormMgrTest_0028
655  * @tc.desc: Verify DeleteForm
656  * @tc.type: FUNC
657  * @tc.require: issueI63OQL
658  */
659 HWTEST_F(FormMgrTest, FormMgrTest_0028, TestSize.Level1) {
660     GTEST_LOG_(INFO) << "FormMgrTest_0028 starts";
661     int64_t formId = 1;
662     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
663     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
664     int result = FormMgr::GetInstance().DeleteForm(formId, token);
665 
666     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
667     GTEST_LOG_(INFO) << "FormMgrTest_0028 test ends";
668 }
669 
670 /**
671  * @tc.name: FormMgrTest_0029
672  * @tc.desc: Verify ReleaseForm
673  * @tc.type: FUNC
674  * @tc.require: issueI63OQL
675  */
676 HWTEST_F(FormMgrTest, FormMgrTest_0029, TestSize.Level1) {
677     GTEST_LOG_(INFO) << "FormMgrTest_0029 starts";
678     int64_t formId = 1;
679     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
680     bool delCache = true;
681     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
682     int result = FormMgr::GetInstance().ReleaseForm(formId, token, delCache);
683 
684     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
685     GTEST_LOG_(INFO) << "FormMgrTest_0029 test ends";
686 }
687 
688 /**
689  * @tc.name: FormMgrTest_0030
690  * @tc.desc: Verify ReleaseForm
691  * @tc.type: FUNC
692  * @tc.require: issueI63OQL
693  */
694 HWTEST_F(FormMgrTest, FormMgrTest_0030, TestSize.Level1) {
695     GTEST_LOG_(INFO) << "FormMgrTest_0030 starts";
696     int64_t formId = -1;
697     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
698     bool delCache = true;
699     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
700     int result = FormMgr::GetInstance().ReleaseForm(formId, token, delCache);
701 
702     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
703     GTEST_LOG_(INFO) << "FormMgrTest_0030 test ends";
704 }
705 
706 /**
707  * @tc.name: FormMgrTest_0031
708  * @tc.desc: Verify UpdateForm
709  * @tc.type: FUNC
710  * @tc.require: issueI63OQL
711  */
712 HWTEST_F(FormMgrTest, FormMgrTest_0031, TestSize.Level1) {
713     GTEST_LOG_(INFO) << "FormMgrTest_0031 starts";
714     int64_t formId = 1;
715     FormProviderData formBindingData;
716     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
717     int result = FormMgr::GetInstance().UpdateForm(formId, formBindingData);
718 
719     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
720     GTEST_LOG_(INFO) << "FormMgrTest_0031 test ends";
721 }
722 
723 /**
724  * @tc.name: FormMgrTest_0032
725  * @tc.desc: Verify UpdateForm
726  * @tc.type: FUNC
727  * @tc.require: issueI63OQL
728  */
729 HWTEST_F(FormMgrTest, FormMgrTest_0032, TestSize.Level1) {
730     GTEST_LOG_(INFO) << "FormMgrTest_0032 starts";
731     int64_t formId = -1;
732     FormProviderData formBindingData;
733     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
734     int result = FormMgr::GetInstance().UpdateForm(formId, formBindingData);
735 
736     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
737     GTEST_LOG_(INFO) << "FormMgrTest_0032 test ends";
738 }
739 
740 /**
741  * @tc.name: FormMgrTest_0033
742  * @tc.desc: Verify UpdateForm
743  * @tc.type: FUNC
744  * @tc.require: issueI63OQL
745  */
746 HWTEST_F(FormMgrTest, FormMgrTest_0033, TestSize.Level1) {
747     GTEST_LOG_(INFO) << "FormMgrTest_0033 starts";
748     int64_t formId = 1;
749     FormProviderData formBindingData;
750     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
751     int result = FormMgr::GetInstance().UpdateForm(formId, formBindingData);
752 
753     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_PROVIDER_DATA_EMPTY);
754     GTEST_LOG_(INFO) << "FormMgrTest_0033 test ends";
755 }
756 
757 /**
758  * @tc.name: FormMgrTest_0034
759  * @tc.desc: Verify RequestForm
760  * @tc.type: FUNC
761  * @tc.require: issueI63OQL
762  */
763 HWTEST_F(FormMgrTest, FormMgrTest_0034, TestSize.Level1) {
764     GTEST_LOG_(INFO) << "FormMgrTest_0034 starts";
765     int64_t formId = 1;
766     Want want;
767     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
768     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
769     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
770     int result = FormMgr::GetInstance().RequestForm(formId, token, want);
771 
772     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
773     GTEST_LOG_(INFO) << "FormMgrTest_0034 test ends";
774 }
775 
776 /**
777  * @tc.name: FormMgrTest_0035
778  * @tc.desc: Verify RequestForm
779  * @tc.type: FUNC
780  * @tc.require: issueI63OQL
781  */
782 HWTEST_F(FormMgrTest, FormMgrTest_0035, TestSize.Level1) {
783     GTEST_LOG_(INFO) << "FormMgrTest_0035 starts";
784     int64_t formId = -1;
785     Want want;
786     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
787     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
788     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
789     int result = FormMgr::GetInstance().RequestForm(formId, token, want);
790 
791     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
792     GTEST_LOG_(INFO) << "FormMgrTest_0035 test ends";
793 }
794 
795 /**
796  * @tc.name: FormMgrTest_0036
797  * @tc.desc: Verify NotifyWhetherVisibleForms
798  * @tc.type: FUNC
799  * @tc.require: issueI63OQL
800  */
801 HWTEST_F(FormMgrTest, FormMgrTest_0036, TestSize.Level1) {
802     GTEST_LOG_(INFO) << "FormMgrTest_0036 starts";
803     std::vector<int64_t> formIds;
804     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
805     int32_t formVisibleType = 1;
806     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
807     int result = FormMgr::GetInstance().NotifyWhetherVisibleForms(formIds, token, formVisibleType);
808 
809     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
810     GTEST_LOG_(INFO) << "FormMgrTest_0036 test ends";
811 }
812 
813 /**
814  * @tc.name: FormMgrTest_0037
815  * @tc.desc: Verify NotifyWhetherVisibleForms
816  * @tc.type: FUNC
817  * @tc.require: issueI63OQL
818  */
819 HWTEST_F(FormMgrTest, FormMgrTest_0037, TestSize.Level1) {
820     GTEST_LOG_(INFO) << "FormMgrTest_0037 starts";
821     std::vector<int64_t> formIds;
822     int64_t formId = 1;
823     formIds.emplace_back(formId);
824     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
825     int32_t formVisibleType = 1;
826     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
827     int result = FormMgr::GetInstance().NotifyWhetherVisibleForms(formIds, token, formVisibleType);
828 
829     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
830     GTEST_LOG_(INFO) << "FormMgrTest_0037 test ends";
831 }
832 
833 /**
834  * @tc.name: FormMgrTest_0038
835  * @tc.desc: Verify SetNextRefreshTime
836  * @tc.type: FUNC
837  * @tc.require: issueI63OQL
838  */
839 HWTEST_F(FormMgrTest, FormMgrTest_0038, TestSize.Level1) {
840     GTEST_LOG_(INFO) << "FormMgrTest_0038 starts";
841     int64_t formId = 10;
842     int64_t nextTime = 50;
843     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
844     int result = FormMgr::GetInstance().SetNextRefreshTime(formId, nextTime);
845 
846     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
847     GTEST_LOG_(INFO) << "FormMgrTest_0038 test ends";
848 }
849 
850 /**
851  * @tc.name: FormMgrTest_0039
852  * @tc.desc: Verify LifecycleUpdate
853  * @tc.type: FUNC
854  * @tc.require: issueI63OQL
855  */
856 HWTEST_F(FormMgrTest, FormMgrTest_0039, TestSize.Level1) {
857     GTEST_LOG_(INFO) << "FormMgrTest_0039 starts";
858     std::vector<int64_t> formIds;
859     int64_t formId = 1;
860     formIds.emplace_back(formId);
861     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
862     bool updateType = true;
863     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
864     int result = FormMgr::GetInstance().LifecycleUpdate(formIds, token, updateType);
865 
866     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
867     GTEST_LOG_(INFO) << "FormMgrTest_0039 test ends";
868 }
869 
870 /**
871  * @tc.name: FormMgrTest_0040
872  * @tc.desc: Verify RegisterDeathCallback
873  * @tc.type: FUNC
874  * @tc.require: issueI63OQL
875  */
876 HWTEST_F(FormMgrTest, FormMgrTest_0040, TestSize.Level1) {
877     GTEST_LOG_(INFO) << "FormMgrTest_0040 starts";
878     std::shared_ptr<FormMgr> formMgr = std::make_shared<FormMgr>();
879     ASSERT_NE(nullptr, formMgr);
880     formMgr->RegisterDeathCallback(nullptr);
881     formMgr->UnRegisterDeathCallback(nullptr);
882     formMgr->SetRecoverStatus(Constants::IN_RECOVERING);
883     GTEST_LOG_(INFO) << "FormMgrTest_0040 test ends";
884 }
885 
886 /**
887  * @tc.name: FormMgrTest_0041
888  * @tc.desc: Verify DeleteInvalidForms
889  * @tc.type: FUNC
890  * @tc.require: issueI63OQL
891  */
892 HWTEST_F(FormMgrTest, FormMgrTest_0041, TestSize.Level1) {
893     GTEST_LOG_(INFO) << "FormMgrTest_0041 starts";
894     std::vector<int64_t> formIds;
895     int64_t formId = 1;
896     formIds.emplace_back(formId);
897     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
898     int32_t numFormsDeleted = 2;
899     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
900     int result = FormMgr::GetInstance().DeleteInvalidForms(formIds, token, numFormsDeleted);
901 
902     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
903     GTEST_LOG_(INFO) << "FormMgrTest_0041 test ends";
904 }
905 
906 /**
907  * @tc.name: FormMgrTest_0042
908  * @tc.desc: Verify AcquireFormState
909  * @tc.type: FUNC
910  * @tc.require: issueI63OQL
911  */
912 HWTEST_F(FormMgrTest, FormMgrTest_0042, TestSize.Level1) {
913     GTEST_LOG_(INFO) << "FormMgrTest_0042 starts";
914     Want want;
915     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
916     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
917     FormStateInfo stateInfo;
918     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
919     int result = FormMgr::GetInstance().AcquireFormState(want, token, stateInfo);
920 
921     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
922     GTEST_LOG_(INFO) << "FormMgrTest_0042 test ends";
923 }
924 
925 /**
926  * @tc.name: FormMgrTest_0043
927  * @tc.desc: Verify NotifyFormsVisible
928  * @tc.type: FUNC
929  * @tc.require: issueI63OQL
930  */
931 HWTEST_F(FormMgrTest, FormMgrTest_0043, TestSize.Level1) {
932     GTEST_LOG_(INFO) << "FormMgrTest_0043 starts";
933     std::vector<int64_t> formIds;
934     int64_t formId = 1;
935     formIds.emplace_back(formId);
936     bool isVisible = true;
937     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
938     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
939     int result = FormMgr::GetInstance().NotifyFormsVisible(formIds, isVisible, token);
940 
941     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
942     GTEST_LOG_(INFO) << "FormMgrTest_0043 test ends";
943 }
944 
945 /**
946  * @tc.name: FormMgrTest_0044
947  * @tc.desc: Verify NotifyFormsPrivacyProtected
948  * @tc.type: FUNC
949  * @tc.require: issueI63OQL
950  */
951 HWTEST_F(FormMgrTest, FormMgrTest_0044, TestSize.Level1) {
952     GTEST_LOG_(INFO) << "FormMgrTest_0044 starts";
953     std::vector<int64_t> formIds;
954     int64_t formId = 1;
955     formIds.emplace_back(formId);
956     bool isProtected = true;
957     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
958     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
959     int result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
960 
961     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
962     GTEST_LOG_(INFO) << "FormMgrTest_0044 test ends";
963 }
964 
965 /**
966  * @tc.name: FormMgrTest_0045
967  * @tc.desc: Verify NotifyFormsEnableUpdate
968  * @tc.type: FUNC
969  * @tc.require: issueI63OQL
970  */
971 HWTEST_F(FormMgrTest, FormMgrTest_0045, TestSize.Level1) {
972     GTEST_LOG_(INFO) << "FormMgrTest_0045 starts";
973     std::vector<int64_t> formIds;
974     int64_t formId = 1;
975     formIds.emplace_back(formId);
976     bool isEnableUpdate = true;
977     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
978     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
979     int result = FormMgr::GetInstance().NotifyFormsEnableUpdate(formIds, isEnableUpdate, token);
980 
981     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
982     GTEST_LOG_(INFO) << "FormMgrTest_0045 test ends";
983 }
984 
985 /**
986  * @tc.name: FormMgrTest_0046
987  * @tc.desc: Verify GetAllFormsInfo
988  * @tc.type: FUNC
989  * @tc.require: issueI63OQL
990  */
991 HWTEST_F(FormMgrTest, FormMgrTest_0046, TestSize.Level1) {
992     GTEST_LOG_(INFO) << "FormMgrTest_0046 starts";
993     std::vector<FormInfo> formInfos;
994     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
995     int result = FormMgr::GetInstance().GetAllFormsInfo(formInfos);
996 
997     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
998     GTEST_LOG_(INFO) << "FormMgrTest_0046 test ends";
999 }
1000 
1001 /**
1002  * @tc.name: FormMgrTest_0047
1003  * @tc.desc: Verify GetFormsInfoByApp
1004  * @tc.type: FUNC
1005  * @tc.require: issueI63OQL
1006  */
1007 HWTEST_F(FormMgrTest, FormMgrTest_0047, TestSize.Level1) {
1008     GTEST_LOG_(INFO) << "FormMgrTest_0047 starts";
1009     std::string bundleName = "this is bundleName";
1010     std::vector<FormInfo> formInfos;
1011     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1012     int result = FormMgr::GetInstance().GetFormsInfoByApp(bundleName, formInfos);
1013 
1014     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
1015     GTEST_LOG_(INFO) << "FormMgrTest_0047 test ends";
1016 }
1017 
1018 /**
1019  * @tc.name: FormMgrTest_0048
1020  * @tc.desc: Verify GetFormsInfoByApp
1021  * @tc.type: FUNC
1022  * @tc.require: issueI63OQL
1023  */
1024 HWTEST_F(FormMgrTest, FormMgrTest_0048, TestSize.Level1) {
1025     GTEST_LOG_(INFO) << "FormMgrTest_0048 starts";
1026     std::string bundleName = "";
1027     std::vector<FormInfo> formInfos;
1028     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1029     int result = FormMgr::GetInstance().GetFormsInfoByApp(bundleName, formInfos);
1030 
1031     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_BUNDLENAME);
1032     GTEST_LOG_(INFO) << "FormMgrTest_0048 test ends";
1033 }
1034 
1035 /**
1036  * @tc.name: FormMgrTest_0050
1037  * @tc.desc: Verify GetFormsInfoByModule
1038  * @tc.type: FUNC
1039  * @tc.require: issueI63OQL
1040  */
1041 HWTEST_F(FormMgrTest, FormMgrTest_0050, TestSize.Level1) {
1042     GTEST_LOG_(INFO) << "FormMgrTest_0050 starts";
1043     std::string bundleName = "";
1044     std::string moduleName = "this is moduleName";
1045     std::vector<FormInfo> formInfos;
1046     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1047     int result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
1048 
1049     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_BUNDLENAME);
1050     GTEST_LOG_(INFO) << "FormMgrTest_0050 test ends";
1051 }
1052 
1053 /**
1054  * @tc.name: FormMgrTest_0051
1055  * @tc.desc: Verify GetFormsInfoByModule
1056  * @tc.type: FUNC
1057  * @tc.require: issueI63OQL
1058  */
1059 HWTEST_F(FormMgrTest, FormMgrTest_0051, TestSize.Level1) {
1060     GTEST_LOG_(INFO) << "FormMgrTest_0051 starts";
1061     std::string bundleName = "this is bundleName";
1062     std::string moduleName = "";
1063     std::vector<FormInfo> formInfos;
1064     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1065     int result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
1066 
1067     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_MODULENAME);
1068     GTEST_LOG_(INFO) << "FormMgrTest_0051 test ends";
1069 }
1070 
1071 /**
1072  * @tc.name: FormMgrTest_0052
1073  * @tc.desc: Verify GetFormsInfoByModule
1074  * @tc.type: FUNC
1075  * @tc.require: issueI63OQL
1076  */
1077 HWTEST_F(FormMgrTest, FormMgrTest_0052, TestSize.Level1) {
1078     GTEST_LOG_(INFO) << "FormMgrTest_0052 starts";
1079     std::string bundleName = "this is bundleName";
1080     std::string moduleName = "this is moduleName";
1081     std::vector<FormInfo> formInfos;
1082     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1083     int result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
1084 
1085     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
1086     GTEST_LOG_(INFO) << "FormMgrTest_0052 test ends";
1087 }
1088 
1089 /**
1090  * @tc.name: FormMgrTest_0053
1091  * @tc.desc: Verify GetErrorMessage
1092  * @tc.type: FUNC
1093  * @tc.require: issueI63Y7Y
1094  */
1095 HWTEST_F(FormMgrTest, FormMgrTest_0053, TestSize.Level1) {
1096     GTEST_LOG_(INFO) << "FormMgrTest_0053 starts";
1097     FormErrors::GetInstance().InitErrorMessageMap();
1098     int errCode = ERR_APPEXECFWK_FORM_COMMON_CODE;
1099     auto result = FormMgr::GetInstance().GetErrorMessage(errCode);
1100 
1101     EXPECT_EQ(result, "some internal server error occurs.");
1102     GTEST_LOG_(INFO) << "FormMgrTest_0053 test ends";
1103 }
1104 
1105 /**
1106  * @tc.name: FormMgrTest_0054
1107  * @tc.desc: Verify AddForm
1108  * @tc.type: FUNC
1109  * @tc.require: issueI63Y7Y
1110  */
1111 HWTEST_F(FormMgrTest, FormMgrTest_0054, TestSize.Level1)
1112 {
1113     GTEST_LOG_(INFO) << "FormMgrTest_0054 starts";
1114     int64_t formId = 10;
1115     Want want;
1116     FormJsInfo formInfo;
1117     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1118     auto data = FormMgr::GetInstance().AddForm(formId, want, token, formInfo);
1119     EXPECT_EQ(data, ERROR_NUMS);
1120     GTEST_LOG_(INFO) << "FormMgrTest_0054 test ends";
1121 }
1122 
1123 /**
1124  * @tc.name: FormMgrTest_0055
1125  * @tc.desc: Verify DeleteForm (ID <= 0)
1126  * @tc.type: FUNC
1127  * @tc.require: issueI63Y7Y
1128  */
1129 HWTEST_F(FormMgrTest, FormMgrTest_0055, TestSize.Level1)
1130 {
1131     GTEST_LOG_(INFO) << "FormMgrTest_0055 starts";
1132     int64_t formId = -1;
1133     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1134     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1135     int result = FormMgr::GetInstance().DeleteForm(formId, token);
1136     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
1137     GTEST_LOG_(INFO) << "FormMgrTest_0055 test ends";
1138 }
1139 
1140 /**
1141  * @tc.name: FormMgrTest_0056
1142  * @tc.desc: Verify DeleteForm (Parameters are normal.)
1143  * @tc.type: FUNC
1144  * @tc.require: issueI63Y7Y
1145  */
1146 HWTEST_F(FormMgrTest, FormMgrTest_0056, TestSize.Level1)
1147 {
1148     GTEST_LOG_(INFO) << "FormMgrTest_0056 starts";
1149     EXPECT_CALL(*mockProxy, DeleteForm(_, _))
1150         .Times(1)
1151         .WillOnce(Return(OHOS::ERR_OK));
1152     int64_t formId = 1;
1153     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1154     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1155     int result = FormMgr::GetInstance().DeleteForm(formId, token);
1156     EXPECT_EQ(result, OHOS::ERR_OK);
1157     GTEST_LOG_(INFO) << "FormMgrTest_0056 test ends";
1158 }
1159 
1160 /**
1161  * @tc.name: FormMgrTest_0057
1162  * @tc.desc: Verify ReleaseForm (Parameters are normal.)
1163  * @tc.type: FUNC
1164  * @tc.require: issueI63Y7Y
1165  */
1166 HWTEST_F(FormMgrTest, FormMgrTest_0057, TestSize.Level1)
1167 {
1168     GTEST_LOG_(INFO) << "FormMgrTest_0057 starts";
1169     EXPECT_CALL(*mockProxy, ReleaseForm(_, _, _))
1170         .Times(1)
1171         .WillOnce(Return(OHOS::ERR_OK));
1172     int64_t formId = 1;
1173     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1174     bool delCache = true;
1175     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1176     int result = FormMgr::GetInstance().ReleaseForm(formId, token, delCache);
1177     EXPECT_EQ(result, OHOS::ERR_OK);
1178     GTEST_LOG_(INFO) << "FormMgrTest_0057 test ends";
1179 }
1180 
1181 /**
1182  * @tc.name: FormMgrTest_0058
1183  * @tc.desc: Verify UpdateForm (Parameter formId exception)
1184  * @tc.type: FUNC
1185  * @tc.require: issueI63Y7Y
1186  */
1187 HWTEST_F(FormMgrTest, FormMgrTest_0058, TestSize.Level1) {
1188     GTEST_LOG_(INFO) << "FormMgrTest_0058 starts";
1189     EXPECT_CALL(*mockProxy, UpdateForm(_, _))
1190         .Times(1)
1191         .WillOnce(Return(NEGATIVE_NUM));
1192     FormJsInfo formJsInfo;
1193     formJsInfo.formId = 0x00000008fffffffL;
1194     FormProviderData formProviderData = FormProviderData(std::string("{\"city\": \"beijing001\"}"));
1195     int32_t result = FormMgr::GetInstance().UpdateForm(formJsInfo.formId, formProviderData);
1196     EXPECT_EQ(result, NEGATIVE_NUM);
1197     GTEST_LOG_(INFO) << "FormMgrTest_0058 test ends";
1198 }
1199 
1200 /**
1201  * @tc.name: FormMgrTest_0059
1202  * @tc.desc: Verify RequestForm (Parameter formId exception)
1203  * @tc.type: FUNC
1204  * @tc.require: issueI63Y7Y
1205  */
1206 HWTEST_F(FormMgrTest, FormMgrTest_0059, TestSize.Level1) {
1207     GTEST_LOG_(INFO) << "FormMgrTest_0059 starts";
1208     EXPECT_CALL(*mockProxy, RequestForm(_, _, _))
1209         .Times(1)
1210         .WillOnce(Return(NEGATIVE_NUM));
1211     Want want;
1212     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
1213     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1214     FormJsInfo formJsInfo;
1215     formJsInfo.formId = 0x00000008fffffffL;
1216     int32_t result = FormMgr::GetInstance().RequestForm(formJsInfo.formId, token, want);
1217     EXPECT_EQ(result, NEGATIVE_NUM);
1218     GTEST_LOG_(INFO) << "FormMgrTest_0059 test ends";
1219 }
1220 
1221 /**
1222  * @tc.name: FormMgrTest_0060
1223  * @tc.desc: Verify NotifyWhetherVisibleForms (Parameters are normal, the return value of mock function is 0)
1224  * @tc.type: FUNC
1225  * @tc.require: issueI63Y7Y
1226  */
1227 HWTEST_F(FormMgrTest, FormMgrTest_0060, TestSize.Level1) {
1228     GTEST_LOG_(INFO) << "FormMgrTest_0060 starts";
1229     EXPECT_CALL(*mockProxy, NotifyWhetherVisibleForms(_, _, _))
1230         .Times(1)
1231         .WillOnce(Return(OHOS::ERR_OK));
1232     std::vector<int64_t> formIds;
1233     int64_t formId = 1;
1234     formIds.emplace_back(formId);
1235     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1236     int32_t formVisibleType = 1;
1237     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1238     int result = FormMgr::GetInstance().NotifyWhetherVisibleForms(formIds, token, formVisibleType);
1239     EXPECT_EQ(result, OHOS::ERR_OK);
1240     GTEST_LOG_(INFO) << "FormMgrTest_0060 test ends";
1241 }
1242 
1243 /**
1244  * @tc.name: FormMgrTest_0061
1245  * @tc.desc: Verify NotifyWhetherVisibleForms (Parameters are normal, the return value of mock function is not 0)
1246  * @tc.type: FUNC
1247  * @tc.require: issueI63Y7Y
1248  */
1249 HWTEST_F(FormMgrTest, FormMgrTest_0061, TestSize.Level1) {
1250     GTEST_LOG_(INFO) << "FormMgrTest_0061 starts";
1251     EXPECT_CALL(*mockProxy, NotifyWhetherVisibleForms(_, _, _))
1252         .Times(1)
1253         .WillOnce(Return(POSITIVE_NUM));
1254     std::vector<int64_t> formIds;
1255     int64_t formId = 1;
1256     formIds.emplace_back(formId);
1257     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1258     int32_t formVisibleType = 1;
1259     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1260     int result = FormMgr::GetInstance().NotifyWhetherVisibleForms(formIds, token, formVisibleType);
1261     EXPECT_EQ(result, POSITIVE_NUM);
1262     GTEST_LOG_(INFO) << "FormMgrTest_0061 test ends";
1263 }
1264 
1265 /**
1266  * @tc.name: FormMgrTest_0062
1267  * @tc.desc: Verify CastTempForm (Parameters are normal, the return value of mock function is 0)
1268  * @tc.type: FUNC
1269  * @tc.require: issueI63Y7Y
1270  */
1271 HWTEST_F(FormMgrTest, FormMgrTest_0062, TestSize.Level1) {
1272     GTEST_LOG_(INFO) << "FormMgrTest_0062 starts";
1273     EXPECT_CALL(*mockProxy, CastTempForm(_, _))
1274         .Times(1)
1275         .WillOnce(Return(OHOS::ERR_OK));
1276     int64_t formId = 1;
1277     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1278     int result = FormMgr::GetInstance().CastTempForm(formId, token);
1279     EXPECT_EQ(result, OHOS::ERR_OK);
1280     GTEST_LOG_(INFO) << "FormMgrTest_0062 test ends";
1281 }
1282 
1283 /**
1284  * @tc.name: FormMgrTest_0063
1285  * @tc.desc: Verify CastTempForm (Parameters are normal, the return value of mock function is not 0)
1286  * @tc.type: FUNC
1287  * @tc.require: issueI63Y7Y
1288  */
1289 HWTEST_F(FormMgrTest, FormMgrTest_0063, TestSize.Level1) {
1290     GTEST_LOG_(INFO) << "FormMgrTest_0063 starts";
1291     EXPECT_CALL(*mockProxy, CastTempForm(_, _))
1292         .Times(1)
1293         .WillOnce(Return(POSITIVE_NUM));
1294     int64_t formId = 1;
1295     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1296     int result = FormMgr::GetInstance().CastTempForm(formId, token);
1297     EXPECT_EQ(result, POSITIVE_NUM);
1298     GTEST_LOG_(INFO) << "FormMgrTest_0063 test ends";
1299 }
1300 
1301 /**
1302  * @tc.name: FormMgrTest_0064
1303  * @tc.desc: Verify CastTempForm (formId <= 0)
1304  * @tc.type: FUNC
1305  * @tc.require: issueI63Y7Y
1306  */
1307 HWTEST_F(FormMgrTest, FormMgrTest_0064, TestSize.Level1) {
1308     GTEST_LOG_(INFO) << "FormMgrTest_0064 starts";
1309     EXPECT_CALL(*mockProxy, CastTempForm(_, _))
1310         .Times(1)
1311         .WillOnce(Return(OHOS::ERR_OK));
1312     int64_t formId = -1;
1313     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1314     int result = FormMgr::GetInstance().CastTempForm(formId, token);
1315     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
1316     GTEST_LOG_(INFO) << "FormMgrTest_0064 test ends";
1317 }
1318 
1319 /**
1320  * @tc.name: FormMgrTest_0065
1321  * @tc.desc: Verify RegisterDeathCallback (Parameter is not nullptr)
1322  * @tc.type: FUNC
1323  * @tc.require: issueI63Y7Y
1324  */
1325 HWTEST_F(FormMgrTest, FormMgrTest_0065, TestSize.Level1) {
1326     GTEST_LOG_(INFO) << "FormMgrTest_0065 starts";
1327     std::shared_ptr<FormMgr> formMgr = std::make_shared<FormMgr>();
1328     ASSERT_NE(nullptr, formMgr);
1329     std::shared_ptr<FormInterfaceCallbackTest> callback = std::make_shared<FormInterfaceCallbackTest>();
1330     std::shared_ptr<FormInterfaceCallbackTest> callback_first = std::make_shared<FormInterfaceCallbackTest>();
1331     formMgr->formDeathCallbacks_.emplace_back(callback);
1332     formMgr->formDeathCallbacks_.emplace_back(callback_first);
1333     formMgr->RegisterDeathCallback(callback);
1334     GTEST_LOG_(INFO) << "FormMgrTest_0065 test ends";
1335 }
1336 
1337 /**
1338  * @tc.name: FormMgrTest_0066
1339  * @tc.desc: Verify UnRegisterDeathCallback (Parameter is not nullptr)
1340  * @tc.type: FUNC
1341  * @tc.require: issueI63Y7Y
1342  */
1343 HWTEST_F(FormMgrTest, FormMgrTest_0066, TestSize.Level1) {
1344     GTEST_LOG_(INFO) << "FormMgrTest_0066 starts";
1345     std::shared_ptr<FormMgr> formMgr = std::make_shared<FormMgr>();
1346     ASSERT_NE(nullptr, formMgr);
1347     std::shared_ptr<FormInterfaceCallbackTest> callback = std::make_shared<FormInterfaceCallbackTest>();
1348     std::shared_ptr<FormInterfaceCallbackTest> callback_first = std::make_shared<FormInterfaceCallbackTest>();
1349     formMgr->formDeathCallbacks_.emplace_back(callback);
1350     formMgr->formDeathCallbacks_.emplace_back(callback_first);
1351     formMgr->UnRegisterDeathCallback(callback);
1352     GTEST_LOG_(INFO) << "FormMgrTest_0066 test ends";
1353 }
1354 
1355 /**
1356  * @tc.name: FormMgrTest_0067
1357  * @tc.desc: Verify GetDeathRecipient
1358  * @tc.type: FUNC
1359  * @tc.require: issueI63Y7Y
1360  */
1361 HWTEST_F(FormMgrTest, FormMgrTest_0067, TestSize.Level1)
1362 {
1363     GTEST_LOG_(INFO) << "FormMgrTest_0067 starts";
1364     auto data = FormMgr::GetInstance().GetDeathRecipient();
1365     EXPECT_TRUE(data == FormMgr::GetInstance().deathRecipient_);
1366     GTEST_LOG_(INFO) << "FormMgrTest_0067 test ends";
1367 }
1368 
1369 /**
1370  * @tc.name: FormMgrTest_0068
1371  * @tc.desc: Verify CheckIsDeathCallbackRegistered (Parameter is nullptr)
1372  * @tc.type: FUNC
1373  * @tc.require: issueI63Y7Y
1374  */
1375 HWTEST_F(FormMgrTest, FormMgrTest_0068, TestSize.Level1) {
1376     GTEST_LOG_(INFO) << "FormMgrTest_0068 starts";
1377     bool data = FormMgr::GetInstance().CheckIsDeathCallbackRegistered(nullptr);
1378     EXPECT_TRUE(data == false);
1379     GTEST_LOG_(INFO) << "FormMgrTest_0068 test ends";
1380 }
1381 
1382 /**
1383  * @tc.name: FormMgrTest_0069
1384  * @tc.desc: Verify CheckIsDeathCallbackRegistered (Parameter is not nullptr)
1385  * @tc.type: FUNC
1386  * @tc.require: issueI63Y7Y
1387  */
1388 HWTEST_F(FormMgrTest, FormMgrTest_0069, TestSize.Level1) {
1389     GTEST_LOG_(INFO) << "FormMgrTest_0069 starts";
1390     std::shared_ptr<FormInterfaceCallbackTest> callback = std::make_shared<FormInterfaceCallbackTest>();
1391     std::shared_ptr<FormInterfaceCallbackTest> callback_first = std::make_shared<FormInterfaceCallbackTest>();
1392     std::shared_ptr<FormInterfaceCallbackTest> callback_second = std::make_shared<FormInterfaceCallbackTest>();
1393     bool result = FormMgr::GetInstance().CheckIsDeathCallbackRegistered(callback_first);
1394     EXPECT_TRUE(result == false);
1395     FormMgr::GetInstance().formDeathCallbacks_.emplace_back(callback_first);
1396     FormMgr::GetInstance().formDeathCallbacks_.emplace_back(callback_second);
1397     bool data = FormMgr::GetInstance().CheckIsDeathCallbackRegistered(callback_first);
1398     EXPECT_TRUE(data);
1399     GTEST_LOG_(INFO) << "FormMgrTest_0069 test ends";
1400 }
1401 
1402 /**
1403  * @tc.name: FormMgrTest_0070
1404  * @tc.desc: Verify CheckIsDeathCallbackRegistered (Parameter exception)
1405  * @tc.type: FUNC
1406  * @tc.require: issueI63Y7Y
1407  */
1408 HWTEST_F(FormMgrTest, FormMgrTest_0070, TestSize.Level1) {
1409     GTEST_LOG_(INFO) << "FormMgrTest_0070 starts";
1410     std::shared_ptr<FormInterfaceCallbackTest> callback = std::make_shared<FormInterfaceCallbackTest>();
1411     std::shared_ptr<FormInterfaceCallbackTest> callback_first = std::make_shared<FormInterfaceCallbackTest>();
1412     std::shared_ptr<FormInterfaceCallbackTest> callback_second = std::make_shared<FormInterfaceCallbackTest>();
1413     FormMgr::GetInstance().formDeathCallbacks_.emplace_back(callback_first);
1414     FormMgr::GetInstance().formDeathCallbacks_.emplace_back(callback_second);
1415     bool data = FormMgr::GetInstance().CheckIsDeathCallbackRegistered(callback);
1416     EXPECT_TRUE(data == false);
1417     GTEST_LOG_(INFO) << "FormMgrTest_0070 test ends";
1418 }
1419 
1420 /**
1421  * @tc.name: FormMgrTest_0071
1422  * @tc.desc: Verify OnRemoteDied
1423  * @tc.type: FUNC
1424  * @tc.require: issueI63Y7Y
1425  */
1426 HWTEST_F(FormMgrTest, FormMgrTest_0071, TestSize.Level1) {
1427     GTEST_LOG_(INFO) << "FormMgrTest_0071 starts";
1428     sptr<IRemoteObject> mockFormProviderClient = new (std::nothrow) MockFormProviderClient();
1429     sptr<FormMgr::FormMgrDeathRecipient> formMgrDeath = new (std::nothrow) FormMgr::FormMgrDeathRecipient();
1430     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1431     formMgrDeath->OnRemoteDied(mockFormProviderClient);
1432     EXPECT_TRUE(FormMgr::GetInstance().GetRecoverStatus() == Constants::IN_RECOVERING);
1433     GTEST_LOG_(INFO) << "FormMgrTest_0071 test ends";
1434 }
1435 
1436 /**
1437  * @tc.name: FormMgrTest_0072
1438  * @tc.desc: Verify OnRemoteDied (Parameter is nullptr)
1439  * @tc.type: FUNC
1440  * @tc.require: issueI63Y7Y
1441  */
1442 HWTEST_F(FormMgrTest, FormMgrTest_0072, TestSize.Level1) {
1443     GTEST_LOG_(INFO) << "FormMgrTest_0072 starts";
1444     sptr<FormMgr::FormMgrDeathRecipient> formMgrDeath = new (std::nothrow) FormMgr::FormMgrDeathRecipient();
1445     formMgrDeath->OnRemoteDied(nullptr);
1446     GTEST_LOG_(INFO) << "FormMgrTest_0072 test ends";
1447 }
1448 
1449 /**
1450  * @tc.name: FormMgrTest_0073
1451  * @tc.desc: Verify Reconnect
1452  * @tc.type: FUNC
1453  * @tc.require: issueI63Y7Y
1454  */
1455 HWTEST_F(FormMgrTest, FormMgrTest_0073, TestSize.Level1) {
1456     GTEST_LOG_(INFO) << "FormMgrTest_0073 starts";
1457     bool data =  FormMgr::GetInstance().Reconnect();
1458     EXPECT_EQ(data, true);
1459     GTEST_LOG_(INFO) << "FormMgrTest_0073 test ends";
1460 }
1461 
1462 /**
1463  * @tc.name: FormMgrTest_0074
1464  * @tc.desc: Verify ResetProxy (Parameter is nullptr)
1465  * @tc.type: FUNC
1466  * @tc.require: issueI63Y7Y
1467  */
1468 HWTEST_F(FormMgrTest, FormMgrTest_0074, TestSize.Level1) {
1469     GTEST_LOG_(INFO) << "FormMgrTest_0074 starts";
1470     std::shared_ptr<FormMgr> formMgr = std::make_shared<FormMgr>();
1471     ASSERT_NE(nullptr, formMgr);
1472     formMgr->ResetProxy(nullptr);
1473     formMgr->SetFormMgrService(mockProxy);
1474     GTEST_LOG_(INFO) << "FormMgrTest_0074 test ends";
1475 }
1476 
1477 /**
1478  * @tc.name: FormMgrTest_0075
1479  * @tc.desc: Verify ResetProxy
1480  * @tc.type: FUNC
1481  * @tc.require: issueI63Y7Y
1482  */
1483 HWTEST_F(FormMgrTest, FormMgrTest_0075, TestSize.Level1) {
1484     GTEST_LOG_(INFO) << "FormMgrTest_0075 starts";
1485     sptr<IRemoteObject> remote = new (std::nothrow) MockFormProviderClient();
1486     FormMgr::GetInstance().ResetProxy(remote);
1487     EXPECT_TRUE(FormMgr::GetInstance().GetRecoverStatus() == Constants::IN_RECOVERING);
1488     FormMgr::GetInstance().SetFormMgrService(mockProxy);
1489     GTEST_LOG_(INFO) << "FormMgrTest_0075 test ends";
1490 }
1491 
1492 /**
1493  * @tc.name: FormMgrTest_0076
1494  * @tc.desc: Verify DeleteInvalidForms (The return value of mock function is not 0)
1495  * @tc.type: FUNC
1496  * @tc.require: issueI63Y7Y
1497  */
1498 HWTEST_F(FormMgrTest, FormMgrTest_0076, TestSize.Level1) {
1499     GTEST_LOG_(INFO) << "FormMgrTest_0076 starts";
1500     EXPECT_CALL(*mockProxy, DeleteInvalidForms(_, _, _))
1501         .Times(1)
1502         .WillOnce(Return(POSITIVE_NUM));
1503     std::vector<int64_t> formInfos;
1504     formInfos.push_back(1);
1505     formInfos.push_back(2);
1506     FormJsInfo formJsInfo;
1507     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1508     int32_t numFormsDeleted = 2;
1509     auto result = FormMgr::GetInstance().DeleteInvalidForms(formInfos, token, numFormsDeleted);
1510     EXPECT_EQ(result, ERROR_NUM);
1511     GTEST_LOG_(INFO) << "FormMgrTest_0076 test ends";
1512 }
1513 
1514 /**
1515  * @tc.name: FormMgrTest_0077
1516  * @tc.desc: Verify AcquireFormState (The return value of mock function is not 0)
1517  * @tc.type: FUNC
1518  * @tc.require: issueI63Y7Y
1519  */
1520 HWTEST_F(FormMgrTest, FormMgrTest_0077, TestSize.Level1) {
1521     GTEST_LOG_(INFO) << "FormMgrTest_0077 starts";
1522     EXPECT_CALL(*mockProxy, AcquireFormState(_, _, _))
1523         .Times(1)
1524         .WillOnce(Return(POSITIVE_NUM));
1525     Want want;
1526     want = want.SetElementName("", "com.example.FormAbility", "MainAbility");
1527     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1528     FormStateInfo stateInfo;
1529     auto result = FormMgr::GetInstance().AcquireFormState(want, token, stateInfo);
1530     EXPECT_EQ(result, ERROR_NUM);
1531     GTEST_LOG_(INFO) << "FormMgrTest_0077 test ends";
1532 }
1533 
1534 /**
1535  * @tc.name: FormMgrTest_0078
1536  * @tc.desc: Verify NotifyFormsVisible (The return value of mock function is not 0)
1537  * @tc.type: FUNC
1538  * @tc.require: issueI63Y7Y
1539  */
1540 HWTEST_F(FormMgrTest, FormMgrTest_0078, TestSize.Level1) {
1541     GTEST_LOG_(INFO) << "FormMgrTest_0078 starts";
1542     EXPECT_CALL(*mockProxy, NotifyFormsVisible(_, _, _))
1543         .Times(1)
1544         .WillOnce(Return(POSITIVE_NUM));
1545     int64_t formId1 = 5;
1546     int64_t formId2 = 6;
1547     std::vector<int64_t> formIds;
1548     formIds.push_back(formId1);
1549     formIds.push_back(formId2);
1550     bool isProtected = true;
1551     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1552     int32_t result = FormMgr::GetInstance().NotifyFormsVisible(formIds, isProtected, token);
1553     EXPECT_EQ(result, ERROR_NUM);
1554     GTEST_LOG_(INFO) << "FormMgrTest_0078 test ends";
1555 }
1556 
1557 /**
1558  * @tc.name: FormMgrTest_0079
1559  * @tc.desc: Verify NotifyFormsPrivacyProtected (The return value of mock function is not 0)
1560  * @tc.type: FUNC
1561  * @tc.require: issueI63Y7Y
1562  */
1563 HWTEST_F(FormMgrTest, FormMgrTest_0079, TestSize.Level1) {
1564     GTEST_LOG_(INFO) << "FormMgrTest_0079 starts";
1565     EXPECT_CALL(*mockProxy, NotifyFormsPrivacyProtected(_, _, _))
1566         .Times(1)
1567         .WillOnce(Return(POSITIVE_NUM));
1568     int64_t formId = 1;
1569     std::vector<int64_t> formIds;
1570     formIds.push_back(formId);
1571     bool isProtected = false;
1572     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1573     int32_t result = FormMgr::GetInstance().NotifyFormsPrivacyProtected(formIds, isProtected, token);
1574     EXPECT_EQ(result, ERROR_NUM);
1575     GTEST_LOG_(INFO) << "FormMgrTest_0079 test ends";
1576 }
1577 
1578 /**
1579  * @tc.name: FormMgrTest_0080
1580  * @tc.desc: Verify NotifyFormsEnableUpdate (The return value of mock function is not 0)
1581  * @tc.type: FUNC
1582  * @tc.require: issueI63Y7Y
1583  */
1584 HWTEST_F(FormMgrTest, FormMgrTest_0080, TestSize.Level1) {
1585     GTEST_LOG_(INFO) << "FormMgrTest_0080 starts";
1586     EXPECT_CALL(*mockProxy, NotifyFormsEnableUpdate(_, _, _))
1587         .Times(1)
1588         .WillOnce(Return(POSITIVE_NUM));
1589     int64_t formId1 = 3;
1590     int64_t formId2 = 4;
1591     std::vector<int64_t> formIds;
1592     formIds.push_back(formId1);
1593     formIds.push_back(formId2);
1594     bool isProtected = true;
1595     sptr<MockFormToken> token = new (std::nothrow) MockFormToken();
1596     int32_t result = FormMgr::GetInstance().NotifyFormsEnableUpdate(formIds, isProtected, token);
1597     EXPECT_EQ(result, ERROR_NUM);
1598     GTEST_LOG_(INFO) << "FormMgrTest_0080 test ends";
1599 }
1600 
1601 /**
1602  * @tc.name: FormMgrTest_0081
1603  * @tc.desc: Verify GetAllFormsInfo (The return value of mock function is not 0)
1604  * @tc.type: FUNC
1605  * @tc.require: issueI63Y7Y
1606  */
1607 HWTEST_F(FormMgrTest, FormMgrTest_0081, TestSize.Level1) {
1608     GTEST_LOG_(INFO) << "FormMgrTest_0081 starts";
1609     EXPECT_CALL(*mockProxy, GetAllFormsInfo(_))
1610         .Times(1)
1611         .WillOnce(Return(POSITIVE_NUM));
1612     std::vector<FormInfo> formInfos;
1613     std::vector<FormInfo> expectFormInfos;
1614     FormInfo formInfo = {};
1615     formInfo.bundleName = "ohos.samples.FormApplication";
1616     formInfo.moduleName = "entry";
1617     expectFormInfos.push_back(formInfo);
1618     auto result = FormMgr::GetInstance().GetAllFormsInfo(formInfos);
1619     EXPECT_EQ(result, ERROR_NUM);
1620     GTEST_LOG_(INFO) << "FormMgrTest_0081 test ends";
1621 }
1622 
1623 /**
1624  * @tc.name: FormMgrTest_0082
1625  * @tc.desc: Verify GetFormsInfoByApp (The return value of mock function is not 0)
1626  * @tc.type: FUNC
1627  * @tc.require: issueI63Y7Y
1628  */
1629 HWTEST_F(FormMgrTest, FormMgrTest_0082, TestSize.Level1) {
1630     GTEST_LOG_(INFO) << "FormMgrTest_0082 starts";
1631     EXPECT_CALL(*mockProxy, GetFormsInfoByApp(_, _))
1632         .Times(1)
1633         .WillOnce(Return(POSITIVE_NUM));
1634     std::vector<FormInfo> formInfos;
1635     std::vector<FormInfo> expectFormInfos;
1636     FormInfo formInfo = {};
1637     formInfo.bundleName = "ohos.samples.FormApplication";
1638     formInfo.moduleName = "entry";
1639     expectFormInfos.push_back(formInfo);
1640     std::string bundleName = "a";
1641     auto result = FormMgr::GetInstance().GetFormsInfoByApp(bundleName, formInfos);
1642     EXPECT_EQ(result, ERROR_NUM);
1643     GTEST_LOG_(INFO) << "FormMgrTest_0082 test ends";
1644 }
1645 
1646 /**
1647  * @tc.name: FormMgrTest_0083
1648  * @tc.desc: Verify GetFormsInfoByModule (The return value of mock function is not 0)
1649  * @tc.type: FUNC
1650  * @tc.require: issueI63Y7Y
1651  */
1652 HWTEST_F(FormMgrTest, FormMgrTest_0083, TestSize.Level1) {
1653     GTEST_LOG_(INFO) << "FormMgrTest_0083 starts";
1654     EXPECT_CALL(*mockProxy, GetFormsInfoByModule(_, _, _))
1655         .Times(1)
1656         .WillOnce(Return(POSITIVE_NUM));
1657     std::vector<FormInfo> formInfos;
1658     std::vector<FormInfo> expectFormInfos;
1659     FormInfo formInfo = {};
1660     formInfo.bundleName = "ohos.samples.FormApplication";
1661     formInfo.moduleName = "entry";
1662     expectFormInfos.push_back(formInfo);
1663     std::string bundleName = "a";
1664     std::string moduleName = "A";
1665     auto result = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos);
1666     EXPECT_EQ(result, ERROR_NUM);
1667     GTEST_LOG_(INFO) << "FormMgrTest_0083 test ends";
1668 }
1669 
1670 /**
1671  * @tc.name: FormMgrTest_0084
1672  * @tc.desc: Verify CheckFMSReady (mock function returns nullptr)
1673  * @tc.type: FUNC
1674  * @tc.require: issueI63Y7Y
1675  */
1676 HWTEST_F(FormMgrTest, FormMgrTest_0084, TestSize.Level1) {
1677     GTEST_LOG_(INFO) << "FormMgrTest_0084 starts";
1678     sptr<MockSystemAbilityManager> mockSamgr = new (std::nothrow) MockSystemAbilityManager();
1679     sptr<ISystemAbilityManager> backupSamgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1680     SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = mockSamgr;
1681     std::shared_ptr<bool> dummyVal = std::make_shared<bool>(true);
1682     mockSamgr->weakGetSystemAbility_ = dummyVal;
1683     auto result = FormMgr::GetInstance().CheckFMSReady();
1684     EXPECT_TRUE(result == false);
1685     GTEST_LOG_(INFO) << "FormMgrTest_0084 test ends";
1686 }
1687 
1688 /**
1689  * @tc.name: FormMgrTest_0085
1690  * @tc.desc: Verify ShareForm (The return value of mock function is 0)
1691  * @tc.type: FUNC
1692  * @tc.require: issueI63Y7Y
1693  */
1694 HWTEST_F(FormMgrTest, FormMgrTest_0085, TestSize.Level1) {
1695     GTEST_LOG_(INFO) << "FormMgrTest_0085 starts";
1696     EXPECT_CALL(*mockProxy, ShareForm(_, _, _,_))
1697         .Times(1)
1698         .WillOnce(Return(OHOS::ERR_OK));
1699     int64_t formId = 0;
1700     std::string deviceId = "aa";
1701     int64_t requestCode = 1;
1702     sptr<IRemoteObject> Token = new (std::nothrow) MockFormProviderClient();
1703     auto result = FormMgr::GetInstance().ShareForm(formId, deviceId, Token, requestCode);
1704     EXPECT_EQ(result, OHOS::ERR_OK);
1705     GTEST_LOG_(INFO) << "FormMgrTest_0085 test ends";
1706 }
1707 
1708 /**
1709  * @tc.name: FormMgrTest_0086
1710  * @tc.desc: Verify GetFormsCount
1711  * @tc.type: FUNC
1712  * @tc.require: issueI63OQL
1713  */
1714 HWTEST_F(FormMgrTest, FormMgrTest_0086, TestSize.Level1) {
1715     GTEST_LOG_(INFO) << "FormMgrTest_0086 starts";
1716     bool isTempFormFlag = true;
1717     int32_t formCount = 0;
1718     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1719     int result = FormMgr::GetInstance().GetFormsCount(isTempFormFlag, formCount);
1720 
1721     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
1722     GTEST_LOG_(INFO) << "FormMgrTest_0086 test ends";
1723 }
1724 
1725 /**
1726  * @tc.name: FormMgrTest_0087
1727  * @tc.desc: Verify GetFormsCount
1728  * @tc.type: FUNC
1729  * @tc.require: issueI63OQL
1730  */
1731 HWTEST_F(FormMgrTest, FormMgrTest_0087, TestSize.Level1) {
1732     GTEST_LOG_(INFO) << "FormMgrTest_0087 starts";
1733     bool isTempFormFlag = true;
1734     int32_t formCount = 0;
1735     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1736     int result = FormMgr::GetInstance().GetFormsCount(isTempFormFlag, formCount);
1737 
1738     EXPECT_EQ(result, 0);
1739     GTEST_LOG_(INFO) << "FormMgrTest_0087 test ends";
1740 }
1741 
1742 /**
1743  * @tc.name: FormMgrTest_0088
1744  * @tc.desc: Verify GetHostFormsCount
1745  * @tc.type: FUNC
1746  * @tc.require: issueI63OQL
1747  */
1748 HWTEST_F(FormMgrTest, FormMgrTest_0088, TestSize.Level1) {
1749     GTEST_LOG_(INFO) << "FormMgrTest_0088 starts";
1750     std::string bundleName = "this is bundleName";
1751     int32_t formCount = 0;
1752     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1753     int result = FormMgr::GetInstance().GetHostFormsCount(bundleName, formCount);
1754 
1755     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
1756     GTEST_LOG_(INFO) << "FormMgrTest_0088 test ends";
1757 }
1758 
1759 /**
1760  * @tc.name: FormMgrTest_0089
1761  * @tc.desc: Verify GetHostFormsCount
1762  * @tc.type: FUNC
1763  * @tc.require: issueI63OQL
1764  */
1765 HWTEST_F(FormMgrTest, FormMgrTest_0089, TestSize.Level1) {
1766     GTEST_LOG_(INFO) << "FormMgrTest_0089 starts";
1767     std::string bundleName = "";
1768     int32_t formCount = 0;
1769     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1770     int result = FormMgr::GetInstance().GetHostFormsCount(bundleName, formCount);
1771 
1772     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_BUNDLENAME);
1773     GTEST_LOG_(INFO) << "FormMgrTest_0089 test ends";
1774 }
1775 
1776 /**
1777  * @tc.name: FormMgrTest_0090
1778  * @tc.desc: Verify GetHostFormsCount
1779  * @tc.type: FUNC
1780  * @tc.require: issueI63OQL
1781  */
1782 HWTEST_F(FormMgrTest, FormMgrTest_0090, TestSize.Level1) {
1783     GTEST_LOG_(INFO) << "FormMgrTest_0090 starts";
1784     std::string bundleName = "this is bundleName";
1785     int32_t formCount = 0;
1786     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1787     int result = FormMgr::GetInstance().GetHostFormsCount(bundleName, formCount);
1788 
1789     EXPECT_EQ(result, 0);
1790     GTEST_LOG_(INFO) << "FormMgrTest_0090 test ends";
1791 }
1792 
1793 /**
1794  * @tc.name: FormMgrTest_0091
1795  * @tc.desc: Verify AcquireFormData (The return value of mock function is 0)
1796  * @tc.type: FUNC
1797  * @tc.require: issueI63Y7Y
1798  */
1799 HWTEST_F(FormMgrTest, FormMgrTest_0091, TestSize.Level1) {
1800     GTEST_LOG_(INFO) << "FormMgrTest_0091 starts";
1801     EXPECT_CALL(*mockProxy, AcquireFormData(_, _, _, _))
1802         .Times(1)
1803         .WillOnce(Return(OHOS::ERR_OK));
1804     int64_t formId = 0;
1805     int64_t requestCode = 1;
1806     AAFwk::WantParams formData;
1807     sptr<IRemoteObject> Token = new (std::nothrow) MockFormProviderClient();
1808     auto result = FormMgr::GetInstance().AcquireFormData(formId, requestCode, Token, formData);
1809     EXPECT_EQ(result, OHOS::ERR_OK);
1810     GTEST_LOG_(INFO) << "FormMgrTest_0091 test ends";
1811 }
1812 
1813 /**
1814  * @tc.name: FormMgrTest_0092
1815  * @tc.desc: Verify GetRunningFormInfos
1816  * @tc.type: FUNC
1817  * @tc.require: issueI63OQL
1818  */
1819 HWTEST_F(FormMgrTest, FormMgrTest_0092, TestSize.Level1) {
1820     GTEST_LOG_(INFO) << "FormMgrTest_0092 starts";
1821     EXPECT_CALL(*mockProxy, GetRunningFormInfos(_))
1822         .Times(1)
1823         .WillOnce(Return(OHOS::ERR_OK));
1824     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1825 
1826     std::vector<RunningFormInfo> runningFormInfos;
1827     int result = FormMgr::GetInstance().GetRunningFormInfos(runningFormInfos);
1828 
1829     EXPECT_EQ(result, 0);
1830     GTEST_LOG_(INFO) << "FormMgrTest_0092 test ends";
1831 }
1832 
1833 /**
1834  * @tc.name: FormMgrTest_0093
1835  * @tc.desc: Verify GetRunningFormInfos
1836  * @tc.type: FUNC
1837  * @tc.require: issueI63OQL
1838  */
1839 HWTEST_F(FormMgrTest, FormMgrTest_0093, TestSize.Level1) {
1840     GTEST_LOG_(INFO) << "FormMgrTest_0093 starts";
1841     EXPECT_CALL(*mockProxy, GetRunningFormInfos(_))
1842         .Times(1)
1843         .WillOnce(Return(OHOS::ERR_OK));
1844     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1845 
1846     std::vector<RunningFormInfo> runningFormInfos;
1847     int result = FormMgr::GetInstance().GetRunningFormInfos(runningFormInfos);
1848 
1849     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
1850     GTEST_LOG_(INFO) << "FormMgrTest_0093 test ends";
1851 }
1852 
1853 /**
1854  * @tc.name: FormMgrTest_0094
1855  * @tc.desc: Verify GetRunningFormInfos
1856  * @tc.type: FUNC
1857  * @tc.require: issueI63OQL
1858  */
1859 HWTEST_F(FormMgrTest, FormMgrTest_0094, TestSize.Level1) {
1860     GTEST_LOG_(INFO) << "FormMgrTest_0094 starts";
1861     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1862     EXPECT_CALL(*mockProxy, GetRunningFormInfos(_))
1863         .Times(1)
1864         .WillOnce(Return(ERROR_NUM));
1865     std::vector<RunningFormInfo> runningFormInfos;
1866     int result = FormMgr::GetInstance().GetRunningFormInfos(runningFormInfos);
1867 
1868     EXPECT_EQ(result, ERROR_NUM);
1869     GTEST_LOG_(INFO) << "FormMgrTest_0094 test ends";
1870 }
1871 
1872 /**
1873  * @tc.name: FormMgrTest_0095
1874  * @tc.desc: Verify GetRunningFormInfos
1875  * @tc.type: FUNC
1876  * @tc.require: issueI63OQL
1877  */
1878 HWTEST_F(FormMgrTest, FormMgrTest_0095, TestSize.Level1) {
1879     GTEST_LOG_(INFO) << "FormMgrTest_0095 starts";
1880     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1881     EXPECT_CALL(*mockProxy, GetRunningFormInfos(_))
1882         .Times(1)
1883         .WillOnce(Return(NEGATIVE_NUM));
1884     std::vector<RunningFormInfo> runningFormInfos;
1885     int result = FormMgr::GetInstance().GetRunningFormInfos(runningFormInfos);
1886 
1887     EXPECT_EQ(result, NEGATIVE_NUM);
1888     GTEST_LOG_(INFO) << "FormMgrTest_0095 test ends";
1889 }
1890 
1891 /**
1892  * @tc.name: FormMgrTest_0096
1893  * @tc.desc: Verify GetRunningFormInfos
1894  * @tc.type: FUNC
1895  * @tc.require: issueI63OQL
1896  */
1897 HWTEST_F(FormMgrTest, FormMgrTest_0096, TestSize.Level1) {
1898     GTEST_LOG_(INFO) << "FormMgrTest_0096 starts";
1899     EXPECT_CALL(*mockProxy, GetRunningFormInfosByBundleName(_, _))
1900         .Times(1)
1901         .WillOnce(Return(OHOS::ERR_OK));
1902     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1903 
1904     std::string bundleName = "a";
1905     std::vector<RunningFormInfo> runningFormInfos;
1906     int result = FormMgr::GetInstance().GetRunningFormInfosByBundleName(bundleName, runningFormInfos);
1907 
1908     EXPECT_EQ(result, 0);
1909     GTEST_LOG_(INFO) << "FormMgrTest_0096 test ends";
1910 }
1911 
1912 /**
1913  * @tc.name: FormMgrTest_0097
1914  * @tc.desc: Verify GetRunningFormInfosByBundleName
1915  * @tc.type: FUNC
1916  * @tc.require: issueI63OQL
1917  */
1918 HWTEST_F(FormMgrTest, FormMgrTest_0097, TestSize.Level1) {
1919     GTEST_LOG_(INFO) << "FormMgrTest_0097 starts";
1920     EXPECT_CALL(*mockProxy, GetRunningFormInfosByBundleName(_, _))
1921         .Times(1)
1922         .WillOnce(Return(OHOS::ERR_OK));
1923     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1924     std::string bundleName = "a";
1925     std::vector<RunningFormInfo> runningFormInfos;
1926     int result = FormMgr::GetInstance().GetRunningFormInfosByBundleName(bundleName, runningFormInfos);
1927 
1928     EXPECT_EQ(result, 0);
1929     GTEST_LOG_(INFO) << "FormMgrTest_0097 test ends";
1930 }
1931 
1932 /**
1933  * @tc.name: FormMgrTest_0098
1934  * @tc.desc: Verify GetRunningFormInfosByBundleName
1935  * @tc.type: FUNC
1936  * @tc.require: issueI63OQL
1937  */
1938 HWTEST_F(FormMgrTest, FormMgrTest_0098, TestSize.Level1) {
1939     GTEST_LOG_(INFO) << "FormMgrTest_0098 starts";
1940     EXPECT_CALL(*mockProxy, GetRunningFormInfosByBundleName(_, _))
1941         .Times(1)
1942         .WillOnce(Return(OHOS::ERR_OK));
1943     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
1944     std::string bundleName = "a";
1945     std::vector<RunningFormInfo> runningFormInfos;
1946     int result = FormMgr::GetInstance().GetRunningFormInfosByBundleName(bundleName, runningFormInfos);
1947 
1948     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
1949     GTEST_LOG_(INFO) << "FormMgrTest_0098 test ends";
1950 }
1951 
1952 /**
1953  * @tc.name: FormMgrTest_0099
1954  * @tc.desc: Verify GetRunningFormInfosByBundleName
1955  * @tc.type: FUNC
1956  * @tc.require: issueI63OQL
1957  */
1958 HWTEST_F(FormMgrTest, FormMgrTest_0099, TestSize.Level1) {
1959     GTEST_LOG_(INFO) << "FormMgrTest_0099 starts";
1960     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1961     EXPECT_CALL(*mockProxy, GetRunningFormInfosByBundleName(_, _))
1962         .Times(1)
1963         .WillOnce(Return(ERROR_NUM));
1964     std::string bundleName = "a";
1965     std::vector<RunningFormInfo> runningFormInfos;
1966     int result = FormMgr::GetInstance().GetRunningFormInfosByBundleName(bundleName, runningFormInfos);
1967 
1968     EXPECT_EQ(result, ERROR_NUM);
1969     GTEST_LOG_(INFO) << "FormMgrTest_0099 test ends";
1970 }
1971 
1972 /**
1973  * @tc.name: FormMgrTest_0100
1974  * @tc.desc: Verify RegisterFormAddObserverByBundle
1975  * @tc.type: FUNC
1976  * @tc.require: issueI63OQL
1977  */
1978 HWTEST_F(FormMgrTest, FormMgrTest_0100, TestSize.Level1) {
1979     GTEST_LOG_(INFO) << "FormMgrTest_0100 starts";
1980     EXPECT_CALL(*mockProxy, RegisterFormAddObserverByBundle(_, _))
1981         .Times(1)
1982         .WillOnce(Return(OHOS::ERR_OK));
1983     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
1984     std::string bundleName = "a";
1985     sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormProviderClient();
1986     int result = FormMgr::GetInstance().RegisterFormAddObserverByBundle(bundleName, callerToken);
1987 
1988     EXPECT_EQ(result, 0);
1989     GTEST_LOG_(INFO) << "FormMgrTest_0100 test ends";
1990 }
1991 
1992 /**
1993  * @tc.name: FormMgrTest_0101
1994  * @tc.desc: Verify RegisterFormAddObserverByBundle
1995  * @tc.type: FUNC
1996  * @tc.require: issueI63OQL
1997  */
1998 HWTEST_F(FormMgrTest, FormMgrTest_0101, TestSize.Level1) {
1999     GTEST_LOG_(INFO) << "FormMgrTest_0101 starts";
2000     EXPECT_CALL(*mockProxy, RegisterFormAddObserverByBundle(_, _))
2001         .Times(1)
2002         .WillOnce(Return(OHOS::ERR_OK));
2003     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
2004     std::string bundleName = "a";
2005     sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormProviderClient();
2006     int result = FormMgr::GetInstance().RegisterFormAddObserverByBundle(bundleName, callerToken);
2007 
2008     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
2009     GTEST_LOG_(INFO) << "FormMgrTest_0101 test ends";
2010 }
2011 
2012 /**
2013  * @tc.name: FormMgrTest_0102
2014  * @tc.desc: Verify RegisterFormAddObserverByBundle
2015  * @tc.type: FUNC
2016  * @tc.require: issueI63OQL
2017  */
2018 HWTEST_F(FormMgrTest, FormMgrTest_0102, TestSize.Level1) {
2019     GTEST_LOG_(INFO) << "FormMgrTest_0102 starts";
2020     EXPECT_CALL(*mockProxy, RegisterFormAddObserverByBundle(_, _))
2021         .Times(1)
2022         .WillOnce(Return(ERROR_NUM));
2023     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
2024     std::string bundleName = "a";
2025     sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormProviderClient();
2026     int result = FormMgr::GetInstance().RegisterFormAddObserverByBundle(bundleName, callerToken);
2027 
2028     EXPECT_EQ(result, ERROR_NUM);
2029     GTEST_LOG_(INFO) << "FormMgrTest_0102 test ends";
2030 }
2031 
2032 /**
2033  * @tc.name: FormMgrTest_0103
2034  * @tc.desc: Verify RegisterFormRemoveObserverByBundle
2035  * @tc.type: FUNC
2036  * @tc.require: issueI63OQL
2037  */
2038 HWTEST_F(FormMgrTest, FormMgrTest_0103, TestSize.Level1) {
2039     GTEST_LOG_(INFO) << "FormMgrTest_0103 starts";
2040     EXPECT_CALL(*mockProxy, RegisterFormRemoveObserverByBundle(_, _))
2041         .Times(1)
2042         .WillOnce(Return(OHOS::ERR_OK));
2043     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
2044     std::string bundleName = "a";
2045     sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormProviderClient();
2046     int result = FormMgr::GetInstance().RegisterFormRemoveObserverByBundle(bundleName, callerToken);
2047 
2048     EXPECT_EQ(result, 0);
2049     GTEST_LOG_(INFO) << "FormMgrTest_0103 test ends";
2050 }
2051 
2052 /**
2053  * @tc.name: FormMgrTest_0104
2054  * @tc.desc: Verify RegisterFormRemoveObserverByBundle
2055  * @tc.type: FUNC
2056  * @tc.require: issueI63OQL
2057  */
2058 HWTEST_F(FormMgrTest, FormMgrTest_0104, TestSize.Level1) {
2059     GTEST_LOG_(INFO) << "FormMgrTest_0104 starts";
2060     EXPECT_CALL(*mockProxy, RegisterFormRemoveObserverByBundle(_, _))
2061         .Times(1)
2062         .WillOnce(Return(OHOS::ERR_OK));
2063     FormMgr::GetInstance().SetRecoverStatus(Constants::IN_RECOVERING);
2064     std::string bundleName = "a";
2065     sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormProviderClient();
2066     int result = FormMgr::GetInstance().RegisterFormRemoveObserverByBundle(bundleName, callerToken);
2067 
2068     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR);
2069     GTEST_LOG_(INFO) << "FormMgrTest_0104 test ends";
2070 }
2071 
2072 /**
2073  * @tc.name: FormMgrTest_0105
2074  * @tc.desc: Verify RegisterFormRemoveObserverByBundle
2075  * @tc.type: FUNC
2076  * @tc.require: issueI63OQL
2077  */
2078 HWTEST_F(FormMgrTest, FormMgrTest_0105, TestSize.Level1) {
2079     GTEST_LOG_(INFO) << "FormMgrTest_0105 starts";
2080     EXPECT_CALL(*mockProxy, RegisterFormRemoveObserverByBundle(_, _))
2081         .Times(1)
2082         .WillOnce(Return(ERROR_NUM));
2083     FormMgr::GetInstance().SetRecoverStatus(Constants::NOT_IN_RECOVERY);
2084     std::string bundleName = "a";
2085     sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormProviderClient();
2086     int result = FormMgr::GetInstance().RegisterFormRemoveObserverByBundle(bundleName, callerToken);
2087 
2088     EXPECT_EQ(result, ERROR_NUM);
2089     GTEST_LOG_(INFO) << "FormMgrTest_0105 test ends";
2090 }
2091 
2092 /**
2093  * @tc.name: FormMgrTest_0106
2094  * @tc.desc: Verify UpdateForm (include data proxies)
2095  * @tc.type: FUNC
2096  * @tc.require: issueI7CGTP
2097  */
2098 HWTEST_F(FormMgrTest, FormMgrTest_0106, TestSize.Level1) {
2099     GTEST_LOG_(INFO) << "FormMgrTest_0106 starts";
2100     EXPECT_CALL(*mockProxy, UpdateProxyForm(_, _, _))
2101         .Times(1)
2102         .WillOnce(Return(NEGATIVE_NUM));
2103     FormJsInfo formJsInfo;
2104     formJsInfo.formId = 0x00000008fffffffL;
2105     FormProviderData formProviderData = FormProviderData(std::string("{\"city\": \"beijing001\"}"));
2106     std::vector<FormDataProxy> formDataProxies;
2107     FormDataProxy formDataProxy("city", "");
2108     formDataProxies.push_back(formDataProxy);
2109     int32_t result = FormMgr::GetInstance().UpdateForm(formJsInfo.formId, formProviderData, formDataProxies);
2110     EXPECT_EQ(result, NEGATIVE_NUM);
2111     GTEST_LOG_(INFO) << "FormMgrTest_0106 test ends";
2112 }
2113 
2114 /**
2115  * @tc.name: FormMgrTest_0107
2116  * @tc.desc: Verify RequestPublishForm (include data proxies)
2117  * @tc.type: FUNC
2118  * @tc.require: issueI7CGTP
2119  */
2120 HWTEST_F(FormMgrTest, FormMgrTest_0107, TestSize.Level1) {
2121     GTEST_LOG_(INFO) << "FormMgrTest_0107 starts";
2122     EXPECT_CALL(*mockProxy, RequestPublishProxyForm(_, _, _, _, _))
2123         .Times(1)
2124         .WillOnce(Return(NEGATIVE_NUM));
2125     Want want;
2126     int64_t formId = 0x00000008fffffffL;
2127     std::unique_ptr<FormProviderData> formProviderData;
2128     std::vector<FormDataProxy> formDataProxies;
2129     FormDataProxy formDataProxy("city", "");
2130     formDataProxies.push_back(formDataProxy);
2131     int32_t result = FormMgr::GetInstance().RequestPublishForm(want, true, formProviderData, formId, formDataProxies);
2132     EXPECT_EQ(result, NEGATIVE_NUM);
2133     GTEST_LOG_(INFO) << "FormMgrTest_0107 test ends";
2134 }
2135 
2136 /**
2137  * @tc.name: FormMgrTest_0108
2138  * @tc.desc: Verify StopRenderingForm
2139  * @tc.type: FUNC
2140  * @tc.require: issueI7HGZ2
2141  */
2142 HWTEST_F(FormMgrTest, FormMgrTest_0108, TestSize.Level1) {
2143     GTEST_LOG_(INFO) << "FormMgrTest_0108 starts";
2144     int64_t formId = 0;
2145     std::string compId = "this is compId";
2146     int result = FormMgr::GetInstance().StopRenderingForm(formId, compId);
2147     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
2148     GTEST_LOG_(INFO) << "FormMgrTest_0108 test ends";
2149 }
2150 
2151 /**
2152  * @tc.name: FormMgrTest_0109
2153  * @tc.desc: Verify ReleaseRenderer
2154  * @tc.type: FUNC
2155  * @tc.require: issueI7HGZ2
2156  */
2157 HWTEST_F(FormMgrTest, FormMgrTest_0109, TestSize.Level1) {
2158     GTEST_LOG_(INFO) << "FormMgrTest_0109 starts";
2159     int64_t formId = 0;
2160     std::string compId = "this is compId";
2161     int result = FormMgr::GetInstance().ReleaseRenderer(formId, compId);
2162     EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_FORM_ID);
2163     GTEST_LOG_(INFO) << "FormMgrTest_0109 test ends";
2164 }
2165 
2166 /**
2167  * @tc.name: FormMgrTest_0111
2168  * @tc.desc: Verify GetErrorMsgByExternalErrorCode
2169  * @tc.type: FUNC
2170  * @tc.require: issueI7HGZ2
2171  */
2172 HWTEST_F(FormMgrTest, FormMgrTest_0111, TestSize.Level1) {
2173     GTEST_LOG_(INFO) << "FormMgrTest_0111 starts";
2174     int32_t innerErrorCode = 0;
2175     int32_t externalErrorCode = 0;
2176     std::string errorMsg = "this is errorMsg";
2177     FormMgr::GetInstance().GetExternalError(innerErrorCode, externalErrorCode, errorMsg);
2178 
2179     std::string result = FormMgr::GetInstance().GetErrorMsgByExternalErrorCode(externalErrorCode);
2180     EXPECT_EQ(result, "success");
2181     GTEST_LOG_(INFO) << "FormMgrTest_0111 test ends";
2182 }
2183 
2184 /**
2185  * @tc.name: FormMgrTest_0112
2186  * @tc.desc: Verify GetFormInstancesByFilter
2187  * @tc.type: FUNC
2188  * @tc.require: issueI7HGZ2
2189  */
2190 HWTEST_F(FormMgrTest, FormMgrTest_0112, TestSize.Level1) {
2191     GTEST_LOG_(INFO) << "FormMgrTest_0112 starts";
2192     FormInstancesFilter filter;
2193     std::vector<FormInstance> formInstances;
2194     ErrCode result = FormMgr::GetInstance().GetFormInstancesByFilter(filter, formInstances);
2195     int code = 8388610;
2196     EXPECT_EQ(result, code);
2197 
2198     int64_t formId = 1;
2199     FormInstance formInstance;
2200     ErrCode result1 = FormMgr::GetInstance().GetFormInstanceById(formId, formInstance);
2201     EXPECT_EQ(result1, code);
2202     GTEST_LOG_(INFO) << "FormMgrTest_0112 test ends";
2203 }
2204 } // namespace