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 "screen_session.h" 16 #include <gtest/gtest.h> 17 #include "session_manager/include/screen_session_manager.h" 18 #include "scene_board_judgement.h" 19 20 // using namespace FRAME_TRACE; 21 using namespace testing; 22 using namespace testing::ext; 23 namespace OHOS { 24 namespace Rosen { 25 class MockScreenChangeListener : public IScreenChangeListener { 26 public: OnConnect(ScreenId screenId)27 void OnConnect(ScreenId screenId) override {} OnDisconnect(ScreenId screenId)28 void OnDisconnect(ScreenId screenId) override {} OnPropertyChange(const ScreenProperty & newProperty,ScreenPropertyChangeReason reason,ScreenId screenId)29 void OnPropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason, 30 ScreenId screenId) override {} OnPowerStatusChange(DisplayPowerEvent event,EventStatus status,PowerStateChangeReason reason)31 void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status, 32 PowerStateChangeReason reason) override {} OnSensorRotationChange(float sensorRotation,ScreenId screenId)33 void OnSensorRotationChange(float sensorRotation, ScreenId screenId) override {} OnScreenOrientationChange(float screenOrientation,ScreenId screenId)34 void OnScreenOrientationChange(float screenOrientation, ScreenId screenId) override {} OnScreenRotationLockedChange(bool isLocked,ScreenId screenId)35 void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override {} OnHoverStatusChange(int32_t hoverStatus,ScreenId screenId)36 void OnHoverStatusChange(int32_t hoverStatus, ScreenId screenId) override {} OnScreenCaptureNotify(ScreenId mainScreenId,int32_t uid,const std::string & clientName)37 void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override {} 38 }; 39 class ScreenSessionTest : public testing::Test { 40 public: ScreenSessionTest()41 ScreenSessionTest() {} ~ScreenSessionTest()42 ~ScreenSessionTest() {} 43 }; 44 45 namespace { 46 47 /** 48 * @tc.name: create ScreenSession 49 * @tc.desc: normal function 50 * @tc.type: FUNC 51 */ 52 HWTEST_F(ScreenSessionTest, ScreenSession, Function | SmallTest | Level2) 53 { 54 ScreenSessionConfig config = { 55 .screenId = 0, 56 .rsId = 0, 57 .name = "OpenHarmony", 58 }; 59 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); 60 EXPECT_NE(nullptr, screenSession); 61 } 62 63 /** 64 * @tc.name: create ScreenSession02 65 * @tc.desc: normal function 66 * @tc.type: FUNC 67 */ 68 HWTEST_F(ScreenSessionTest, ScreenSession02, Function | SmallTest | Level2) 69 { 70 ScreenSessionConfig config = { 71 .screenId = 0, 72 .rsId = 0, 73 .name = "OpenHarmony", 74 }; 75 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 76 EXPECT_NE(nullptr, screenSession); 77 } 78 79 /** 80 * @tc.name: create ScreenSession03 81 * @tc.desc: normal function 82 * @tc.type: FUNC 83 */ 84 HWTEST_F(ScreenSessionTest, ScreenSession03, Function | SmallTest | Level2) 85 { 86 ScreenSessionConfig config = { 87 .screenId = 0, 88 .rsId = 0, 89 .name = "OpenHarmony", 90 }; 91 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_MIRROR); 92 EXPECT_NE(nullptr, screenSession); 93 } 94 95 /** 96 * @tc.name: create ScreenSession03 97 * @tc.desc: normal function 98 * @tc.type: FUNC 99 */ 100 HWTEST_F(ScreenSessionTest, ScreenSession04, Function | SmallTest | Level2) 101 { 102 ScreenSessionConfig config = { 103 .screenId = 0, 104 .rsId = 0, 105 .name = "OpenHarmony", 106 }; 107 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_REAL); 108 EXPECT_NE(nullptr, screenSession); 109 } 110 111 /** 112 * @tc.name: create ScreenSession05 113 * @tc.desc: normal function 114 * @tc.type: FUNC 115 */ 116 HWTEST_F(ScreenSessionTest, ScreenSession05, Function | SmallTest | Level2) 117 { 118 ScreenSessionConfig config = { 119 .screenId = 0, 120 .rsId = 0, 121 .name = "OpenHarmony", 122 }; 123 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::INVALID); 124 EXPECT_NE(nullptr, screenSession); 125 } 126 127 /** 128 * @tc.name: CreateDisplayNode 129 * @tc.desc: normal function 130 * @tc.type: FUNC 131 */ 132 HWTEST_F(ScreenSessionTest, CreateDisplayNode, Function | SmallTest | Level2) 133 { 134 GTEST_LOG_(INFO) << "ScreenSessionTest: CreateDisplayNode start"; 135 Rosen::RSDisplayNodeConfig rsConfig; 136 ScreenSessionConfig config = { 137 .screenId = 100, 138 .rsId = 101, 139 .name = "OpenHarmony", 140 }; 141 rsConfig.isMirrored = true; 142 rsConfig.screenId = 101; 143 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 144 EXPECT_NE(nullptr, screenSession); 145 screenSession->CreateDisplayNode(rsConfig); 146 GTEST_LOG_(INFO) << "ScreenSessionTest: CreateDisplayNode end"; 147 } 148 149 /** 150 * @tc.name: SetMirrorScreenType 151 * @tc.desc: normal function 152 * @tc.type: FUNC 153 */ 154 HWTEST_F(ScreenSessionTest, SetMirrorScreenType, Function | SmallTest | Level2) 155 { 156 GTEST_LOG_(INFO) << "SetMirrorScreenType start"; 157 ScreenSessionConfig config = { 158 .screenId = 100, 159 .rsId = 101, 160 .name = "OpenHarmony", 161 }; 162 Rosen::RSDisplayNodeConfig rsConfig; 163 rsConfig.isMirrored = true; 164 rsConfig.screenId = 101; 165 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 166 EXPECT_NE(nullptr, screenSession); 167 MirrorScreenType mirrorType = MirrorScreenType::VIRTUAL_MIRROR; 168 screenSession->SetMirrorScreenType(mirrorType); 169 GTEST_LOG_(INFO) << "SetMirrorScreenType end"; 170 } 171 172 /** 173 * @tc.name: GetMirrorScreenType 174 * @tc.desc: normal function 175 * @tc.type: FUNC 176 */ 177 HWTEST_F(ScreenSessionTest, GetMirrorScreenType, Function | SmallTest | Level2) 178 { 179 GTEST_LOG_(INFO) << "GetMirrorScreenType start"; 180 ScreenSessionConfig config = { 181 .screenId = 100, 182 .rsId = 101, 183 .name = "OpenHarmony", 184 }; 185 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 186 EXPECT_NE(nullptr, screenSession); 187 MirrorScreenType mirrorType = MirrorScreenType::VIRTUAL_MIRROR; 188 screenSession->SetMirrorScreenType(mirrorType); 189 MirrorScreenType res = screenSession->GetMirrorScreenType(); 190 ASSERT_EQ(mirrorType, res); 191 GTEST_LOG_(INFO) << "GetMirrorScreenType end"; 192 } 193 194 /** 195 * @tc.name: SetDefaultDeviceRotationOffset 196 * @tc.desc: normal function 197 * @tc.type: FUNC 198 */ 199 HWTEST_F(ScreenSessionTest, SetDefaultDeviceRotationOffset, Function | SmallTest | Level2) 200 { 201 GTEST_LOG_(INFO) << "SetDefaultDeviceRotationOffset start"; 202 ScreenSessionConfig config = { 203 .screenId = 100, 204 .rsId = 101, 205 .name = "OpenHarmony", 206 }; 207 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 208 EXPECT_NE(nullptr, screenSession); 209 uint32_t defaultRotationOffset = 0; 210 screenSession->SetDefaultDeviceRotationOffset(defaultRotationOffset); 211 GTEST_LOG_(INFO) << "SetDefaultDeviceRotationOffset end"; 212 } 213 214 /** 215 * @tc.name: UpdateDisplayState 216 * @tc.desc: normal function 217 * @tc.type: FUNC 218 */ 219 HWTEST_F(ScreenSessionTest, UpdateDisplayState, Function | SmallTest | Level2) 220 { 221 GTEST_LOG_(INFO) << "UpdateDisplayState start"; 222 ScreenSessionConfig config = { 223 .screenId = 100, 224 .rsId = 101, 225 .name = "OpenHarmony", 226 }; 227 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 228 EXPECT_NE(nullptr, screenSession); 229 DisplayState displayState = DisplayState::OFF; 230 screenSession->UpdateDisplayState(displayState); 231 GTEST_LOG_(INFO) << "UpdateDisplayState end"; 232 } 233 234 /** 235 * @tc.name: UpdateRefreshRate 236 * @tc.desc: normal function 237 * @tc.type: FUNC 238 */ 239 HWTEST_F(ScreenSessionTest, UpdateRefreshRate, Function | SmallTest | Level2) 240 { 241 GTEST_LOG_(INFO) << "UpdateRefreshRate start"; 242 ScreenSessionConfig config = { 243 .screenId = 100, 244 .rsId = 101, 245 .name = "OpenHarmony", 246 }; 247 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 248 EXPECT_NE(nullptr, screenSession); 249 uint32_t refreshRate = 2; 250 screenSession->UpdateRefreshRate(refreshRate); 251 GTEST_LOG_(INFO) << "UpdateRefreshRate end"; 252 } 253 254 /** 255 * @tc.name: GetRefreshRate 256 * @tc.desc: normal function 257 * @tc.type: FUNC 258 */ 259 HWTEST_F(ScreenSessionTest, GetRefreshRate, Function | SmallTest | Level2) 260 { 261 GTEST_LOG_(INFO) << "GetRefreshRate start"; 262 ScreenSessionConfig config = { 263 .screenId = 100, 264 .rsId = 101, 265 .name = "OpenHarmony", 266 }; 267 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 268 EXPECT_NE(nullptr, screenSession); 269 uint32_t refreshRate = 2; 270 screenSession->UpdateRefreshRate(refreshRate); 271 auto res = screenSession->GetRefreshRate(); 272 ASSERT_EQ(refreshRate, res); 273 GTEST_LOG_(INFO) << "GetRefreshRate end"; 274 } 275 276 /** 277 * @tc.name: UpdatePropertyByResolution 278 * @tc.desc: normal function 279 * @tc.type: FUNC 280 */ 281 HWTEST_F(ScreenSessionTest, UpdatePropertyByResolution, Function | SmallTest | Level2) 282 { 283 GTEST_LOG_(INFO) << "UpdatePropertyByResolution start"; 284 ScreenSessionConfig config = { 285 .screenId = 100, 286 .rsId = 101, 287 .name = "OpenHarmony", 288 }; 289 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 290 EXPECT_NE(nullptr, screenSession); 291 uint32_t width = 1000; 292 uint32_t height = 1500; 293 screenSession->UpdatePropertyByResolution(width, height); 294 GTEST_LOG_(INFO) << "UpdatePropertyByResolution end"; 295 } 296 297 /** 298 * @tc.name: HandleSensorRotation 299 * @tc.desc: normal function 300 * @tc.type: FUNC 301 */ 302 HWTEST_F(ScreenSessionTest, HandleSensorRotation, Function | SmallTest | Level2) 303 { 304 GTEST_LOG_(INFO) << "HandleSensorRotation start"; 305 ScreenSessionConfig config = { 306 .screenId = 100, 307 .rsId = 101, 308 .name = "OpenHarmony", 309 }; 310 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 311 EXPECT_NE(nullptr, screenSession); 312 float sensorRotation = 0.0f; 313 screenSession->HandleSensorRotation(sensorRotation); 314 GTEST_LOG_(INFO) << "HandleSensorRotation end"; 315 } 316 317 /** 318 * @tc.name: ConvertIntToRotation 319 * @tc.desc: normal function 320 * @tc.type: FUNC 321 */ 322 HWTEST_F(ScreenSessionTest, ConvertIntToRotation, Function | SmallTest | Level2) 323 { 324 GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertIntToRotation start"; 325 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 326 int rotation = 0; 327 auto res = session->ConvertIntToRotation(rotation); 328 ASSERT_EQ(res, Rotation::ROTATION_0); 329 rotation = 90; 330 res = session->ConvertIntToRotation(rotation); 331 ASSERT_EQ(res, Rotation::ROTATION_90); 332 rotation = 180; 333 res = session->ConvertIntToRotation(rotation); 334 ASSERT_EQ(res, Rotation::ROTATION_180); 335 rotation = 270; 336 res = session->ConvertIntToRotation(rotation); 337 ASSERT_EQ(res, Rotation::ROTATION_270); 338 GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertIntToRotation end"; 339 } 340 341 /** 342 * @tc.name: SetVirtualScreenFlag 343 * @tc.desc: normal function 344 * @tc.type: FUNC 345 */ 346 HWTEST_F(ScreenSessionTest, SetVirtualScreenFlag, Function | SmallTest | Level2) 347 { 348 GTEST_LOG_(INFO) << "SetVirtualScreenFlag start"; 349 ScreenSessionConfig config = { 350 .screenId = 100, 351 .rsId = 101, 352 .name = "OpenHarmony", 353 }; 354 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 355 EXPECT_NE(nullptr, screenSession); 356 VirtualScreenFlag screenFlag = VirtualScreenFlag::CAST; 357 screenSession->SetVirtualScreenFlag(screenFlag); 358 GTEST_LOG_(INFO) << "SetVirtualScreenFlag end"; 359 } 360 361 /** 362 * @tc.name: GetVirtualScreenFlag 363 * @tc.desc: normal function 364 * @tc.type: FUNC 365 */ 366 HWTEST_F(ScreenSessionTest, GetVirtualScreenFlag, Function | SmallTest | Level2) 367 { 368 GTEST_LOG_(INFO) << "GetVirtualScreenFlag start"; 369 ScreenSessionConfig config = { 370 .screenId = 100, 371 .rsId = 101, 372 .name = "OpenHarmony", 373 }; 374 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 375 EXPECT_NE(nullptr, screenSession); 376 VirtualScreenFlag screenFlag = VirtualScreenFlag::CAST; 377 screenSession->SetVirtualScreenFlag(screenFlag); 378 auto res = screenSession->GetVirtualScreenFlag(); 379 ASSERT_EQ(screenFlag, res); 380 GTEST_LOG_(INFO) << "GetVirtualScreenFlag end"; 381 } 382 383 /** 384 * @tc.name: SetPhysicalRotation 385 * @tc.desc: normal function 386 * @tc.type: FUNC 387 */ 388 HWTEST_F(ScreenSessionTest, SetPhysicalRotation, Function | SmallTest | Level2) 389 { 390 GTEST_LOG_(INFO) << "SetPhysicalRotation start"; 391 ScreenSessionConfig config = { 392 .screenId = 100, 393 .rsId = 101, 394 .name = "OpenHarmony", 395 }; 396 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 397 EXPECT_NE(nullptr, screenSession); 398 int rotation = 0; 399 screenSession->SetPhysicalRotation(rotation); 400 GTEST_LOG_(INFO) << "SetPhysicalRotation end"; 401 } 402 403 /** 404 * @tc.name: SetScreenComponentRotation 405 * @tc.desc: normal function 406 * @tc.type: FUNC 407 */ 408 HWTEST_F(ScreenSessionTest, SetScreenComponentRotation, Function | SmallTest | Level2) 409 { 410 GTEST_LOG_(INFO) << "SetScreenComponentRotation start"; 411 ScreenSessionConfig config = { 412 .screenId = 100, 413 .rsId = 101, 414 .name = "OpenHarmony", 415 }; 416 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 417 EXPECT_NE(nullptr, screenSession); 418 int rotation = 0; 419 screenSession->SetScreenComponentRotation(rotation); 420 GTEST_LOG_(INFO) << "SetScreenComponentRotation end"; 421 } 422 423 /** 424 * @tc.name: UpdateToInputManager 425 * @tc.desc: normal function 426 * @tc.type: FUNC 427 */ 428 HWTEST_F(ScreenSessionTest, UpdateToInputManager, Function | SmallTest | Level2) 429 { 430 GTEST_LOG_(INFO) << "UpdateToInputManager start"; 431 ScreenSessionConfig config = { 432 .screenId = 100, 433 .rsId = 101, 434 .name = "OpenHarmony", 435 }; 436 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 437 EXPECT_NE(nullptr, screenSession); 438 RRect bounds; 439 int rotation = 90; 440 int deviceRotation = 90; 441 FoldDisplayMode foldDisplayMode = FoldDisplayMode::FULL; 442 screenSession->UpdateToInputManager(bounds, rotation, deviceRotation, foldDisplayMode); 443 bounds.rect_.width_ = 1344; 444 bounds.rect_.height_ = 2772; 445 rotation = 0; 446 foldDisplayMode = FoldDisplayMode::MAIN; 447 screenSession->UpdateToInputManager(bounds, rotation, deviceRotation, foldDisplayMode); 448 GTEST_LOG_(INFO) << "UpdateToInputManager end"; 449 } 450 451 /** 452 * @tc.name: UpdatePropertyAfterRotation 453 * @tc.desc: normal function 454 * @tc.type: FUNC 455 */ 456 HWTEST_F(ScreenSessionTest, UpdatePropertyAfterRotation, Function | SmallTest | Level2) 457 { 458 GTEST_LOG_(INFO) << "UpdatePropertyAfterRotation start"; 459 ScreenSessionConfig config = { 460 .screenId = 100, 461 .rsId = 101, 462 .name = "OpenHarmony", 463 }; 464 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 465 EXPECT_NE(nullptr, screenSession); 466 RRect bounds; 467 bounds.rect_.width_ = 1344; 468 bounds.rect_.height_ = 2772; 469 int rotation = 90; 470 FoldDisplayMode foldDisplayMode = FoldDisplayMode::MAIN; 471 screenSession->UpdatePropertyAfterRotation(bounds, rotation, foldDisplayMode); 472 GTEST_LOG_(INFO) << "UpdatePropertyAfterRotation end"; 473 } 474 475 /** 476 * @tc.name: ReportNotifyModeChange 477 * @tc.desc: normal function 478 * @tc.type: FUNC 479 */ 480 HWTEST_F(ScreenSessionTest, ReportNotifyModeChange, Function | SmallTest | Level2) 481 { 482 GTEST_LOG_(INFO) << "ReportNotifyModeChange start"; 483 ScreenSessionConfig config = { 484 .screenId = 100, 485 .rsId = 101, 486 .name = "OpenHarmony", 487 }; 488 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 489 EXPECT_NE(nullptr, screenSession); 490 DisplayOrientation displayOrientation = DisplayOrientation::LANDSCAPE; 491 screenSession->ReportNotifyModeChange(displayOrientation); 492 displayOrientation = DisplayOrientation::PORTRAIT; 493 screenSession->ReportNotifyModeChange(displayOrientation); 494 GTEST_LOG_(INFO) << "ReportNotifyModeChange end"; 495 } 496 497 /** 498 * @tc.name: UpdateRotationAfterBoot 499 * @tc.desc: normal function 500 * @tc.type: FUNC 501 */ 502 HWTEST_F(ScreenSessionTest, UpdateRotationAfterBoot, Function | SmallTest | Level2) 503 { 504 GTEST_LOG_(INFO) << "UpdateRotationAfterBoot start"; 505 ScreenSessionConfig config = { 506 .screenId = 100, 507 .rsId = 101, 508 .name = "OpenHarmony", 509 }; 510 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 511 EXPECT_NE(nullptr, screenSession); 512 bool foldToExpand = true; 513 screenSession->UpdateRotationAfterBoot(foldToExpand); 514 GTEST_LOG_(INFO) << "UpdateRotationAfterBoot end"; 515 } 516 517 /** 518 * @tc.name: UpdateValidRotationToScb 519 * @tc.desc: normal function 520 * @tc.type: FUNC 521 */ 522 HWTEST_F(ScreenSessionTest, UpdateValidRotationToScb, Function | SmallTest | Level2) 523 { 524 GTEST_LOG_(INFO) << "UpdateValidRotationToScb start"; 525 ScreenSessionConfig config = { 526 .screenId = 100, 527 .rsId = 101, 528 .name = "OpenHarmony", 529 }; 530 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 531 EXPECT_NE(nullptr, screenSession); 532 screenSession->UpdateValidRotationToScb(); 533 GTEST_LOG_(INFO) << "UpdateValidRotationToScb end"; 534 } 535 536 /** 537 * @tc.name: SetScreenSceneDpiChangeListener 538 * @tc.desc: normal function 539 * @tc.type: FUNC 540 */ 541 HWTEST_F(ScreenSessionTest, SetScreenSceneDpiChangeListener, Function | SmallTest | Level2) 542 { 543 GTEST_LOG_(INFO) << "SetScreenSceneDpiChangeListener start"; 544 ScreenSessionConfig config = { 545 .screenId = 100, 546 .rsId = 101, 547 .name = "OpenHarmony", 548 }; 549 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 550 EXPECT_NE(nullptr, screenSession); 551 SetScreenSceneDpiFunc func = nullptr; 552 screenSession->SetScreenSceneDpiChangeListener(func); 553 GTEST_LOG_(INFO) << "SetScreenSceneDpiChangeListener end"; 554 } 555 556 /** 557 * @tc.name: SetScreenSceneDestroyListener 558 * @tc.desc: normal function 559 * @tc.type: FUNC 560 */ 561 HWTEST_F(ScreenSessionTest, SetScreenSceneDestroyListener, Function | SmallTest | Level2) 562 { 563 GTEST_LOG_(INFO) << "SetScreenSceneDestroyListener start"; 564 ScreenSessionConfig config = { 565 .screenId = 100, 566 .rsId = 101, 567 .name = "OpenHarmony", 568 }; 569 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 570 EXPECT_NE(nullptr, screenSession); 571 DestroyScreenSceneFunc func = nullptr; 572 screenSession->SetScreenSceneDestroyListener(func); 573 GTEST_LOG_(INFO) << "SetScreenSceneDestroyListener end"; 574 } 575 576 /** 577 * @tc.name: SetScreenSceneDpi 578 * @tc.desc: normal function 579 * @tc.type: FUNC 580 */ 581 HWTEST_F(ScreenSessionTest, SetScreenSceneDpi, Function | SmallTest | Level2) 582 { 583 GTEST_LOG_(INFO) << "SetScreenSceneDpi start"; 584 ScreenSessionConfig config = { 585 .screenId = 100, 586 .rsId = 101, 587 .name = "OpenHarmony", 588 }; 589 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 590 EXPECT_NE(nullptr, screenSession); 591 float density = 1.5f; 592 SetScreenSceneDpiFunc func = nullptr; 593 screenSession->SetScreenSceneDpiChangeListener(func); 594 screenSession->SetScreenSceneDpi(density); __anon9684af770202(float density) 595 SetScreenSceneDpiFunc func2 = [](float density) { 596 EXPECT_TRUE(true); 597 }; 598 screenSession->SetScreenSceneDpiChangeListener(func2); 599 screenSession->SetScreenSceneDpi(density); 600 GTEST_LOG_(INFO) << "SetScreenSceneDpi end"; 601 } 602 603 /** 604 * @tc.name: DestroyScreenScene 605 * @tc.desc: normal function 606 * @tc.type: FUNC 607 */ 608 HWTEST_F(ScreenSessionTest, DestroyScreenScene, Function | SmallTest | Level2) 609 { 610 GTEST_LOG_(INFO) << "DestroyScreenScene start"; 611 ScreenSessionConfig config = { 612 .screenId = 100, 613 .rsId = 101, 614 .name = "OpenHarmony", 615 }; 616 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 617 EXPECT_NE(nullptr, screenSession); 618 DestroyScreenSceneFunc func = nullptr; 619 screenSession->SetScreenSceneDestroyListener(func); 620 screenSession->DestroyScreenScene(); __anon9684af770302() 621 DestroyScreenSceneFunc func2 = []() { 622 EXPECT_TRUE(true); 623 }; 624 screenSession->SetScreenSceneDestroyListener(func2); 625 screenSession->DestroyScreenScene(); 626 GTEST_LOG_(INFO) << "DestroyScreenScene end"; 627 } 628 629 /** 630 * @tc.name: SetDensityInCurResolution 631 * @tc.desc: normal function 632 * @tc.type: FUNC 633 */ 634 HWTEST_F(ScreenSessionTest, SetDensityInCurResolution, Function | SmallTest | Level2) 635 { 636 GTEST_LOG_(INFO) << "SetDensityInCurResolution start"; 637 ScreenSessionConfig config = { 638 .screenId = 100, 639 .rsId = 101, 640 .name = "OpenHarmony", 641 }; 642 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 643 EXPECT_NE(nullptr, screenSession); 644 float densityInCurResolution = 1.5f; 645 screenSession->SetDensityInCurResolution(densityInCurResolution); 646 GTEST_LOG_(INFO) << "SetDensityInCurResolution end"; 647 } 648 649 /** 650 * @tc.name: GetSourceMode 651 * @tc.desc: normal function 652 * @tc.type: FUNC 653 */ 654 HWTEST_F(ScreenSessionTest, GetSourceMode, Function | SmallTest | Level2) 655 { 656 GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode start"; 657 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 658 session->screenId_ = session->defaultScreenId_; 659 ScreenSourceMode mode = session->GetSourceMode(); 660 ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN); 661 ScreenSessionConfig config = { 662 .screenId = 100, 663 .rsId = 101, 664 .name = "OpenHarmony", 665 }; 666 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 667 mode = screenSession->GetSourceMode(); 668 ASSERT_EQ(mode, ScreenSourceMode::SCREEN_ALONE); 669 screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXPAND); 670 mode = screenSession->GetSourceMode(); 671 ASSERT_EQ(mode, ScreenSourceMode::SCREEN_EXTEND); 672 screenSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); 673 mode = screenSession->GetSourceMode(); 674 ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MIRROR); 675 screenSession->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE); 676 mode = screenSession->GetSourceMode(); 677 ASSERT_EQ(mode, ScreenSourceMode::SCREEN_UNIQUE); 678 GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode end"; 679 } 680 681 /** 682 * @tc.name: GetPixelFormat 683 * @tc.desc: normal function 684 * @tc.type: FUNC 685 */ 686 HWTEST_F(ScreenSessionTest, GetPixelFormat, Function | SmallTest | Level2) 687 { 688 GTEST_LOG_(INFO) << "GetPixelFormat start"; 689 ScreenSessionConfig config = { 690 .screenId = 100, 691 .rsId = 0, 692 .name = "OpenHarmony", 693 }; 694 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 695 EXPECT_NE(nullptr, screenSession); 696 GraphicPixelFormat pixelFormat; 697 auto res = screenSession->GetPixelFormat(pixelFormat); 698 ASSERT_EQ(res, DMError::DM_OK); 699 GTEST_LOG_(INFO) << "GetPixelFormat end"; 700 } 701 702 /** 703 * @tc.name: SetPixelFormat 704 * @tc.desc: normal function 705 * @tc.type: FUNC 706 */ 707 HWTEST_F(ScreenSessionTest, SetPixelFormat, Function | SmallTest | Level2) 708 { 709 GTEST_LOG_(INFO) << "SetPixelFormat start"; 710 ScreenSessionConfig config = { 711 .screenId = 100, 712 .rsId = 0, 713 .name = "OpenHarmony", 714 }; 715 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 716 EXPECT_NE(nullptr, screenSession); 717 GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8}; 718 auto res = screenSession->SetPixelFormat(pixelFormat); 719 ASSERT_EQ(res, DMError::DM_OK); 720 GTEST_LOG_(INFO) << "SetPixelFormat end"; 721 } 722 723 /** 724 * @tc.name: GetSupportedHDRFormats 725 * @tc.desc: normal function 726 * @tc.type: FUNC 727 */ 728 HWTEST_F(ScreenSessionTest, GetSupportedHDRFormats, Function | SmallTest | Level2) 729 { 730 GTEST_LOG_(INFO) << "GetSupportedHDRFormats start"; 731 ScreenSessionConfig config = { 732 .screenId = 100, 733 .rsId = 0, 734 .name = "OpenHarmony", 735 }; 736 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 737 EXPECT_NE(nullptr, screenSession); 738 std::vector<ScreenHDRFormat> hdrFormats; 739 auto res = screenSession->GetSupportedHDRFormats(hdrFormats); 740 if (SceneBoardJudgement::IsSceneBoardEnabled()) { 741 ASSERT_EQ(res, DMError::DM_OK); 742 } else { 743 ASSERT_NE(res, DMError::DM_OK); 744 } 745 GTEST_LOG_(INFO) << "GetSupportedHDRFormats end"; 746 } 747 748 /** 749 * @tc.name: GetScreenHDRFormat 750 * @tc.desc: normal function 751 * @tc.type: FUNC 752 */ 753 HWTEST_F(ScreenSessionTest, GetScreenHDRFormat, Function | SmallTest | Level2) 754 { 755 GTEST_LOG_(INFO) << "GetScreenHDRFormat start"; 756 ScreenSessionConfig config = { 757 .screenId = 100, 758 .rsId = 0, 759 .name = "OpenHarmony", 760 }; 761 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 762 EXPECT_NE(nullptr, screenSession); 763 ScreenHDRFormat hdrFormat; 764 auto res = screenSession->GetScreenHDRFormat(hdrFormat); 765 if (SceneBoardJudgement::IsSceneBoardEnabled()) { 766 ASSERT_EQ(res, DMError::DM_OK); 767 } else { 768 ASSERT_NE(res, DMError::DM_OK); 769 } 770 GTEST_LOG_(INFO) << "GetScreenHDRFormat end"; 771 } 772 773 /** 774 * @tc.name: SetScreenHDRFormat 775 * @tc.desc: normal function 776 * @tc.type: FUNC 777 */ 778 HWTEST_F(ScreenSessionTest, SetScreenHDRFormat, Function | SmallTest | Level2) 779 { 780 GTEST_LOG_(INFO) << "SetScreenHDRFormat start"; 781 ScreenSessionConfig config = { 782 .screenId = 100, 783 .rsId = 0, 784 .name = "OpenHarmony", 785 }; 786 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 787 EXPECT_NE(nullptr, screenSession); 788 int32_t modeIdx = 0; 789 auto res = screenSession->SetScreenHDRFormat(modeIdx); 790 if (SceneBoardJudgement::IsSceneBoardEnabled()) { 791 ASSERT_EQ(res, DMError::DM_OK); 792 modeIdx = -1; 793 res = screenSession->SetScreenHDRFormat(modeIdx); 794 ASSERT_EQ(res, DMError::DM_ERROR_INVALID_PARAM); 795 } else { 796 ASSERT_NE(res, DMError::DM_OK); 797 } 798 GTEST_LOG_(INFO) << "SetScreenHDRFormat end"; 799 } 800 801 /** 802 * @tc.name: GetSupportedColorSpaces 803 * @tc.desc: normal function 804 * @tc.type: FUNC 805 */ 806 HWTEST_F(ScreenSessionTest, GetSupportedColorSpaces, Function | SmallTest | Level2) 807 { 808 GTEST_LOG_(INFO) << "GetSupportedColorSpaces start"; 809 ScreenSessionConfig config = { 810 .screenId = 100, 811 .rsId = 0, 812 .name = "OpenHarmony", 813 }; 814 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 815 EXPECT_NE(nullptr, screenSession); 816 std::vector<GraphicCM_ColorSpaceType> colorSpaces; 817 auto res = screenSession->GetSupportedColorSpaces(colorSpaces); 818 if (SceneBoardJudgement::IsSceneBoardEnabled()) { 819 ASSERT_EQ(res, DMError::DM_OK); 820 } else { 821 ASSERT_NE(res, DMError::DM_OK); 822 } 823 GTEST_LOG_(INFO) << "GetSupportedColorSpaces end"; 824 } 825 826 /** 827 * @tc.name: GetScreenColorSpace 828 * @tc.desc: normal function 829 * @tc.type: FUNC 830 */ 831 HWTEST_F(ScreenSessionTest, GetScreenColorSpace, Function | SmallTest | Level2) 832 { 833 GTEST_LOG_(INFO) << "GetScreenColorSpace start"; 834 ScreenSessionConfig config = { 835 .screenId = 100, 836 .rsId = 0, 837 .name = "OpenHarmony", 838 }; 839 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 840 EXPECT_NE(nullptr, screenSession); 841 GraphicCM_ColorSpaceType colorSpace; 842 auto res = screenSession->GetScreenColorSpace(colorSpace); 843 if (SceneBoardJudgement::IsSceneBoardEnabled()) { 844 ASSERT_EQ(res, DMError::DM_OK); 845 } else { 846 ASSERT_NE(res, DMError::DM_OK); 847 } 848 GTEST_LOG_(INFO) << "GetScreenColorSpace end"; 849 } 850 851 /** 852 * @tc.name: SetScreenColorSpace 853 * @tc.desc: normal function 854 * @tc.type: FUNC 855 */ 856 HWTEST_F(ScreenSessionTest, SetScreenColorSpace, Function | SmallTest | Level2) 857 { 858 GTEST_LOG_(INFO) << "SetScreenColorSpace start"; 859 ScreenSessionConfig config = { 860 .screenId = 100, 861 .rsId = 101, 862 .name = "OpenHarmony", 863 }; 864 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 865 EXPECT_NE(nullptr, screenSession); 866 GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE}; 867 screenSession->SetScreenColorSpace(colorSpace); 868 EXPECT_TRUE(true); 869 GTEST_LOG_(INFO) << "SetScreenColorSpace end"; 870 } 871 872 /** 873 * @tc.name: SetPrivateSessionForeground 874 * @tc.desc: normal function 875 * @tc.type: FUNC 876 */ 877 HWTEST_F(ScreenSessionTest, SetPrivateSessionForeground, Function | SmallTest | Level2) 878 { 879 GTEST_LOG_(INFO) << "SetPrivateSessionForeground start"; 880 ScreenSessionConfig config = { 881 .screenId = 100, 882 .rsId = 101, 883 .name = "OpenHarmony", 884 }; 885 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 886 EXPECT_NE(nullptr, screenSession); 887 bool hasPrivate = true; 888 screenSession->SetPrivateSessionForeground(hasPrivate); 889 auto res = screenSession->HasPrivateSessionForeground(); 890 ASSERT_EQ(res, hasPrivate); 891 GTEST_LOG_(INFO) << "SetPrivateSessionForeground end"; 892 } 893 894 /** 895 * @tc.name: GetScreenCombination 896 * @tc.desc: normal function 897 * @tc.type: FUNC 898 */ 899 HWTEST_F(ScreenSessionTest, GetScreenCombination, Function | SmallTest | Level2) 900 { 901 GTEST_LOG_(INFO) << "GetScreenCombination start"; 902 ScreenSessionConfig config = { 903 .screenId = 100, 904 .rsId = 101, 905 .name = "OpenHarmony", 906 }; 907 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 908 EXPECT_NE(nullptr, screenSession); 909 ScreenCombination combination { ScreenCombination::SCREEN_ALONE }; 910 screenSession->SetScreenCombination(combination); 911 auto res = screenSession->GetScreenCombination(); 912 ASSERT_EQ(res, combination); 913 GTEST_LOG_(INFO) << "GetScreenCombination end"; 914 } 915 916 /** 917 * @tc.name: Resize 918 * @tc.desc: normal function 919 * @tc.type: FUNC 920 */ 921 HWTEST_F(ScreenSessionTest, Resize, Function | SmallTest | Level2) 922 { 923 GTEST_LOG_(INFO) << "Resize start"; 924 ScreenSessionConfig config = { 925 .screenId = 100, 926 .rsId = 101, 927 .name = "OpenHarmony", 928 }; 929 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 930 EXPECT_NE(nullptr, screenSession); 931 uint32_t width = 1000; 932 uint32_t height = 1000; 933 screenSession->Resize(width, height); 934 GTEST_LOG_(INFO) << "Resize end"; 935 } 936 937 /** 938 * @tc.name: UpdateAvailableArea 939 * @tc.desc: normal function 940 * @tc.type: FUNC 941 */ 942 HWTEST_F(ScreenSessionTest, UpdateAvailableArea, Function | SmallTest | Level2) 943 { 944 GTEST_LOG_(INFO) << "UpdateAvailableArea start"; 945 ScreenSessionConfig config = { 946 .screenId = 100, 947 .rsId = 101, 948 .name = "OpenHarmony", 949 }; 950 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 951 EXPECT_NE(nullptr, screenSession); 952 DMRect area = screenSession->GetAvailableArea(); 953 auto res = screenSession->UpdateAvailableArea(area); 954 ASSERT_EQ(res, false); 955 area = {2, 2, 2, 2}; 956 res = screenSession->UpdateAvailableArea(area); 957 ASSERT_EQ(res, true); 958 GTEST_LOG_(INFO) << "UpdateAvailableArea end"; 959 } 960 961 /** 962 * @tc.name: SetAvailableArea 963 * @tc.desc: normal function 964 * @tc.type: FUNC 965 */ 966 HWTEST_F(ScreenSessionTest, SetAvailableArea, Function | SmallTest | Level2) 967 { 968 GTEST_LOG_(INFO) << "SetAvailableArea start"; 969 ScreenSessionConfig config = { 970 .screenId = 100, 971 .rsId = 101, 972 .name = "OpenHarmony", 973 }; 974 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 975 EXPECT_NE(nullptr, screenSession); 976 DMRect area = {2, 2, 2, 2}; 977 screenSession->SetAvailableArea(area); 978 GTEST_LOG_(INFO) << "SetAvailableArea end"; 979 } 980 981 /** 982 * @tc.name: GetAvailableArea 983 * @tc.desc: normal function 984 * @tc.type: FUNC 985 */ 986 HWTEST_F(ScreenSessionTest, GetAvailableArea, Function | SmallTest | Level2) 987 { 988 GTEST_LOG_(INFO) << "GetAvailableArea start"; 989 ScreenSessionConfig config = { 990 .screenId = 100, 991 .rsId = 101, 992 .name = "OpenHarmony", 993 }; 994 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 995 EXPECT_NE(nullptr, screenSession); 996 DMRect area = {2, 2, 2, 2}; 997 screenSession->SetAvailableArea(area); 998 auto res = screenSession->GetAvailableArea(); 999 ASSERT_EQ(res, area); 1000 GTEST_LOG_(INFO) << "GetAvailableArea end"; 1001 } 1002 1003 /** 1004 * @tc.name: SetFoldScreen 1005 * @tc.desc: normal function 1006 * @tc.type: FUNC 1007 */ 1008 HWTEST_F(ScreenSessionTest, SetFoldScreen, Function | SmallTest | Level2) 1009 { 1010 GTEST_LOG_(INFO) << "SetFoldScreen start"; 1011 ScreenSessionConfig config = { 1012 .screenId = 100, 1013 .rsId = 101, 1014 .name = "OpenHarmony", 1015 }; 1016 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 1017 EXPECT_NE(nullptr, screenSession); 1018 bool isFold = false; 1019 screenSession->SetFoldScreen(isFold); 1020 GTEST_LOG_(INFO) << "SetFoldScreen end"; 1021 } 1022 1023 /** 1024 * @tc.name: SetHdrFormats 1025 * @tc.desc: normal function 1026 * @tc.type: FUNC 1027 */ 1028 HWTEST_F(ScreenSessionTest, SetHdrFormats, Function | SmallTest | Level2) 1029 { 1030 GTEST_LOG_(INFO) << "SetHdrFormats start"; 1031 ScreenSessionConfig config = { 1032 .screenId = 100, 1033 .rsId = 101, 1034 .name = "OpenHarmony", 1035 }; 1036 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 1037 EXPECT_NE(nullptr, screenSession); 1038 std::vector<uint32_t> hdrFormats = { 0, 0, 0, 0 }; 1039 screenSession->SetHdrFormats(std::move(hdrFormats)); 1040 GTEST_LOG_(INFO) << "SetHdrFormats end"; 1041 } 1042 1043 /** 1044 * @tc.name: SetColorSpaces 1045 * @tc.desc: normal function 1046 * @tc.type: FUNC 1047 */ 1048 HWTEST_F(ScreenSessionTest, SetColorSpaces, Function | SmallTest | Level2) 1049 { 1050 GTEST_LOG_(INFO) << "SetColorSpaces start"; 1051 ScreenSessionConfig config = { 1052 .screenId = 100, 1053 .rsId = 101, 1054 .name = "OpenHarmony", 1055 }; 1056 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 1057 EXPECT_NE(nullptr, screenSession); 1058 std::vector<uint32_t> colorSpaces = { 0, 0, 0, 0 }; 1059 screenSession->SetColorSpaces(std::move(colorSpaces)); 1060 GTEST_LOG_(INFO) << "SetColorSpaces end"; 1061 } 1062 1063 /** 1064 * @tc.name: SetDisplayNodeScreenId 1065 * @tc.desc: normal function 1066 * @tc.type: FUNC 1067 */ 1068 HWTEST_F(ScreenSessionTest, SetDisplayNodeScreenId, Function | SmallTest | Level2) 1069 { 1070 GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNodeScreenId start"; 1071 ScreenId screenId = 0; 1072 ScreenId rsId = 1; 1073 std::string name = "OpenHarmony"; 1074 ScreenProperty property; 1075 RSDisplayNodeConfig displayNodeConfig; 1076 std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig); 1077 EXPECT_NE(nullptr, displayNode); 1078 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(screenId, rsId, name, property, displayNode); 1079 session->SetDisplayNodeScreenId(screenId); 1080 GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNodeScreenId end"; 1081 } 1082 1083 /** 1084 * @tc.name: UnregisterScreenChangeListener 1085 * @tc.desc: normal function 1086 * @tc.type: FUNC 1087 */ 1088 HWTEST_F(ScreenSessionTest, UnregisterScreenChangeListener, Function | SmallTest | Level2) 1089 { 1090 GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener start"; 1091 IScreenChangeListener* screenChangeListener = nullptr; 1092 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1093 int64_t ret = 0; 1094 session->UnregisterScreenChangeListener(screenChangeListener); 1095 ASSERT_EQ(ret, 0); 1096 GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener end"; 1097 } 1098 1099 /** 1100 * @tc.name: UnregisterScreenChangeListener02 1101 * @tc.desc: normal function 1102 * @tc.type: FUNC 1103 */ 1104 HWTEST_F(ScreenSessionTest, UnregisterScreenChangeListener02, Function | SmallTest | Level2) 1105 { 1106 GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener02 start"; 1107 IScreenChangeListener* screenChangeListener = new ScreenSessionManager(); 1108 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1109 int64_t ret = 0; 1110 session->UnregisterScreenChangeListener(screenChangeListener); 1111 ASSERT_EQ(ret, 0); 1112 GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener02 end"; 1113 } 1114 1115 /** 1116 * @tc.name: ConvertToDisplayInfo 1117 * @tc.desc: normal function 1118 * @tc.type: FUNC 1119 */ 1120 HWTEST_F(ScreenSessionTest, ConvertToDisplayInfo, Function | SmallTest | Level2) 1121 { 1122 GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToDisplayInfo start"; 1123 sptr<DisplayInfo> displayInfo = new(std::nothrow) DisplayInfo(); 1124 EXPECT_NE(displayInfo, nullptr); 1125 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1126 EXPECT_NE(nullptr, session->ConvertToDisplayInfo()); 1127 1128 sptr<ScreenInfo> info = new(std::nothrow) ScreenInfo(); 1129 EXPECT_NE(info, nullptr); 1130 EXPECT_NE(nullptr, session->ConvertToScreenInfo()); 1131 GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToDisplayInfo end"; 1132 } 1133 1134 /** 1135 * @tc.name: GetScreenSupportedColorGamuts 1136 * @tc.desc: normal function 1137 * @tc.type: FUNC 1138 */ 1139 HWTEST_F(ScreenSessionTest, GetScreenSupportedColorGamuts, Function | SmallTest | Level2) 1140 { 1141 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts start"; 1142 std::vector<ScreenColorGamut> colorGamuts; 1143 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1144 DMError ret = session->GetScreenSupportedColorGamuts(colorGamuts); 1145 if (SceneBoardJudgement::IsSceneBoardEnabled()) { 1146 ASSERT_EQ(ret, DMError::DM_OK); 1147 } else { 1148 ASSERT_NE(ret, DMError::DM_OK); 1149 } 1150 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts end"; 1151 } 1152 1153 /** 1154 * @tc.name: GetActiveScreenMode 1155 * @tc.desc: normal function 1156 * @tc.type: FUNC 1157 */ 1158 HWTEST_F(ScreenSessionTest, GetActiveScreenMode, Function | SmallTest | Level2) 1159 { 1160 GTEST_LOG_(INFO) << "ScreenSessionTest: GetActiveScreenMode start"; 1161 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1162 session->activeIdx_ = -1; 1163 sptr<SupportedScreenModes> mode1 = session->GetActiveScreenMode(); 1164 session->GetActiveScreenMode(); 1165 ASSERT_EQ(mode1, nullptr); 1166 1167 session->activeIdx_ = 100; 1168 sptr<SupportedScreenModes> mode2 = session->GetActiveScreenMode(); 1169 session->GetActiveScreenMode(); 1170 ASSERT_EQ(mode2, nullptr); 1171 1172 GTEST_LOG_(INFO) << "ScreenSessionTest: GetActiveScreenMode end"; 1173 } 1174 1175 /** 1176 * @tc.name: SetScreenCombination 1177 * @tc.desc: normal function 1178 * @tc.type: FUNC 1179 */ 1180 HWTEST_F(ScreenSessionTest, SetScreenCombination, Function | SmallTest | Level2) 1181 { 1182 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenCombination start"; 1183 ScreenId screenId = 2024; 1184 ScreenProperty property; 1185 NodeId nodeId = 0; 1186 ScreenId defaultScreenId = 0; 1187 ScreenCombination combination { ScreenCombination::SCREEN_ALONE }; 1188 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(screenId, property, nodeId, defaultScreenId); 1189 session->SetScreenCombination(combination); 1190 EXPECT_NE(session, nullptr); 1191 EXPECT_EQ(combination, session->GetScreenCombination()); 1192 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenCombination end"; 1193 } 1194 1195 /** 1196 * @tc.name: GetScreenColorGamut 1197 * @tc.desc: normal function 1198 * @tc.type: FUNC 1199 */ 1200 HWTEST_F(ScreenSessionTest, GetScreenColorGamut, Function | SmallTest | Level2) 1201 { 1202 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut start"; 1203 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1204 ASSERT_NE(session, nullptr); 1205 1206 ScreenColorGamut colorGamut; 1207 DMError res = session->GetScreenColorGamut(colorGamut); 1208 if (SceneBoardJudgement::IsSceneBoardEnabled()) { 1209 ASSERT_EQ(res, DMError::DM_OK); 1210 } else { 1211 ASSERT_NE(res, DMError::DM_OK); 1212 } 1213 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut end"; 1214 } 1215 1216 /** 1217 * @tc.name: SetScreenColorGamut 1218 * @tc.desc: normal function 1219 * @tc.type: FUNC 1220 */ 1221 HWTEST_F(ScreenSessionTest, SetScreenColorGamut, Function | SmallTest | Level2) 1222 { 1223 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut start"; 1224 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1225 ASSERT_NE(session, nullptr); 1226 1227 int32_t colorGamut = 1; 1228 DMError res = session->SetScreenColorGamut(colorGamut); 1229 ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED); 1230 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut end"; 1231 } 1232 1233 /** 1234 * @tc.name: GetScreenGamutMap 1235 * @tc.desc: normal function 1236 * @tc.type: FUNC 1237 */ 1238 HWTEST_F(ScreenSessionTest, GetScreenGamutMap, Function | SmallTest | Level2) 1239 { 1240 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenGamutMap start"; 1241 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1242 ASSERT_NE(session, nullptr); 1243 1244 ScreenGamutMap gamutMap; 1245 DMError res = session->GetScreenGamutMap(gamutMap); 1246 ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED); 1247 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenGamutMap end"; 1248 } 1249 1250 /** 1251 * @tc.name: SetScreenGamutMap 1252 * @tc.desc: normal function 1253 * @tc.type: FUNC 1254 */ 1255 HWTEST_F(ScreenSessionTest, SetScreenGamutMap, Function | SmallTest | Level2) 1256 { 1257 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenGamutMap start"; 1258 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1259 ASSERT_NE(session, nullptr); 1260 ScreenGamutMap gamutMap = GAMUT_MAP_CONSTANT; 1261 DMError res = session->SetScreenGamutMap(gamutMap); 1262 ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED); 1263 1264 gamutMap = GAMUT_MAP_HDR_EXTENSION; 1265 res = session->SetScreenGamutMap(gamutMap); 1266 ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED); 1267 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenGamutMap end"; 1268 } 1269 1270 /** 1271 * @tc.name: InitRSDisplayNode 1272 * @tc.desc: normal function 1273 * @tc.type: FUNC 1274 */ 1275 HWTEST_F(ScreenSessionTest, InitRSDisplayNode, Function | SmallTest | Level2) 1276 { 1277 GTEST_LOG_(INFO) << "ScreenSessionTest: InitRSDisplayNode start"; 1278 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1279 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1280 ASSERT_NE(session, nullptr); 1281 RSDisplayNodeConfig config; 1282 Point startPoint; 1283 int res = 0; 1284 sessionGroup.InitRSDisplayNode(config, startPoint); 1285 ASSERT_EQ(res, 0); 1286 GTEST_LOG_(INFO) << "ScreenSessionTest: InitRSDisplayNode end"; 1287 } 1288 1289 /** 1290 * @tc.name: GetRSDisplayNodeConfig 1291 * @tc.desc: normal function 1292 * @tc.type: FUNC 1293 */ 1294 HWTEST_F(ScreenSessionTest, GetRSDisplayNodeConfig, Function | SmallTest | Level2) 1295 { 1296 GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig start"; 1297 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1298 sptr<ScreenSession> session0 = nullptr; 1299 RSDisplayNodeConfig config = {1}; 1300 sptr<ScreenSession> defaultScreenSession; 1301 bool res = sessionGroup.GetRSDisplayNodeConfig(session0, config, defaultScreenSession); 1302 ASSERT_EQ(res, false); 1303 1304 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1305 sessionGroup.combination_ = ScreenCombination::SCREEN_ALONE; 1306 res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession); 1307 ASSERT_EQ(res, true); 1308 1309 sessionGroup.combination_ = ScreenCombination::SCREEN_EXPAND; 1310 res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession); 1311 ASSERT_EQ(res, true); 1312 1313 sessionGroup.combination_ = ScreenCombination::SCREEN_MIRROR; 1314 res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession); 1315 ASSERT_EQ(res, true); 1316 GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig end"; 1317 } 1318 1319 /** 1320 * @tc.name: AddChild 1321 * @tc.desc: normal function 1322 * @tc.type: FUNC 1323 */ 1324 HWTEST_F(ScreenSessionTest, AddChild, Function | SmallTest | Level2) 1325 { 1326 GTEST_LOG_(INFO) << "ScreenSessionTest: AddChild start"; 1327 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1328 sptr<ScreenSession> session0 = nullptr; 1329 Point startPoint(0, 0); 1330 sptr<ScreenSession> defaultScreenSession; 1331 bool res = sessionGroup.AddChild(session0, startPoint, defaultScreenSession); 1332 ASSERT_EQ(res, false); 1333 1334 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1335 res = sessionGroup.AddChild(session, startPoint, defaultScreenSession); 1336 ASSERT_EQ(res, true); 1337 GTEST_LOG_(INFO) << "ScreenSessionTest: AddChild end"; 1338 } 1339 1340 /** 1341 * @tc.name: AddChildren 1342 * @tc.desc: normal function 1343 * @tc.type: FUNC 1344 */ 1345 HWTEST_F(ScreenSessionTest, AddChildren, Function | SmallTest | Level2) 1346 { 1347 GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren start"; 1348 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1349 std::vector<sptr<ScreenSession>> smsScreens; 1350 std::vector<Point> startPoints; 1351 bool res = sessionGroup.AddChildren(smsScreens, startPoints); 1352 ASSERT_EQ(res, true); 1353 GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren end"; 1354 } 1355 1356 /** 1357 * @tc.name: RemoveChild 1358 * @tc.desc: normal function 1359 * @tc.type: FUNC 1360 */ 1361 HWTEST_F(ScreenSessionTest, RemoveChild, Function | SmallTest | Level2) 1362 { 1363 GTEST_LOG_(INFO) << "ScreenSessionTest: RemoveChild start"; 1364 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1365 sptr<ScreenSession> session0 = nullptr; 1366 bool res = sessionGroup.RemoveChild(session0); 1367 ASSERT_EQ(res, false); 1368 1369 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1370 res = sessionGroup.RemoveChild(session); 1371 ASSERT_EQ(res, false); 1372 GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig end"; 1373 } 1374 1375 /** 1376 * @tc.name: GetChildPosition 1377 * @tc.desc: normal function 1378 * @tc.type: FUNC 1379 */ 1380 HWTEST_F(ScreenSessionTest, GetChildPosition, Function | SmallTest | Level2) 1381 { 1382 GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildPosition start"; 1383 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1384 ScreenId screenId = 1; 1385 Point res = sessionGroup.GetChildPosition(screenId); 1386 ASSERT_EQ(res.posX_, 0); 1387 GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildPosition end"; 1388 } 1389 1390 /** 1391 * @tc.name: ConvertToScreenGroupInfo 1392 * @tc.desc: normal function 1393 * @tc.type: FUNC 1394 */ 1395 HWTEST_F(ScreenSessionTest, ConvertToScreenGroupInfo, Function | SmallTest | Level2) 1396 { 1397 GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToScreenGroupInfo start"; 1398 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1399 sptr<ScreenGroupInfo> res = sessionGroup.ConvertToScreenGroupInfo(); 1400 ASSERT_NE(res, nullptr); 1401 GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToScreenGroupInfo end"; 1402 } 1403 1404 /** 1405 * @tc.name: RegisterScreenChangeListener 1406 * @tc.desc: normal function 1407 * @tc.type: FUNC 1408 */ 1409 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener01, Function | SmallTest | Level2) 1410 { 1411 GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener start"; 1412 int res = 0; 1413 IScreenChangeListener* screenChangeListener = nullptr; 1414 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1415 session->RegisterScreenChangeListener(screenChangeListener); 1416 ASSERT_EQ(res, 0); 1417 GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener end"; 1418 } 1419 1420 /** 1421 * @tc.name: RegisterScreenChangeListener 1422 * @tc.desc: Repeat to register 1423 * @tc.type: FUNC 1424 */ 1425 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener02, Function | SmallTest | Level2) 1426 { 1427 GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener start"; 1428 IScreenChangeListener* screenChangeListener = new MockScreenChangeListener(); 1429 IScreenChangeListener* screenChangeListener1 = new MockScreenChangeListener(); 1430 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1431 session->RegisterScreenChangeListener(screenChangeListener); 1432 session->RegisterScreenChangeListener(screenChangeListener1); 1433 ASSERT_FALSE(session->isFold_); 1434 } 1435 1436 /** 1437 * @tc.name: RegisterScreenChangeListener 1438 * @tc.desc: screenState_ == ScreenState::CONNECTION 1439 * @tc.type: FUNC 1440 */ 1441 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener03, Function | SmallTest | Level2) 1442 { 1443 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1444 ASSERT_EQ(session->screenState_, ScreenState::INIT); 1445 session->screenState_ = ScreenState::CONNECTION; 1446 IScreenChangeListener* screenChangeListener = new MockScreenChangeListener(); 1447 session->RegisterScreenChangeListener(screenChangeListener); 1448 ASSERT_FALSE(session->isFold_); 1449 session->screenState_ = ScreenState::INIT; 1450 } 1451 1452 /** 1453 * @tc.name: Connect 1454 * @tc.desc: Connect 1455 * @tc.type: FUNC 1456 */ 1457 HWTEST_F(ScreenSessionTest, Connect, Function | SmallTest | Level2) 1458 { 1459 IScreenChangeListener* screenChangeListener = new MockScreenChangeListener(); 1460 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1461 session->RegisterScreenChangeListener(screenChangeListener); 1462 session->Connect(); 1463 ASSERT_FALSE(session->isFold_); 1464 } 1465 1466 /** 1467 * @tc.name: UpdatePropertyByActiveMode 1468 * @tc.desc: normal function 1469 * @tc.type: FUNC 1470 */ 1471 HWTEST_F(ScreenSessionTest, UpdatePropertyByActiveMode, Function | SmallTest | Level2) 1472 { 1473 GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByActiveMode start"; 1474 int res = 0; 1475 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1476 session->UpdatePropertyByActiveMode(); 1477 ASSERT_EQ(res, 0); 1478 GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByActiveMode end"; 1479 } 1480 1481 /** 1482 * @tc.name: Disconnect 1483 * @tc.desc: normal function 1484 * @tc.type: FUNC 1485 */ 1486 HWTEST_F(ScreenSessionTest, Disconnect, Function | SmallTest | Level2) 1487 { 1488 GTEST_LOG_(INFO) << "ScreenSessionTest: Disconnect start"; 1489 int res = 0; 1490 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1491 session->Disconnect(); 1492 ASSERT_EQ(res, 0); 1493 GTEST_LOG_(INFO) << "ScreenSessionTest: Disconnect end"; 1494 } 1495 1496 /** 1497 * @tc.name: Disconnect 1498 * @tc.desc: !listener 1499 * @tc.type: FUNC 1500 */ 1501 HWTEST_F(ScreenSessionTest, Disconnect02, Function | SmallTest | Level2) 1502 { 1503 IScreenChangeListener* screenChangeListener = new MockScreenChangeListener(); 1504 IScreenChangeListener* screenChangeListener1 = new MockScreenChangeListener(); 1505 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1506 sptr<ScreenSession> session1 = new(std::nothrow) ScreenSession(); 1507 session->RegisterScreenChangeListener(screenChangeListener); 1508 session1->RegisterScreenChangeListener(screenChangeListener1); 1509 session1->Connect(); 1510 session1->Disconnect(); 1511 ASSERT_FALSE(session->isFold_); 1512 } 1513 1514 /** 1515 * @tc.name: SensorRotationChange 1516 * @tc.desc: normal function 1517 * @tc.type: FUNC 1518 */ 1519 HWTEST_F(ScreenSessionTest, SensorRotationChange01, Function | SmallTest | Level2) 1520 { 1521 GTEST_LOG_(INFO) << "ScreenSessionTest: SensorRotationChange start"; 1522 int res = 0; 1523 Rotation sensorRotation = Rotation::ROTATION_0; 1524 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1525 session->SensorRotationChange(sensorRotation); 1526 ASSERT_EQ(res, 0); 1527 GTEST_LOG_(INFO) << "ScreenSessionTest: SensorRotationChange end"; 1528 } 1529 1530 /** 1531 * @tc.name: SensorRotationChange 1532 * @tc.desc: run in for 1533 * @tc.type: FUNC 1534 */ 1535 HWTEST_F(ScreenSessionTest, SensorRotationChange02, Function | SmallTest | Level2) 1536 { 1537 IScreenChangeListener* screenChangeListener = new MockScreenChangeListener(); 1538 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1539 session->RegisterScreenChangeListener(screenChangeListener); 1540 Rotation sensorRotation = Rotation::ROTATION_90; 1541 session->SensorRotationChange(sensorRotation); 1542 ASSERT_FALSE(session->isFold_); 1543 } 1544 1545 /** 1546 * @tc.name: SetOrientation 1547 * @tc.desc: normal function 1548 * @tc.type: FUNC 1549 */ 1550 HWTEST_F(ScreenSessionTest, SetOrientation, Function | SmallTest | Level2) 1551 { 1552 GTEST_LOG_(INFO) << "ScreenSessionTest: SetOrientation start"; 1553 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1554 Orientation orientation = Orientation::UNSPECIFIED; 1555 session->SetOrientation(orientation); 1556 Orientation res = session->GetOrientation(); 1557 ASSERT_EQ(res, orientation); 1558 GTEST_LOG_(INFO) << "ScreenSessionTest: SetOrientation end"; 1559 } 1560 1561 /** 1562 * @tc.name: SetScreenRequestedOrientation 1563 * @tc.desc: normal function 1564 * @tc.type: FUNC 1565 */ 1566 HWTEST_F(ScreenSessionTest, SetScreenRequestedOrientation, Function | SmallTest | Level2) 1567 { 1568 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRequestedOrientation start"; 1569 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1570 Orientation orientation = Orientation::UNSPECIFIED; 1571 session->SetScreenRequestedOrientation(orientation); 1572 Orientation res = session->GetScreenRequestedOrientation(); 1573 ASSERT_EQ(res, orientation); 1574 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRequestedOrientation end"; 1575 } 1576 1577 /** 1578 * @tc.name: SetUpdateToInputManagerCallback 1579 * @tc.desc: normal function 1580 * @tc.type: FUNC 1581 */ 1582 HWTEST_F(ScreenSessionTest, SetUpdateToInputManagerCallback, Function | SmallTest | Level2) 1583 { 1584 GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateToInputManagerCallback start"; 1585 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); __anon9684af770402(float x) 1586 auto func = [session](float x) { 1587 session->SetVirtualPixelRatio(x); 1588 }; 1589 session->SetUpdateToInputManagerCallback(func); 1590 EXPECT_NE(nullptr, &func); 1591 1592 ScreenProperty screenPropert = session->GetScreenProperty(); 1593 EXPECT_NE(nullptr, &screenPropert); 1594 session->SetVirtualPixelRatio(3.14); 1595 1596 ScreenType screenType { ScreenType::REAL }; 1597 session->SetScreenType(screenType); 1598 1599 GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateToInputManagerCallbackend"; 1600 } 1601 /** 1602 * @tc.name: SetScreenRotationLocked 1603 * @tc.desc: normal function 1604 * @tc.type: FUNC 1605 */ 1606 HWTEST_F(ScreenSessionTest, SetScreenRotationLocked, Function | SmallTest | Level2) 1607 { 1608 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLocked start"; 1609 bool isLocked = true; 1610 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1611 session->SetScreenRotationLocked(isLocked); 1612 bool res = session->IsScreenRotationLocked(); 1613 ASSERT_EQ(res, isLocked); 1614 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLocked end"; 1615 } 1616 1617 /** 1618 * @tc.name: SetScreenRotationLockedFromJs 1619 * @tc.desc: normal function 1620 * @tc.type: FUNC 1621 */ 1622 HWTEST_F(ScreenSessionTest, SetScreenRotationLockedFromJs, Function | SmallTest | Level2) 1623 { 1624 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLockedFromJs start"; 1625 bool isLocked = true; 1626 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1627 session->SetScreenRotationLockedFromJs(isLocked); 1628 bool res = session->IsScreenRotationLocked(); 1629 ASSERT_EQ(res, isLocked); 1630 GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLockedFromJs end"; 1631 } 1632 1633 /** 1634 * @tc.name: IsScreenRotationLocked 1635 * @tc.desc: normal function 1636 * @tc.type: FUNC 1637 */ 1638 HWTEST_F(ScreenSessionTest, IsScreenRotationLocked, Function | SmallTest | Level2) 1639 { 1640 GTEST_LOG_(INFO) << "ScreenSessionTest: IsScreenRotationLocked start"; 1641 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1642 bool res = session->IsScreenRotationLocked(); 1643 ASSERT_EQ(res, session->isScreenLocked_); 1644 GTEST_LOG_(INFO) << "ScreenSessionTest: IsScreenRotationLocked end"; 1645 } 1646 1647 /** 1648 * @tc.name: GetScreenRequestedOrientation 1649 * @tc.desc: normal function 1650 * @tc.type: FUNC 1651 */ 1652 HWTEST_F(ScreenSessionTest, GetScreenRequestedOrientation, Function | SmallTest | Level2) 1653 { 1654 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenRequestedOrientation start"; 1655 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1656 Orientation res = session->GetScreenRequestedOrientation(); 1657 ASSERT_EQ(res, session->property_.GetScreenRequestedOrientation()); 1658 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenRequestedOrientation end"; 1659 } 1660 1661 /** 1662 * @tc.name: SetVirtualPixelRatio 1663 * @tc.desc: normal function 1664 * @tc.type: FUNC 1665 */ 1666 HWTEST_F(ScreenSessionTest, SetVirtualPixelRatio, Function | SmallTest | Level2) 1667 { 1668 GTEST_LOG_(INFO) << "ScreenSessionTest: SetVirtualPixelRatio start"; 1669 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1670 float virtualPixelRatio = 1; 1671 session->SetVirtualPixelRatio(virtualPixelRatio); 1672 float res = session->property_.GetVirtualPixelRatio(); 1673 ASSERT_EQ(res, virtualPixelRatio); 1674 GTEST_LOG_(INFO) << "ScreenSessionTest: SetVirtualPixelRatio end"; 1675 } 1676 1677 /** 1678 * @tc.name: screen_session_test001 1679 * @tc.desc: normal function 1680 * @tc.type: FUNC 1681 */ 1682 HWTEST_F(ScreenSessionTest, screen_session_test001, Function | SmallTest | Level2) 1683 { 1684 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 start"; 1685 IScreenChangeListener* screenChangeListener = nullptr; 1686 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1687 session->screenState_ = ScreenState::CONNECTION; 1688 int res = 0; 1689 session->RegisterScreenChangeListener(screenChangeListener); 1690 ASSERT_EQ(res, 0); 1691 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 end"; 1692 } 1693 1694 /** 1695 * @tc.name: screen_session_test002 1696 * @tc.desc: normal function 1697 * @tc.type: FUNC 1698 */ 1699 HWTEST_F(ScreenSessionTest, screen_session_test002, Function | SmallTest | Level2) 1700 { 1701 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 start"; 1702 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1703 ScreenId res = session->GetScreenId(); 1704 ASSERT_EQ(res, session->screenId_); 1705 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 end"; 1706 } 1707 1708 /** 1709 * @tc.name: screen_session_test003 1710 * @tc.desc: normal function 1711 * @tc.type: FUNC 1712 */ 1713 HWTEST_F(ScreenSessionTest, screen_session_test003, Function | SmallTest | Level2) 1714 { 1715 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 start"; 1716 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1717 DMError res = session->SetScreenColorTransform(); 1718 ASSERT_EQ(res, DMError::DM_OK); 1719 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 end"; 1720 } 1721 1722 /** 1723 * @tc.name: screen_session_test004 1724 * @tc.desc: normal function 1725 * @tc.type: FUNC 1726 */ 1727 HWTEST_F(ScreenSessionTest, screen_session_test004, Function | SmallTest | Level2) 1728 { 1729 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 start"; 1730 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1731 ScreenProperty newProperty; 1732 int res = 0; 1733 session->UpdatePropertyByFoldControl(newProperty); 1734 ASSERT_EQ(res, 0); 1735 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 end"; 1736 } 1737 1738 /** 1739 * @tc.name: screen_session_test005 1740 * @tc.desc: normal function 1741 * @tc.type: FUNC 1742 */ 1743 HWTEST_F(ScreenSessionTest, screen_session_test005, Function | SmallTest | Level2) 1744 { 1745 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 start"; 1746 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1747 ScreenProperty newProperty; 1748 ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::CHANGE_MODE; 1749 int res = 0; 1750 session->PropertyChange(newProperty, reason); 1751 ASSERT_EQ(res, 0); 1752 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 end"; 1753 } 1754 1755 /** 1756 * @tc.name: screen_session_test006 1757 * @tc.desc: normal function 1758 * @tc.type: FUNC 1759 */ 1760 HWTEST_F(ScreenSessionTest, screen_session_test006, Function | SmallTest | Level2) 1761 { 1762 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 start"; 1763 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1764 Rotation sensorRotation = Rotation::ROTATION_90; 1765 float res = session->ConvertRotationToFloat(sensorRotation); 1766 ASSERT_EQ(res, 90.f); 1767 sensorRotation = Rotation::ROTATION_180; 1768 res = session->ConvertRotationToFloat(sensorRotation); 1769 ASSERT_EQ(res, 180.f); 1770 sensorRotation = Rotation::ROTATION_270; 1771 res = session->ConvertRotationToFloat(sensorRotation); 1772 ASSERT_EQ(res, 270.f); 1773 sensorRotation = Rotation::ROTATION_0; 1774 res = session->ConvertRotationToFloat(sensorRotation); 1775 ASSERT_EQ(res, 0.f); 1776 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 end"; 1777 } 1778 1779 /** 1780 * @tc.name: screen_session_test007 1781 * @tc.desc: normal function 1782 * @tc.type: FUNC 1783 */ 1784 HWTEST_F(ScreenSessionTest, screen_session_test007, Function | SmallTest | Level2) 1785 { 1786 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 start"; 1787 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1788 Orientation orientation = Orientation::UNSPECIFIED; 1789 int res = 0; 1790 session->ScreenOrientationChange(orientation, FoldDisplayMode::UNKNOWN); 1791 ASSERT_EQ(res, 0); 1792 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 end"; 1793 } 1794 1795 /** 1796 * @tc.name: screen_session_test008 1797 * @tc.desc: normal function 1798 * @tc.type: FUNC 1799 */ 1800 HWTEST_F(ScreenSessionTest, screen_session_test008, Function | SmallTest | Level2) 1801 { 1802 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 start"; 1803 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1804 bool res = session->HasPrivateSessionForeground(); 1805 ASSERT_EQ(res, false); 1806 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 end"; 1807 } 1808 1809 /** 1810 * @tc.name: screen_session_test009 1811 * @tc.desc: normal function 1812 * @tc.type: FUNC 1813 */ 1814 HWTEST_F(ScreenSessionTest, screen_session_test009, Function | SmallTest | Level2) 1815 { 1816 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 start"; 1817 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1818 Rotation rotation = Rotation::ROTATION_90; 1819 session->SetRotation(rotation); 1820 Rotation res = session->GetRotation(); 1821 ASSERT_EQ(res, rotation); 1822 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 end"; 1823 } 1824 1825 /** 1826 * @tc.name: screen_session_test010 1827 * @tc.desc: normal function 1828 * @tc.type: FUNC 1829 */ 1830 HWTEST_F(ScreenSessionTest, screen_session_test010, Function | SmallTest | Level2) 1831 { 1832 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 start"; 1833 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1834 ScreenId childScreen = 1; 1835 bool res = sessionGroup.HasChild(childScreen); 1836 ASSERT_EQ(res, false); 1837 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 end"; 1838 } 1839 1840 /** 1841 * @tc.name: screen_session_test011 1842 * @tc.desc: normal function 1843 * @tc.type: FUNC 1844 */ 1845 HWTEST_F(ScreenSessionTest, screen_session_test011, Function | SmallTest | Level2) 1846 { 1847 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 start"; 1848 ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE); 1849 std::vector<sptr<ScreenSession>> res = sessionGroup.GetChildren(); 1850 ASSERT_EQ(res.empty(), true); 1851 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 end"; 1852 } 1853 1854 /** 1855 * @tc.name: screen_session_test012 1856 * @tc.desc: normal function 1857 * @tc.type: FUNC 1858 */ 1859 HWTEST_F(ScreenSessionTest, screen_session_test012, Function | SmallTest | Level2) 1860 { 1861 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 start"; 1862 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1863 int res = 0; 1864 RectF rect = RectF(0, 0, 0, 0); 1865 uint32_t offsetY = 0; 1866 session->SetDisplayBoundary(rect, offsetY); 1867 ASSERT_EQ(res, 0); 1868 GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 end"; 1869 } 1870 1871 /** 1872 * @tc.name: GetName 1873 * @tc.desc: normal function 1874 * @tc.type: FUNC 1875 */ 1876 HWTEST_F(ScreenSessionTest, GetName, Function | SmallTest | Level2) 1877 { 1878 GTEST_LOG_(INFO) << "ScreenSessionTest: GetName start"; 1879 std::string name { "UNKNOWN" }; 1880 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1881 ASSERT_EQ(name, session->GetName()); 1882 GTEST_LOG_(INFO) << "ScreenSessionTest: GetName end"; 1883 } 1884 1885 /** 1886 * @tc.name: SetName 1887 * @tc.desc: normal function 1888 * @tc.type: FUNC 1889 */ 1890 HWTEST_F(ScreenSessionTest, SetName, Function | SmallTest | Level2) 1891 { 1892 GTEST_LOG_(INFO) << "ScreenSessionTest: SetName start"; 1893 std::string name { "UNKNOWN" }; 1894 int ret = 0; 1895 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1896 session->SetName(name); 1897 ASSERT_EQ(ret, 0); 1898 GTEST_LOG_(INFO) << "ScreenSessionTest: SetName end"; 1899 } 1900 1901 /** 1902 * @tc.name: GetScreenSnapshot 1903 * @tc.desc: normal function 1904 * @tc.type: FUNC 1905 */ 1906 HWTEST_F(ScreenSessionTest, GetScreenSnapshot, Function | SmallTest | Level2) 1907 { 1908 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSnapshot start"; 1909 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1910 session->displayNode_ = nullptr; 1911 auto pixelmap = session->GetScreenSnapshot(1.0, 1.0); 1912 EXPECT_EQ(pixelmap, nullptr); 1913 1914 ScreenProperty newScreenProperty; 1915 session = new(std::nothrow) ScreenSession(0, newScreenProperty, 0); 1916 pixelmap = session->GetScreenSnapshot(1.0, 1.0); 1917 int ret = 0; 1918 ASSERT_EQ(ret, 0); 1919 GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSnapshot end"; 1920 } 1921 1922 /** 1923 * @tc.name: GetRSScreenId 1924 * @tc.desc: normal function 1925 * @tc.type: FUNC 1926 */ 1927 HWTEST_F(ScreenSessionTest, GetRSScreenId, Function | SmallTest | Level2) 1928 { 1929 GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSScreenId start"; 1930 ScreenProperty property; 1931 sptr<ScreenSession> session = new(std::nothrow) 1932 ScreenSession("OpenHarmony", 1, 100, 0); 1933 EXPECT_EQ(100, session->GetRSScreenId()); 1934 1935 RSDisplayNodeConfig displayNodeConfig; 1936 std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig); 1937 session = new ScreenSession(1, 100, "OpenHarmony", 1938 property, displayNode); 1939 EXPECT_NE(nullptr, session->GetDisplayNode()); 1940 session->ReleaseDisplayNode(); 1941 EXPECT_EQ(nullptr, session->GetDisplayNode()); 1942 GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSScreenId end"; 1943 } 1944 1945 /** 1946 * @tc.name: CalcRotation 1947 * @tc.desc: normal function 1948 * @tc.type: FUNC 1949 */ 1950 HWTEST_F(ScreenSessionTest, CalcRotation, Function | SmallTest | Level2) 1951 { 1952 GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation start"; 1953 Orientation orientation { Orientation::BEGIN }; 1954 FoldDisplayMode foldDisplayMode { FoldDisplayMode::COORDINATION }; 1955 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 1956 session->activeIdx_ = -1; 1957 auto res = session->CalcRotation(orientation, foldDisplayMode); 1958 EXPECT_EQ(Rotation::ROTATION_0, res); 1959 1960 sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes; 1961 supportedScreenModes->width_ = 40; 1962 supportedScreenModes->height_ = 20; 1963 session->modes_ = { supportedScreenModes }; 1964 session->activeIdx_ = 0; 1965 1966 orientation = Orientation::UNSPECIFIED; 1967 res = session->CalcRotation(orientation, foldDisplayMode); 1968 EXPECT_EQ(Rotation::ROTATION_0, res); 1969 1970 orientation = Orientation::VERTICAL; 1971 res = session->CalcRotation(orientation, foldDisplayMode); 1972 if (ScreenSessionManager::GetInstance().IsFoldable()) { 1973 EXPECT_EQ(Rotation::ROTATION_0, res); 1974 } else { 1975 EXPECT_EQ(Rotation::ROTATION_90, res); 1976 } 1977 1978 orientation = Orientation::HORIZONTAL; 1979 res = session->CalcRotation(orientation, foldDisplayMode); 1980 if (ScreenSessionManager::GetInstance().IsFoldable()) { 1981 EXPECT_EQ(Rotation::ROTATION_90, res); 1982 } else { 1983 EXPECT_EQ(Rotation::ROTATION_0, res); 1984 } 1985 1986 orientation = Orientation::REVERSE_VERTICAL; 1987 res = session->CalcRotation(orientation, foldDisplayMode); 1988 if (ScreenSessionManager::GetInstance().IsFoldable()) { 1989 EXPECT_EQ(Rotation::ROTATION_180, res); 1990 } else { 1991 EXPECT_EQ(Rotation::ROTATION_270, res); 1992 } 1993 1994 orientation = Orientation::REVERSE_HORIZONTAL; 1995 res = session->CalcRotation(orientation, foldDisplayMode); 1996 if (ScreenSessionManager::GetInstance().IsFoldable()) { 1997 EXPECT_EQ(Rotation::ROTATION_270, res); 1998 } else { 1999 EXPECT_EQ(Rotation::ROTATION_180, res); 2000 } 2001 2002 orientation = Orientation::LOCKED; 2003 res = session->CalcRotation(orientation, foldDisplayMode); 2004 EXPECT_EQ(Rotation::ROTATION_0, res); 2005 2006 GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation end"; 2007 } 2008 2009 /** 2010 * @tc.name: CalcDisplayOrientation 2011 * @tc.desc: normal function 2012 * @tc.type: FUNC 2013 */ 2014 HWTEST_F(ScreenSessionTest, CalcDisplayOrientation, Function | SmallTest | Level2) 2015 { 2016 GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation start"; 2017 Rotation rotation { Rotation::ROTATION_0 }; 2018 FoldDisplayMode foldDisplayMode { FoldDisplayMode::COORDINATION }; 2019 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 2020 session->activeIdx_ = -1; 2021 auto res = session->CalcDisplayOrientation(rotation, foldDisplayMode); 2022 EXPECT_EQ(DisplayOrientation::LANDSCAPE, res); 2023 2024 sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes; 2025 supportedScreenModes->width_ = 40; 2026 supportedScreenModes->height_ = 20; 2027 session->modes_ = { supportedScreenModes }; 2028 session->activeIdx_ = 0; 2029 2030 rotation = Rotation::ROTATION_0; 2031 res = session->CalcDisplayOrientation(rotation, foldDisplayMode); 2032 EXPECT_EQ(DisplayOrientation::LANDSCAPE, res); 2033 2034 rotation = Rotation::ROTATION_90; 2035 res = session->CalcDisplayOrientation(rotation, foldDisplayMode); 2036 EXPECT_EQ(DisplayOrientation::PORTRAIT, res); 2037 2038 rotation = Rotation::ROTATION_180; 2039 res = session->CalcDisplayOrientation(rotation, foldDisplayMode); 2040 EXPECT_EQ(DisplayOrientation::LANDSCAPE_INVERTED, res); 2041 2042 rotation = Rotation::ROTATION_270; 2043 res = session->CalcDisplayOrientation(rotation, foldDisplayMode); 2044 EXPECT_EQ(DisplayOrientation::PORTRAIT_INVERTED, res); 2045 2046 GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation end"; 2047 } 2048 2049 /** 2050 * @tc.name: FillScreenInfo 2051 * @tc.desc: normal function 2052 * @tc.type: FUNC 2053 */ 2054 HWTEST_F(ScreenSessionTest, FillScreenInfo, Function | SmallTest | Level2) 2055 { 2056 GTEST_LOG_(INFO) << "ScreenSessionTest: FillScreenInfo start"; 2057 ScreenProperty property; 2058 property.SetVirtualPixelRatio(3.1415927); 2059 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(2024, property, 0); 2060 sptr<ScreenInfo> info = nullptr; 2061 session->FillScreenInfo(info); 2062 2063 sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes; 2064 session->modes_ = { supportedScreenModes }; 2065 supportedScreenModes->width_ = 40; 2066 supportedScreenModes->height_ = 20; 2067 info = new ScreenInfo; 2068 session->FillScreenInfo(info); 2069 EXPECT_NE(nullptr, info); 2070 GTEST_LOG_(INFO) << "ScreenSessionTest: FillScreenInfo end"; 2071 } 2072 2073 /** 2074 * @tc.name: SetScreenScale 2075 * @tc.desc: SetScreenScale test 2076 * @tc.type: FUNC 2077 */ 2078 HWTEST_F(ScreenSessionTest, SetScreenScale, Function | SmallTest | Level2) 2079 { 2080 ScreenSession session; 2081 float scaleX = 1.0f; 2082 float scaleY = 1.0f; 2083 float pivotX = 0.5f; 2084 float pivotY = 0.5f; 2085 float translateX = 0.0f; 2086 float translateY = 0.0f; 2087 session.SetScreenScale(scaleX, scaleY, pivotX, pivotY, translateX, translateY); 2088 EXPECT_EQ(session.property_.GetScaleX(), scaleX); 2089 EXPECT_EQ(session.property_.GetScaleY(), scaleY); 2090 EXPECT_EQ(session.property_.GetPivotX(), pivotX); 2091 EXPECT_EQ(session.property_.GetPivotY(), pivotY); 2092 EXPECT_EQ(session.property_.GetTranslateX(), translateX); 2093 EXPECT_EQ(session.property_.GetTranslateY(), translateY); 2094 } 2095 2096 /** 2097 * @tc.name: HoverStatusChange01 2098 * @tc.desc: normal function 2099 * @tc.type: FUNC 2100 */ 2101 HWTEST_F(ScreenSessionTest, HoverStatusChange01, Function | SmallTest | Level2) 2102 { 2103 GTEST_LOG_(INFO) << "HoverStatusChange start"; 2104 ScreenSessionConfig config = { 2105 .screenId = 100, 2106 .rsId = 101, 2107 .name = "OpenHarmony", 2108 }; 2109 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); 2110 EXPECT_NE(nullptr, screenSession); 2111 int32_t HoverStatus = 0; 2112 screenSession->HoverStatusChange(HoverStatus); 2113 GTEST_LOG_(INFO) << "HoverStatusChange end"; 2114 } 2115 2116 /** 2117 * @tc.name: HoverStatusChange02 2118 * @tc.desc: run in for 2119 * @tc.type: FUNC 2120 */ 2121 HWTEST_F(ScreenSessionTest, HoverStatusChange02, Function | SmallTest | Level2) 2122 { 2123 IScreenChangeListener* screenChangeListener = new MockScreenChangeListener(); 2124 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 2125 EXPECT_NE(nullptr, session); 2126 session->RegisterScreenChangeListener(screenChangeListener); 2127 int32_t hoverStatus = 0; 2128 session->HoverStatusChange(hoverStatus); 2129 } 2130 2131 /** 2132 * @tc.name: HandleHoverStatusChange01 2133 * @tc.desc: run in for 2134 * @tc.type: FUNC 2135 */ 2136 HWTEST_F(ScreenSessionTest, HandleHoverStatusChange01, Function | SmallTest | Level2) 2137 { 2138 IScreenChangeListener* screenChangeListener = new MockScreenChangeListener(); 2139 sptr<ScreenSession> session = new(std::nothrow) ScreenSession(); 2140 EXPECT_NE(nullptr, session); 2141 session->RegisterScreenChangeListener(screenChangeListener); 2142 int32_t hoverStatus = 0; 2143 session->HandleHoverStatusChange(hoverStatus); 2144 } 2145 2146 /** 2147 * @tc.name: ScreenCaptureNotify 2148 * @tc.desc: ScreenCaptureNotify test 2149 * @tc.type: FUNC 2150 */ 2151 HWTEST_F(ScreenSessionTest, ScreenCaptureNotify, Function | SmallTest | Level2) 2152 { 2153 sptr<ScreenSession> session = new ScreenSession(); 2154 ASSERT_NE(session, nullptr); 2155 ScreenId screenId = 0; 2156 int32_t uid = 0; 2157 std::string clientName = "test"; 2158 session->ScreenCaptureNotify(screenId, uid, clientName); 2159 } 2160 } // namespace 2161 } // namespace Rosen 2162 } // namespace OHOS 2163