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 18 #include "appexecfwk_errors.h" 19 #include "form_mgr_proxy.h" 20 #include "gmock/gmock.h" 21 #include "mock_form_mgr_service.h" 22 #include "mock_form_token.h" 23 #include "form_provider_proxy.h" 24 #include "form_mgr_errors.h" 25 #include "form_mgr_proxy.h" 26 27 using namespace testing::ext; 28 using namespace OHOS; 29 using namespace OHOS::AppExecFwk; 30 31 32 using ::testing::Return; 33 using ::testing::SetArgReferee; 34 using ::testing::ContainerEq; 35 using ::testing::_; 36 using ::testing::DoAll; 37 38 // overload operator for ContainerEq 39 namespace OHOS::AppExecFwk { operator ==(const FormInfo & lhs,const FormInfo & rhs)40 bool operator==(const FormInfo& lhs, const FormInfo& rhs) 41 { 42 if (lhs.bundleName != rhs.bundleName) { 43 return false; 44 } 45 if (lhs.moduleName != rhs.moduleName) { 46 return false; 47 } 48 if (lhs.name != rhs.name) { 49 return false; 50 } 51 // to be continued... 52 return true; 53 } 54 } 55 namespace { 56 class FormMgrProxyTest : public testing::Test { 57 public: SetUp()58 void SetUp() override 59 { 60 mockFormMgrService = new MockFormMgrService(); 61 formMgrProxy = new FormMgrProxy(mockFormMgrService); 62 formProviderProxy = new FormProviderProxy(mockFormMgrService); 63 } 64 // TearDown() is unnecessary. 65 sptr<MockFormMgrService> mockFormMgrService; 66 sptr<FormMgrProxy> formMgrProxy; 67 sptr<FormProviderProxy> formProviderProxy; 68 }; 69 70 /** 71 * @tc.name: FormMgrProxyTest_0001 72 * @tc.desc: Verify GetFormsInfo 73 * @tc.type: FUNC 74 * @tc.require: #I59O23 75 */ 76 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0001, TestSize.Level1) { 77 GTEST_LOG_(INFO) << "FormMgrProxyTest_001 starts"; 78 // initialize input parameters. 79 FormInfoFilter filter; 80 filter.moduleName = ""; 81 std::vector<FormInfo> formInfos; 82 // setup expectations. 83 std::vector<FormInfo> expectFormInfos; 84 FormInfo formInfo = {}; 85 formInfo.bundleName = "ohos.samples.FormApplication"; 86 expectFormInfos.push_back(formInfo); 87 EXPECT_CALL(*mockFormMgrService, GetFormsInfo(_, _)) 88 .Times(1) 89 .WillOnce(DoAll(SetArgReferee<1>(expectFormInfos), Return(ERR_OK))); 90 // test. 91 formMgrProxy->GetFormsInfo(filter, formInfos); 92 // expect result. 93 EXPECT_THAT(formInfos, ContainerEq(expectFormInfos)); 94 GTEST_LOG_(INFO) << "FormMgrProxyTest_0001 test ends"; 95 } 96 97 /** 98 * @tc.name: FormMgrProxyTest_0002 99 * @tc.desc: Verify GetFormsInfo 100 * @tc.type: FUNC 101 * @tc.require: #I59O23 102 */ 103 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0002, TestSize.Level1) { 104 GTEST_LOG_(INFO) << "FormMgrProxyTest_0002 starts"; 105 // initialize input parameters. 106 FormInfoFilter filter; 107 filter.moduleName = "empty"; 108 std::vector<FormInfo> formInfos; 109 // setup expectations. 110 std::vector<FormInfo> expectFormInfos; 111 FormInfo formInfo = {}; 112 formInfo.bundleName = "ohos.samples.FormApplication"; 113 formInfo.moduleName = "entry"; 114 expectFormInfos.push_back(formInfo); 115 EXPECT_CALL(*mockFormMgrService, GetFormsInfo(_, _)) 116 .Times(1) 117 .WillOnce(Return(ERR_OK)); 118 // test. 119 formMgrProxy->GetFormsInfo(filter, formInfos); 120 // expect result. 121 EXPECT_EQ(formInfos.size(), 0); 122 GTEST_LOG_(INFO) << "FormMgrProxyTest_0002 test ends"; 123 } 124 125 /** 126 * @tc.name: FormMgrProxyTest_0003 127 * @tc.desc: Verify IsRequestPublishFormSupported 128 * @tc.type: FUNC 129 * @tc.require: #I58Y0A 130 */ 131 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0003, TestSize.Level1) { 132 GTEST_LOG_(INFO) << "FormMgrProxyTest_0003 starts"; 133 // initialize input parameters. 134 EXPECT_CALL(*mockFormMgrService, IsRequestPublishFormSupported()) 135 .Times(1) 136 .WillOnce(Return(true)); 137 // test. 138 bool result = formMgrProxy->IsRequestPublishFormSupported(); 139 // expect result. 140 EXPECT_EQ(result, true); 141 GTEST_LOG_(INFO) << "FormMgrProxyTest_0003 test ends"; 142 } 143 144 /** 145 * @tc.name: FormMgrProxyTest_0004 146 * @tc.desc: Verify StartAbility 147 * @tc.type: FUNC 148 * @tc.require: #I5EFDX 149 */ 150 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0004, TestSize.Level1) { 151 GTEST_LOG_(INFO) << "FormMgrProxyTest_0004 starts"; 152 // initialize input parameters. 153 EXPECT_CALL(*mockFormMgrService, StartAbility(_, _)) 154 .Times(1) 155 .WillOnce(Return(0)); 156 Want want; 157 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 158 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 159 int32_t result = formMgrProxy->StartAbility(want, token); 160 // expect result. 161 EXPECT_EQ(result, 0); 162 GTEST_LOG_(INFO) << "FormMgrProxyTest_0004 test ends"; 163 } 164 165 /** 166 * @tc.name: FormMgrProxyTest_0005 167 * @tc.desc: Verify StartAbility 168 * @tc.type: FUNC 169 * @tc.require: #I5EFDX 170 */ 171 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0005, TestSize.Level1) { 172 GTEST_LOG_(INFO) << "FormMgrProxyTest_0005 starts"; 173 Want want; 174 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 175 int32_t result = formMgrProxy->StartAbility(want, nullptr); 176 // expect result. 177 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 178 GTEST_LOG_(INFO) << "FormMgrProxyTest_0005 test ends"; 179 } 180 181 /** 182 * @tc.name: FormMgrProxyTest_0006 183 * @tc.desc: Verify NotifyFormsPrivacyProtected 184 * @tc.type: FUNC 185 * @tc.require: #I5ST27 186 */ 187 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0006, TestSize.Level1) { 188 GTEST_LOG_(INFO) << "FormMgrProxyTest_0006 starts"; 189 EXPECT_CALL(*mockFormMgrService, NotifyFormsPrivacyProtected(_, _, _)) 190 .Times(1) 191 .WillOnce(Return(0)); 192 // initialize input parameters. 193 int64_t formId = 1; 194 std::vector<int64_t> formIds; 195 formIds.push_back(formId); 196 bool isProtected = false; 197 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 198 int32_t result = formMgrProxy->NotifyFormsPrivacyProtected(formIds, isProtected, token); 199 // expect result. 200 EXPECT_EQ(result, 0); 201 GTEST_LOG_(INFO) << "FormMgrProxyTest_0006 test ends"; 202 } 203 204 /** 205 * @tc.name: FormMgrProxyTest_0007 206 * @tc.desc: Verify NotifyFormsPrivacyProtected 207 * @tc.type: FUNC 208 * @tc.require: #I5ST27 209 */ 210 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0007, TestSize.Level1) { 211 GTEST_LOG_(INFO) << "FormMgrProxyTest_0007 starts"; 212 EXPECT_CALL(*mockFormMgrService, NotifyFormsPrivacyProtected(_, _, _)) 213 .Times(1) 214 .WillOnce(Return(0)); 215 // initialize input parameters. 216 int64_t formId = 2; 217 std::vector<int64_t> formIds; 218 formIds.push_back(formId); 219 bool isProtected = true; 220 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 221 int32_t result = formMgrProxy->NotifyFormsPrivacyProtected(formIds, isProtected, token); 222 // expect result. 223 EXPECT_EQ(result, 0); 224 GTEST_LOG_(INFO) << "FormMgrProxyTest_0007 test ends"; 225 } 226 227 /** 228 * @tc.name: FormMgrProxyTest_0008 229 * @tc.desc: Verify NotifyFormsPrivacyProtected 230 * @tc.type: FUNC 231 * @tc.require: #I5ST27 232 */ 233 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0008, TestSize.Level1) { 234 GTEST_LOG_(INFO) << "FormMgrProxyTest_0008 starts"; 235 EXPECT_CALL(*mockFormMgrService, NotifyFormsPrivacyProtected(_, _, _)) 236 .Times(1) 237 .WillOnce(Return(0)); 238 // initialize input parameters. 239 int64_t formId1 = 3; 240 int64_t formId2 = 4; 241 std::vector<int64_t> formIds; 242 formIds.push_back(formId1); 243 formIds.push_back(formId2); 244 bool isProtected = false; 245 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 246 int32_t result = formMgrProxy->NotifyFormsPrivacyProtected(formIds, isProtected, token); 247 // expect result. 248 EXPECT_EQ(result, 0); 249 GTEST_LOG_(INFO) << "FormMgrProxyTest_0008 test ends"; 250 } 251 252 /** 253 * @tc.name: FormMgrProxyTest_0009 254 * @tc.desc: Verify NotifyFormsPrivacyProtected 255 * @tc.type: FUNC 256 * @tc.require: #I5ST27 257 */ 258 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0009, TestSize.Level1) { 259 GTEST_LOG_(INFO) << "FormMgrProxyTest_0009 starts"; 260 EXPECT_CALL(*mockFormMgrService, NotifyFormsPrivacyProtected(_, _, _)) 261 .Times(1) 262 .WillOnce(Return(0)); 263 // initialize input parameters. 264 int64_t formId1 = 5; 265 int64_t formId2 = 6; 266 std::vector<int64_t> formIds; 267 formIds.push_back(formId1); 268 formIds.push_back(formId2); 269 bool isProtected = true; 270 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 271 int32_t result = formMgrProxy->NotifyFormsPrivacyProtected(formIds, isProtected, token); 272 // expect result. 273 EXPECT_EQ(result, 0); 274 GTEST_LOG_(INFO) << "FormMgrProxyTest_0009 test ends"; 275 } 276 277 /** 278 * @tc.name: FormMgrProxyTest_0010 279 * @tc.desc: text GetRunningFormInfos function. 280 * @tc.type: FUNC 281 * @tc.require: issueI639Z3 282 */ 283 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0010, TestSize.Level1) { 284 GTEST_LOG_(INFO) << "FormMgrProxyTest_0010 starts"; 285 bool isUnusedInclude = false; 286 std::vector<RunningFormInfo> runningFormInfos; 287 int result = formMgrProxy->GetRunningFormInfos(isUnusedInclude, runningFormInfos); 288 EXPECT_EQ(result, ERR_OK); 289 GTEST_LOG_(INFO) << "FormMgrProxyTest_0010 test ends"; 290 } 291 292 /** 293 * @tc.name: FormMgrProxyTest_0011 294 * @tc.desc: text GetRunningFormInfosByBundleName function. 295 * @tc.type: FUNC 296 * @tc.require: issueI639Z3 297 */ 298 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0011, TestSize.Level1) { 299 GTEST_LOG_(INFO) << "FormMgrProxyTest_0011 starts"; 300 std::vector<RunningFormInfo> runningFormInfos; 301 std::string bundleName = "ohos.samples.FormApplication"; 302 bool isUnusedInclude = false; 303 int result = formMgrProxy->GetRunningFormInfosByBundleName(bundleName, isUnusedInclude, runningFormInfos); 304 EXPECT_EQ(result, ERR_OK); 305 GTEST_LOG_(INFO) << "FormMgrProxyTest_0011 test ends"; 306 } 307 308 /** 309 * @tc.name: FormMgrProxyTest_0012 310 * @tc.desc: text RegisterFormAddObserverByBundle function. 311 * @tc.type: FUNC 312 * @tc.require: issueI639Z3 313 */ 314 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0012, TestSize.Level1) { 315 GTEST_LOG_(INFO) << "FormMgrProxyTest_0012 starts"; 316 std::string bundleName = "ohos.samples.FormApplication"; 317 const sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormToken(); 318 int result = formMgrProxy->RegisterFormAddObserverByBundle(bundleName, callerToken); 319 EXPECT_EQ(result, ERR_OK); 320 GTEST_LOG_(INFO) << "FormMgrProxyTest_0012 test ends"; 321 } 322 323 /** 324 * @tc.name: FormMgrProxyTest_0013 325 * @tc.desc: text RegisterFormAddObserverByBundle function. 326 * @tc.type: FUNC 327 * @tc.require: issueI639Z3 328 */ 329 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0013, TestSize.Level1) { 330 GTEST_LOG_(INFO) << "FormMgrProxyTest_0013 starts"; 331 std::string bundleName = "ohos.samples.FormApplication"; 332 int result = formMgrProxy->RegisterFormAddObserverByBundle(bundleName, nullptr); 333 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 334 GTEST_LOG_(INFO) << "FormMgrProxyTest_0013 test ends"; 335 } 336 337 /** 338 * @tc.name: FormMgrProxyTest_0014 339 * @tc.desc: text RegisterFormRemoveObserverByBundle function. 340 * @tc.type: FUNC 341 * @tc.require: issueI639Z3 342 */ 343 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0014, TestSize.Level1) { 344 GTEST_LOG_(INFO) << "FormMgrProxyTest_0012 starts"; 345 std::string bundleName = "ohos.samples.FormApplication"; 346 const sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormToken(); 347 int result = formMgrProxy->RegisterFormRemoveObserverByBundle(bundleName, callerToken); 348 EXPECT_EQ(result, ERR_OK); 349 GTEST_LOG_(INFO) << "FormMgrProxyTest_0014 test ends"; 350 } 351 352 /** 353 * @tc.name: FormMgrProxyTest_0015 354 * @tc.desc: text RegisterFormRemoveObserverByBundle function. 355 * @tc.type: FUNC 356 * @tc.require: issueI639Z3 357 */ 358 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0015, TestSize.Level1) { 359 GTEST_LOG_(INFO) << "FormMgrProxyTest_0015 starts"; 360 std::string bundleName = "ohos.samples.FormApplication"; 361 int result = formMgrProxy->RegisterFormRemoveObserverByBundle(bundleName, nullptr); 362 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 363 GTEST_LOG_(INFO) << "FormMgrProxyTest_0015 test ends"; 364 } 365 366 /** 367 * @tc.name: FormMgrProxyTest_0016 368 * @tc.desc: text RegisterFormRouterProxy function. 369 * @tc.type: FUNC 370 * @tc.require: IssueI8H9R5 371 */ 372 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0016, TestSize.Level1) { 373 GTEST_LOG_(INFO) << "FormMgrProxyTest_0016 starts"; 374 int64_t formId = 2; 375 std::vector<int64_t> formIds; 376 formIds.push_back(formId); 377 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 378 int result = formMgrProxy->RegisterFormRouterProxy(formIds, token); 379 EXPECT_EQ(result, ERR_OK); 380 GTEST_LOG_(INFO) << "FormMgrProxyTest_0016 test ends"; 381 } 382 383 /** 384 * @tc.name: FormMgrProxyTest_0017 385 * @tc.desc: text RegisterFormRouterProxy function. 386 * @tc.type: FUNC 387 * @tc.require: IssueI8H9R5 388 */ 389 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0017, TestSize.Level1) { 390 GTEST_LOG_(INFO) << "FormMgrProxyTest_0016 starts"; 391 int64_t formId = 2; 392 std::vector<int64_t> formIds; 393 formIds.push_back(formId); 394 int result = formMgrProxy->RegisterFormRouterProxy(formIds, nullptr); 395 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 396 GTEST_LOG_(INFO) << "FormMgrProxyTest_0016 test ends"; 397 } 398 399 /** 400 * @tc.name: FormMgrProxyTest_0018 401 * @tc.desc: text UnregisterFormRouterProxy function. 402 * @tc.type: FUNC 403 * @tc.require: IssueI8H9R5 404 */ 405 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0018, TestSize.Level1) { 406 GTEST_LOG_(INFO) << "FormMgrProxyTest_0018 starts"; 407 int64_t formId = 2; 408 std::vector<int64_t> formIds; 409 formIds.push_back(formId); 410 int result = formMgrProxy->UnregisterFormRouterProxy(formIds); 411 EXPECT_EQ(result, ERR_OK); 412 GTEST_LOG_(INFO) << "FormMgrProxyTest_0018 test ends"; 413 } 414 415 /** 416 * @tc.name: FormMgrProxyTest_0019 417 * @tc.desc: text StartAbilityByFms function. 418 * @tc.type: FUNC 419 * @tc.require: IssueI8H9R5 420 */ 421 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0019, TestSize.Level1) { 422 GTEST_LOG_(INFO) << "FormMgrProxyTest_0019 starts"; 423 Want want; 424 auto result = formMgrProxy->StartAbilityByFms(want); 425 EXPECT_EQ(result, ERR_OK); 426 GTEST_LOG_(INFO) << "FormMgrProxyTest_0019 test ends"; 427 } 428 429 /** 430 * @tc.name: FormMgrProxyTest_0020 431 * @tc.desc: text RegisterAddObserver function. 432 * @tc.type: FUNC 433 * @tc.require: IssueI8H9R5 434 */ 435 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0020, TestSize.Level1) { 436 GTEST_LOG_(INFO) << "FormMgrProxyTest_0020 starts"; 437 std::string bundleName = "bundleName"; 438 const sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormToken(); 439 auto result = formMgrProxy->RegisterAddObserver(bundleName, callerToken); 440 EXPECT_EQ(result, ERR_OK); 441 GTEST_LOG_(INFO) << "FormMgrProxyTest_0020 test ends"; 442 } 443 444 /** 445 * @tc.name: FormMgrProxyTest_0021 446 * @tc.desc: text RegisterRemoveObserver function. 447 * @tc.type: FUNC 448 * @tc.require: IssueI8H9R5 449 */ 450 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0021, TestSize.Level1) { 451 GTEST_LOG_(INFO) << "FormMgrProxyTest_0021 starts"; 452 std::string bundleName = "bundleName"; 453 sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormToken(); 454 auto result = formMgrProxy->RegisterRemoveObserver(bundleName, callerToken); 455 EXPECT_EQ(result, ERR_OK); 456 GTEST_LOG_(INFO) << "FormMgrProxyTest_0021 test ends"; 457 } 458 459 /** 460 * @tc.name: FormMgrProxyTest_0022 461 * @tc.desc: text LockForms function. 462 * @tc.type: FUNC 463 * @tc.require: IssueI8H9R5 464 */ 465 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0022, TestSize.Level1) { 466 GTEST_LOG_(INFO) << "FormMgrProxyTest_0022 starts"; 467 std::vector<FormLockInfo> formLockInfos; 468 LockChangeType type = LockChangeType::SWITCH_CHANGE; 469 auto result = formMgrProxy->LockForms(formLockInfos, type); 470 EXPECT_EQ(result, ERR_OK); 471 GTEST_LOG_(INFO) << "FormMgrProxyTest_0022 test ends"; 472 } 473 474 /** 475 * @tc.name: FormMgrProxyTest_0023 476 * @tc.desc: text NotifyFormLocked function. 477 * @tc.type: FUNC 478 * @tc.require: IssueI8H9R5 479 */ 480 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0023, TestSize.Level1) { 481 GTEST_LOG_(INFO) << "FormMgrProxyTest_0023 starts"; 482 int64_t formId = 1; 483 bool isLocked = true; 484 auto result = formMgrProxy->NotifyFormLocked(formId, isLocked); 485 EXPECT_EQ(result, ERR_OK); 486 GTEST_LOG_(INFO) << "FormMgrProxyTest_0023 test ends"; 487 } 488 489 /** 490 * @tc.name: FormMgrProxyTest_0024 491 * @tc.desc: text GetRunningFormInfosByBundleName function. 492 * @tc.type: FUNC 493 * @tc.require: issueI639Z3 494 */ 495 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0024, TestSize.Level1) { 496 GTEST_LOG_(INFO) << "FormMgrProxyTest_0024 starts"; 497 std::vector<RunningFormInfo> runningFormInfos; 498 std::string bundleName = "ohos.samples.FormApplication"; 499 bool isUnusedInclude = false; 500 int result = formMgrProxy->GetRunningFormInfosByBundleName(bundleName, isUnusedInclude, runningFormInfos); 501 EXPECT_EQ(result, ERR_OK); 502 GTEST_LOG_(INFO) << "FormMgrProxyTest_0024 test ends"; 503 } 504 505 /** 506 * @tc.name: FormMgrProxyTest_0025 507 * @tc.desc: text RegisterFormAddObserverByBundle function. 508 * @tc.type: FUNC 509 * @tc.require: issueI639Z3 510 */ 511 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0025, TestSize.Level1) { 512 GTEST_LOG_(INFO) << "FormMgrProxyTest_0025 starts"; 513 std::string bundleName = "ohos.samples.FormApplication"; 514 const sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormToken(); 515 int result = formMgrProxy->RegisterFormAddObserverByBundle(bundleName, callerToken); 516 EXPECT_EQ(result, ERR_OK); 517 GTEST_LOG_(INFO) << "FormMgrProxyTest_0025 test ends"; 518 } 519 520 /** 521 * @tc.name: FormMgrProxyTest_0026 522 * @tc.desc: text RegisterFormAddObserverByBundle function. 523 * @tc.type: FUNC 524 * @tc.require: issueI639Z3 525 */ 526 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0026, TestSize.Level1) { 527 GTEST_LOG_(INFO) << "FormMgrProxyTest_0026 starts"; 528 std::string bundleName = "ohos.samples.FormApplication"; 529 int result = formMgrProxy->RegisterFormAddObserverByBundle(bundleName, nullptr); 530 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 531 GTEST_LOG_(INFO) << "FormMgrProxyTest_0026 test ends"; 532 } 533 534 /** 535 * @tc.name: FormMgrProxyTest_0027 536 * @tc.desc: text RegisterFormRemoveObserverByBundle function. 537 * @tc.type: FUNC 538 * @tc.require: issueI639Z3 539 */ 540 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0027, TestSize.Level1) { 541 GTEST_LOG_(INFO) << "FormMgrProxyTest_0027 starts"; 542 std::string bundleName = "ohos.samples.FormApplication"; 543 const sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormToken(); 544 int result = formMgrProxy->RegisterFormRemoveObserverByBundle(bundleName, callerToken); 545 EXPECT_EQ(result, ERR_OK); 546 GTEST_LOG_(INFO) << "FormMgrProxyTest_0027 test ends"; 547 } 548 549 /** 550 * @tc.name: FormMgrProxyTest_0028 551 * @tc.desc: text RegisterFormRemoveObserverByBundle function. 552 * @tc.type: FUNC 553 * @tc.require: issueI639Z3 554 */ 555 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0028, TestSize.Level1) { 556 GTEST_LOG_(INFO) << "FormMgrProxyTest_0028 starts"; 557 std::string bundleName = "ohos.samples.FormApplication"; 558 int result = formMgrProxy->RegisterFormRemoveObserverByBundle(bundleName, nullptr); 559 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 560 GTEST_LOG_(INFO) << "FormMgrProxyTest_0028 test ends"; 561 } 562 563 /** 564 * @tc.name: FormMgrProxyTest_0029 565 * @tc.desc: text RegisterFormRouterProxy function. 566 * @tc.type: FUNC 567 * @tc.require: IssueI8H9R5 568 */ 569 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0029, TestSize.Level1) { 570 GTEST_LOG_(INFO) << "FormMgrProxyTest_0029 starts"; 571 int64_t formId = 2; 572 std::vector<int64_t> formIds; 573 formIds.push_back(formId); 574 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 575 int result = formMgrProxy->RegisterFormRouterProxy(formIds, token); 576 EXPECT_EQ(result, ERR_OK); 577 GTEST_LOG_(INFO) << "FormMgrProxyTest_0029 test ends"; 578 } 579 580 /** 581 * @tc.name: FormMgrProxyTest_0030 582 * @tc.desc: text RegisterFormRouterProxy function. 583 * @tc.type: FUNC 584 * @tc.require: IssueI8H9R5 585 */ 586 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0030, TestSize.Level1) { 587 GTEST_LOG_(INFO) << "FormMgrProxyTest_0030 starts"; 588 int64_t formId = 2; 589 std::vector<int64_t> formIds; 590 formIds.push_back(formId); 591 int result = formMgrProxy->RegisterFormRouterProxy(formIds, nullptr); 592 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 593 GTEST_LOG_(INFO) << "FormMgrProxyTest_0030 test ends"; 594 } 595 596 /** 597 * @tc.name: FormMgrProxyTest_0031 598 * @tc.desc: text UnregisterFormRouterProxy function. 599 * @tc.type: FUNC 600 * @tc.require: IssueI8H9R5 601 */ 602 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0031, TestSize.Level1) { 603 GTEST_LOG_(INFO) << "FormMgrProxyTest_0031 starts"; 604 int64_t formId = 2; 605 std::vector<int64_t> formIds; 606 formIds.push_back(formId); 607 int result = formMgrProxy->UnregisterFormRouterProxy(formIds); 608 EXPECT_EQ(result, ERR_OK); 609 GTEST_LOG_(INFO) << "FormMgrProxyTest_0031 test ends"; 610 } 611 612 /** 613 * @tc.name: FormMgrProxyTest_0032 614 * @tc.desc: text StartAbilityByFms function. 615 * @tc.type: FUNC 616 * @tc.require: IssueI8H9R5 617 */ 618 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0032, TestSize.Level1) { 619 GTEST_LOG_(INFO) << "FormMgrProxyTest_0032 starts"; 620 Want want; 621 auto result = formMgrProxy->StartAbilityByFms(want); 622 EXPECT_EQ(result, ERR_OK); 623 GTEST_LOG_(INFO) << "FormMgrProxyTest_0032 test ends"; 624 } 625 626 /** 627 * @tc.name: FormMgrProxyTest_0033 628 * @tc.desc: text RegisterAddObserver function. 629 * @tc.type: FUNC 630 * @tc.require: IssueI8H9R5 631 */ 632 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0033, TestSize.Level1) { 633 GTEST_LOG_(INFO) << "FormMgrProxyTest_0033 starts"; 634 std::string bundleName = "bundleName"; 635 const sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormToken(); 636 auto result = formMgrProxy->RegisterAddObserver(bundleName, callerToken); 637 EXPECT_EQ(result, ERR_OK); 638 GTEST_LOG_(INFO) << "FormMgrProxyTest_0033 test ends"; 639 } 640 641 /** 642 * @tc.name: FormMgrProxyTest_0034 643 * @tc.desc: text RegisterRemoveObserver function. 644 * @tc.type: FUNC 645 * @tc.require: IssueI8H9R5 646 */ 647 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0034, TestSize.Level1) { 648 GTEST_LOG_(INFO) << "FormMgrProxyTest_0034 starts"; 649 std::string bundleName = "bundleName"; 650 sptr<IRemoteObject> callerToken = new (std::nothrow) MockFormToken(); 651 auto result = formMgrProxy->RegisterRemoveObserver(bundleName, callerToken); 652 EXPECT_EQ(result, ERR_OK); 653 GTEST_LOG_(INFO) << "FormMgrProxyTest_0034 test ends"; 654 } 655 656 /** 657 * @tc.name: FormMgrProxyTest_0035 658 * @tc.desc: text LockForms function. 659 * @tc.type: FUNC 660 * @tc.require: IssueI8H9R5 661 */ 662 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0035, TestSize.Level1) { 663 GTEST_LOG_(INFO) << "FormMgrProxyTest_0035 starts"; 664 std::vector<FormLockInfo> formLockInfos; 665 LockChangeType type = LockChangeType::SWITCH_CHANGE; 666 auto result = formMgrProxy->LockForms(formLockInfos, type); 667 EXPECT_EQ(result, ERR_OK); 668 GTEST_LOG_(INFO) << "FormMgrProxyTest_0035 test ends"; 669 } 670 671 /** 672 * @tc.name: FormMgrProxyTest_0036 673 * @tc.desc: text NotifyFormLocked function. 674 * @tc.type: FUNC 675 * @tc.require: IssueI8H9R5 676 */ 677 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0036, TestSize.Level1) { 678 GTEST_LOG_(INFO) << "FormMgrProxyTest_0036 starts"; 679 int64_t formId = 1; 680 bool isLocked = true; 681 auto result = formMgrProxy->NotifyFormLocked(formId, isLocked); 682 EXPECT_EQ(result, ERR_OK); 683 GTEST_LOG_(INFO) << "FormMgrProxyTest_0036 test ends"; 684 } 685 686 /** 687 * @tc.name: FormMgrProxyTest_0037 688 * @tc.desc: Verify GetFormsInfo 689 * @tc.type: FUNC 690 * @tc.require: #I59O23 691 */ 692 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0037, TestSize.Level1) { 693 GTEST_LOG_(INFO) << "FormMgrProxyTest_001 starts"; 694 // initialize input parameters. 695 FormInfoFilter filter; 696 filter.moduleName = ""; 697 std::vector<FormInfo> formInfos; 698 // setup expectations. 699 std::vector<FormInfo> expectFormInfos; 700 FormInfo formInfo = {}; 701 formInfo.bundleName = "ohos.samples.FormApplication"; 702 expectFormInfos.push_back(formInfo); 703 EXPECT_CALL(*mockFormMgrService, GetFormsInfo(_, _)) 704 .Times(1) 705 .WillOnce(DoAll(SetArgReferee<1>(expectFormInfos), Return(ERR_OK))); 706 // test. 707 formMgrProxy->GetFormsInfo(filter, formInfos); 708 // expect result. 709 EXPECT_THAT(formInfos, ContainerEq(expectFormInfos)); 710 GTEST_LOG_(INFO) << "FormMgrProxyTest_0037 test ends"; 711 } 712 713 /** 714 * @tc.name: FormMgrProxyTest_0038 715 * @tc.desc: Verify GetFormsInfo 716 * @tc.type: FUNC 717 * @tc.require: #I59O23 718 */ 719 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0038, TestSize.Level1) { 720 GTEST_LOG_(INFO) << "FormMgrProxyTest_0038 starts"; 721 // initialize input parameters. 722 FormInfoFilter filter; 723 filter.moduleName = "empty"; 724 std::vector<FormInfo> formInfos; 725 // setup expectations. 726 std::vector<FormInfo> expectFormInfos; 727 FormInfo formInfo = {}; 728 formInfo.bundleName = "ohos.samples.FormApplication"; 729 formInfo.moduleName = "entry"; 730 expectFormInfos.push_back(formInfo); 731 EXPECT_CALL(*mockFormMgrService, GetFormsInfo(_, _)) 732 .Times(1) 733 .WillOnce(Return(ERR_OK)); 734 // test. 735 formMgrProxy->GetFormsInfo(filter, formInfos); 736 // expect result. 737 EXPECT_EQ(formInfos.size(), 0); 738 GTEST_LOG_(INFO) << "FormMgrProxyTest_0038 test ends"; 739 } 740 741 /** 742 * @tc.name: FormMgrProxyTest_0039 743 * @tc.desc: Verify IsRequestPublishFormSupported 744 * @tc.type: FUNC 745 * @tc.require: #I58Y0A 746 */ 747 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0039, TestSize.Level1) { 748 GTEST_LOG_(INFO) << "FormMgrProxyTest_0039 starts"; 749 // initialize input parameters. 750 EXPECT_CALL(*mockFormMgrService, IsRequestPublishFormSupported()) 751 .Times(1) 752 .WillOnce(Return(true)); 753 // test. 754 bool result = formMgrProxy->IsRequestPublishFormSupported(); 755 // expect result. 756 EXPECT_EQ(result, true); 757 GTEST_LOG_(INFO) << "FormMgrProxyTest_0039 test ends"; 758 } 759 760 /** 761 * @tc.name: FormMgrProxyTest_0040 762 * @tc.desc: Verify StartAbility 763 * @tc.type: FUNC 764 * @tc.require: #I5EFDX 765 */ 766 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0040, TestSize.Level1) { 767 GTEST_LOG_(INFO) << "FormMgrProxyTest_0040 starts"; 768 // initialize input parameters. 769 EXPECT_CALL(*mockFormMgrService, StartAbility(_, _)) 770 .Times(1) 771 .WillOnce(Return(0)); 772 Want want; 773 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 774 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 775 int32_t result = formMgrProxy->StartAbility(want, token); 776 // expect result. 777 EXPECT_EQ(result, 0); 778 GTEST_LOG_(INFO) << "FormMgrProxyTest_0040 test ends"; 779 } 780 781 /** 782 * @tc.name: FormMgrProxyTest_0041 783 * @tc.desc: Verify StartAbility 784 * @tc.type: FUNC 785 * @tc.require: #I5EFDX 786 */ 787 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0041, TestSize.Level1) { 788 GTEST_LOG_(INFO) << "FormMgrProxyTest_0041 starts"; 789 Want want; 790 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 791 int32_t result = formMgrProxy->StartAbility(want, nullptr); 792 // expect result. 793 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 794 GTEST_LOG_(INFO) << "FormMgrProxyTest_0041 test ends"; 795 } 796 797 /** 798 * @tc.name: FormMgrProxyTest_0042 799 * @tc.desc: Verify NotifyFormsPrivacyProtected 800 * @tc.type: FUNC 801 * @tc.require: #I5ST27 802 */ 803 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0042, TestSize.Level1) { 804 GTEST_LOG_(INFO) << "FormMgrProxyTest_0042 starts"; 805 EXPECT_CALL(*mockFormMgrService, NotifyFormsPrivacyProtected(_, _, _)) 806 .Times(1) 807 .WillOnce(Return(0)); 808 // initialize input parameters. 809 int64_t formId = 1; 810 std::vector<int64_t> formIds; 811 formIds.push_back(formId); 812 bool isProtected = false; 813 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 814 int32_t result = formMgrProxy->NotifyFormsPrivacyProtected(formIds, isProtected, token); 815 // expect result. 816 EXPECT_EQ(result, 0); 817 GTEST_LOG_(INFO) << "FormMgrProxyTest_0042 test ends"; 818 } 819 820 /** 821 * @tc.name: FormMgrProxyTest_0043 822 * @tc.desc: Verify NotifyFormsPrivacyProtected 823 * @tc.type: FUNC 824 * @tc.require: #I5ST27 825 */ 826 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0043, TestSize.Level1) { 827 GTEST_LOG_(INFO) << "FormMgrProxyTest_0043 starts"; 828 EXPECT_CALL(*mockFormMgrService, NotifyFormsPrivacyProtected(_, _, _)) 829 .Times(1) 830 .WillOnce(Return(0)); 831 // initialize input parameters. 832 int64_t formId = 2; 833 std::vector<int64_t> formIds; 834 formIds.push_back(formId); 835 bool isProtected = true; 836 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 837 int32_t result = formMgrProxy->NotifyFormsPrivacyProtected(formIds, isProtected, token); 838 // expect result. 839 EXPECT_EQ(result, 0); 840 GTEST_LOG_(INFO) << "FormMgrProxyTest_0043 test ends"; 841 } 842 843 /** 844 * @tc.name: FormMgrProxyTest_0044 845 * @tc.desc: Verify NotifyFormsPrivacyProtected 846 * @tc.type: FUNC 847 * @tc.require: #I5ST27 848 */ 849 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0044, TestSize.Level1) { 850 GTEST_LOG_(INFO) << "FormMgrProxyTest_0044 starts"; 851 EXPECT_CALL(*mockFormMgrService, NotifyFormsPrivacyProtected(_, _, _)) 852 .Times(1) 853 .WillOnce(Return(0)); 854 // initialize input parameters. 855 int64_t formId1 = 3; 856 int64_t formId2 = 4; 857 std::vector<int64_t> formIds; 858 formIds.push_back(formId1); 859 formIds.push_back(formId2); 860 bool isProtected = false; 861 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 862 int32_t result = formMgrProxy->NotifyFormsPrivacyProtected(formIds, isProtected, token); 863 // expect result. 864 EXPECT_EQ(result, 0); 865 GTEST_LOG_(INFO) << "FormMgrProxyTest_0044 test ends"; 866 } 867 868 /** 869 * @tc.name: FormMgrProxyTest_0045 870 * @tc.desc: Verify NotifyFormsPrivacyProtected 871 * @tc.type: FUNC 872 * @tc.require: #I5ST27 873 */ 874 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0045, TestSize.Level1) { 875 GTEST_LOG_(INFO) << "FormMgrProxyTest_0045 starts"; 876 EXPECT_CALL(*mockFormMgrService, NotifyFormsPrivacyProtected(_, _, _)) 877 .Times(1) 878 .WillOnce(Return(0)); 879 // initialize input parameters. 880 int64_t formId1 = 5; 881 int64_t formId2 = 6; 882 std::vector<int64_t> formIds; 883 formIds.push_back(formId1); 884 formIds.push_back(formId2); 885 bool isProtected = true; 886 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 887 int32_t result = formMgrProxy->NotifyFormsPrivacyProtected(formIds, isProtected, token); 888 // expect result. 889 EXPECT_EQ(result, 0); 890 GTEST_LOG_(INFO) << "FormMgrProxyTest_0045 test ends"; 891 } 892 893 /** 894 * @tc.name: FormMgrProxyTest_0046 895 * @tc.desc: text GetRunningFormInfos function. 896 * @tc.type: FUNC 897 * @tc.require: issueI639Z3 898 */ 899 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0046, TestSize.Level1) { 900 GTEST_LOG_(INFO) << "FormMgrProxyTest_0046 starts"; 901 bool isUnusedInclude = false; 902 std::vector<RunningFormInfo> runningFormInfos; 903 int result = formMgrProxy->GetRunningFormInfos(isUnusedInclude, runningFormInfos); 904 EXPECT_EQ(result, ERR_OK); 905 GTEST_LOG_(INFO) << "FormMgrProxyTest_0046 test ends"; 906 } 907 908 /** 909 * @tc.name: FormProviderProxyTest_0001 910 * @tc.desc: text AcquireProviderFormInfo function. 911 * @tc.type: FUNC 912 * @tc.require: issueI639Z3 913 */ 914 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0001, TestSize.Level1) { 915 GTEST_LOG_(INFO) << "FormProviderProxyTest_0001 starts"; 916 FormJsInfo formJsInfo; 917 formJsInfo.formId = 1001L; 918 Want want; 919 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 920 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 921 int result = formProviderProxy->AcquireProviderFormInfo(formJsInfo, want, token); 922 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 923 GTEST_LOG_(INFO) << "FormProviderProxyTest_0001 test ends"; 924 } 925 926 /** 927 * @tc.name: FormProviderProxyTest_0002 928 * @tc.desc: text AcquireProviderFormInfo function. 929 * @tc.type: FUNC 930 * @tc.require: issueI639Z3 931 */ 932 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0002, TestSize.Level1) { 933 GTEST_LOG_(INFO) << "FormProviderProxyTest_0002 starts"; 934 FormJsInfo formJsInfo; 935 Want want; 936 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 937 int result = formProviderProxy->AcquireProviderFormInfo(formJsInfo, want, nullptr); 938 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 939 GTEST_LOG_(INFO) << "FormProviderProxyTest_0002 test ends"; 940 } 941 942 /** 943 * @tc.name: FormProviderProxyTest_0003 944 * @tc.desc: text NotifyFormDelete function. 945 * @tc.type: FUNC 946 * @tc.require: issueI639Z3 947 */ 948 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0003, TestSize.Level1) { 949 GTEST_LOG_(INFO) << "FormProviderProxyTest_0003 starts"; 950 int64_t formId = 1; 951 Want want; 952 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 953 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 954 int result = formProviderProxy->NotifyFormDelete(formId, want, token); 955 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 956 GTEST_LOG_(INFO) << "FormProviderProxyTest_0003 test ends"; 957 } 958 959 /** 960 * @tc.name: FormProviderProxyTest_0004 961 * @tc.desc: text NotifyFormDelete function. 962 * @tc.type: FUNC 963 * @tc.require: issueI639Z3 964 */ 965 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0004, TestSize.Level1) { 966 GTEST_LOG_(INFO) << "FormProviderProxyTest_0004 starts"; 967 int64_t formId = 1; 968 Want want; 969 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 970 int result = formProviderProxy->NotifyFormDelete(formId, want, nullptr); 971 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 972 GTEST_LOG_(INFO) << "FormProviderProxyTest_0004 test ends"; 973 } 974 975 /** 976 * @tc.name: FormProviderProxyTest_0005 977 * @tc.desc: text NotifyFormsDelete function. 978 * @tc.type: FUNC 979 * @tc.require: issueI639Z3 980 */ 981 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0005, TestSize.Level1) { 982 GTEST_LOG_(INFO) << "FormProviderProxyTest_0005 starts"; 983 std::vector<int64_t> formIds; 984 int64_t formId = 1; 985 formIds.emplace_back(formId); 986 Want want; 987 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 988 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 989 int result = formProviderProxy->NotifyFormsDelete(formIds, want, token); 990 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 991 GTEST_LOG_(INFO) << "FormProviderProxyTest_0005 test ends"; 992 } 993 994 /** 995 * @tc.name: FormProviderProxyTest_0006 996 * @tc.desc: text NotifyFormsDelete function. 997 * @tc.type: FUNC 998 * @tc.require: issueI639Z3 999 */ 1000 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0006, TestSize.Level1) { 1001 GTEST_LOG_(INFO) << "FormProviderProxyTest_0006 starts"; 1002 std::vector<int64_t> formIds; 1003 int64_t formId = 1; 1004 formIds.emplace_back(formId); 1005 Want want; 1006 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1007 int result = formProviderProxy->NotifyFormsDelete(formIds, want, nullptr); 1008 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1009 GTEST_LOG_(INFO) << "FormProviderProxyTest_0006 test ends"; 1010 } 1011 1012 /** 1013 * @tc.name: FormProviderProxyTest_0007 1014 * @tc.desc: text NotifyFormUpdate function. 1015 * @tc.type: FUNC 1016 * @tc.require: issueI639Z3 1017 */ 1018 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0007, TestSize.Level1) { 1019 GTEST_LOG_(INFO) << "FormProviderProxyTest_0007 starts"; 1020 int64_t formId = 1; 1021 Want want; 1022 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1023 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1024 int result = formProviderProxy->NotifyFormUpdate(formId, want, token); 1025 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1026 GTEST_LOG_(INFO) << "FormProviderProxyTest_0007 test ends"; 1027 } 1028 1029 /** 1030 * @tc.name: FormProviderProxyTest_0008 1031 * @tc.desc: text NotifyFormUpdate function. 1032 * @tc.type: FUNC 1033 * @tc.require: issueI639Z3 1034 */ 1035 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0008, TestSize.Level1) { 1036 GTEST_LOG_(INFO) << "FormProviderProxyTest_0008 starts"; 1037 int64_t formId = 1; 1038 Want want; 1039 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1040 int result = formProviderProxy->NotifyFormUpdate(formId, want, nullptr); 1041 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1042 GTEST_LOG_(INFO) << "FormProviderProxyTest_0008 test ends"; 1043 } 1044 1045 /** 1046 * @tc.name: FormProviderProxyTest_0009 1047 * @tc.desc: text EventNotify function. 1048 * @tc.type: FUNC 1049 * @tc.require: issueI639Z3 1050 */ 1051 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0009, TestSize.Level1) { 1052 GTEST_LOG_(INFO) << "FormProviderProxyTest_0009 starts"; 1053 std::vector<int64_t> formIds; 1054 int64_t formId = 1; 1055 formIds.emplace_back(formId); 1056 int32_t formVisibleType = 2; 1057 Want want; 1058 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1059 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1060 int result = formProviderProxy->EventNotify(formIds, formVisibleType, want, token); 1061 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1062 GTEST_LOG_(INFO) << "FormProviderProxyTest_0009 test ends"; 1063 } 1064 1065 /** 1066 * @tc.name: FormProviderProxyTest_0010 1067 * @tc.desc: text EventNotify function. 1068 * @tc.type: FUNC 1069 * @tc.require: issueI639Z3 1070 */ 1071 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0010, TestSize.Level1) { 1072 GTEST_LOG_(INFO) << "FormProviderProxyTest_0010 starts"; 1073 std::vector<int64_t> formIds; 1074 int64_t formId = 1; 1075 formIds.emplace_back(formId); 1076 int32_t formVisibleType = 2; 1077 Want want; 1078 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1079 int result = formProviderProxy->EventNotify(formIds, formVisibleType, want, nullptr); 1080 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1081 GTEST_LOG_(INFO) << "FormProviderProxyTest_0010 test ends"; 1082 } 1083 1084 /** 1085 * @tc.name: FormProviderProxyTest_0011 1086 * @tc.desc: text NotifyFormCastTempForm function. 1087 * @tc.type: FUNC 1088 * @tc.require: issueI639Z3 1089 */ 1090 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0011, TestSize.Level1) { 1091 GTEST_LOG_(INFO) << "FormProviderProxyTest_0011 starts"; 1092 int64_t formId = 1; 1093 Want want; 1094 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1095 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1096 int result = formProviderProxy->NotifyFormCastTempForm(formId, want, token); 1097 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1098 GTEST_LOG_(INFO) << "FormProviderProxyTest_0011 test ends"; 1099 } 1100 1101 /** 1102 * @tc.name: FormProviderProxyTest_0012 1103 * @tc.desc: text NotifyFormCastTempForm function. 1104 * @tc.type: FUNC 1105 * @tc.require: issueI639Z3 1106 */ 1107 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0012, TestSize.Level1) { 1108 GTEST_LOG_(INFO) << "FormProviderProxyTest_0012 starts"; 1109 int64_t formId = 1; 1110 Want want; 1111 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1112 int result = formProviderProxy->NotifyFormCastTempForm(formId, want, nullptr); 1113 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1114 GTEST_LOG_(INFO) << "FormProviderProxyTest_0012 test ends"; 1115 } 1116 1117 /** 1118 * @tc.name: FormProviderProxyTest_0013 1119 * @tc.desc: text FireFormEvent function. 1120 * @tc.type: FUNC 1121 * @tc.require: issueI639Z3 1122 */ 1123 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0013, TestSize.Level1) { 1124 GTEST_LOG_(INFO) << "FormProviderProxyTest_0013 starts"; 1125 int64_t formId = 1; 1126 std::string message = "this is message"; 1127 Want want; 1128 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1129 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1130 int result = formProviderProxy->FireFormEvent(formId, message, want, token); 1131 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1132 GTEST_LOG_(INFO) << "FormProviderProxyTest_0013 test ends"; 1133 } 1134 1135 /** 1136 * @tc.name: FormProviderProxyTest_0014 1137 * @tc.desc: text FireFormEvent function. 1138 * @tc.type: FUNC 1139 * @tc.require: issueI639Z3 1140 */ 1141 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0014, TestSize.Level1) { 1142 GTEST_LOG_(INFO) << "FormProviderProxyTest_0014 starts"; 1143 int64_t formId = 1; 1144 std::string message = "this is message"; 1145 Want want; 1146 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1147 int result = formProviderProxy->FireFormEvent(formId, message, want, nullptr); 1148 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1149 GTEST_LOG_(INFO) << "FormProviderProxyTest_0014 test ends"; 1150 } 1151 1152 /** 1153 * @tc.name: FormProviderProxyTest_0015 1154 * @tc.desc: text AcquireState function. 1155 * @tc.type: FUNC 1156 * @tc.require: issueI639Z3 1157 */ 1158 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0015, TestSize.Level1) { 1159 GTEST_LOG_(INFO) << "FormProviderProxyTest_0015 starts"; 1160 Want wantArg; 1161 std::string provider = "this is provider"; 1162 Want want; 1163 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1164 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1165 int result = formProviderProxy->AcquireState(wantArg, provider, want, token); 1166 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1167 GTEST_LOG_(INFO) << "FormProviderProxyTest_0015 test ends"; 1168 } 1169 1170 /** 1171 * @tc.name: FormProviderProxyTest_0016 1172 * @tc.desc: text AcquireState function. 1173 * @tc.type: FUNC 1174 * @tc.require: issueI639Z3 1175 */ 1176 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0016, TestSize.Level1) { 1177 GTEST_LOG_(INFO) << "FormProviderProxyTest_0016 starts"; 1178 Want wantArg; 1179 std::string provider = "this is provider"; 1180 Want want; 1181 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1182 int result = formProviderProxy->AcquireState(wantArg, provider, want, nullptr); 1183 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1184 GTEST_LOG_(INFO) << "FormProviderProxyTest_0016 test ends"; 1185 } 1186 1187 /** 1188 * @tc.name: FormProviderProxyTest_0017 1189 * @tc.desc: text AcquireShareFormData function. 1190 * @tc.type: FUNC 1191 * @tc.require: issueI639Z3 1192 */ 1193 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0017, TestSize.Level1) { 1194 GTEST_LOG_(INFO) << "FormProviderProxyTest_0017 starts"; 1195 int64_t formId = 2; 1196 std::string remoteDeviceId = "this is remoteDeviceId"; 1197 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1198 int64_t requestCode = 1; 1199 int result = formProviderProxy->AcquireShareFormData(formId, remoteDeviceId, token, requestCode); 1200 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1201 GTEST_LOG_(INFO) << "FormProviderProxyTest_0017 test ends"; 1202 } 1203 1204 /** 1205 * @tc.name: FormProviderProxyTest_0018 1206 * @tc.desc: text AcquireShareFormData function. 1207 * @tc.type: FUNC 1208 * @tc.require: issueI639Z3 1209 */ 1210 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0018, TestSize.Level1) { 1211 GTEST_LOG_(INFO) << "FormProviderProxyTest_0018 starts"; 1212 int64_t formId = 2; 1213 std::string remoteDeviceId = "this is remoteDeviceId"; 1214 int64_t requestCode = 1; 1215 int result = formProviderProxy->AcquireShareFormData(formId, remoteDeviceId, nullptr, requestCode); 1216 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1217 GTEST_LOG_(INFO) << "FormProviderProxyTest_0018 test ends"; 1218 } 1219 1220 /** 1221 * @tc.name: FormProviderProxyTest_0019 1222 * @tc.desc: text AcquireFormData function. 1223 * @tc.type: FUNC 1224 * @tc.require: issueI639Z3 1225 */ 1226 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0019, TestSize.Level1) { 1227 GTEST_LOG_(INFO) << "FormProviderProxyTest_0019 starts"; 1228 int64_t formId = 2; 1229 std::string remoteDeviceId = "this is remoteDeviceId"; 1230 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1231 int64_t requestCode = 1; 1232 int result = formProviderProxy->AcquireFormData(formId, token, requestCode); 1233 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1234 GTEST_LOG_(INFO) << "FormProviderProxyTest_0019 test ends"; 1235 } 1236 1237 /** 1238 * @tc.name: FormProviderProxyTest_0020 1239 * @tc.desc: text AcquireFormData function. 1240 * @tc.type: FUNC 1241 * @tc.require: issueI639Z3 1242 */ 1243 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0020, TestSize.Level1) { 1244 GTEST_LOG_(INFO) << "FormProviderProxyTest_0020 starts"; 1245 int64_t formId = 2; 1246 std::string remoteDeviceId = "this is remoteDeviceId"; 1247 int64_t requestCode = 1; 1248 int result = formProviderProxy->AcquireFormData(formId, nullptr, requestCode); 1249 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1250 GTEST_LOG_(INFO) << "FormProviderProxyTest_0020 test ends"; 1251 } 1252 1253 /** 1254 * @tc.name: FormProviderProxyTest_0021 1255 * @tc.desc: text EventNotify function. 1256 * @tc.type: FUNC 1257 * @tc.require: issueI639Z3 1258 */ 1259 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0021, TestSize.Level1) { 1260 GTEST_LOG_(INFO) << "FormProviderProxyTest_0021 starts"; 1261 std::vector<int64_t> formIds; 1262 int64_t formId = 1; 1263 formIds.emplace_back(formId); 1264 int32_t formVisibleType = 2; 1265 Want want; 1266 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1267 int result = formProviderProxy->EventNotify(formIds, formVisibleType, want, nullptr); 1268 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1269 GTEST_LOG_(INFO) << "FormProviderProxyTest_0021 test ends"; 1270 } 1271 1272 /** 1273 * @tc.name: FormProviderProxyTest_0022 1274 * @tc.desc: text NotifyFormCastTempForm function. 1275 * @tc.type: FUNC 1276 * @tc.require: issueI639Z3 1277 */ 1278 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0022, TestSize.Level1) { 1279 GTEST_LOG_(INFO) << "FormProviderProxyTest_0022 starts"; 1280 int64_t formId = 1; 1281 Want want; 1282 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1283 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1284 int result = formProviderProxy->NotifyFormCastTempForm(formId, want, token); 1285 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1286 GTEST_LOG_(INFO) << "FormProviderProxyTest_0022 test ends"; 1287 } 1288 1289 /** 1290 * @tc.name: FormProviderProxyTest_0023 1291 * @tc.desc: text NotifyFormCastTempForm function. 1292 * @tc.type: FUNC 1293 * @tc.require: issueI639Z3 1294 */ 1295 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0023, TestSize.Level1) { 1296 GTEST_LOG_(INFO) << "FormProviderProxyTest_0023 starts"; 1297 int64_t formId = 1; 1298 Want want; 1299 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1300 int result = formProviderProxy->NotifyFormCastTempForm(formId, want, nullptr); 1301 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1302 GTEST_LOG_(INFO) << "FormProviderProxyTest_0023 test ends"; 1303 } 1304 1305 /** 1306 * @tc.name: FormProviderProxyTest_0024 1307 * @tc.desc: text FireFormEvent function. 1308 * @tc.type: FUNC 1309 * @tc.require: issueI639Z3 1310 */ 1311 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0024, TestSize.Level1) { 1312 GTEST_LOG_(INFO) << "FormProviderProxyTest_0024 starts"; 1313 int64_t formId = 1; 1314 std::string message = "this is message"; 1315 Want want; 1316 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1317 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1318 int result = formProviderProxy->FireFormEvent(formId, message, want, token); 1319 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1320 GTEST_LOG_(INFO) << "FormProviderProxyTest_0024 test ends"; 1321 } 1322 1323 /** 1324 * @tc.name: FormProviderProxyTest_0025 1325 * @tc.desc: text FireFormEvent function. 1326 * @tc.type: FUNC 1327 * @tc.require: issueI639Z3 1328 */ 1329 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0025, TestSize.Level1) { 1330 GTEST_LOG_(INFO) << "FormProviderProxyTest_0025 starts"; 1331 int64_t formId = 1; 1332 std::string message = "this is message"; 1333 Want want; 1334 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1335 int result = formProviderProxy->FireFormEvent(formId, message, want, nullptr); 1336 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1337 GTEST_LOG_(INFO) << "FormProviderProxyTest_0025 test ends"; 1338 } 1339 1340 /** 1341 * @tc.name: FormProviderProxyTest_0026 1342 * @tc.desc: text AcquireState function. 1343 * @tc.type: FUNC 1344 * @tc.require: issueI639Z3 1345 */ 1346 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0026, TestSize.Level1) { 1347 GTEST_LOG_(INFO) << "FormProviderProxyTest_0026 starts"; 1348 Want wantArg; 1349 std::string provider = "this is provider"; 1350 Want want; 1351 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1352 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1353 int result = formProviderProxy->AcquireState(wantArg, provider, want, token); 1354 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1355 GTEST_LOG_(INFO) << "FormProviderProxyTest_0026 test ends"; 1356 } 1357 1358 /** 1359 * @tc.name: FormProviderProxyTest_0027 1360 * @tc.desc: text AcquireState function. 1361 * @tc.type: FUNC 1362 * @tc.require: issueI639Z3 1363 */ 1364 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0027, TestSize.Level1) { 1365 GTEST_LOG_(INFO) << "FormProviderProxyTest_0027 starts"; 1366 Want wantArg; 1367 std::string provider = "this is provider"; 1368 Want want; 1369 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1370 int result = formProviderProxy->AcquireState(wantArg, provider, want, nullptr); 1371 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1372 GTEST_LOG_(INFO) << "FormProviderProxyTest_0027 test ends"; 1373 } 1374 1375 /** 1376 * @tc.name: FormProviderProxyTest_0028 1377 * @tc.desc: text AcquireShareFormData function. 1378 * @tc.type: FUNC 1379 * @tc.require: issueI639Z3 1380 */ 1381 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0028, TestSize.Level1) { 1382 GTEST_LOG_(INFO) << "FormProviderProxyTest_0028 starts"; 1383 int64_t formId = 2; 1384 std::string remoteDeviceId = "this is remoteDeviceId"; 1385 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1386 int64_t requestCode = 1; 1387 int result = formProviderProxy->AcquireShareFormData(formId, remoteDeviceId, token, requestCode); 1388 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1389 GTEST_LOG_(INFO) << "FormProviderProxyTest_0028 test ends"; 1390 } 1391 1392 /** 1393 * @tc.name: FormProviderProxyTest_0029 1394 * @tc.desc: text AcquireShareFormData function. 1395 * @tc.type: FUNC 1396 * @tc.require: issueI639Z3 1397 */ 1398 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0029, TestSize.Level1) { 1399 GTEST_LOG_(INFO) << "FormProviderProxyTest_0029 starts"; 1400 int64_t formId = 2; 1401 std::string remoteDeviceId = "this is remoteDeviceId"; 1402 int64_t requestCode = 1; 1403 int result = formProviderProxy->AcquireShareFormData(formId, remoteDeviceId, nullptr, requestCode); 1404 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1405 GTEST_LOG_(INFO) << "FormProviderProxyTest_0029 test ends"; 1406 } 1407 1408 /** 1409 * @tc.name: FormProviderProxyTest_0030 1410 * @tc.desc: text AcquireFormData function. 1411 * @tc.type: FUNC 1412 * @tc.require: issueI639Z3 1413 */ 1414 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0030, TestSize.Level1) { 1415 GTEST_LOG_(INFO) << "FormProviderProxyTest_0030 starts"; 1416 int64_t formId = 2; 1417 std::string remoteDeviceId = "this is remoteDeviceId"; 1418 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1419 int64_t requestCode = 1; 1420 int result = formProviderProxy->AcquireFormData(formId, token, requestCode); 1421 EXPECT_EQ(result, ERR_APPEXECFWK_FORM_INVALID_PARAM); 1422 GTEST_LOG_(INFO) << "FormProviderProxyTest_0030 test ends"; 1423 } 1424 1425 /** 1426 * @tc.name: FormProviderProxyTest_0031 1427 * @tc.desc: text AcquireFormData function. 1428 * @tc.type: FUNC 1429 * @tc.require: issueI639Z3 1430 */ 1431 HWTEST_F(FormMgrProxyTest, FormProviderProxyTest_0031, TestSize.Level1) { 1432 GTEST_LOG_(INFO) << "FormProviderProxyTest_0031 starts"; 1433 int64_t formId = 2; 1434 std::string remoteDeviceId = "this is remoteDeviceId"; 1435 int64_t requestCode = 1; 1436 int result = formProviderProxy->AcquireFormData(formId, nullptr, requestCode); 1437 EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); 1438 GTEST_LOG_(INFO) << "FormProviderProxyTest_0031 test ends"; 1439 } 1440 1441 /** 1442 * @tc.name: GetFormInstanceById_0100 1443 * @tc.desc: text the return of GetFormInstanceById. 1444 * @tc.type: FUNC 1445 */ 1446 HWTEST_F(FormMgrProxyTest, GetFormInstanceById_0100, TestSize.Level1) { 1447 GTEST_LOG_(INFO) << "GetFormInstanceById_0100 starts"; 1448 int64_t formId = 2; 1449 bool isUnusedIncluded = false; 1450 FormInstance formInstance; 1451 auto result = formMgrProxy->GetFormInstanceById(formId, isUnusedIncluded, formInstance); 1452 EXPECT_EQ(result, ERR_OK); 1453 GTEST_LOG_(INFO) << "GetFormInstanceById_0100 test ends"; 1454 } 1455 1456 /** 1457 * @tc.name: FormMgrProxyTest_0101 1458 * @tc.desc: Verify HasFormVisible 1459 * @tc.type: FUNC 1460 */ 1461 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0101, TestSize.Level1) { 1462 GTEST_LOG_(INFO) << "FormMgrProxyTest_0101 starts"; 1463 EXPECT_CALL(*mockFormMgrService, HasFormVisible(_)) 1464 .Times(1) 1465 .WillOnce(Return(true)); 1466 uint32_t tokenId = 0; 1467 bool result = formMgrProxy->HasFormVisible(tokenId); 1468 EXPECT_EQ(result, true); 1469 GTEST_LOG_(INFO) << "FormMgrProxyTest_0101 test ends"; 1470 } 1471 1472 /** 1473 * @tc.name: FormMgrProxyTest_0102 1474 * @tc.desc: Verify GetFormsInfoByFilter is called. 1475 * @tc.type: FUNC 1476 */ 1477 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0102, TestSize.Level1) { 1478 GTEST_LOG_(INFO) << "FormMgrProxyTest_0102 starts"; 1479 EXPECT_CALL(*mockFormMgrService, GetFormsInfoByFilter(_, _)) 1480 .Times(1) 1481 .WillOnce(Return(true)); 1482 std::vector<FormInfo> formInfos; 1483 FormInfoFilter filter; 1484 bool result = formMgrProxy->GetFormsInfoByFilter(filter, formInfos); 1485 EXPECT_EQ(result, true); 1486 GTEST_LOG_(INFO) << "FormMgrProxyTest_0102 test ends"; 1487 } 1488 1489 /** 1490 * @tc.number: FormMgrProxyTest_0103 1491 * @tc.name: test UpdateFormLocation function. 1492 * @tc.desc: Verify that the UpdateFormLocation interface is called normally 1493 * and the return value is ERR_OK. 1494 */ 1495 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0103, TestSize.Level1) { 1496 GTEST_LOG_(INFO) << "FormMgrProxyTest_0103 starts"; 1497 int64_t formId = 0; 1498 int32_t formLocation = 1; 1499 EXPECT_EQ(formMgrProxy->UpdateFormLocation(formId, formLocation), ERR_OK); 1500 GTEST_LOG_(INFO) << "FormMgrProxyTest_0103 test ends"; 1501 } 1502 1503 /** 1504 * @tc.name: FormMgrProxyTest_0104 1505 * @tc.desc: Verify CreateForm 1506 * @tc.type: FUNC 1507 */ 1508 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0104, TestSize.Level1) { 1509 GTEST_LOG_(INFO) << "FormMgrProxyTest_0104 starts"; 1510 EXPECT_CALL(*mockFormMgrService, CreateForm(_, _)) 1511 .Times(1) 1512 .WillOnce(Return(0)); 1513 Want want; 1514 RunningFormInfo runningFormInfo; 1515 int result = formMgrProxy->CreateForm(want, runningFormInfo); 1516 EXPECT_EQ(result, 0); 1517 GTEST_LOG_(INFO) << "FormMgrProxyTest_0104 test ends"; 1518 } 1519 1520 /** 1521 * @tc.number: FormMgrProxyTest_0105 1522 * @tc.name: test SetPublishFormResult function. 1523 * @tc.desc: Verify that the SetPublishFormResult interface is called normally and the return value is ERR_OK. 1524 */ 1525 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0105, TestSize.Level1) { 1526 GTEST_LOG_(INFO) << "FormMgrProxyTest_0105 starts"; 1527 int64_t formId = 0; 1528 Constants::PublishFormResult result {Constants::PublishFormErrorCode::SUCCESS, ""}; 1529 EXPECT_EQ(formMgrProxy->SetPublishFormResult(formId, result), ERR_OK); 1530 GTEST_LOG_(INFO) << "FormMgrProxyTest_0105 test ends"; 1531 } 1532 1533 /** 1534 * @tc.number: FormMgrProxyTest_0106 1535 * @tc.name: test AcquireAddFormResult function. 1536 * @tc.desc: Verify that the AcquireAddFormResult interface is called normally and the return value is ERR_OK. 1537 */ 1538 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0106, TestSize.Level1) { 1539 GTEST_LOG_(INFO) << "FormMgrProxyTest_0106 starts"; 1540 int64_t formId = 0; 1541 EXPECT_EQ(formMgrProxy->AcquireAddFormResult(formId), ERR_OK); 1542 GTEST_LOG_(INFO) << "FormMgrProxyTest_0106 test ends"; 1543 } 1544 1545 /** 1546 * @tc.number: FormMgrProxyTest_BatchRefreshForms_001 1547 * @tc.name: test BatchRefreshForms function. 1548 * @tc.desc: Verify that the BatchRefreshForms interface is called normally and the return value is ERR_OK. 1549 */ 1550 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_BatchRefreshForms_001, TestSize.Level1) { 1551 GTEST_LOG_(INFO) << "FormMgrProxyTest_BatchRefreshForms_001 starts"; 1552 int32_t formRefreshType = Constants::REFRESH_ALL_FORM; 1553 EXPECT_EQ(formMgrProxy->BatchRefreshForms(formRefreshType), ERR_OK); 1554 GTEST_LOG_(INFO) << "FormMgrProxyTest_BatchRefreshForms_001 test ends"; 1555 } 1556 1557 /** 1558 * @tc.number: FormMgrProxyTest_BatchRefreshForms_002 1559 * @tc.name: test BatchRefreshForms function. 1560 * @tc.desc: Verify that the BatchRefreshForms interface is called normally and the return value is ERR_OK. 1561 */ 1562 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_BatchRefreshForms_002, TestSize.Level1) { 1563 GTEST_LOG_(INFO) << "FormMgrProxyTest_BatchRefreshForms_002 starts"; 1564 int32_t formRefreshType = Constants::REFRESH_ALL_FORM; 1565 EXPECT_EQ(formMgrProxy->BatchRefreshForms(formRefreshType), ERR_OK); 1566 GTEST_LOG_(INFO) << "FormMgrProxyTest_BatchRefreshForms_002 test ends"; 1567 } 1568 1569 /** 1570 * @tc.number: FormMgrProxyTest_IsFormBundleForbidden_001 1571 * @tc.name: test IsFormBundleForbidden function. 1572 * @tc.desc: Verify that the IsFormBundleForbidden. 1573 */ 1574 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_IsFormBundleForbidden_001, TestSize.Level1) { 1575 GTEST_LOG_(INFO) << "FormMgrProxyTest_IsFormBundleForbidden_001 starts"; 1576 std::string bundleName = "ohos.samples.FormApplication"; 1577 bool result = formMgrProxy->IsFormBundleForbidden(bundleName); 1578 EXPECT_EQ(result, false); 1579 GTEST_LOG_(INFO) << "FormMgrProxyTest_IsFormBundleForbidden_001 test ends"; 1580 } 1581 1582 /** 1583 * @tc.number: FormMgrProxyTest_IsFormBundleForbidden_002 1584 * @tc.name: test IsFormBundleForbidden function. 1585 * @tc.desc: Verify that the IsFormBundleForbidden. 1586 */ 1587 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_IsFormBundleForbidden_002, TestSize.Level1) { 1588 GTEST_LOG_(INFO) << "FormMgrProxyTest_IsFormBundleForbidden_002 starts"; 1589 std::string bundleName = "ohos.samples.FormApplication"; 1590 bool result = formMgrProxy->IsFormBundleForbidden(bundleName); 1591 EXPECT_EQ(result, false); 1592 GTEST_LOG_(INFO) << "FormMgrProxyTest_IsFormBundleForbidden_002 test ends"; 1593 } 1594 1595 /** 1596 * @tc.number: FormMgrProxyTest_EnableForms_001 1597 * @tc.name: test EnableForms function. 1598 * @tc.desc: Verify that the EnableForms interface is called normally and the return value is ERR_OK. 1599 */ 1600 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_EnableForms_001, TestSize.Level1) { 1601 GTEST_LOG_(INFO) << "FormMgrProxyTest_EnableForms_001 starts"; 1602 std::string bundleName = "ohos.samples.FormApplication"; 1603 EXPECT_EQ(formMgrProxy->EnableForms(bundleName, true), ERR_OK); 1604 EXPECT_EQ(formMgrProxy->EnableForms(bundleName, false), ERR_OK); 1605 GTEST_LOG_(INFO) << "FormMgrProxyTest_EnableForms_001 test ends"; 1606 } 1607 1608 /** 1609 * @tc.number: FormMgrProxyTest_EnableForms_002 1610 * @tc.name: test EnableForms function. 1611 * @tc.desc: Verify that the EnableForms interface is called normally and the return value is ERR_OK. 1612 */ 1613 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_EnableForms_002, TestSize.Level1) { 1614 GTEST_LOG_(INFO) << "FormMgrProxyTest_EnableForms_002 starts"; 1615 std::string bundleName = "ohos.samples.FormApplication"; 1616 EXPECT_EQ(formMgrProxy->EnableForms(bundleName, true), ERR_OK); 1617 EXPECT_EQ(formMgrProxy->EnableForms(bundleName, false), ERR_OK); 1618 GTEST_LOG_(INFO) << "FormMgrProxyTest_EnableForms_002 test ends"; 1619 } 1620 1621 /** 1622 * @tc.name: FormMgrProxyTest_IsSystemAppForm_001 1623 * @tc.desc: Verify IsSystemAppForm 1624 * @tc.type: FUNC 1625 */ 1626 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_IsSystemAppForm_001, TestSize.Level1) { 1627 GTEST_LOG_(INFO) << "FormMgrProxyTest_IsSystemAppForm_001 starts"; 1628 EXPECT_CALL(*mockFormMgrService, IsSystemAppForm(_)) 1629 .Times(1) 1630 .WillOnce(Return(true)); 1631 std::string bundleName = "ohos.samples.FormApplicationTest"; 1632 bool result = formMgrProxy->IsSystemAppForm(bundleName); 1633 EXPECT_EQ(result, true); 1634 GTEST_LOG_(INFO) << "FormMgrProxyTest_IsSystemAppForm_001 test ends"; 1635 } 1636 1637 /** 1638 * @tc.name: FormMgrProxyTest_IsSystemAppForm_002 1639 * @tc.desc: Verify IsSystemAppForm 1640 * @tc.type: FUNC 1641 */ 1642 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_IsSystemAppForm_002, TestSize.Level1) { 1643 GTEST_LOG_(INFO) << "FormMgrProxyTest_IsSystemAppForm_002 starts"; 1644 EXPECT_CALL(*mockFormMgrService, IsSystemAppForm(_)) 1645 .Times(1) 1646 .WillOnce(Return(true)); 1647 std::string bundleName = "ohos.samples.FormApplicationTest"; 1648 bool result = formMgrProxy->IsSystemAppForm(bundleName); 1649 EXPECT_EQ(result, true); 1650 GTEST_LOG_(INFO) << "FormMgrProxyTest_IsSystemAppForm_002 test ends"; 1651 } 1652 1653 /** 1654 * @tc.name: FormMgrProxyTest_StartAbilityByCrossBundle_001 1655 * @tc.desc: test StartAbilityByCrossBundle function. 1656 * @tc.type: FUNC 1657 */ 1658 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_StartAbilityByCrossBundle_001, TestSize.Level1) { 1659 GTEST_LOG_(INFO) << "FormMgrProxyTest_StartAbilityByCrossBundle_001 start"; 1660 Want want; 1661 want = want.SetElementName("", "com.example.FormAbility", "MainAbility"); 1662 auto result = formMgrProxy->StartAbilityByCrossBundle(want); 1663 EXPECT_EQ(result, ERR_OK); 1664 GTEST_LOG_(INFO) << "FormMgrProxyTest_StartAbilityByCrossBundle_001 end"; 1665 } 1666 1667 /* 1668 * @tc.number: FormMgrProxyTest_RegisterGetFormRectProxy_001 1669 * @tc.name: Verify RegisterGetFormRectProxy 1670 * @tc.desc: text RegisterGetFormRectProxy function. 1671 */ 1672 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_RegisterGetFormRectProxy_001, TestSize.Level1) { 1673 GTEST_LOG_(INFO) << "FormMgrProxyTest_RegisterGetFormRectProxy_001 starts"; 1674 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1675 auto result = formMgrProxy->RegisterGetFormRectProxy(token); 1676 EXPECT_EQ(result, ERR_OK); 1677 GTEST_LOG_(INFO) << "FormMgrProxyTest_RegisterGetFormRectProxy_001 ends"; 1678 } 1679 1680 /** 1681 * @tc.number: FormMgrProxyTest_UnregisterGetFormRectProxy_001 1682 * @tc.name: Verify UnregisterGetFormRectProxy 1683 * @tc.desc: text UnregisterGetFormRectProxy function. 1684 */ 1685 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_UnregisterGetFormRectProxy_001, TestSize.Level1) { 1686 GTEST_LOG_(INFO) << "FormMgrProxyTest_UnregisterGetFormRectProxy_001 starts"; 1687 auto result = formMgrProxy->UnregisterGetFormRectProxy(); 1688 EXPECT_EQ(result, ERR_OK); 1689 GTEST_LOG_(INFO) << "FormMgrProxyTest_UnregisterGetFormRectProxy_001 ends"; 1690 } 1691 1692 /** 1693 * @tc.number: FormMgrProxyTest_GetFormRect_001 1694 * @tc.name: Verify GetFormRect 1695 * @tc.desc: When the parameter code is FORM_MGR_GET_FORM_RECT, the interface return value is ERR_OK. 1696 */ 1697 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_GetFormRect_001, TestSize.Level1) { 1698 GTEST_LOG_(INFO) << "FormMgrProxyTest_GetFormRect_001 starts"; 1699 EXPECT_TRUE(mockFormMgrService != nullptr); 1700 EXPECT_CALL(*mockFormMgrService, GetFormRect(_, _)).Times(1).WillOnce(Return(ERR_OK)); 1701 constexpr int64_t formId = 1; 1702 Rect rect; 1703 auto result = formMgrProxy->GetFormRect(formId, rect); 1704 EXPECT_EQ(result, ERR_OK); 1705 GTEST_LOG_(INFO) << "FormMgrProxyTest_GetFormRect_001 ends"; 1706 } 1707 1708 /* 1709 * @tc.number: FormMgrProxyTest_RegisterGetLiveFormStatusProxy_001 1710 * @tc.name: Verify RegisterGetLiveFormStatusProxy 1711 * @tc.desc: text RegisterGetLiveFormStatusProxy function. 1712 */ 1713 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_RegisterGetLiveFormStatusProxy_001, TestSize.Level1) { 1714 GTEST_LOG_(INFO) << "FormMgrProxyTest_RegisterGetLiveFormStatusProxy_001 starts"; 1715 sptr<MockFormToken> token = new (std::nothrow) MockFormToken(); 1716 auto result = formMgrProxy->RegisterGetLiveFormStatusProxy(token); 1717 EXPECT_EQ(result, ERR_OK); 1718 GTEST_LOG_(INFO) << "FormMgrProxyTest_RegisterGetLiveFormStatusProxy_001 ends"; 1719 } 1720 1721 /** 1722 * @tc.number: FormMgrProxyTest_UnregisterGetLiveFormStatusProxy_001 1723 * @tc.name: Verify UnregisterGetLiveFormStatusProxy 1724 * @tc.desc: text UnregisterGetLiveFormStatusProxy function. 1725 */ 1726 HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_UnregisterGetLiveFormStatusProxy_001, TestSize.Level1) { 1727 GTEST_LOG_(INFO) << "FormMgrProxyTest_UnregisterGetLiveFormStatusProxy_001 starts"; 1728 auto result = formMgrProxy->UnregisterGetLiveFormStatusProxy(); 1729 EXPECT_EQ(result, ERR_OK); 1730 GTEST_LOG_(INFO) << "FormMgrProxyTest_UnregisterGetLiveFormStatusProxy_001 ends"; 1731 } 1732 }