1 /* 2 * Copyright (c) 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 16 #include "session_proxy.h" 17 #include "iremote_object_mocker.h" 18 #include <gtest/gtest.h> 19 #include "accessibility_event_info.h" 20 #include "ws_common.h" 21 #include "mock_message_parcel.h" 22 #include "pointer_event.h" 23 #include "ui/rs_canvas_node.h" 24 #include "transaction/rs_transaction.h" 25 #include "window_manager_hilog.h" 26 27 // using namespace FRAME_TRACE; 28 using namespace testing; 29 using namespace testing::ext; 30 31 namespace { 32 std::string logMsg; MyLogCallback(const LogType type,const LogLevel level,const unsigned int domain,const char * tag,const char * msg)33 void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char* tag, 34 const char* msg) 35 { 36 logMsg = msg; 37 } 38 } 39 40 namespace OHOS { 41 namespace Rosen { 42 class SessionProxyTest : public testing::Test { 43 public: SessionProxyTest()44 SessionProxyTest() {} ~SessionProxyTest()45 ~SessionProxyTest() {} 46 }; 47 namespace { 48 49 /** 50 * @tc.name: OnSessionEvent 51 * @tc.desc: normal function 52 * @tc.type: FUNC 53 */ 54 HWTEST_F(SessionProxyTest, OnSessionEvent, TestSize.Level1) 55 { 56 GTEST_LOG_(INFO) << "SessionProxyTest: OnSessionEvent start"; 57 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 58 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 59 SessionEvent event = SessionEvent::EVENT_MAXIMIZE; 60 WSError res = sProxy->OnSessionEvent(event); 61 ASSERT_EQ(res, WSError::WS_OK); 62 GTEST_LOG_(INFO) << "SessionProxyTest: OnSessionEvent end"; 63 } 64 65 /** 66 * @tc.name: UpdateSessionRect 67 * @tc.desc: normal function 68 * @tc.type: FUNC 69 */ 70 HWTEST_F(SessionProxyTest, UpdateSessionRect, TestSize.Level1) 71 { 72 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionRect start"; 73 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 74 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 75 WSRect rect{ .posX_ = 1, .posY_ = 1, .width_ = 100, .height_ = 100 }; 76 SizeChangeReason reason = SizeChangeReason::RECOVER; 77 WSError res = sProxy->UpdateSessionRect(rect, reason); 78 ASSERT_EQ(res, WSError::WS_OK); 79 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionRect end"; 80 } 81 82 /** 83 * @tc.name: Restore 84 * @tc.desc: normal function 85 * @tc.type: FUNC 86 */ 87 HWTEST_F(SessionProxyTest, OnRestoreMainWindow, TestSize.Level1) 88 { 89 GTEST_LOG_(INFO) << "SessionProxyTest: OnRestoreMainWindow start"; 90 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 91 ASSERT_NE(iRemoteObjectMocker, nullptr); 92 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 93 ASSERT_NE(sProxy, nullptr); 94 WSError res = sProxy->OnRestoreMainWindow(); 95 ASSERT_EQ(res, WSError::WS_OK); 96 GTEST_LOG_(INFO) << "SessionProxyTest: OnRestoreMainWindow end"; 97 } 98 99 /** 100 * @tc.name: RaiseToAppTop 101 * @tc.desc: normal function 102 * @tc.type: FUNC 103 */ 104 HWTEST_F(SessionProxyTest, RaiseToAppTop, TestSize.Level1) 105 { 106 GTEST_LOG_(INFO) << "SessionProxyTest: RaiseToAppTop start"; 107 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 108 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 109 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 110 WSError res = sProxy->RaiseToAppTop(); 111 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 112 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 113 114 sptr<SessionProxy> tempProxy = sptr<SessionProxy>::MakeSptr(nullptr); 115 res = tempProxy->RaiseToAppTop(); 116 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 117 118 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 119 res = sProxy->RaiseToAppTop(); 120 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 121 remoteMocker->SetRequestResult(ERR_NONE); 122 123 res = sProxy->RaiseToAppTop(); 124 ASSERT_EQ(res, WSError::WS_OK); 125 126 GTEST_LOG_(INFO) << "SessionProxyTest: RaiseToAppTop end"; 127 } 128 129 /** 130 * @tc.name: RaiseAboveTarget 131 * @tc.desc: normal function 132 * @tc.type: FUNC 133 */ 134 HWTEST_F(SessionProxyTest, RaiseAboveTarget, TestSize.Level1) 135 { 136 GTEST_LOG_(INFO) << "SessionProxyTest: RaiseAboveTarget start"; 137 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 138 sptr<SessionProxy> proxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 139 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 140 int32_t subWindowId = 0; 141 WSError res = proxy->RaiseAboveTarget(subWindowId); 142 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 143 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 144 145 sptr<SessionProxy> tempProxy = sptr<SessionProxy>::MakeSptr(nullptr); 146 res = tempProxy->RaiseAboveTarget(subWindowId); 147 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 148 149 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 150 res = proxy->RaiseAboveTarget(subWindowId); 151 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 152 remoteMocker->SetRequestResult(ERR_NONE); 153 154 res = proxy->RaiseAboveTarget(subWindowId); 155 ASSERT_EQ(res, WSError::WS_OK); 156 157 GTEST_LOG_(INFO) << "SessionProxyTest: RaiseAboveTarget end"; 158 } 159 160 /** 161 * @tc.name: OnNeedAvoid 162 * @tc.desc: normal function 163 * @tc.type: FUNC 164 */ 165 HWTEST_F(SessionProxyTest, OnNeedAvoid, TestSize.Level1) 166 { 167 GTEST_LOG_(INFO) << "SessionProxyTest: OnNeedAvoid start"; 168 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 169 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 170 bool status = false; 171 WSError res = sProxy->OnNeedAvoid(status); 172 ASSERT_EQ(res, WSError::WS_OK); 173 174 GTEST_LOG_(INFO) << "SessionProxyTest: OnNeedAvoid end"; 175 } 176 177 /** 178 * @tc.name: RequestSessionBack 179 * @tc.desc: normal function 180 * @tc.type: FUNC 181 */ 182 HWTEST_F(SessionProxyTest, RequestSessionBack, TestSize.Level1) 183 { 184 GTEST_LOG_(INFO) << "SessionProxyTest: RequestSessionBack start"; 185 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 186 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 187 bool needMoveToBackground = true; 188 WSError res = sProxy->RequestSessionBack(needMoveToBackground); 189 ASSERT_EQ(res, WSError::WS_OK); 190 191 GTEST_LOG_(INFO) << "SessionProxyTest: RequestSessionBack end"; 192 } 193 194 /** 195 * @tc.name: MarkProcessed 196 * @tc.desc: normal function 197 * @tc.type: FUNC 198 */ 199 HWTEST_F(SessionProxyTest, MarkProcessed, TestSize.Level1) 200 { 201 GTEST_LOG_(INFO) << "SessionProxyTest: MarkProcessed start"; 202 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 203 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 204 int32_t eventId = 0; 205 WSError res = sProxy->MarkProcessed(eventId); 206 ASSERT_EQ(res, WSError::WS_OK); 207 208 GTEST_LOG_(INFO) << "SessionProxyTest: MarkProcessed end"; 209 } 210 211 /** 212 * @tc.name: SetGlobalMaximizeMode 213 * @tc.desc: normal function 214 * @tc.type: FUNC 215 */ 216 HWTEST_F(SessionProxyTest, SetGlobalMaximizeMode, TestSize.Level1) 217 { 218 GTEST_LOG_(INFO) << "SessionProxyTest: SetGlobalMaximizeMode start"; 219 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 220 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 221 MaximizeMode mode = MaximizeMode::MODE_AVOID_SYSTEM_BAR; 222 WSError res = sProxy->SetGlobalMaximizeMode(mode); 223 ASSERT_EQ(res, WSError::WS_OK); 224 225 GTEST_LOG_(INFO) << "SessionProxyTest: SetGlobalMaximizeMode end"; 226 } 227 228 /** 229 * @tc.name: GetGlobalMaximizeMode 230 * @tc.desc: normal function 231 * @tc.type: FUNC 232 */ 233 HWTEST_F(SessionProxyTest, GetGlobalMaximizeMode, TestSize.Level1) 234 { 235 GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalMaximizeMode start"; 236 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 237 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 238 MaximizeMode mode = MaximizeMode::MODE_AVOID_SYSTEM_BAR; 239 WSError res = sProxy->GetGlobalMaximizeMode(mode); 240 ASSERT_EQ(res, WSError::WS_OK); 241 242 GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalMaximizeMode end"; 243 } 244 245 /** 246 * @tc.name: SetAspectRatio 247 * @tc.desc: normal function 248 * @tc.type: FUNC 249 */ 250 HWTEST_F(SessionProxyTest, SetAspectRatio, TestSize.Level1) 251 { 252 GTEST_LOG_(INFO) << "SessionProxyTest: SetAspectRatio start"; 253 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 254 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 255 float ratio = 10; 256 WSError res = sProxy->SetAspectRatio(ratio); 257 ASSERT_EQ(res, WSError::WS_OK); 258 259 GTEST_LOG_(INFO) << "SessionProxyTest: SetAspectRatio end"; 260 } 261 262 /** 263 * @tc.name: UpdateWindowSceneAfterCustomAnimation 264 * @tc.desc: normal function 265 * @tc.type: FUNC 266 */ 267 HWTEST_F(SessionProxyTest, UpdateWindowSceneAfterCustomAnimation, TestSize.Level1) 268 { 269 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowSceneAfterCustomAnimation start"; 270 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 271 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 272 bool isAdd = false; 273 WSError res = sProxy->UpdateWindowSceneAfterCustomAnimation(isAdd); 274 ASSERT_EQ(res, WSError::WS_OK); 275 276 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowSceneAfterCustomAnimation end"; 277 } 278 279 /** 280 * @tc.name: SetSystemWindowEnableDrag 281 * @tc.desc: normal function 282 * @tc.type: FUNC 283 */ 284 HWTEST_F(SessionProxyTest, SetSystemWindowEnableDrag, TestSize.Level1) 285 { 286 GTEST_LOG_(INFO) << "SessionProxyTest: SetSystemWindowEnableDrag start"; 287 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 288 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 289 bool enableDrag = false; 290 WMError res = sProxy->SetSystemWindowEnableDrag(enableDrag); 291 ASSERT_EQ(res, WMError::WM_OK); 292 293 GTEST_LOG_(INFO) << "SessionProxyTest: SetSystemWindowEnableDrag end"; 294 } 295 296 /** 297 * @tc.name: TransferAbilityResult 298 * @tc.desc: normal function 299 * @tc.type: FUNC 300 */ 301 HWTEST_F(SessionProxyTest, TransferAbilityResult, TestSize.Level1) 302 { 303 GTEST_LOG_(INFO) << "SessionProxyTest: TransferAbilityResult start"; 304 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 305 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 306 uint32_t resultCode = 0; 307 AAFwk::Want want; 308 WSError res = sProxy->TransferAbilityResult(resultCode, want); 309 ASSERT_EQ(res, WSError::WS_OK); 310 311 GTEST_LOG_(INFO) << "SessionProxyTest: TransferAbilityResult end"; 312 } 313 314 /** 315 * @tc.name: NotifyExtensionDied 316 * @tc.desc: normal function 317 * @tc.type: FUNC 318 */ 319 HWTEST_F(SessionProxyTest, NotifyExtensionDied, TestSize.Level1) 320 { 321 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionDied start"; 322 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 323 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 324 sProxy->NotifyExtensionDied(); 325 326 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionDied end"; 327 } 328 329 /** 330 * @tc.name: NotifyExtensionTimeout 331 * @tc.desc: normal function 332 * @tc.type: FUNC 333 */ 334 HWTEST_F(SessionProxyTest, NotifyExtensionTimeout, TestSize.Level1) 335 { 336 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout start"; 337 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 338 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 339 sProxy->NotifyExtensionTimeout(2); 340 341 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout end"; 342 } 343 344 /** 345 * @tc.name: UpdateWindowAnimationFlag 346 * @tc.desc: normal function 347 * @tc.type: FUNC 348 */ 349 HWTEST_F(SessionProxyTest, UpdateWindowAnimationFlag, TestSize.Level1) 350 { 351 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowAnimationFlag start"; 352 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 353 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 354 bool needDefaultAnimationFlag = false; 355 WSError res = sProxy->UpdateWindowAnimationFlag(needDefaultAnimationFlag); 356 ASSERT_EQ(res, WSError::WS_OK); 357 358 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowAnimationFlag end"; 359 } 360 361 /** 362 * @tc.name: TransferAccessibilityEvent 363 * @tc.desc: normal function 364 * @tc.type: FUNC 365 */ 366 HWTEST_F(SessionProxyTest, TransferAccessibilityEvent, TestSize.Level1) 367 { 368 GTEST_LOG_(INFO) << "SessionProxyTest: TransferAccessibilityEvent start"; 369 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 370 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 371 Accessibility::AccessibilityEventInfo info; 372 int64_t uiExtensionIdLevel = 0; 373 WSError res = sProxy->TransferAccessibilityEvent(info, uiExtensionIdLevel); 374 ASSERT_EQ(res, WSError::WS_OK); 375 376 GTEST_LOG_(INFO) << "SessionProxyTest: TransferAccessibilityEvent end"; 377 } 378 379 /** 380 * @tc.name: OnTitleAndDockHoverShowChange 381 * @tc.desc: normal function 382 * @tc.type: FUNC 383 */ 384 HWTEST_F(SessionProxyTest, OnTitleAndDockHoverShowChange, TestSize.Level1) 385 { 386 GTEST_LOG_(INFO) << "SessionProxyTest: OnTitleAndDockHoverShowChange start"; 387 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 388 ASSERT_NE(iRemoteObjectMocker, nullptr); 389 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 390 ASSERT_NE(sProxy, nullptr); 391 bool isTitleHoverShown = true; 392 bool isDockHoverShown = true; 393 WSError res = sProxy->OnTitleAndDockHoverShowChange(isTitleHoverShown, isDockHoverShown); 394 EXPECT_EQ(res, WSError::WS_OK); 395 GTEST_LOG_(INFO) << "SessionProxyTest: OnTitleAndDockHoverShowChange end"; 396 } 397 398 /** 399 * @tc.name: UpdatePiPControlStatus 400 * @tc.desc: normal function 401 * @tc.type: FUNC 402 */ 403 HWTEST_F(SessionProxyTest, UpdatePiPControlStatus, TestSize.Level1) 404 { 405 GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPControlStatus start"; 406 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 407 ASSERT_NE(iRemoteObjectMocker, nullptr); 408 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 409 ASSERT_NE(sProxy, nullptr); 410 auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE; 411 auto status = WsPiPControlStatus::PLAY; 412 WSError res = sProxy->UpdatePiPControlStatus(controlType, status); 413 ASSERT_EQ(res, WSError::WS_OK); 414 GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPControlStatus end"; 415 } 416 417 /** 418 * @tc.name: SetAutoStartPiP 419 * @tc.desc: sessionStub sessionStubTest 420 * @tc.type: FUNC 421 * @tc.require: #I6JLSI 422 */ 423 HWTEST_F(SessionProxyTest, SetAutoStartPiP, TestSize.Level1) 424 { 425 GTEST_LOG_(INFO) << "SetAutoStartPiP: SetAutoStartPiP start"; 426 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 427 ASSERT_NE(iRemoteObjectMocker, nullptr); 428 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 429 ASSERT_NE(sProxy, nullptr); 430 bool isAutoStartValid = true; 431 uint32_t priority = 0; 432 uint32_t width = 0; 433 uint32_t height = 0; 434 ASSERT_EQ(WSError::WS_OK, sProxy->SetAutoStartPiP(isAutoStartValid, priority, width, height)); 435 GTEST_LOG_(INFO) << "SetAutoStartPiP: SetAutoStartPiP end"; 436 } 437 438 /** 439 * @tc.name: UpdatePiPTemplateInfo 440 * @tc.desc: sessionStub sessionStubTest 441 * @tc.type: FUNC 442 * @tc.require: #I6JLSI 443 */ 444 HWTEST_F(SessionProxyTest, UpdatePiPTemplateInfo, Function | SmallTest | Level2) 445 { 446 GTEST_LOG_(INFO) << "UpdatePiPTemplateInfo: UpdatePiPTemplateInfo start"; 447 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 448 ASSERT_NE(iRemoteObjectMocker, nullptr); 449 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 450 ASSERT_NE(sProxy, nullptr); 451 PiPTemplateInfo templateInfo; 452 ASSERT_EQ(WSError::WS_OK, sProxy->UpdatePiPTemplateInfo(templateInfo)); 453 GTEST_LOG_(INFO) << "UpdatePiPTemplateInfo: UpdatePiPTemplateInfo end"; 454 } 455 456 /** 457 * @tc.name: SetWindowAnchorInfo 458 * @tc.desc: sessionStub sessionStubTest 459 * @tc.type: FUNC 460 * @tc.require: #I6JLSI 461 */ 462 HWTEST_F(SessionProxyTest, SetWindowAnchorInfo, Function | SmallTest | Level2) 463 { 464 GTEST_LOG_(INFO) << "SetWindowAnchorInfo: SetWindowAnchorInfo start"; 465 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 466 auto sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 467 ASSERT_NE(sProxy, nullptr); 468 WindowAnchorInfo anchorInfo; 469 WSError res = sProxy->SetWindowAnchorInfo(anchorInfo); 470 ASSERT_EQ(res, WSError::WS_OK); 471 472 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 473 res = sProxy->SetWindowAnchorInfo(anchorInfo); 474 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 475 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 476 477 MockMessageParcel::SetWriteParcelableErrorFlag(true); 478 res = sProxy->SetWindowAnchorInfo(anchorInfo); 479 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 480 MockMessageParcel::SetWriteParcelableErrorFlag(false); 481 482 sptr<SessionProxy> tempProxy = sptr<SessionProxy>::MakeSptr(nullptr); 483 res = tempProxy->SetWindowAnchorInfo(anchorInfo); 484 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 485 486 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 487 res = sProxy->SetWindowAnchorInfo(anchorInfo); 488 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 489 remoteMocker->SetRequestResult(ERR_NONE); 490 491 MockMessageParcel::SetReadInt32ErrorFlag(true); 492 res = sProxy->SetWindowAnchorInfo(anchorInfo); 493 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 494 MockMessageParcel::SetReadInt32ErrorFlag(false); 495 496 MockMessageParcel::ClearAllErrorFlag(); 497 GTEST_LOG_(INFO) << "SetWindowAnchorInfo: SetWindowAnchorInfo end"; 498 } 499 500 /** 501 * @tc.name: SetWindowTransitionAnimation 502 * @tc.desc: sessionStub sessionStubTest 503 * @tc.type: FUNC 504 * @tc.require: #I6JLSI 505 */ 506 HWTEST_F(SessionProxyTest, SetWindowTransitionAnimation, Function | SmallTest | Level2) 507 { 508 GTEST_LOG_(INFO) << "SetWindowTransitionAnimation: SetWindowTransitionAnimation start"; 509 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 510 ASSERT_NE(iRemoteObjectMocker, nullptr); 511 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 512 ASSERT_NE(sProxy, nullptr); 513 TransitionAnimation animation; 514 WSError res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); 515 ASSERT_EQ(res, WSError::WS_OK); 516 517 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 518 res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); 519 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 520 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 521 522 MockMessageParcel::SetWriteUint32ErrorFlag(true); 523 res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); 524 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 525 MockMessageParcel::SetWriteUint32ErrorFlag(false); 526 527 MockMessageParcel::SetWriteParcelableErrorFlag(true); 528 res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); 529 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 530 MockMessageParcel::SetWriteParcelableErrorFlag(false); 531 532 MockMessageParcel::SetReadInt32ErrorFlag(true); 533 res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); 534 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 535 MockMessageParcel::SetReadInt32ErrorFlag(false); 536 537 MockMessageParcel::ClearAllErrorFlag(); 538 GTEST_LOG_(INFO) << "SetWindowTransitionAnimation: SetWindowTransitionAnimation end"; 539 } 540 541 /** 542 * @tc.name: GetGlobalScaledRect 543 * @tc.desc: normal function 544 * @tc.type: FUNC 545 */ 546 HWTEST_F(SessionProxyTest, GetGlobalScaledRect, TestSize.Level1) 547 { 548 GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalScaledRect start"; 549 Rect rect; 550 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 551 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 552 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 553 WMError res = sProxy->GetGlobalScaledRect(rect); 554 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 555 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 556 557 sptr<SessionProxy> tempProxy = sptr<SessionProxy>::MakeSptr(nullptr); 558 res = tempProxy->GetGlobalScaledRect(rect); 559 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 560 561 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 562 res = sProxy->GetGlobalScaledRect(rect); 563 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 564 remoteMocker->SetRequestResult(ERR_NONE); 565 566 MockMessageParcel::SetReadInt32ErrorFlag(true); 567 MockMessageParcel::SetReadUint32ErrorFlag(true); 568 res = sProxy->GetGlobalScaledRect(rect); 569 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 570 571 MockMessageParcel::ClearAllErrorFlag(); 572 res = sProxy->GetGlobalScaledRect(rect); 573 ASSERT_EQ(res, WMError::WM_OK); 574 GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalScaledRect end"; 575 } 576 577 /** 578 * @tc.name: GetStatusBarHeight 579 * @tc.desc: normal function 580 * @tc.type: FUNC 581 */ 582 HWTEST_F(SessionProxyTest, GetStatusBarHeight, TestSize.Level1) 583 { 584 GTEST_LOG_(INFO) << "SessionProxyTest: GetStatusBarHeight start"; 585 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 586 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 587 int32_t res = sProxy->GetStatusBarHeight(); 588 ASSERT_EQ(res, 0); 589 GTEST_LOG_(INFO) << "SessionProxyTest: GetStatusBarHeight end"; 590 } 591 592 /** 593 * @tc.name: SetDialogSessionBackGestureEnabled 594 * @tc.desc: normal function 595 * @tc.type: FUNC 596 */ 597 HWTEST_F(SessionProxyTest, SetDialogSessionBackGestureEnabled, TestSize.Level1) 598 { 599 GTEST_LOG_(INFO) << "SessionProxyTest: SetDialogSessionBackGestureEnabled start"; 600 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 601 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 602 WSError res = sProxy->SetDialogSessionBackGestureEnabled(true); 603 ASSERT_EQ(res, WSError::WS_OK); 604 GTEST_LOG_(INFO) << "SessionProxyTest: SetDialogSessionBackGestureEnabled end"; 605 } 606 607 /** 608 * @tc.name: GetAppForceLandscapeConfig 609 * @tc.desc: normal function 610 * @tc.type: FUNC 611 */ 612 HWTEST_F(SessionProxyTest, GetAppForceLandscapeConfig, TestSize.Level1) 613 { 614 GTEST_LOG_(INFO) << "SessionProxyTest: GetAppForceLandscapeConfig start"; 615 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 616 ASSERT_NE(iRemoteObjectMocker, nullptr); 617 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 618 ASSERT_NE(sProxy, nullptr); 619 AppForceLandscapeConfig config = {}; 620 auto res = sProxy->GetAppForceLandscapeConfig(config); 621 ASSERT_EQ(res, WMError::WM_OK); 622 GTEST_LOG_(INFO) << "SessionProxyTest: GetAppForceLandscapeConfig end"; 623 } 624 625 /** 626 * @tc.name: NotifyExtensionEventAsync 627 * @tc.desc: NotifyExtensionEventAsync test 628 * @tc.type: FUNC 629 */ 630 HWTEST_F(SessionProxyTest, NotifyExtensionEventAsync, TestSize.Level1) 631 { 632 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 633 ASSERT_NE(sProxy, nullptr); 634 sProxy->NotifyExtensionEventAsync(0); 635 636 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 637 ASSERT_NE(iRemoteObjectMocker, nullptr); 638 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 639 ASSERT_NE(sProxy, nullptr); 640 sProxy->NotifyExtensionEventAsync(0); 641 642 MockMessageParcel::SetWriteUint32ErrorFlag(true); 643 sProxy->NotifyExtensionEventAsync(0); 644 645 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 646 sProxy->NotifyExtensionEventAsync(0); 647 MockMessageParcel::ClearAllErrorFlag(); 648 } 649 650 /** 651 * @tc.name: RequestFocus 652 * @tc.desc: RequestFocus Test 653 * @tc.type: FUNC 654 */ 655 HWTEST_F(SessionProxyTest, RequestFocus, TestSize.Level1) 656 { 657 GTEST_LOG_(INFO) << "SessionProxyTest: RequestFocus start"; 658 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 659 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 660 WSError res = sProxy->RequestFocus(true); 661 ASSERT_EQ(res, WSError::WS_OK); 662 GTEST_LOG_(INFO) << "SessionProxyTest: RequestFocus end"; 663 } 664 665 /** 666 * @tc.name: UpdateClientRect01 667 * @tc.desc: UpdateClientRect test 668 * @tc.type: FUNC 669 */ 670 HWTEST_F(SessionProxyTest, UpdateClientRect01, TestSize.Level1) 671 { 672 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateClientRect01 start"; 673 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 674 WSRect rect = { 200, 200, 200, 200 }; 675 ASSERT_EQ(sProxy->UpdateClientRect(rect), WSError::WS_ERROR_IPC_FAILED); 676 677 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 678 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 679 ASSERT_EQ(sProxy->UpdateClientRect(rect), WSError::WS_OK); 680 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateClientRect01 start"; 681 } 682 683 /** 684 * @tc.name: TransferExtensionData 685 * @tc.desc: TransferExtensionData test 686 * @tc.type: FUNC 687 */ 688 HWTEST_F(SessionProxyTest, TransferExtensionData, TestSize.Level1) 689 { 690 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 691 ASSERT_NE(sProxy, nullptr); 692 AAFwk::WantParams wantParams; 693 auto res = sProxy->TransferExtensionData(wantParams); 694 ASSERT_EQ(res, IPC_PROXY_ERR); 695 696 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 697 ASSERT_NE(iRemoteObjectMocker, nullptr); 698 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 699 ASSERT_NE(sProxy, nullptr); 700 701 res = sProxy->TransferExtensionData(wantParams); 702 ASSERT_EQ(res, ERR_NONE); 703 MockMessageParcel::SetWriteParcelableErrorFlag(true); 704 res = sProxy->TransferExtensionData(wantParams); 705 ASSERT_EQ(res, IPC_PROXY_ERR); 706 707 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 708 res = sProxy->TransferExtensionData(wantParams); 709 ASSERT_EQ(res, IPC_PROXY_ERR); 710 MockMessageParcel::ClearAllErrorFlag(); 711 } 712 713 /** 714 * @tc.name: NotifyAsyncOn 715 * @tc.desc: NotifyAsyncOn test 716 * @tc.type: FUNC 717 */ 718 HWTEST_F(SessionProxyTest, NotifyAsyncOn, TestSize.Level1) 719 { 720 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 721 ASSERT_NE(sProxy, nullptr); 722 sProxy->NotifyAsyncOn(); 723 724 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 725 ASSERT_NE(iRemoteObjectMocker, nullptr); 726 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 727 ASSERT_NE(sProxy, nullptr); 728 sProxy->NotifyAsyncOn(); 729 730 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 731 sProxy->NotifyAsyncOn(); 732 MockMessageParcel::ClearAllErrorFlag(); 733 } 734 735 /** 736 * @tc.name: OnSetWindowRectAutoSave 737 * @tc.desc: normal function 738 * @tc.type: FUNC 739 */ 740 HWTEST_F(SessionProxyTest, OnSetWindowRectAutoSave, TestSize.Level1) 741 { 742 GTEST_LOG_(INFO) << "SessionProxyTest: OnSetWindowRectAutoSave start"; 743 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 744 ASSERT_NE(iRemoteObjectMocker, nullptr); 745 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 746 ASSERT_NE(sProxy, nullptr); 747 WSError res = sProxy->OnSetWindowRectAutoSave(true, false); 748 ASSERT_EQ(res, WSError::WS_OK); 749 GTEST_LOG_(INFO) << "SessionProxyTest: OnSetWindowRectAutoSave end"; 750 } 751 752 /** 753 * @tc.name: NotifyMainModalTypeChange 754 * @tc.desc: NotifyMainModalTypeChange test 755 * @tc.type: FUNC 756 */ 757 HWTEST_F(SessionProxyTest, NotifyMainModalTypeChange, TestSize.Level1) 758 { 759 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyMainModalTypeChange start"; 760 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 761 ASSERT_EQ(sProxy->NotifyMainModalTypeChange(true), WSError::WS_ERROR_IPC_FAILED); 762 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 763 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 764 ASSERT_EQ(sProxy->NotifyMainModalTypeChange(true), WSError::WS_OK); 765 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyMainModalTypeChange end"; 766 } 767 768 /** 769 * @tc.name: Foreground 770 * @tc.desc: Foreground test 771 * @tc.type: FUNC 772 */ 773 HWTEST_F(SessionProxyTest, Foreground, TestSize.Level1) 774 { 775 GTEST_LOG_(INFO) << "SessionProxyTest: Foreground start"; 776 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 777 ASSERT_NE(sProxy, nullptr); 778 779 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr(); 780 ASSERT_NE(property, nullptr); 781 bool isFromClient = true; 782 std::string identityToken = "foregroundTest"; 783 WSError ret = sProxy->Foreground(property, isFromClient, identityToken); 784 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 785 GTEST_LOG_(INFO) << "SessionProxyTest: Foreground end"; 786 } 787 788 /** 789 * @tc.name: Foreground02 790 * @tc.desc: Foreground test property is nullptr 791 * @tc.type: FUNC 792 */ 793 HWTEST_F(SessionProxyTest, Foreground02, TestSize.Level1) 794 { 795 GTEST_LOG_(INFO) << "SessionProxyTest: Foreground02 start"; 796 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 797 ASSERT_NE(sProxy, nullptr); 798 799 bool isFromClient = true; 800 std::string identityToken = "foregroundTest"; 801 WSError ret = sProxy->Foreground(nullptr, isFromClient, identityToken); 802 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 803 GTEST_LOG_(INFO) << "SessionProxyTest: Foreground02 end"; 804 } 805 806 /** 807 * @tc.name: Foreground03 808 * @tc.desc: Foreground test isFromClient is false 809 * @tc.type: FUNC 810 */ 811 HWTEST_F(SessionProxyTest, Foreground03, TestSize.Level1) 812 { 813 GTEST_LOG_(INFO) << "SessionProxyTest: Foreground03 start"; 814 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 815 ASSERT_NE(sProxy, nullptr); 816 817 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr(); 818 ASSERT_NE(property, nullptr); 819 bool isFromClient = false; 820 std::string identityToken = "foregroundTest"; 821 WSError ret = sProxy->Foreground(property, isFromClient, identityToken); 822 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 823 GTEST_LOG_(INFO) << "SessionProxyTest: Foreground03 end"; 824 } 825 826 /** 827 * @tc.name: Background 828 * @tc.desc: Background test 829 * @tc.type: FUNC 830 */ 831 HWTEST_F(SessionProxyTest, Background, TestSize.Level1) 832 { 833 GTEST_LOG_(INFO) << "SessionProxyTest: Background start"; 834 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 835 ASSERT_NE(sProxy, nullptr); 836 837 bool isFromClient = true; 838 std::string identityToken = "backgroundTest"; 839 WSError ret = sProxy->Background(isFromClient, identityToken); 840 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 841 GTEST_LOG_(INFO) << "SessionProxyTest: Background end"; 842 } 843 844 /** 845 * @tc.name: Background02 846 * @tc.desc: Background test isFromClient is false 847 * @tc.type: FUNC 848 */ 849 HWTEST_F(SessionProxyTest, Background02, TestSize.Level1) 850 { 851 GTEST_LOG_(INFO) << "SessionProxyTest: Background02 start"; 852 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 853 ASSERT_NE(sProxy, nullptr); 854 855 bool isFromClient = false; 856 std::string identityToken = "backgroundTest"; 857 WSError ret = sProxy->Background(isFromClient, identityToken); 858 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 859 GTEST_LOG_(INFO) << "SessionProxyTest: Background02 end"; 860 } 861 862 /** 863 * @tc.name: Show 864 * @tc.desc: Show Test 865 * @tc.type: FUNC 866 */ 867 HWTEST_F(SessionProxyTest, Show, TestSize.Level1) 868 { 869 GTEST_LOG_(INFO) << "SessionProxyTest: Show start"; 870 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 871 ASSERT_NE(sProxy, nullptr); 872 873 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr(); 874 WSError ret = sProxy->Show(property); 875 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 876 877 // property is nullptr 878 ret = sProxy->Show(nullptr); 879 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 880 GTEST_LOG_(INFO) << "SessionProxyTest: Show end"; 881 } 882 883 /** 884 * @tc.name: Hide 885 * @tc.desc: Hide Test 886 * @tc.type: FUNC 887 */ 888 HWTEST_F(SessionProxyTest, Hide, TestSize.Level1) 889 { 890 GTEST_LOG_(INFO) << "SessionProxyTest: Hide start"; 891 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 892 ASSERT_NE(sProxy, nullptr); 893 894 WSError ret = sProxy->Hide(); 895 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 896 GTEST_LOG_(INFO) << "SessionProxyTest: Hide end"; 897 } 898 899 /** 900 * @tc.name: Disconnect 901 * @tc.desc: Disconnect Test 902 * @tc.type: FUNC 903 */ 904 HWTEST_F(SessionProxyTest, Disconnect, TestSize.Level1) 905 { 906 GTEST_LOG_(INFO) << "SessionProxyTest: Disconnect start"; 907 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 908 ASSERT_NE(sProxy, nullptr); 909 910 bool isFromClient = true; 911 std::string identityToken = "disconnectTest"; 912 WSError ret = sProxy->Disconnect(isFromClient, identityToken); 913 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 914 915 // isFromClient is false 916 isFromClient = false; 917 ret = sProxy->Disconnect(isFromClient, identityToken); 918 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 919 GTEST_LOG_(INFO) << "SessionProxyTest: Disconnect end"; 920 } 921 922 /** 923 * @tc.name: DrawingCompleted 924 * @tc.desc: DrawingCompleted Test 925 * @tc.type: FUNC 926 */ 927 HWTEST_F(SessionProxyTest, DrawingCompleted, TestSize.Level1) 928 { 929 GTEST_LOG_(INFO) << "SessionProxyTest: DrawingCompleted start"; 930 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 931 ASSERT_NE(sProxy, nullptr); 932 933 WSError ret = sProxy->DrawingCompleted(); 934 ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); 935 GTEST_LOG_(INFO) << "SessionProxyTest: DrawingCompleted end"; 936 } 937 938 /** 939 * @tc.name: NotifySupportWindowModesChange 940 * @tc.desc: normal function 941 * @tc.type: FUNC 942 */ 943 HWTEST_F(SessionProxyTest, NotifySupportWindowModesChange, TestSize.Level1) 944 { 945 GTEST_LOG_(INFO) << "SessionProxyTest: NotifySupportWindowModesChange start"; 946 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 947 ASSERT_NE(iRemoteObjectMocker, nullptr); 948 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 949 950 std::vector<AppExecFwk::SupportWindowMode> supportedWindowModes = { AppExecFwk::SupportWindowMode::FULLSCREEN, 951 AppExecFwk::SupportWindowMode::SPLIT, 952 AppExecFwk::SupportWindowMode::FLOATING }; 953 WSError res = sProxy->NotifySupportWindowModesChange(supportedWindowModes); 954 ASSERT_EQ(res, WSError::WS_OK); 955 GTEST_LOG_(INFO) << "SessionProxyTest: NotifySupportWindowModesChange end"; 956 } 957 958 /** 959 * @tc.name: GetIsMidScene 960 * @tc.desc: GetIsMidScene 961 * @tc.type: FUNC 962 */ 963 HWTEST_F(SessionProxyTest, GetIsMidScene, TestSize.Level1) 964 { 965 GTEST_LOG_(INFO) << "SessionProxyTest: GetIsMidScene start"; 966 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 967 968 bool isMidScene = false; 969 WSError res = sProxy->GetIsMidScene(isMidScene); 970 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 971 GTEST_LOG_(INFO) << "SessionProxyTest: GetIsMidScene end"; 972 } 973 974 /** 975 * @tc.name: ChangeSessionVisibilityWithStatusBar 976 * @tc.desc: ChangeSessionVisibilityWithStatusBar test 977 * @tc.type: FUNC 978 */ 979 HWTEST_F(SessionProxyTest, ChangeSessionVisibilityWithStatusBar, TestSize.Level1) 980 { 981 GTEST_LOG_(INFO) << "SessionProxyTest: ChangeSessionVisibilityWithStatusBar start"; 982 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 983 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 984 985 bool visible = true; 986 sptr<AAFwk::SessionInfo> abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr(); 987 WSError res = sProxy->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible); 988 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 989 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 990 res = sProxy->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible); 991 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 992 abilitySessionInfo = nullptr; 993 res = sProxy->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible); 994 ASSERT_EQ(res, WSError::WS_ERROR_INVALID_SESSION); 995 GTEST_LOG_(INFO) << "SessionProxyTest: ChangeSessionVisibilityWithStatusBar end"; 996 } 997 998 /** 999 * @tc.name: SyncSessionEvent 1000 * @tc.desc: SyncSessionEvent test 1001 * @tc.type: FUNC 1002 */ 1003 HWTEST_F(SessionProxyTest, SyncSessionEvent, TestSize.Level1) 1004 { 1005 GTEST_LOG_(INFO) << "SessionProxyTest: SyncSessionEvent start"; 1006 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1007 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1008 1009 SessionEvent event = SessionEvent::EVENT_MAXIMIZE; 1010 WSError res = sProxy->SyncSessionEvent(event); 1011 ASSERT_EQ(res, WSError::WS_OK); 1012 GTEST_LOG_(INFO) << "SessionProxyTest: SyncSessionEvent end"; 1013 } 1014 1015 /** 1016 * @tc.name: OnLayoutFullScreenChange 1017 * @tc.desc: OnLayoutFullScreenChange test 1018 * @tc.type: FUNC 1019 */ 1020 HWTEST_F(SessionProxyTest, OnLayoutFullScreenChange, TestSize.Level1) 1021 { 1022 GTEST_LOG_(INFO) << "SessionProxyTest: OnLayoutFullScreenChange start"; 1023 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1024 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1025 1026 bool isLayoutFullScreen = true; 1027 WSError res = sProxy->OnLayoutFullScreenChange(isLayoutFullScreen); 1028 ASSERT_EQ(res, WSError::WS_OK); 1029 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1030 res = sProxy->OnLayoutFullScreenChange(isLayoutFullScreen); 1031 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1032 GTEST_LOG_(INFO) << "SessionProxyTest: OnLayoutFullScreenChange end"; 1033 } 1034 1035 /** 1036 * @tc.name: OnDefaultDensityEnabled 1037 * @tc.desc: OnDefaultDensityEnabled test 1038 * @tc.type: FUNC 1039 */ 1040 HWTEST_F(SessionProxyTest, OnDefaultDensityEnabled, TestSize.Level1) 1041 { 1042 GTEST_LOG_(INFO) << "SessionProxyTest: OnDefaultDensityEnabled start"; 1043 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1044 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1045 1046 bool isDefaultDensityEnabled = true; 1047 WSError res = sProxy->OnDefaultDensityEnabled(isDefaultDensityEnabled); 1048 ASSERT_EQ(res, WSError::WS_OK); 1049 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1050 res = sProxy->OnDefaultDensityEnabled(isDefaultDensityEnabled); 1051 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1052 GTEST_LOG_(INFO) << "SessionProxyTest: OnDefaultDensityEnabled end"; 1053 } 1054 1055 /** 1056 * @tc.name: NotifyFrameLayoutFinishFromApp 1057 * @tc.desc: NotifyFrameLayoutFinishFromApp test 1058 * @tc.type: FUNC 1059 */ 1060 HWTEST_F(SessionProxyTest, NotifyFrameLayoutFinishFromApp, TestSize.Level1) 1061 { 1062 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyFrameLayoutFinishFromApp start"; 1063 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1064 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1065 1066 bool notifyListener = true; 1067 WSRect rect = { 200, 200, 200, 200 }; 1068 WSError res = sProxy->NotifyFrameLayoutFinishFromApp(notifyListener, rect); 1069 ASSERT_EQ(res, WSError::WS_OK); 1070 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1071 res = sProxy->NotifyFrameLayoutFinishFromApp(notifyListener, rect); 1072 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1073 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyFrameLayoutFinishFromApp end"; 1074 } 1075 1076 /** 1077 * @tc.name: NotifySnapshotUpdate 1078 * @tc.desc: NotifySnapshotUpdate test 1079 * @tc.type: FUNC 1080 */ 1081 HWTEST_F(SessionProxyTest, NotifySnapshotUpdate, TestSize.Level1) 1082 { 1083 GTEST_LOG_(INFO) << "SessionProxyTest: NotifySnapshotUpdate start"; 1084 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1085 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1086 1087 WMError res = sProxy->NotifySnapshotUpdate(); 1088 EXPECT_EQ(res, WMError::WM_OK); 1089 1090 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1091 res = sProxy->NotifySnapshotUpdate(); 1092 EXPECT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 1093 MockMessageParcel::ClearAllErrorFlag(); 1094 1095 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1096 res = sProxy->NotifySnapshotUpdate(); 1097 EXPECT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 1098 GTEST_LOG_(INFO) << "SessionProxyTest: NotifySnapshotUpdate end"; 1099 } 1100 1101 /** 1102 * @tc.name: RaiseAppMainWindowToTop 1103 * @tc.desc: RaiseAppMainWindowToTop test 1104 * @tc.type: FUNC 1105 */ 1106 HWTEST_F(SessionProxyTest, RaiseAppMainWindowToTop, TestSize.Level1) 1107 { 1108 GTEST_LOG_(INFO) << "SessionProxyTest: RaiseAppMainWindowToTop start"; 1109 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1110 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1111 1112 WSError res = sProxy->RaiseAppMainWindowToTop(); 1113 ASSERT_EQ(res, WSError::WS_OK); 1114 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1115 res = sProxy->RaiseAppMainWindowToTop(); 1116 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1117 GTEST_LOG_(INFO) << "SessionProxyTest: RaiseAppMainWindowToTop end"; 1118 } 1119 1120 /** 1121 * @tc.name: GetAllAvoidAreas 1122 * @tc.desc: GetAllAvoidAreas test 1123 * @tc.type: FUNC 1124 */ 1125 HWTEST_F(SessionProxyTest, GetAllAvoidAreas, TestSize.Level1) 1126 { 1127 GTEST_LOG_(INFO) << "SessionProxyTest: GetAllAvoidAreas start"; 1128 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1129 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1130 1131 std::map<AvoidAreaType, AvoidArea> avoidAreas; 1132 WSError res = sProxy->GetAllAvoidAreas(avoidAreas); 1133 ASSERT_EQ(res, WSError::WS_OK); 1134 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1135 res = sProxy->GetAllAvoidAreas(avoidAreas); 1136 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1137 GTEST_LOG_(INFO) << "SessionProxyTest: GetAllAvoidAreas end"; 1138 } 1139 1140 /** 1141 * @tc.name: SetLandscapeMultiWindow 1142 * @tc.desc: SetLandscapeMultiWindow test 1143 * @tc.type: FUNC 1144 */ 1145 HWTEST_F(SessionProxyTest, SetLandscapeMultiWindow, TestSize.Level1) 1146 { 1147 GTEST_LOG_(INFO) << "SessionProxyTest: SetLandscapeMultiWindow start"; 1148 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1149 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1150 1151 bool isLandscapeMultiWindow = true; 1152 WSError res = sProxy->SetLandscapeMultiWindow(isLandscapeMultiWindow); 1153 ASSERT_EQ(res, WSError::WS_OK); 1154 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1155 res = sProxy->SetLandscapeMultiWindow(isLandscapeMultiWindow); 1156 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1157 GTEST_LOG_(INFO) << "SessionProxyTest: SetLandscapeMultiWindow end"; 1158 } 1159 1160 /** 1161 * @tc.name: NotifySyncOn 1162 * @tc.desc: NotifySyncOn test 1163 * @tc.type: FUNC 1164 */ 1165 HWTEST_F(SessionProxyTest, NotifySyncOn, TestSize.Level1) 1166 { 1167 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1168 ASSERT_NE(sProxy, nullptr); 1169 sProxy->NotifySyncOn(); 1170 1171 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1172 ASSERT_NE(iRemoteObjectMocker, nullptr); 1173 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1174 ASSERT_NE(sProxy, nullptr); 1175 sProxy->NotifySyncOn(); 1176 1177 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1178 sProxy->NotifySyncOn(); 1179 MockMessageParcel::ClearAllErrorFlag(); 1180 } 1181 1182 /** 1183 * @tc.name: TriggerBindModalUIExtension 1184 * @tc.desc: TriggerBindModalUIExtension test 1185 * @tc.type: FUNC 1186 */ 1187 HWTEST_F(SessionProxyTest, TriggerBindModalUIExtension, TestSize.Level1) 1188 { 1189 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1190 ASSERT_NE(sProxy, nullptr); 1191 sProxy->TriggerBindModalUIExtension(); 1192 1193 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1194 ASSERT_NE(iRemoteObjectMocker, nullptr); 1195 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1196 ASSERT_NE(sProxy, nullptr); 1197 sProxy->TriggerBindModalUIExtension(); 1198 1199 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1200 sProxy->TriggerBindModalUIExtension(); 1201 MockMessageParcel::ClearAllErrorFlag(); 1202 } 1203 1204 /** 1205 * @tc.name: NotifyPiPWindowPrepareClose 1206 * @tc.desc: NotifyPiPWindowPrepareClose test 1207 * @tc.type: FUNC 1208 */ 1209 HWTEST_F(SessionProxyTest, NotifyPiPWindowPrepareClose, TestSize.Level1) 1210 { 1211 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1212 ASSERT_NE(sProxy, nullptr); 1213 sProxy->NotifyPiPWindowPrepareClose(); 1214 1215 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1216 ASSERT_NE(iRemoteObjectMocker, nullptr); 1217 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1218 ASSERT_NE(sProxy, nullptr); 1219 sProxy->NotifyPiPWindowPrepareClose(); 1220 1221 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1222 sProxy->NotifyPiPWindowPrepareClose(); 1223 MockMessageParcel::ClearAllErrorFlag(); 1224 } 1225 1226 /** 1227 * @tc.name: UpdatePiPRect 1228 * @tc.desc: UpdatePiPRect test 1229 * @tc.type: FUNC 1230 */ 1231 HWTEST_F(SessionProxyTest, UpdatePiPRect, TestSize.Level1) 1232 { 1233 GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPRect start"; 1234 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1235 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1236 1237 Rect rect = { 200, 200, 200, 200 }; 1238 SizeChangeReason reason = SizeChangeReason::UNDEFINED; 1239 WSError res = sProxy->UpdatePiPRect(rect, reason); 1240 ASSERT_EQ(res, WSError::WS_OK); 1241 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1242 res = sProxy->UpdatePiPRect(rect, reason); 1243 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1244 GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPRect end"; 1245 } 1246 1247 /** 1248 * @tc.name: SetSessionLabelAndIcon 1249 * @tc.desc: SetSessionLabelAndIcon 1250 * @tc.type: FUNC 1251 */ 1252 HWTEST_F(SessionProxyTest, SetSessionLabelAndIcon, TestSize.Level1) 1253 { 1254 std::string label = "SetSessionLabelAndIcon"; 1255 std::shared_ptr<Media::PixelMap> icon = std::make_shared<Media::PixelMap>(); 1256 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1257 1258 ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sProxy->SetSessionLabelAndIcon(label, icon)); 1259 } 1260 1261 /** 1262 * @tc.name: UpdateFlag 1263 * @tc.desc: UpdateFlag 1264 * @tc.type: FUNC 1265 */ 1266 HWTEST_F(SessionProxyTest, UpdateFlag, TestSize.Level1) 1267 { 1268 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateFlag start"; 1269 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1270 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1271 ASSERT_NE(sProxy, nullptr); 1272 std::string flag = "test"; 1273 WSError res = sProxy->UpdateFlag(flag); 1274 ASSERT_EQ(res, WSError::WS_OK); 1275 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateFlag end"; 1276 } 1277 1278 /** 1279 * @tc.name: ProcessPointDownSession 1280 * @tc.desc: ProcessPointDownSession test 1281 * @tc.type: FUNC 1282 */ 1283 HWTEST_F(SessionProxyTest, ProcessPointDownSession, TestSize.Level1) 1284 { 1285 GTEST_LOG_(INFO) << "SessionProxyTest: ProcessPointDownSession start"; 1286 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1287 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1288 1289 int32_t posX = 50; 1290 int32_t posY = 50; 1291 WSError res = sProxy->ProcessPointDownSession(posX, posY); 1292 ASSERT_EQ(res, WSError::WS_OK); 1293 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1294 res = sProxy->ProcessPointDownSession(posX, posY); 1295 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1296 GTEST_LOG_(INFO) << "SessionProxyTest: ProcessPointDownSession end"; 1297 } 1298 1299 /** 1300 * @tc.name: SendPointEventForMoveDrag 1301 * @tc.desc: SendPointEventForMoveDrag test 1302 * @tc.type: FUNC 1303 */ 1304 HWTEST_F(SessionProxyTest, SendPointEventForMoveDrag, TestSize.Level1) 1305 { 1306 GTEST_LOG_(INFO) << "SessionProxyTest: SendPointEventForMoveDrag start"; 1307 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1308 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1309 1310 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create(); 1311 bool isExecuteDelayRaise = true; 1312 WSError res = sProxy->SendPointEventForMoveDrag(pointerEvent, isExecuteDelayRaise); 1313 ASSERT_EQ(res, WSError::WS_OK); 1314 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1315 res = sProxy->SendPointEventForMoveDrag(pointerEvent, isExecuteDelayRaise); 1316 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1317 GTEST_LOG_(INFO) << "SessionProxyTest: SendPointEventForMoveDrag end"; 1318 } 1319 1320 /** 1321 * @tc.name: IsStartMoving 1322 * @tc.desc: IsStartMoving test 1323 * @tc.type: FUNC 1324 */ 1325 HWTEST_F(SessionProxyTest, IsStartMoving, TestSize.Level1) 1326 { 1327 GTEST_LOG_(INFO) << "SessionProxyTest: IsStartMoving start"; 1328 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1329 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1330 1331 bool res = sProxy->IsStartMoving(); 1332 ASSERT_EQ(res, false); 1333 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1334 res = sProxy->IsStartMoving(); 1335 ASSERT_EQ(res, false); 1336 GTEST_LOG_(INFO) << "SessionProxyTest: IsStartMoving end"; 1337 } 1338 1339 /** 1340 * @tc.name: UpdateRectChangeListenerRegistered 1341 * @tc.desc: UpdateRectChangeListenerRegistered test 1342 * @tc.type: FUNC 1343 */ 1344 HWTEST_F(SessionProxyTest, UpdateRectChangeListenerRegistered, TestSize.Level1) 1345 { 1346 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateRectChangeListenerRegistered start"; 1347 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1348 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1349 1350 bool isRegister = true; 1351 WSError res = sProxy->UpdateRectChangeListenerRegistered(isRegister); 1352 ASSERT_EQ(res, WSError::WS_OK); 1353 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1354 res = sProxy->UpdateRectChangeListenerRegistered(isRegister); 1355 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1356 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateRectChangeListenerRegistered end"; 1357 } 1358 1359 /** 1360 * @tc.name: SendExtensionData 1361 * @tc.desc: SendExtensionData test 1362 * @tc.type: FUNC 1363 */ 1364 HWTEST_F(SessionProxyTest, SendExtensionData, TestSize.Level1) 1365 { 1366 GTEST_LOG_(INFO) << "SessionProxyTest: SendExtensionData start"; 1367 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1368 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1369 1370 MessageParcel data; 1371 MessageParcel reply; 1372 MessageOption option(MessageOption::TF_SYNC); 1373 WSError res = sProxy->SendExtensionData(data, reply, option); 1374 ASSERT_EQ(res, WSError::WS_OK); 1375 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1376 res = sProxy->SendExtensionData(data, reply, option); 1377 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1378 GTEST_LOG_(INFO) << "SessionProxyTest: SendExtensionData end"; 1379 } 1380 1381 /** 1382 * @tc.name: SetGestureBackEnabled 1383 * @tc.desc: SetGestureBackEnabled test 1384 * @tc.type: FUNC 1385 */ 1386 HWTEST_F(SessionProxyTest, SetGestureBackEnabled, TestSize.Level1) 1387 { 1388 GTEST_LOG_(INFO) << "SessionProxyTest: SetGestureBackEnabled start"; 1389 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1390 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1391 1392 bool isEnabled = true; 1393 WMError res = sProxy->SetGestureBackEnabled(isEnabled); 1394 ASSERT_EQ(res, WMError::WM_OK); 1395 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1396 res = sProxy->SetGestureBackEnabled(isEnabled); 1397 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 1398 GTEST_LOG_(INFO) << "SessionProxyTest: SetGestureBackEnabled end"; 1399 } 1400 1401 /** 1402 * @tc.name: NotifySubModalTypeChange 1403 * @tc.desc: NotifySubModalTypeChange test 1404 * @tc.type: FUNC 1405 */ 1406 HWTEST_F(SessionProxyTest, NotifySubModalTypeChange, TestSize.Level1) 1407 { 1408 GTEST_LOG_(INFO) << "SessionProxyTest: NotifySubModalTypeChange start"; 1409 sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1410 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1411 1412 SubWindowModalType subWindowModalType = SubWindowModalType::TYPE_APPLICATION_MODALITY; 1413 WSError res = sProxy->NotifySubModalTypeChange(subWindowModalType); 1414 ASSERT_EQ(res, WSError::WS_OK); 1415 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1416 res = sProxy->NotifySubModalTypeChange(subWindowModalType); 1417 ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1418 GTEST_LOG_(INFO) << "SessionProxyTest: NotifySubModalTypeChange end"; 1419 } 1420 1421 /** 1422 * @tc.name: GetCrossAxisState 1423 * @tc.desc: normal function 1424 * @tc.type: FUNC 1425 */ 1426 HWTEST_F(SessionProxyTest, GetCrossAxisState, TestSize.Level1) 1427 { 1428 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1429 ASSERT_NE(iRemoteObjectMocker, nullptr); 1430 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1431 ASSERT_NE(sProxy, nullptr); 1432 CrossAxisState state = CrossAxisState::STATE_CROSS; 1433 WSError res = sProxy->GetCrossAxisState(state); 1434 ASSERT_EQ(res, WSError::WS_OK); 1435 } 1436 1437 /** 1438 * @tc.name: OnContainerModalEvent 1439 * @tc.desc: OnContainerModalEvent Test 1440 * @tc.type: FUNC 1441 */ 1442 HWTEST_F(SessionProxyTest, OnContainerModalEvent, TestSize.Level1) 1443 { 1444 GTEST_LOG_(INFO) << "SessionProxyTest: OnContainerModalEvent start"; 1445 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1446 ASSERT_NE(iRemoteObjectMocker, nullptr); 1447 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1448 ASSERT_NE(sProxy, nullptr); 1449 WSError res = sProxy->OnContainerModalEvent("name", "value"); 1450 ASSERT_EQ(res, WSError::WS_OK); 1451 GTEST_LOG_(INFO) << "SessionProxyTest: OnContainerModalEvent end"; 1452 } 1453 1454 /** 1455 * @tc.name: GetWaterfallMode 1456 * @tc.desc: normal function 1457 * @tc.type: FUNC 1458 */ 1459 HWTEST_F(SessionProxyTest, GetWaterfallMode, TestSize.Level1) 1460 { 1461 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1462 ASSERT_NE(iRemoteObjectMocker, nullptr); 1463 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1464 ASSERT_NE(sProxy, nullptr); 1465 bool isWaterfallMode = false; 1466 WSError res = sProxy->GetWaterfallMode(isWaterfallMode); 1467 ASSERT_EQ(res, WSError::WS_OK); 1468 } 1469 1470 /** 1471 * @tc.name: NotifyFollowParentMultiScreenPolicy 1472 * @tc.desc: NotifyFollowParentMultiScreenPolicy test 1473 * @tc.type: FUNC 1474 */ 1475 HWTEST_F(SessionProxyTest, NotifyFollowParentMultiScreenPolicy, TestSize.Level1) 1476 { 1477 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyFollowParentMultiScreenPolicy start"; 1478 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1479 ASSERT_EQ(sProxy->NotifyFollowParentMultiScreenPolicy(true), WSError::WS_ERROR_IPC_FAILED); 1480 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1481 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1482 ASSERT_EQ(sProxy->NotifyFollowParentMultiScreenPolicy(true), WSError::WS_OK); 1483 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyFollowParentMultiScreenPolicy end"; 1484 } 1485 1486 1487 /** 1488 * @tc.name: UpdateRotationChangeRegistered 1489 * @tc.desc: UpdateRotationChangeRegistered test 1490 * @tc.type: FUNC 1491 */ 1492 HWTEST_F(SessionProxyTest, UpdateRotationChangeRegistered, Function | SmallTest | Level2) 1493 { 1494 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateRotationChangeRegistered start"; 1495 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1496 ASSERT_NE(iRemoteObjectMocker, nullptr); 1497 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1498 ASSERT_NE(sProxy, nullptr); 1499 WSError res = sProxy->UpdateRotationChangeRegistered(0, false); 1500 ASSERT_EQ(res, WSError::WS_OK); 1501 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateRotationChangeRegistered start"; 1502 } 1503 1504 /** 1505 * @tc.name: UpdateScreenshotAppEventRegistered 1506 * @tc.desc: UpdateScreenshotAppEventRegistered test 1507 * @tc.type: FUNC 1508 */ 1509 HWTEST_F(SessionProxyTest, UpdateScreenshotAppEventRegistered, Function | SmallTest | Level2) 1510 { 1511 MockMessageParcel::ClearAllErrorFlag(); 1512 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1513 ASSERT_NE(sProxy, nullptr); 1514 auto ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); 1515 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1516 1517 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1518 ASSERT_NE(iRemoteObjectMocker, nullptr); 1519 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1520 ASSERT_NE(sProxy, nullptr); 1521 ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); 1522 EXPECT_EQ(ret, WMError::WM_OK); 1523 1524 MockMessageParcel::SetReadInt32ErrorFlag(true); 1525 ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); 1526 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1527 1528 MockMessageParcel::SetWriteBoolErrorFlag(true); 1529 ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); 1530 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1531 1532 MockMessageParcel::SetWriteInt32ErrorFlag(true); 1533 ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); 1534 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1535 1536 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1537 ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); 1538 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1539 MockMessageParcel::ClearAllErrorFlag(); 1540 } 1541 1542 /** 1543 * @tc.name: UpdateAcrossDisplaysChangeRegistered 1544 * @tc.desc: UpdateAcrossDisplaysChangeRegistered test 1545 * @tc.type: FUNC 1546 */ 1547 HWTEST_F(SessionProxyTest, UpdateAcrossDisplaysChangeRegistered, Function | SmallTest | Level2) 1548 { 1549 MockMessageParcel::ClearAllErrorFlag(); 1550 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1551 ASSERT_NE(sProxy, nullptr); 1552 auto ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); 1553 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1554 1555 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 1556 sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 1557 ASSERT_NE(sProxy, nullptr); 1558 ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); 1559 EXPECT_EQ(ret, WMError::WM_OK); 1560 1561 MockMessageParcel::SetReadInt32ErrorFlag(true); 1562 ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); 1563 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1564 1565 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 1566 ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); 1567 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1568 remoteMocker->SetRequestResult(ERR_NONE); 1569 1570 MockMessageParcel::SetWriteBoolErrorFlag(true); 1571 ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); 1572 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1573 1574 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1575 ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); 1576 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1577 MockMessageParcel::ClearAllErrorFlag(); 1578 } 1579 1580 /** 1581 * @tc.name: UpdateAcrossDisplaysChangeRegistered 1582 * @tc.desc: UpdateAcrossDisplaysChangeRegistered test 1583 * @tc.type: FUNC 1584 */ 1585 HWTEST_F(SessionProxyTest, IsMainWindowFullScreenAcrossDisplays, Function | SmallTest | Level2) 1586 { 1587 bool isAcrossDisplays = false; 1588 MockMessageParcel::ClearAllErrorFlag(); 1589 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1590 ASSERT_NE(sProxy, nullptr); 1591 auto ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); 1592 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1593 1594 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 1595 sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 1596 ASSERT_NE(sProxy, nullptr); 1597 ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); 1598 EXPECT_EQ(ret, WMError::WM_OK); 1599 1600 MockMessageParcel::SetReadInt32ErrorFlag(true); 1601 ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); 1602 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1603 1604 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 1605 ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); 1606 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1607 remoteMocker->SetRequestResult(ERR_NONE); 1608 1609 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1610 ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); 1611 EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); 1612 MockMessageParcel::ClearAllErrorFlag(); 1613 } 1614 1615 /** 1616 * @tc.name: GetTargetOrientationConfigInfo 1617 * @tc.desc: GetTargetOrientationConfigInfo test 1618 * @tc.type: FUNC 1619 */ 1620 HWTEST_F(SessionProxyTest, GetTargetOrientationConfigInfo, Function | SmallTest | Level2) 1621 { 1622 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1623 ASSERT_NE(iRemoteObjectMocker, nullptr); 1624 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1625 ASSERT_NE(sProxy, nullptr); 1626 std::map<Rosen::WindowType, Rosen::SystemBarProperty> properties; 1627 Rosen::SystemBarProperty statusBarProperty; 1628 properties[Rosen::WindowType::WINDOW_TYPE_STATUS_BAR] = statusBarProperty; 1629 WSError res = sProxy->GetTargetOrientationConfigInfo(Orientation::USER_ROTATION_PORTRAIT, properties); 1630 ASSERT_EQ(res, WSError::WS_OK); 1631 } 1632 1633 /** 1634 * @tc.name: KeyFrameAnimateEnd 1635 * @tc.desc: KeyFrameAnimateEnd test 1636 * @tc.type: FUNC 1637 */ 1638 HWTEST_F(SessionProxyTest, KeyFrameAnimateEnd, Function | SmallTest | Level2) 1639 { 1640 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1641 ASSERT_NE(iRemoteObjectMocker, nullptr); 1642 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1643 ASSERT_NE(sProxy, nullptr); 1644 ASSERT_EQ(sProxy->KeyFrameAnimateEnd(), WSError::WS_OK); 1645 } 1646 1647 /** 1648 * @tc.name: UpdateKeyFrameCloneNode 1649 * @tc.desc: UpdateKeyFrameCloneNode test 1650 * @tc.type: FUNC 1651 */ 1652 HWTEST_F(SessionProxyTest, UpdateKeyFrameCloneNode, Function | SmallTest | Level2) 1653 { 1654 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1655 ASSERT_NE(iRemoteObjectMocker, nullptr); 1656 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1657 ASSERT_NE(sProxy, nullptr); 1658 auto rsCanvasNode = RSCanvasNode::Create(); 1659 ASSERT_NE(rsCanvasNode, nullptr); 1660 auto rsTransaction = std::make_shared<RSTransaction>(); 1661 ASSERT_NE(rsTransaction, nullptr); 1662 ASSERT_EQ(sProxy->UpdateKeyFrameCloneNode(rsCanvasNode, rsTransaction), WSError::WS_OK); 1663 } 1664 1665 /** 1666 * @tc.name: GetIsHighlighted 1667 * @tc.desc: GetIsHighlighted test 1668 * @tc.type: FUNC 1669 */ 1670 HWTEST_F(SessionProxyTest, GetIsHighlighted, Function | SmallTest | Level2) 1671 { 1672 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 1673 ASSERT_NE(iRemoteObjectMocker, nullptr); 1674 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1675 ASSERT_NE(sProxy, nullptr); 1676 bool isHighlighted = false; 1677 ASSERT_EQ(sProxy->GetIsHighlighted(isHighlighted), WSError::WS_OK); 1678 } 1679 1680 /** 1681 * @tc.name: SetSubWindowSource 1682 * @tc.desc: SetSubWindowSource test 1683 * @tc.type: FUNC 1684 */ 1685 HWTEST_F(SessionProxyTest, SetSubWindowSource, Function | SmallTest | Level2) 1686 { 1687 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 1688 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 1689 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1690 auto res = sProxy->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_UNKNOWN); 1691 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1692 1693 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 1694 sptr<SessionProxy> tempProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1695 res = tempProxy->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_UNKNOWN); 1696 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1697 1698 remoteMocker->SetRequestResult(1); 1699 res = sProxy->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_UNKNOWN); 1700 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1701 1702 remoteMocker->SetRequestResult(0); 1703 SubWindowSource source = SubWindowSource::SUB_WINDOW_SOURCE_UNKNOWN; 1704 EXPECT_EQ(sProxy->SetSubWindowSource(source), WSError::WS_OK); 1705 } 1706 1707 /** 1708 * @tc.name: StartMovingWithCoordinate 1709 * @tc.desc: StartMovingWithCoordinate test 1710 * @tc.type: FUNC 1711 */ 1712 HWTEST_F(SessionProxyTest, StartMovingWithCoordinate, TestSize.Level2) 1713 { 1714 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 1715 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 1716 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1717 WSError res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); 1718 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1719 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 1720 1721 sptr<SessionProxy> tempProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1722 res = tempProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); 1723 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1724 1725 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 1726 res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); 1727 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1728 remoteMocker->SetRequestResult(ERR_NONE); 1729 1730 MockMessageParcel::SetReadInt32ErrorFlag(true); 1731 res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); 1732 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1733 MockMessageParcel::SetReadInt32ErrorFlag(false); 1734 1735 MockMessageParcel::SetWriteUint64ErrorFlag(true); 1736 res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); 1737 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1738 MockMessageParcel::SetWriteUint64ErrorFlag(false); 1739 1740 MockMessageParcel::ClearAllErrorFlag(); 1741 res = sProxy->StartMovingWithCoordinate(-1, 0, 0, 0, 0); 1742 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1743 res = sProxy->StartMovingWithCoordinate(0, -1, 0, 0, 0); 1744 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1745 res = sProxy->StartMovingWithCoordinate(0, 0, -1, 0, 0); 1746 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1747 res = sProxy->StartMovingWithCoordinate(0, 0, 0, -1, 0); 1748 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1749 1750 res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); 1751 EXPECT_EQ(res, WSError::WS_OK); 1752 } 1753 1754 /** 1755 * @tc.name: SetFrameRectForPartialZoomIn 1756 * @tc.desc: SetFrameRectForPartialZoomIn test 1757 * @tc.type: FUNC 1758 */ 1759 HWTEST_F(SessionProxyTest, SetFrameRectForPartialZoomIn, Function | SmallTest | Level2) 1760 { 1761 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 1762 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 1763 1764 Rect frameRect; 1765 WSError res = sProxy->SetFrameRectForPartialZoomIn(frameRect); 1766 EXPECT_EQ(res, WSError::WS_OK); 1767 1768 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1769 res = sProxy->SetFrameRectForPartialZoomIn(frameRect); 1770 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1771 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 1772 1773 MockMessageParcel::SetWriteInt32ErrorFlag(true); 1774 res = sProxy->SetFrameRectForPartialZoomIn(frameRect); 1775 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1776 MockMessageParcel::SetWriteInt32ErrorFlag(false); 1777 1778 MockMessageParcel::SetWriteUint32ErrorFlag(true); 1779 res = sProxy->SetFrameRectForPartialZoomIn(frameRect); 1780 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1781 MockMessageParcel::SetWriteUint32ErrorFlag(false); 1782 1783 MockMessageParcel::SetReadInt32ErrorFlag(true); 1784 res = sProxy->SetFrameRectForPartialZoomIn(frameRect); 1785 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1786 MockMessageParcel::SetReadInt32ErrorFlag(false); 1787 1788 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 1789 res = sProxy->SetFrameRectForPartialZoomIn(frameRect); 1790 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1791 remoteMocker->SetRequestResult(ERR_NONE); 1792 1793 MockMessageParcel::ClearAllErrorFlag(); 1794 } 1795 1796 /** 1797 * @tc.name: SetFrameRectForPartialZoomIn01 1798 * @tc.desc: SetFrameRectForPartialZoomIn test 1799 * @tc.type: FUNC 1800 */ 1801 HWTEST_F(SessionProxyTest, SetFrameRectForPartialZoomIn01, Function | SmallTest | Level2) 1802 { 1803 Rect frameRect; 1804 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1805 WSError res = sProxy->SetFrameRectForPartialZoomIn(frameRect); 1806 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1807 } 1808 1809 /** 1810 * @tc.name: ChangeKeyboardEffectOption01 1811 * @tc.desc: ChangeKeyboardEffectOption test 1812 * @tc.type: FUNC 1813 */ 1814 HWTEST_F(SessionProxyTest, ChangeKeyboardEffectOption01, Function | SmallTest | Level2) 1815 { 1816 KeyboardEffectOption effectOption; 1817 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1818 WSError res = sProxy->ChangeKeyboardEffectOption(effectOption); 1819 EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); 1820 } 1821 1822 /** 1823 * @tc.name: UpdateFloatingBall 1824 * @tc.desc: UpdateFloatingBall 1825 * @tc.type: FUNC 1826 */ 1827 HWTEST_F(SessionProxyTest, UpdateFloatingBall, Function | SmallTest | Level2) 1828 { 1829 auto iRemoteObjectMocker = sptr<MockIRemoteObject>::MakeSptr(); 1830 ASSERT_NE(iRemoteObjectMocker, nullptr); 1831 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1832 ASSERT_NE(sProxy, nullptr); 1833 FloatingBallTemplateInfo fbTemplateInfo; 1834 1835 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1836 WMError res = sProxy->UpdateFloatingBall(fbTemplateInfo); 1837 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 1838 1839 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 1840 res = sProxy->UpdateFloatingBall(fbTemplateInfo); 1841 ASSERT_EQ(res, WMError::WM_OK); 1842 1843 MockMessageParcel::SetWriteParcelableErrorFlag(true); 1844 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->UpdateFloatingBall(fbTemplateInfo)); 1845 MockMessageParcel::SetWriteParcelableErrorFlag(false); 1846 1847 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1848 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->UpdateFloatingBall(fbTemplateInfo)); 1849 1850 iRemoteObjectMocker->sendRequestResult_ = 1; 1851 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1852 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->UpdateFloatingBall(fbTemplateInfo)); 1853 } 1854 1855 /** 1856 * @tc.name: RestoreFbMainWindow 1857 * @tc.desc: RestoreFbMainWindow 1858 * @tc.type: FUNC 1859 */ 1860 HWTEST_F(SessionProxyTest, RestoreFbMainWindow, Function | SmallTest | Level2) 1861 { 1862 auto iRemoteObjectMocker = sptr<MockIRemoteObject>::MakeSptr(); 1863 ASSERT_NE(iRemoteObjectMocker, nullptr); 1864 auto want = std::make_shared<AAFwk::Want>(); 1865 ASSERT_NE(want, nullptr); 1866 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1867 ASSERT_NE(sProxy, nullptr); 1868 1869 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1870 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->RestoreFbMainWindow(want)); 1871 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 1872 1873 MockMessageParcel::SetWriteParcelableErrorFlag(true); 1874 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->RestoreFbMainWindow(want)); 1875 MockMessageParcel::SetWriteParcelableErrorFlag(false); 1876 1877 WMError res = sProxy->RestoreFbMainWindow(want); 1878 ASSERT_EQ(res, WMError::WM_OK); 1879 1880 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1881 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->RestoreFbMainWindow(want)); 1882 1883 iRemoteObjectMocker->sendRequestResult_ = 1; 1884 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1885 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->RestoreFbMainWindow(want)); 1886 } 1887 1888 /** 1889 * @tc.name: GetFloatingBallWindowId 1890 * @tc.desc: GetFloatingBallWindowId 1891 * @tc.type: FUNC 1892 */ 1893 HWTEST_F(SessionProxyTest, GetFloatingBallWindowId, Function | SmallTest | Level2) 1894 { 1895 auto iRemoteObjectMocker = sptr<MockIRemoteObject>::MakeSptr(); 1896 ASSERT_NE(iRemoteObjectMocker, nullptr); 1897 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1898 ASSERT_NE(sProxy, nullptr); 1899 uint32_t windowId = 0; 1900 1901 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1902 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetFloatingBallWindowId(windowId)); 1903 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 1904 1905 WMError res = sProxy->GetFloatingBallWindowId(windowId); 1906 ASSERT_EQ(res, WMError::WM_OK); 1907 1908 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1909 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetFloatingBallWindowId(windowId)); 1910 1911 iRemoteObjectMocker->sendRequestResult_ = 1; 1912 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1913 ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetFloatingBallWindowId(windowId)); 1914 } 1915 1916 /** 1917 * @tc.name: NotifyFloatingBallPrepareClose 1918 * @tc.desc: NotifyFloatingBallPrepareClose 1919 * @tc.type: FUNC 1920 */ 1921 HWTEST_F(SessionProxyTest, NotifyFloatingBallPrepareClose, Function | SmallTest | Level2) 1922 { 1923 auto iRemoteObjectMocker = sptr<MockIRemoteObject>::MakeSptr(); 1924 ASSERT_NE(iRemoteObjectMocker, nullptr); 1925 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1926 ASSERT_NE(sProxy, nullptr); 1927 1928 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1929 sProxy->NotifyFloatingBallPrepareClose(); 1930 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 1931 1932 sProxy->NotifyFloatingBallPrepareClose(); 1933 1934 sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1935 sProxy->NotifyFloatingBallPrepareClose(); 1936 1937 iRemoteObjectMocker->sendRequestResult_ = 1; 1938 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 1939 sProxy->NotifyFloatingBallPrepareClose(); 1940 } 1941 1942 /** 1943 * @tc.name: TestUpdateGlobalDisplayRectFromClient 1944 * @tc.desc: Test UpdateGlobalDisplayRectFromClient behavior in various IPC scenarios 1945 * @tc.type: FUNC 1946 */ 1947 HWTEST_F(SessionProxyTest, TestUpdateGlobalDisplayRectFromClient, Function | SmallTest | Level1) 1948 { 1949 auto mockRemote = sptr<MockIRemoteObject>::MakeSptr(); 1950 auto sessionProxy = sptr<SessionProxy>::MakeSptr(mockRemote); 1951 WSRect rect { 10, 20, 200, 100 }; 1952 SizeChangeReason reason = SizeChangeReason::UNDEFINED; 1953 1954 // Case 1: Failed to write interface token 1955 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1956 EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); 1957 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 1958 1959 // Case 2: Failed to write rect 1960 MockMessageParcel::SetWriteInt32ErrorFlag(true); 1961 EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); 1962 MockMessageParcel::SetWriteInt32ErrorFlag(false); 1963 1964 // Case 3: Failed to write reason 1965 MockMessageParcel::SetWriteUint32ErrorFlag(true); 1966 EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); 1967 MockMessageParcel::SetWriteUint32ErrorFlag(false); 1968 1969 // Case 4: remote is nullptr 1970 sptr<SessionProxy> nullProxy = sptr<SessionProxy>::MakeSptr(nullptr); 1971 EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, nullProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); 1972 1973 // Case 5: Failed to send request 1974 mockRemote->sendRequestResult_ = ERR_TRANSACTION_FAILED; 1975 sptr<SessionProxy> failProxy = sptr<SessionProxy>::MakeSptr(mockRemote); 1976 EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, failProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); 1977 1978 // Case 6: Success 1979 mockRemote->sendRequestResult_ = ERR_NONE; 1980 sptr<SessionProxy> okProxy = sptr<SessionProxy>::MakeSptr(mockRemote); 1981 EXPECT_EQ(WSError::WS_OK, okProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); 1982 } 1983 1984 /** 1985 * @tc.name: GetAppHookWindowInfoFromServer 1986 * @tc.desc: normal function 1987 * @tc.type: FUNC 1988 */ 1989 HWTEST_F(SessionProxyTest, GetAppHookWindowInfoFromServer, TestSize.Level1) 1990 { 1991 GTEST_LOG_(INFO) << "SessionProxyTest: GetAppHookWindowInfoFromServer start"; 1992 auto mockRemote = sptr<MockIRemoteObject>::MakeSptr(); 1993 auto sProxy = sptr<SessionProxy>::MakeSptr(mockRemote); 1994 MockMessageParcel::ClearAllErrorFlag(); 1995 HookWindowInfo hookWindowInfo; 1996 1997 // Case 1: Failed to write interface token 1998 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 1999 EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); 2000 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 2001 2002 // Case 2: remote is nullptr 2003 sptr<SessionProxy> nullProxy = sptr<SessionProxy>::MakeSptr(nullptr); 2004 EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, nullProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); 2005 2006 // Case 3: Failed to send request 2007 mockRemote->SetRequestResult(ERR_TRANSACTION_FAILED); 2008 sptr<SessionProxy> failSendRequestProxy = sptr<SessionProxy>::MakeSptr(mockRemote); 2009 EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, failSendRequestProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); 2010 mockRemote->SetRequestResult(ERR_NONE); 2011 2012 // Case 4: Failed to read replyInfo and ret 2013 MockMessageParcel::SetReadBoolErrorFlag(true); 2014 MockMessageParcel::SetReadInt32ErrorFlag(true); 2015 EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); 2016 MockMessageParcel::SetReadBoolErrorFlag(false); 2017 MockMessageParcel::SetReadInt32ErrorFlag(false); 2018 2019 // Case 5: Success 2020 sptr<SessionProxy> okProxy = sptr<SessionProxy>::MakeSptr(mockRemote); 2021 EXPECT_EQ(WMError::WM_OK, okProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); 2022 MockMessageParcel::ClearAllErrorFlag(); 2023 GTEST_LOG_(INFO) << "SessionProxyTest: GetAppHookWindowInfoFromServer end"; 2024 } 2025 } // namespace 2026 } // namespace Rosen 2027 } // namespace OHOS