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 #include "session_proxy.h" 16 #include "iremote_object_mocker.h" 17 #include <gtest/gtest.h> 18 #include "accessibility_event_info.h" 19 #include "ws_common.h" 20 #include "mock_message_parcel.h" 21 22 // using namespace FRAME_TRACE; 23 using namespace testing; 24 using namespace testing::ext; 25 26 namespace OHOS { 27 namespace Rosen { 28 class SessionProxyTest : public testing::Test { 29 public: SessionProxyTest()30 SessionProxyTest() {} ~SessionProxyTest()31 ~SessionProxyTest() {} 32 }; 33 namespace { 34 35 /** 36 * @tc.name: WriteAbilitySessionInfoBasic 37 * @tc.desc: normal function 38 * @tc.type: FUNC 39 */ 40 HWTEST_F(SessionProxyTest, WriteAbilitySessionInfoBasic, Function | SmallTest | Level2) 41 { 42 GTEST_LOG_(INFO) << "SessionProxyTest: WriteAbilitySessionInfoBasic start"; 43 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 44 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 45 sptr<AAFwk::SessionInfo> abilitySessionInfo = nullptr; 46 MessageParcel data; 47 bool res = sProxy->WriteAbilitySessionInfoBasic(data, abilitySessionInfo); 48 ASSERT_EQ(res, false); 49 50 sptr<AAFwk::SessionInfo> abilitySessionInfo1 = new(std::nothrow) AAFwk::SessionInfo(); 51 ASSERT_NE(abilitySessionInfo1, nullptr); 52 res = sProxy->WriteAbilitySessionInfoBasic(data, abilitySessionInfo1); 53 ASSERT_EQ(res, false); 54 GTEST_LOG_(INFO) << "SessionProxyTest: WriteAbilitySessionInfoBasic end"; 55 } 56 57 /** 58 * @tc.name: OnSessionEvent 59 * @tc.desc: normal function 60 * @tc.type: FUNC 61 */ 62 HWTEST_F(SessionProxyTest, OnSessionEvent, Function | SmallTest | Level2) 63 { 64 GTEST_LOG_(INFO) << "SessionProxyTest: OnSessionEvent start"; 65 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 66 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 67 SessionEvent event = SessionEvent::EVENT_MAXIMIZE; 68 WSError res = sProxy->OnSessionEvent(event); 69 ASSERT_EQ(res, WSError::WS_OK); 70 GTEST_LOG_(INFO) << "SessionProxyTest: OnSessionEvent end"; 71 } 72 73 /** 74 * @tc.name: UpdateSessionRect 75 * @tc.desc: normal function 76 * @tc.type: FUNC 77 */ 78 HWTEST_F(SessionProxyTest, UpdateSessionRect, Function | SmallTest | Level2) 79 { 80 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionRect start"; 81 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 82 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 83 WSRect rect{.posX_ = 1, .posY_ = 1, .width_ = 100, .height_ = 100}; 84 SizeChangeReason reason = SizeChangeReason::RECOVER; 85 WSError res = sProxy->UpdateSessionRect(rect, reason); 86 ASSERT_EQ(res, WSError::WS_OK); 87 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionRect end"; 88 } 89 90 /** 91 * @tc.name: Restore 92 * @tc.desc: normal function 93 * @tc.type: FUNC 94 */ 95 HWTEST_F(SessionProxyTest, OnRestoreMainWindow, Function | SmallTest | Level2) 96 { 97 GTEST_LOG_(INFO) << "SessionProxyTest: OnRestoreMainWindow start"; 98 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 99 ASSERT_NE(iRemoteObjectMocker, nullptr); 100 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 101 ASSERT_NE(sProxy, nullptr); 102 WSError res = sProxy->OnRestoreMainWindow(); 103 ASSERT_EQ(res, WSError::WS_OK); 104 GTEST_LOG_(INFO) << "SessionProxyTest: OnRestoreMainWindow end"; 105 } 106 107 /** 108 * @tc.name: RaiseToAppTop 109 * @tc.desc: normal function 110 * @tc.type: FUNC 111 */ 112 HWTEST_F(SessionProxyTest, RaiseToAppTop, Function | SmallTest | Level2) 113 { 114 GTEST_LOG_(INFO) << "SessionProxyTest: RaiseToAppTop start"; 115 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 116 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 117 WSError res = sProxy->RaiseToAppTop(); 118 ASSERT_EQ(res, WSError::WS_OK); 119 120 GTEST_LOG_(INFO) << "SessionProxyTest: RaiseToAppTop end"; 121 } 122 123 /** 124 * @tc.name: OnNeedAvoid 125 * @tc.desc: normal function 126 * @tc.type: FUNC 127 */ 128 HWTEST_F(SessionProxyTest, OnNeedAvoid, Function | SmallTest | Level2) 129 { 130 GTEST_LOG_(INFO) << "SessionProxyTest: OnNeedAvoid start"; 131 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 132 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 133 bool status = false; 134 WSError res = sProxy->OnNeedAvoid(status); 135 ASSERT_EQ(res, WSError::WS_OK); 136 137 GTEST_LOG_(INFO) << "SessionProxyTest: OnNeedAvoid end"; 138 } 139 140 /** 141 * @tc.name: GetAvoidAreaByType 142 * @tc.desc: normal function 143 * @tc.type: FUNC 144 */ 145 HWTEST_F(SessionProxyTest, GetAvoidAreaByType, Function | SmallTest | Level2) 146 { 147 GTEST_LOG_(INFO) << "SessionProxyTest: GetAvoidAreaByType start"; 148 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 149 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 150 AvoidAreaType status = AvoidAreaType::TYPE_SYSTEM; 151 AvoidArea res = sProxy->GetAvoidAreaByType(status); 152 AvoidArea area; 153 ASSERT_EQ(res, area); 154 155 GTEST_LOG_(INFO) << "SessionProxyTest: GetAvoidAreaByType end"; 156 } 157 158 /** 159 * @tc.name: RequestSessionBack 160 * @tc.desc: normal function 161 * @tc.type: FUNC 162 */ 163 HWTEST_F(SessionProxyTest, RequestSessionBack, Function | SmallTest | Level2) 164 { 165 GTEST_LOG_(INFO) << "SessionProxyTest: RequestSessionBack start"; 166 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 167 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 168 bool needMoveToBackground = true; 169 WSError res = sProxy->RequestSessionBack(needMoveToBackground); 170 ASSERT_EQ(res, WSError::WS_OK); 171 172 GTEST_LOG_(INFO) << "SessionProxyTest: RequestSessionBack end"; 173 } 174 175 /** 176 * @tc.name: MarkProcessed 177 * @tc.desc: normal function 178 * @tc.type: FUNC 179 */ 180 HWTEST_F(SessionProxyTest, MarkProcessed, Function | SmallTest | Level2) 181 { 182 GTEST_LOG_(INFO) << "SessionProxyTest: MarkProcessed start"; 183 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 184 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 185 int32_t eventId = 0; 186 WSError res = sProxy->MarkProcessed(eventId); 187 ASSERT_EQ(res, WSError::WS_OK); 188 189 GTEST_LOG_(INFO) << "SessionProxyTest: MarkProcessed end"; 190 } 191 192 /** 193 * @tc.name: SetGlobalMaximizeMode 194 * @tc.desc: normal function 195 * @tc.type: FUNC 196 */ 197 HWTEST_F(SessionProxyTest, SetGlobalMaximizeMode, Function | SmallTest | Level2) 198 { 199 GTEST_LOG_(INFO) << "SessionProxyTest: SetGlobalMaximizeMode start"; 200 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 201 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 202 MaximizeMode mode = MaximizeMode::MODE_AVOID_SYSTEM_BAR; 203 WSError res = sProxy->SetGlobalMaximizeMode(mode); 204 ASSERT_EQ(res, WSError::WS_OK); 205 206 GTEST_LOG_(INFO) << "SessionProxyTest: SetGlobalMaximizeMode end"; 207 } 208 209 /** 210 * @tc.name: GetGlobalMaximizeMode 211 * @tc.desc: normal function 212 * @tc.type: FUNC 213 */ 214 HWTEST_F(SessionProxyTest, GetGlobalMaximizeMode, Function | SmallTest | Level2) 215 { 216 GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalMaximizeMode start"; 217 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 218 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 219 MaximizeMode mode = MaximizeMode::MODE_AVOID_SYSTEM_BAR; 220 WSError res = sProxy->GetGlobalMaximizeMode(mode); 221 ASSERT_EQ(res, WSError::WS_OK); 222 223 GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalMaximizeMode end"; 224 } 225 226 /** 227 * @tc.name: SetAspectRatio 228 * @tc.desc: normal function 229 * @tc.type: FUNC 230 */ 231 HWTEST_F(SessionProxyTest, SetAspectRatio, Function | SmallTest | Level2) 232 { 233 GTEST_LOG_(INFO) << "SessionProxyTest: SetAspectRatio start"; 234 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 235 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 236 float ratio = 10; 237 WSError res = sProxy->SetAspectRatio(ratio); 238 ASSERT_EQ(res, WSError::WS_OK); 239 240 GTEST_LOG_(INFO) << "SessionProxyTest: SetAspectRatio end"; 241 } 242 243 /** 244 * @tc.name: UpdateSessionPropertyByAction01 245 * @tc.desc: UpdateSessionPropertyByAction 246 * @tc.type: FUNC 247 */ 248 HWTEST_F(SessionProxyTest, UpdateSessionPropertyByAction01, Function | SmallTest | Level2) 249 { 250 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionPropertyByAction01 start"; 251 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 252 ASSERT_NE(iRemoteObjectMocker, nullptr); 253 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 254 ASSERT_NE(sProxy, nullptr); 255 WMError res = sProxy->UpdateSessionPropertyByAction(nullptr, 256 WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); 257 ASSERT_EQ(res, WMError::WM_OK); 258 delete sProxy; 259 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionPropertyByAction01 end"; 260 } 261 262 /** 263 * @tc.name: UpdateSessionPropertyByAction02 264 * @tc.desc: UpdateSessionPropertyByAction 265 * @tc.type: FUNC 266 */ 267 HWTEST_F(SessionProxyTest, UpdateSessionPropertyByAction02, Function | SmallTest | Level2) 268 { 269 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionPropertyByAction02 start"; 270 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 271 ASSERT_NE(iRemoteObjectMocker, nullptr); 272 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 273 ASSERT_NE(sProxy, nullptr); 274 WMError res = sProxy->UpdateSessionPropertyByAction(nullptr, 275 WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); 276 ASSERT_EQ(res, WMError::WM_OK); 277 delete sProxy; 278 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionPropertyByAction02 end"; 279 } 280 281 /** 282 * @tc.name: UpdateWindowSceneAfterCustomAnimation 283 * @tc.desc: normal function 284 * @tc.type: FUNC 285 */ 286 HWTEST_F(SessionProxyTest, UpdateWindowSceneAfterCustomAnimation, Function | SmallTest | Level2) 287 { 288 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowSceneAfterCustomAnimation start"; 289 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 290 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 291 bool isAdd = false; 292 WSError res = sProxy->UpdateWindowSceneAfterCustomAnimation(isAdd); 293 ASSERT_EQ(res, WSError::WS_OK); 294 295 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowSceneAfterCustomAnimation end"; 296 } 297 298 /** 299 * @tc.name: SetSystemWindowEnableDrag 300 * @tc.desc: normal function 301 * @tc.type: FUNC 302 */ 303 HWTEST_F(SessionProxyTest, SetSystemWindowEnableDrag, Function | SmallTest | Level2) 304 { 305 GTEST_LOG_(INFO) << "SessionProxyTest: SetSystemWindowEnableDrag start"; 306 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 307 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 308 bool enableDrag = false; 309 WMError res = sProxy->SetSystemWindowEnableDrag(enableDrag); 310 ASSERT_EQ(res, WMError::WM_OK); 311 312 GTEST_LOG_(INFO) << "SessionProxyTest: SetSystemWindowEnableDrag end"; 313 } 314 315 /** 316 * @tc.name: TransferAbilityResult 317 * @tc.desc: normal function 318 * @tc.type: FUNC 319 */ 320 HWTEST_F(SessionProxyTest, TransferAbilityResult, Function | SmallTest | Level2) 321 { 322 GTEST_LOG_(INFO) << "SessionProxyTest: TransferAbilityResult start"; 323 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 324 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 325 uint32_t resultCode = 0; 326 AAFwk::Want want; 327 WSError res = sProxy->TransferAbilityResult(resultCode, want); 328 ASSERT_EQ(res, WSError::WS_OK); 329 330 GTEST_LOG_(INFO) << "SessionProxyTest: TransferAbilityResult end"; 331 } 332 333 /** 334 * @tc.name: NotifyExtensionDied 335 * @tc.desc: normal function 336 * @tc.type: FUNC 337 */ 338 HWTEST_F(SessionProxyTest, NotifyExtensionDied, Function | SmallTest | Level2) 339 { 340 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionDied start"; 341 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 342 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 343 sProxy->NotifyExtensionDied(); 344 345 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionDied end"; 346 } 347 348 /** 349 * @tc.name: NotifyExtensionTimeout 350 * @tc.desc: normal function 351 * @tc.type: FUNC 352 */ 353 HWTEST_F(SessionProxyTest, NotifyExtensionTimeout, Function | SmallTest | Level2) 354 { 355 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout start"; 356 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 357 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 358 sProxy->NotifyExtensionTimeout(2); 359 360 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout end"; 361 } 362 363 /** 364 * @tc.name: UpdateWindowAnimationFlag 365 * @tc.desc: normal function 366 * @tc.type: FUNC 367 */ 368 HWTEST_F(SessionProxyTest, UpdateWindowAnimationFlag, Function | SmallTest | Level2) 369 { 370 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowAnimationFlag start"; 371 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 372 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 373 bool needDefaultAnimationFlag = false; 374 WSError res = sProxy->UpdateWindowAnimationFlag(needDefaultAnimationFlag); 375 ASSERT_EQ(res, WSError::WS_OK); 376 377 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowAnimationFlag end"; 378 } 379 380 /** 381 * @tc.name: TransferAccessibilityEvent 382 * @tc.desc: normal function 383 * @tc.type: FUNC 384 */ 385 HWTEST_F(SessionProxyTest, TransferAccessibilityEvent, Function | SmallTest | Level2) 386 { 387 GTEST_LOG_(INFO) << "SessionProxyTest: TransferAccessibilityEvent start"; 388 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 389 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 390 Accessibility::AccessibilityEventInfo info; 391 int64_t uiExtensionIdLevel = 0; 392 WSError res = sProxy->TransferAccessibilityEvent(info, uiExtensionIdLevel); 393 ASSERT_EQ(res, WSError::WS_OK); 394 395 GTEST_LOG_(INFO) << "SessionProxyTest: TransferAccessibilityEvent end"; 396 } 397 398 /** 399 * @tc.name: OnTitleAndDockHoverShowChange 400 * @tc.desc: normal function 401 * @tc.type: FUNC 402 */ 403 HWTEST_F(SessionProxyTest, OnTitleAndDockHoverShowChange, Function | SmallTest | Level2) 404 { 405 GTEST_LOG_(INFO) << "SessionProxyTest: OnTitleAndDockHoverShowChange 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 bool isTitleHoverShown = true; 411 bool isDockHoverShown = true; 412 WSError res = sProxy->OnTitleAndDockHoverShowChange(isTitleHoverShown, isDockHoverShown); 413 EXPECT_EQ(res, WSError::WS_OK); 414 GTEST_LOG_(INFO) << "SessionProxyTest: OnTitleAndDockHoverShowChange end"; 415 } 416 417 /** 418 * @tc.name: UpdatePiPControlStatus 419 * @tc.desc: normal function 420 * @tc.type: FUNC 421 */ 422 HWTEST_F(SessionProxyTest, UpdatePiPControlStatus, Function | SmallTest | Level2) 423 { 424 GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPControlStatus start"; 425 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 426 ASSERT_NE(iRemoteObjectMocker, nullptr); 427 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 428 ASSERT_NE(sProxy, nullptr); 429 auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE; 430 auto status = WsPiPControlStatus::PLAY; 431 WSError res = sProxy->UpdatePiPControlStatus(controlType, status); 432 ASSERT_EQ(res, WSError::WS_OK); 433 GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPControlStatus end"; 434 } 435 436 /** 437 * @tc.name: SetAutoStartPiP 438 * @tc.desc: sessionStub sessionStubTest 439 * @tc.type: FUNC 440 * @tc.require: #I6JLSI 441 */ 442 HWTEST_F(SessionProxyTest, SetAutoStartPiP, Function | SmallTest | Level2) 443 { 444 GTEST_LOG_(INFO) << "SetAutoStartPiP: SetAutoStartPiP start"; 445 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 446 ASSERT_NE(iRemoteObjectMocker, nullptr); 447 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 448 ASSERT_NE(sProxy, nullptr); 449 bool isAutoStartValid = true; 450 uint32_t priority = 0; 451 ASSERT_EQ(WSError::WS_OK, sProxy->SetAutoStartPiP(isAutoStartValid, priority)); 452 GTEST_LOG_(INFO) << "SetAutoStartPiP: SetAutoStartPiP end"; 453 } 454 455 /** 456 * @tc.name: GetGlobalScaledRect 457 * @tc.desc: normal function 458 * @tc.type: FUNC 459 */ 460 HWTEST_F(SessionProxyTest, GetGlobalScaledRect, Function | SmallTest | Level2) 461 { 462 GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalScaledRect start"; 463 Rect rect; 464 sptr<MockIRemoteObject> remoteMocker = sptr<MockIRemoteObject>::MakeSptr(); 465 sptr<SessionProxy> sProxy = sptr<SessionProxy>::MakeSptr(remoteMocker); 466 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 467 WMError res = sProxy->GetGlobalScaledRect(rect); 468 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 469 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); 470 471 sptr<SessionProxy> tempProxy = sptr<SessionProxy>::MakeSptr(nullptr); 472 res = tempProxy->GetGlobalScaledRect(rect); 473 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 474 475 remoteMocker->SetRequestResult(ERR_INVALID_DATA); 476 res = sProxy->GetGlobalScaledRect(rect); 477 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 478 remoteMocker->SetRequestResult(ERR_NONE); 479 480 MockMessageParcel::SetReadInt32ErrorFlag(true); 481 MockMessageParcel::SetReadUint32ErrorFlag(true); 482 res = sProxy->GetGlobalScaledRect(rect); 483 ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); 484 485 MockMessageParcel::ClearAllErrorFlag(); 486 res = sProxy->GetGlobalScaledRect(rect); 487 ASSERT_EQ(res, WMError::WM_OK); 488 GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalScaledRect end"; 489 } 490 491 /** 492 * @tc.name: RequestFocus 493 * @tc.desc: RequestFocus Test 494 * @tc.type: FUNC 495 */ 496 HWTEST_F(SessionProxyTest, RequestFocus, Function | SmallTest | Level2) 497 { 498 GTEST_LOG_(INFO) << "SessionProxyTest: RequestFocus start"; 499 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker(); 500 SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); 501 WSError res = sProxy->RequestFocus(true); 502 ASSERT_EQ(res, WSError::WS_OK); 503 GTEST_LOG_(INFO) << "SessionProxyTest: RequestFocus end"; 504 } 505 506 /** 507 * @tc.name: UpdateClientRect01 508 * @tc.desc: UpdateClientRect test 509 * @tc.type: FUNC 510 */ 511 HWTEST_F(SessionProxyTest, UpdateClientRect01, Function | SmallTest | Level2) 512 { 513 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateClientRect01 start"; 514 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 515 WSRect rect = { 200, 200, 200, 200 }; 516 ASSERT_EQ(sProxy->UpdateClientRect(rect), WSError::WS_ERROR_IPC_FAILED); 517 518 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 519 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 520 ASSERT_EQ(sProxy->UpdateClientRect(rect), WSError::WS_OK); 521 GTEST_LOG_(INFO) << "SessionProxyTest: UpdateClientRect01 start"; 522 } 523 524 /** 525 * @tc.name: GetAppForceLandscapeConfig 526 * @tc.desc: normal function 527 * @tc.type: FUNC 528 */ 529 HWTEST_F(SessionProxyTest, GetAppForceLandscapeConfig, Function | SmallTest | Level2) 530 { 531 GTEST_LOG_(INFO) << "SessionProxyTest: GetAppForceLandscapeConfig start"; 532 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 533 ASSERT_NE(iRemoteObjectMocker, nullptr); 534 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 535 ASSERT_NE(sProxy, nullptr); 536 AppForceLandscapeConfig config = {}; 537 auto res = sProxy->GetAppForceLandscapeConfig(config); 538 ASSERT_EQ(res, WMError::WM_OK); 539 GTEST_LOG_(INFO) << "SessionProxyTest: GetAppForceLandscapeConfig end"; 540 } 541 542 /** 543 * @tc.name: NotifyExtensionEventAsync 544 * @tc.desc: NotifyExtensionEventAsync test 545 * @tc.type: FUNC 546 */ 547 HWTEST_F(SessionProxyTest, NotifyExtensionEventAsync, Function | SmallTest | Level2) 548 { 549 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 550 ASSERT_NE(sProxy, nullptr); 551 sProxy->NotifyExtensionEventAsync(0); 552 553 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 554 ASSERT_NE(iRemoteObjectMocker, nullptr); 555 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 556 ASSERT_NE(sProxy, nullptr); 557 sProxy->NotifyExtensionEventAsync(0); 558 559 MockMessageParcel::SetWriteUint32ErrorFlag(true); 560 sProxy->NotifyExtensionEventAsync(0); 561 562 MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); 563 sProxy->NotifyExtensionEventAsync(0); 564 MockMessageParcel::ClearAllErrorFlag(); 565 } 566 567 /** 568 * @tc.name: OnSetWindowRectAutoSave 569 * @tc.desc: normal function 570 * @tc.type: FUNC 571 */ 572 HWTEST_F(SessionProxyTest, OnSetWindowRectAutoSave, Function | SmallTest | Level2) 573 { 574 GTEST_LOG_(INFO) << "SessionProxyTest: OnSetWindowRectAutoSave start"; 575 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 576 ASSERT_NE(iRemoteObjectMocker, nullptr); 577 auto sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 578 ASSERT_NE(sProxy, nullptr); 579 WSError res = sProxy->OnSetWindowRectAutoSave(true); 580 ASSERT_EQ(res, WSError::WS_OK); 581 GTEST_LOG_(INFO) << "SessionProxyTest: OnSetWindowRectAutoSave end"; 582 } 583 584 /** 585 * @tc.name: NotifyMainModalTypeChange 586 * @tc.desc: NotifyMainModalTypeChange test 587 * @tc.type: FUNC 588 */ 589 HWTEST_F(SessionProxyTest, NotifyMainModalTypeChange, Function | SmallTest | Level2) 590 { 591 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyMainModalTypeChange start"; 592 auto sProxy = sptr<SessionProxy>::MakeSptr(nullptr); 593 ASSERT_EQ(sProxy->NotifyMainModalTypeChange(true), WSError::WS_ERROR_IPC_FAILED); 594 auto iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr(); 595 sProxy = sptr<SessionProxy>::MakeSptr(iRemoteObjectMocker); 596 ASSERT_EQ(sProxy->NotifyMainModalTypeChange(true), WSError::WS_OK); 597 GTEST_LOG_(INFO) << "SessionProxyTest: NotifyMainModalTypeChange end"; 598 } 599 } // namespace 600 } // namespace Rosen 601 } // namespace OHOS 602