1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "gtest/gtest.h" 17 #define private public 18 #include "start_options_impl.h" 19 #undef private 20 #include "hilog_tag_wrapper.h" 21 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 22 #include "pixelmap_native_impl.h" 23 #endif 24 #include "securec.h" 25 #include "start_window_option.h" 26 27 using namespace testing; 28 29 constexpr int MAX_SUPPOPRT_WINDOW_MODES_SIZE = 10; 30 31 // Test suite 32 class StartOptionsImplTest : public ::testing::Test { 33 protected: SetUp()34 void SetUp() override 35 { 36 // Create a StartOptionsImpl object before each test case 37 startOptions = new AbilityRuntime_StartOptions(); 38 } 39 TearDown()40 void TearDown() override 41 { 42 // Delete the StartOptionsImpl object after each test case 43 delete startOptions; 44 startOptions = nullptr; 45 } 46 47 // Declare a StartOptionsImpl pointer 48 AbilityRuntime_StartOptions* startOptions = nullptr; 49 }; 50 51 // Test cases 52 // Test SetStartOptionsWindowMode function - Normal case 53 /** 54 * @tc.name: SetStartOptionsWindowMode_001 55 * @tc.desc: test class StartOptions number function 56 * @tc.type: FUNC 57 */ 58 HWTEST_F(StartOptionsImplTest, SetStartOptionsWindowMode_001, testing::ext::TestSize.Level1) 59 { 60 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowMode_001 begin"); 61 // Arrange 62 AbilityRuntime_WindowMode windowMode = ABILITY_RUNTIME_WINDOW_MODE_FULL_SCREEN; 63 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 64 65 // Act 66 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsWindowMode(windowMode); 67 TAG_LOGI(AAFwkTag::TEST, 68 "SetStartOptionsWindowMode_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 69 resultErrorCode, expectedErrorCode); 70 71 // Assert 72 EXPECT_EQ(expectedErrorCode, resultErrorCode); 73 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowMode_001 end"); 74 } 75 76 // Test SetStartOptionsWindowMode function - Boundary case 77 /** 78 * @tc.name: SetStartOptionsWindowMode_002 79 * @tc.desc: test class StartOptions number function 80 * @tc.type: FUNC 81 */ 82 HWTEST_F(StartOptionsImplTest, SetStartOptionsWindowMode_002, testing::ext::TestSize.Level1) 83 { 84 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowMode_002 begin"); 85 // Arrange 86 AbilityRuntime_WindowMode windowMode = ABILITY_RUNTIME_WINDOW_MODE_UNDEFINED; 87 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 88 89 // Act 90 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsWindowMode(windowMode); 91 TAG_LOGI(AAFwkTag::TEST, 92 "SetStartOptionsWindowMode_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 93 resultErrorCode, expectedErrorCode); 94 95 // Assert 96 EXPECT_EQ(expectedErrorCode, resultErrorCode); 97 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowMode_002 end"); 98 } 99 100 // Test SetStartOptionsWindowMode function - Exception case 101 /** 102 * @tc.name: SetStartOptionsWindowMode_003 103 * @tc.desc: test class StartOptions number function 104 * @tc.type: FUNC 105 */ 106 HWTEST_F(StartOptionsImplTest, SetStartOptionsWindowMode_003, testing::ext::TestSize.Level1) 107 { 108 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowMode_003 begin"); 109 // Arrange 110 // Assuming 100 is outside the enum definition range 111 AbilityRuntime_WindowMode windowMode = static_cast<AbilityRuntime_WindowMode>(100); 112 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; 113 114 // Act 115 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsWindowMode(windowMode); 116 TAG_LOGI(AAFwkTag::TEST, 117 "SetStartOptionsWindowMode_003 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 118 resultErrorCode, expectedErrorCode); 119 120 // Assert 121 EXPECT_EQ(expectedErrorCode, resultErrorCode); 122 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowMode_003 end"); 123 } 124 125 // Test cases 126 // Test GetStartOptionsWindowMode function - Normal case 127 /** 128 * @tc.name: GetStartOptionsWindowMode_001 129 * @tc.desc: test class StartOptions number function 130 * @tc.type: FUNC 131 */ 132 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowMode_001, testing::ext::TestSize.Level1) 133 { 134 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowMode_001 begin"); 135 // Arrange 136 AbilityRuntime_WindowMode expectedWindowMode = ABILITY_RUNTIME_WINDOW_MODE_FULL_SCREEN; 137 startOptions->SetStartOptionsWindowMode(expectedWindowMode); 138 AbilityRuntime_WindowMode windowMode; 139 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 140 141 // Act 142 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowMode(windowMode); 143 TAG_LOGI(AAFwkTag::TEST, 144 "GetStartOptionsWindowMode_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 145 resultErrorCode, expectedErrorCode); 146 147 // Assert 148 EXPECT_EQ(expectedErrorCode, resultErrorCode); 149 EXPECT_EQ(expectedWindowMode, windowMode); 150 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowMode_001 end"); 151 } 152 153 // Test cases 154 // Test SetStartOptionsDisplayId function - Normal case 155 /** 156 * @tc.name: SetStartOptionsDisplayId_001 157 * @tc.desc: test class StartOptions number function 158 * @tc.type: FUNC 159 */ 160 HWTEST_F(StartOptionsImplTest, SetStartOptionsDisplayId_001, testing::ext::TestSize.Level1) 161 { 162 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsDisplayId_001 begin"); 163 // Arrange 164 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 165 166 // Act 167 int32_t displayId = 10; 168 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsDisplayId(displayId); 169 TAG_LOGI(AAFwkTag::TEST, 170 "SetStartOptionsDisplayId_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 171 resultErrorCode, expectedErrorCode); 172 173 // Assert 174 EXPECT_EQ(expectedErrorCode, resultErrorCode); 175 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsDisplayId_001 end"); 176 } 177 178 // Test cases 179 // Test GetStartOptionsDisplayId function - Normal case 180 /** 181 * @tc.name: GetStartOptionsDisplayId_001 182 * @tc.desc: test class StartOptions number function 183 * @tc.type: FUNC 184 */ 185 HWTEST_F(StartOptionsImplTest, GetStartOptionsDisplayId_001, testing::ext::TestSize.Level1) 186 { 187 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsDisplayId_001 begin"); 188 // Arrange 189 int32_t expectedDisplayId = 10; 190 startOptions->SetStartOptionsDisplayId(expectedDisplayId); 191 int32_t displayId; 192 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 193 194 // Act 195 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsDisplayId(displayId); 196 TAG_LOGI(AAFwkTag::TEST, 197 "GetStartOptionsDisplayId_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 198 resultErrorCode, expectedErrorCode); 199 200 // Assert 201 EXPECT_EQ(expectedErrorCode, resultErrorCode); 202 EXPECT_EQ(expectedDisplayId, displayId); 203 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsDisplayId_001 end"); 204 } 205 206 // Test cases 207 // Test SetStartOptionsWithAnimation function - Normal case 208 /** 209 * @tc.name: SetStartOptionsWithAnimation_001 210 * @tc.desc: test class StartOptions number function 211 * @tc.type: FUNC 212 */ 213 HWTEST_F(StartOptionsImplTest, SetStartOptionsWithAnimation_001, testing::ext::TestSize.Level1) 214 { 215 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWithAnimation_001 begin"); 216 // Arrange 217 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 218 219 // Act 220 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsWithAnimation(true); 221 TAG_LOGI(AAFwkTag::TEST, 222 "SetStartOptionsWithAnimation_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 223 resultErrorCode, expectedErrorCode); 224 225 // Assert 226 EXPECT_EQ(expectedErrorCode, resultErrorCode); 227 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWithAnimation_001 end"); 228 } 229 230 // Test cases 231 // Test GetStartOptionsWithAnimation function - Normal case 232 /** 233 * @tc.name: GetStartOptionsWithAnimation_001 234 * @tc.desc: test class StartOptions number function 235 * @tc.type: FUNC 236 */ 237 HWTEST_F(StartOptionsImplTest, GetStartOptionsWithAnimation_001, testing::ext::TestSize.Level1) 238 { 239 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWithAnimation_001 begin"); 240 // Arrange 241 bool expectedWithAnimation = true; 242 startOptions->SetStartOptionsWithAnimation(expectedWithAnimation); 243 bool withAnimation; 244 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 245 246 // Act 247 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWithAnimation(withAnimation); 248 TAG_LOGI(AAFwkTag::TEST, 249 "GetStartOptionsWithAnimation_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 250 resultErrorCode, expectedErrorCode); 251 252 // Assert 253 EXPECT_EQ(expectedErrorCode, resultErrorCode); 254 EXPECT_EQ(expectedWithAnimation, withAnimation); 255 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWithAnimation_001 end"); 256 } 257 258 // Test cases 259 // Test SetStartOptionsWindowLeft function - Normal case 260 /** 261 * @tc.name: SetStartOptionsWindowLeft_001 262 * @tc.desc: test class StartOptions number function 263 * @tc.type: FUNC 264 */ 265 HWTEST_F(StartOptionsImplTest, SetStartOptionsWindowLeft_001, testing::ext::TestSize.Level1) 266 { 267 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowLeft_001 begin"); 268 // Arrange 269 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 270 271 // Act 272 int32_t windowLeft = 100; 273 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsWindowLeft(windowLeft); 274 TAG_LOGI(AAFwkTag::TEST, 275 "SetStartOptionsWindowLeft_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 276 resultErrorCode, expectedErrorCode); 277 278 // Assert 279 EXPECT_EQ(expectedErrorCode, resultErrorCode); 280 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowLeft_001 end"); 281 } 282 283 // Test cases 284 // Test GetStartOptionsWindowLeft function - Normal case 285 /** 286 * @tc.name: GetStartOptionsWindowLeft_001 287 * @tc.desc: test class StartOptions number function 288 * @tc.type: FUNC 289 */ 290 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowLeft_001, testing::ext::TestSize.Level1) 291 { 292 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowLeft_001 begin"); 293 // Arrange 294 int32_t expectedWindowLeft = 500; 295 startOptions->SetStartOptionsWindowLeft(expectedWindowLeft); 296 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 297 298 // Act 299 int32_t windowLeft = 500; 300 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowLeft(windowLeft); 301 TAG_LOGI(AAFwkTag::TEST, 302 "GetStartOptionsWindowLeft_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 303 resultErrorCode, expectedErrorCode); 304 305 // Assert 306 EXPECT_EQ(expectedErrorCode, resultErrorCode); 307 EXPECT_EQ(expectedWindowLeft, windowLeft); 308 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowLeft_001 end"); 309 } 310 311 // Test cases 312 // Test GetStartOptionsWindowLeft function 313 /** 314 * @tc.name: GetStartOptionsWindowLeft_002 315 * @tc.desc: test class StartOptions number function 316 * @tc.type: FUNC 317 */ 318 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowLeft_002, testing::ext::TestSize.Level1) 319 { 320 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowLeft_002 begin"); 321 // Arrange 322 int32_t expectedWindowLeft = -100; 323 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 324 325 // Act 326 int32_t windowLeft = -100; 327 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowLeft(windowLeft); 328 TAG_LOGI(AAFwkTag::TEST, 329 "GetStartOptionsWindowLeft_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 330 resultErrorCode, expectedErrorCode); 331 332 // Assert 333 EXPECT_EQ(expectedErrorCode, resultErrorCode); 334 EXPECT_EQ(expectedWindowLeft, windowLeft); 335 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowLeft_002 end"); 336 } 337 338 // Test cases 339 // Test SetStartOptionsWindowTop function - Normal case 340 /** 341 * @tc.name: SetStartOptionsWindowTop_001 342 * @tc.desc: test class StartOptions number function 343 * @tc.type: FUNC 344 */ 345 HWTEST_F(StartOptionsImplTest, SetStartOptionsWindowTop_001, testing::ext::TestSize.Level1) 346 { 347 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowTop_001 begin"); 348 // Arrange 349 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 350 351 // Act 352 int32_t windowTop = 100; 353 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsWindowTop(windowTop); 354 TAG_LOGI(AAFwkTag::TEST, 355 "SetStartOptionsWindowTop_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 356 resultErrorCode, expectedErrorCode); 357 358 // Assert 359 EXPECT_EQ(expectedErrorCode, resultErrorCode); 360 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowTop_001 end"); 361 } 362 363 // Test cases 364 // Test GetStartOptionsWindowTop function - Normal case 365 /** 366 * @tc.name: GetStartOptionsWindowTop_001 367 * @tc.desc: test class StartOptions number function 368 * @tc.type: FUNC 369 */ 370 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowTop_001, testing::ext::TestSize.Level1) 371 { 372 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowTop_001 begin"); 373 // Arrange 374 int32_t expectedWindowTop = 500; 375 startOptions->SetStartOptionsWindowTop(expectedWindowTop); 376 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 377 378 // Act 379 int32_t windowTop = 500; 380 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowTop(windowTop); 381 TAG_LOGI(AAFwkTag::TEST, 382 "GetStartOptionsWindowTop_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 383 resultErrorCode, expectedErrorCode); 384 385 // Assert 386 EXPECT_EQ(expectedErrorCode, resultErrorCode); 387 EXPECT_EQ(expectedWindowTop, windowTop); 388 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowTop_001 end"); 389 } 390 391 // Test cases 392 // Test GetStartOptionsWindowTop function 393 /** 394 * @tc.name: GetStartOptionsWindowTop_002 395 * @tc.desc: test class StartOptions number function 396 * @tc.type: FUNC 397 */ 398 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowTop_002, testing::ext::TestSize.Level1) 399 { 400 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowTop_002 begin"); 401 // Arrange 402 int32_t expectedWindowTop = 500; 403 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 404 405 // Act 406 int32_t windowTop = 500; 407 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowTop(windowTop); 408 TAG_LOGI(AAFwkTag::TEST, 409 "GetStartOptionsWindowTop_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 410 resultErrorCode, expectedErrorCode); 411 412 // Assert 413 EXPECT_EQ(expectedErrorCode, resultErrorCode); 414 EXPECT_EQ(expectedWindowTop, windowTop); 415 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowTop_002 end"); 416 } 417 418 // Test cases 419 // Test SetStartOptionsWindowHeight function - Normal case 420 /** 421 * @tc.name: SetStartOptionsWindowHeight_001 422 * @tc.desc: test class StartOptions number function 423 * @tc.type: FUNC 424 */ 425 HWTEST_F(StartOptionsImplTest, SetStartOptionsWindowHeight_001, testing::ext::TestSize.Level1) 426 { 427 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowHeight_001 begin"); 428 // Arrange 429 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 430 431 // Act 432 int32_t windowHeight = 100; 433 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsWindowHeight(windowHeight); 434 TAG_LOGI(AAFwkTag::TEST, 435 "SetStartOptionsWindowHeight_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 436 resultErrorCode, expectedErrorCode); 437 438 // Assert 439 EXPECT_EQ(expectedErrorCode, resultErrorCode); 440 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowHeight_001 end"); 441 } 442 443 // Test cases 444 // Test GetStartOptionsWindowHeight function - Normal case 445 /** 446 * @tc.name: GetStartOptionsWindowHeight_001 447 * @tc.desc: test class StartOptions number function 448 * @tc.type: FUNC 449 */ 450 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowHeight_001, testing::ext::TestSize.Level1) 451 { 452 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowHeight_001 begin"); 453 // Arrange 454 int32_t expectedWindowHeight = 500; 455 startOptions->SetStartOptionsWindowHeight(expectedWindowHeight); 456 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 457 458 // Act 459 int32_t windowHeight = 500; 460 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowHeight(windowHeight); 461 TAG_LOGI(AAFwkTag::TEST, 462 "GetStartOptionsWindowHeight_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 463 resultErrorCode, expectedErrorCode); 464 465 // Assert 466 EXPECT_EQ(expectedErrorCode, resultErrorCode); 467 EXPECT_EQ(expectedWindowHeight, windowHeight); 468 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowHeight_001 end"); 469 } 470 471 // Test cases 472 // Test GetStartOptionsWindowHeight function 473 /** 474 * @tc.name: GetStartOptionsWindowHeight_002 475 * @tc.desc: test class StartOptions number function 476 * @tc.type: FUNC 477 */ 478 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowHeight_002, testing::ext::TestSize.Level1) 479 { 480 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowHeight_002 begin"); 481 // Arrange 482 int32_t expectedWindowHeight = 500; 483 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 484 485 // Act 486 int32_t windowHeight = 500; 487 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowHeight(windowHeight); 488 TAG_LOGI(AAFwkTag::TEST, 489 "GetStartOptionsWindowHeight_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 490 resultErrorCode, expectedErrorCode); 491 492 // Assert 493 EXPECT_EQ(expectedErrorCode, resultErrorCode); 494 EXPECT_EQ(expectedWindowHeight, windowHeight); 495 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowHeight_002 end"); 496 } 497 498 // Test cases 499 // Test SetStartOptionsWindowWidth function - Normal case 500 /** 501 * @tc.name: SetStartOptionsWindowWidth_001 502 * @tc.desc: test class StartOptions number function 503 * @tc.type: FUNC 504 */ 505 HWTEST_F(StartOptionsImplTest, SetStartOptionsWindowWidth_001, testing::ext::TestSize.Level1) 506 { 507 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowWidth_001 begin"); 508 // Arrange 509 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 510 511 // Act 512 int32_t windowWidth = 100; 513 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsWindowWidth(windowWidth); 514 TAG_LOGI(AAFwkTag::TEST, 515 "SetStartOptionsWindowWidth_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 516 resultErrorCode, expectedErrorCode); 517 518 // Assert 519 EXPECT_EQ(expectedErrorCode, resultErrorCode); 520 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsWindowWidth_001 end"); 521 } 522 523 // Test cases 524 // Test GetStartOptionsWindowWidth function - Normal case 525 /** 526 * @tc.name: GetStartOptionsWindowWidth_001 527 * @tc.desc: test class StartOptions number function 528 * @tc.type: FUNC 529 */ 530 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowWidth_001, testing::ext::TestSize.Level1) 531 { 532 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowWidth_001 begin"); 533 // Arrange 534 int32_t expectedWindowWidth = 500; 535 startOptions->SetStartOptionsWindowWidth(expectedWindowWidth); 536 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 537 538 // Act 539 int32_t windowWidth = 500; 540 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowWidth(windowWidth); 541 TAG_LOGI(AAFwkTag::TEST, 542 "GetStartOptionsWindowWidth_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 543 resultErrorCode, expectedErrorCode); 544 545 // Assert 546 EXPECT_EQ(expectedErrorCode, resultErrorCode); 547 EXPECT_EQ(expectedWindowWidth, windowWidth); 548 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowWidth_001 end"); 549 } 550 551 // Test cases 552 // Test GetStartOptionsWindowWidth function 553 /** 554 * @tc.name: GetStartOptionsWindowWidth_002 555 * @tc.desc: test class StartOptions number function 556 * @tc.type: FUNC 557 */ 558 HWTEST_F(StartOptionsImplTest, GetStartOptionsWindowWidth_002, testing::ext::TestSize.Level1) 559 { 560 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowWidth_002 begin"); 561 // Arrange 562 int32_t expectedWindowWidth = 500; 563 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 564 565 // Act 566 int32_t windowWidth = 500; 567 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsWindowWidth(windowWidth); 568 TAG_LOGI(AAFwkTag::TEST, 569 "GetStartOptionsWindowWidth_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 570 resultErrorCode, expectedErrorCode); 571 572 // Assert 573 EXPECT_EQ(expectedErrorCode, resultErrorCode); 574 EXPECT_EQ(expectedWindowWidth, windowWidth); 575 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsWindowWidth_002 end"); 576 } 577 578 // Test cases 579 // Test SetStartOptionsStartVisibility function - Normal case 580 /** 581 * @tc.name: SetStartOptionsStartVisibility_001 582 * @tc.desc: test class StartOptions number function 583 * @tc.type: FUNC 584 */ 585 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartVisibility_001, testing::ext::TestSize.Level1) 586 { 587 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsStartVisibility_001 begin"); 588 // Arrange 589 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 590 591 // Act 592 AbilityRuntime_StartVisibility startVisibility = AbilityRuntime_StartVisibility::ABILITY_RUNTIME_SHOW_UPON_START; 593 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsStartVisibility(startVisibility); 594 TAG_LOGI(AAFwkTag::TEST, 595 "SetStartOptionsStartVisibility_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 596 resultErrorCode, expectedErrorCode); 597 598 // Assert 599 EXPECT_EQ(expectedErrorCode, resultErrorCode); 600 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsStartVisibility_001 end"); 601 } 602 603 // Test cases 604 // Test SetStartOptionsStartVisibility function - Failure case 605 /** 606 * @tc.name: SetStartOptionsStartVisibility_002 607 * @tc.desc: test class StartOptions number function 608 * @tc.type: FUNC 609 */ 610 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartVisibility_002, testing::ext::TestSize.Level1) 611 { 612 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsStartVisibility_002 begin"); 613 // Arrange 614 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; 615 616 // Act 617 AbilityRuntime_StartVisibility startVisibility = AbilityRuntime_StartVisibility(100); 618 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsStartVisibility(startVisibility); 619 TAG_LOGI(AAFwkTag::TEST, 620 "SetStartOptionsStartVisibility_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 621 resultErrorCode, expectedErrorCode); 622 623 // Assert 624 EXPECT_EQ(expectedErrorCode, resultErrorCode); 625 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsStartVisibility_002 end"); 626 } 627 628 // Test cases 629 // Test SetStartOptionsStartVisibility function - Failure case 630 /** 631 * @tc.name: SetStartOptionsStartVisibility_003 632 * @tc.desc: test class StartOptions number function 633 * @tc.type: FUNC 634 */ 635 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartVisibility_003, testing::ext::TestSize.Level1) 636 { 637 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsStartVisibility_003 begin"); 638 // Arrange 639 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; 640 641 // Act 642 AbilityRuntime_StartVisibility startVisibility = AbilityRuntime_StartVisibility(-1); 643 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsStartVisibility(startVisibility); 644 TAG_LOGI(AAFwkTag::TEST, 645 "SetStartOptionsStartVisibility_003 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 646 resultErrorCode, expectedErrorCode); 647 648 // Assert 649 EXPECT_EQ(expectedErrorCode, resultErrorCode); 650 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsStartVisibility_003 end"); 651 } 652 653 // Test cases 654 // Test GetStartOptionsStartVisibility function - Normal case 655 /** 656 * @tc.name: GetStartOptionsStartVisibility_001 657 * @tc.desc: test class StartOptions number function 658 * @tc.type: FUNC 659 */ 660 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartVisibility_001, testing::ext::TestSize.Level1) 661 { 662 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsStartVisibility_001 begin"); 663 // Arrange 664 AbilityRuntime_StartVisibility expectedStartVisibility = 665 AbilityRuntime_StartVisibility::ABILITY_RUNTIME_SHOW_UPON_START; 666 startOptions->SetStartOptionsStartVisibility(expectedStartVisibility); 667 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 668 669 // Act 670 AbilityRuntime_StartVisibility startVisibility = AbilityRuntime_StartVisibility::ABILITY_RUNTIME_HIDE_UPON_START; 671 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsStartVisibility(startVisibility); 672 TAG_LOGI(AAFwkTag::TEST, 673 "GetStartOptionsStartVisibility_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 674 resultErrorCode, expectedErrorCode); 675 676 // Assert 677 EXPECT_EQ(expectedErrorCode, resultErrorCode); 678 EXPECT_EQ(expectedStartVisibility, startVisibility); 679 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsStartVisibility_001 end"); 680 } 681 682 // Test cases 683 // Test GetStartOptionsStartVisibility function - Get without set 684 /** 685 * @tc.name: GetStartOptionsStartVisibility_002 686 * @tc.desc: test class StartOptions number function 687 * @tc.type: FUNC 688 */ 689 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartVisibility_002, testing::ext::TestSize.Level1) 690 { 691 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsStartVisibility_002 begin"); 692 // Arrange 693 startOptions = new AbilityRuntime_StartOptions(); 694 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; 695 696 // Act 697 AbilityRuntime_StartVisibility startVisibility = AbilityRuntime_StartVisibility::ABILITY_RUNTIME_HIDE_UPON_START; 698 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsStartVisibility(startVisibility); 699 TAG_LOGI(AAFwkTag::TEST, 700 "GetStartOptionsStartVisibility_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 701 resultErrorCode, expectedErrorCode); 702 703 // Assert 704 EXPECT_EQ(expectedErrorCode, resultErrorCode); 705 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsStartVisibility_002 end"); 706 } 707 708 // Test cases 709 // Test SetStartOptionsStartWindowIcon function - Normal case 710 /** 711 * @tc.name: SetStartOptionsStartWindowIcon_001 712 * @tc.desc: test class StartOptions number function 713 * @tc.type: FUNC 714 */ 715 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowIcon_001, testing::ext::TestSize.Level1) 716 { 717 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 718 OH_PixelmapNative* startWindowIcon = nullptr; 719 EXPECT_EQ(startOptions->SetStartOptionsStartWindowIcon(startWindowIcon), 720 ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID); 721 #endif 722 } 723 724 // Test cases 725 // Test SetStartOptionsStartWindowIcon function - Normal case 726 /** 727 * @tc.name: SetStartOptionsStartWindowIcon_002 728 * @tc.desc: test class StartOptions number function 729 * @tc.type: FUNC 730 */ 731 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowIcon_002, testing::ext::TestSize.Level1) 732 { 733 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 734 OH_PixelmapNative *startWindowIcon = new OH_PixelmapNative(nullptr); 735 EXPECT_EQ(startOptions->SetStartOptionsStartWindowIcon(startWindowIcon), 736 ABILITY_RUNTIME_ERROR_CODE_NO_ERROR); 737 delete startWindowIcon; 738 #endif 739 } 740 741 // Test cases 742 // Test SetStartOptionsStartWindowIcon function - Normal case 743 /** 744 * @tc.name: SetStartOptionsStartWindowIcon_003 745 * @tc.desc: test class StartOptions number function 746 * @tc.type: FUNC 747 */ 748 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowIcon_003, testing::ext::TestSize.Level1) 749 { 750 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 751 OH_PixelmapNative *startWindowIcon = new OH_PixelmapNative(nullptr); 752 startOptions->options.startWindowOption = nullptr; 753 EXPECT_EQ(startOptions->SetStartOptionsStartWindowIcon(startWindowIcon), 754 ABILITY_RUNTIME_ERROR_CODE_NO_ERROR); 755 delete startWindowIcon; 756 #endif 757 } 758 759 // Test cases 760 // Test SetStartOptionsStartWindowIcon function - Normal case 761 /** 762 * @tc.name: SetStartOptionsStartWindowIcon_004 763 * @tc.desc: test class StartOptions number function 764 * @tc.type: FUNC 765 */ 766 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowIcon_004, testing::ext::TestSize.Level1) 767 { 768 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 769 OH_PixelmapNative *startWindowIcon = new OH_PixelmapNative(nullptr); 770 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 771 EXPECT_EQ(startOptions->SetStartOptionsStartWindowIcon(startWindowIcon), 772 ABILITY_RUNTIME_ERROR_CODE_NO_ERROR); 773 delete startWindowIcon; 774 #endif 775 } 776 777 // Test cases 778 // Test SetStartOptionsStartWindowIcon function - Normal case 779 /** 780 * @tc.name: SetStartOptionsStartWindowIcon_005 781 * @tc.desc: test class StartOptions number function 782 * @tc.type: FUNC 783 */ 784 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowIcon_005, testing::ext::TestSize.Level1) 785 { 786 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 787 OH_PixelmapNative *startWindowIcon = new OH_PixelmapNative(nullptr); 788 startOptions->options.startWindowOption = nullptr; 789 EXPECT_EQ(startOptions->SetStartOptionsStartWindowIcon(startWindowIcon), 790 ABILITY_RUNTIME_ERROR_CODE_NO_ERROR); 791 EXPECT_NE(startOptions->options.startWindowOption, nullptr); 792 delete startWindowIcon; 793 #endif 794 } 795 796 // Test cases 797 // Test GetStartOptionsStartWindowIcon function - Normal case 798 /** 799 * @tc.name: GetStartOptionsStartWindowIcon_001 800 * @tc.desc: test class StartOptions number function 801 * @tc.type: FUNC 802 */ 803 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowIcon_001, testing::ext::TestSize.Level1) 804 { 805 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 806 // Arrange 807 startOptions->options.startWindowOption = nullptr; 808 OH_PixelmapNative* startWindowIcon = nullptr; 809 810 // Act 811 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowIcon(&startWindowIcon); 812 813 // Assert 814 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, result); 815 #endif 816 } 817 818 // Test cases 819 // Test SetStartOptionsStartWindowIcon function - Normal case 820 /** 821 * @tc.name: GetStartOptionsStartWindowIcon_002 822 * @tc.desc: test class StartOptions number function 823 * @tc.type: FUNC 824 */ 825 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowIcon_002, testing::ext::TestSize.Level1) 826 { 827 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 828 // Arrange 829 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 830 startOptions->options.startWindowOption->hasStartWindow = true; 831 startOptions->options.startWindowOption->startWindowIcon = nullptr; 832 OH_PixelmapNative* startWindowIcon = new OH_PixelmapNative(nullptr); 833 834 // Act 835 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowIcon(&startWindowIcon); 836 837 // Assert 838 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, result); 839 delete startWindowIcon; 840 #endif 841 } 842 843 // Test cases 844 // Test SetStartOptionsStartWindowIcon function - Normal case 845 /** 846 * @tc.name: GetStartOptionsStartWindowIcon_003 847 * @tc.desc: test class StartOptions number function 848 * @tc.type: FUNC 849 */ 850 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowIcon_003, testing::ext::TestSize.Level1) 851 { 852 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 853 // Arrange 854 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 855 startOptions->options.startWindowOption->hasStartWindow = true; 856 startOptions->options.startWindowOption->startWindowIcon = nullptr; 857 OH_PixelmapNative* startWindowIcon = nullptr; 858 859 // Act 860 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowIcon(&startWindowIcon); 861 862 // Assert 863 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, result); 864 EXPECT_NE(nullptr, startWindowIcon); 865 #endif 866 } 867 868 // Test cases 869 // Test SetStartOptionsStartWindowIcon function - Normal case 870 /** 871 * @tc.name: GetStartOptionsStartWindowIcon_004 872 * @tc.desc: test class StartOptions number function 873 * @tc.type: FUNC 874 */ 875 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowIcon_004, testing::ext::TestSize.Level1) 876 { 877 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 878 // Arrange 879 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 880 startOptions->options.startWindowOption->hasStartWindow = false; 881 startOptions->options.startWindowOption->startWindowIcon = nullptr; 882 OH_PixelmapNative* startWindowIcon = nullptr; 883 884 // Act 885 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowIcon(&startWindowIcon); 886 887 // Assert 888 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, result); 889 EXPECT_EQ(nullptr, startWindowIcon); 890 #endif 891 } 892 893 // Test cases 894 // Test SetStartOptionsStartWindowIcon function - Normal case 895 /** 896 * @tc.name: GetStartOptionsStartWindowIcon_005 897 * @tc.desc: test class StartOptions number function 898 * @tc.type: FUNC 899 */ 900 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowIcon_005, testing::ext::TestSize.Level1) 901 { 902 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 903 // Arrange 904 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 905 startOptions->options.startWindowOption->hasStartWindow = true; 906 startOptions->options.startWindowOption->startWindowIcon = std::make_shared<OHOS::Media::PixelMap>(); 907 OH_PixelmapNative* startWindowIcon = new OH_PixelmapNative(nullptr); 908 909 // Act 910 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowIcon(&startWindowIcon); 911 912 // Assert 913 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, result); 914 delete startWindowIcon; 915 #endif 916 } 917 918 // Test cases 919 // Test SetStartOptionsStartWindowIcon function - Normal case 920 /** 921 * @tc.name: GetStartOptionsStartWindowIcon_006 922 * @tc.desc: test class StartOptions number function 923 * @tc.type: FUNC 924 */ 925 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowIcon_006, testing::ext::TestSize.Level1) 926 { 927 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 928 // Arrange 929 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 930 startOptions->options.startWindowOption->hasStartWindow = true; 931 startOptions->options.startWindowOption->startWindowIcon = std::make_shared<OHOS::Media::PixelMap>(); 932 OH_PixelmapNative* startWindowIcon = nullptr; 933 934 // Act 935 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowIcon(&startWindowIcon); 936 937 // Assert 938 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, result); 939 EXPECT_NE(nullptr, startWindowIcon); 940 delete startWindowIcon; 941 #endif 942 } 943 944 // Test cases 945 // Test SetStartOptionsStartWindowBackgroundColor function 946 /** 947 * @tc.name: SetStartOptionsStartWindowBackgroundColor_001 948 * @tc.desc: test class StartOptions number function 949 * @tc.type: FUNC 950 */ 951 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowBackgroundColor_001, testing::ext::TestSize.Level1) 952 { 953 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, 954 startOptions->SetStartOptionsStartWindowBackgroundColor(nullptr)); 955 } 956 957 // Test cases 958 // Test SetStartOptionsStartWindowBackgroundColor function 959 /** 960 * @tc.name: SetStartOptionsStartWindowBackgroundColor_002 961 * @tc.desc: test class StartOptions number function 962 * @tc.type: FUNC 963 */ 964 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowBackgroundColor_002, testing::ext::TestSize.Level1) 965 { 966 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, 967 startOptions->SetStartOptionsStartWindowBackgroundColor("#FFFFFFFF")); 968 } 969 970 // Test cases 971 // Test SetStartOptionsStartWindowBackgroundColor function 972 /** 973 * @tc.name: SetStartOptionsStartWindowBackgroundColor_003 974 * @tc.desc: test class StartOptions number function 975 * @tc.type: FUNC 976 */ 977 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowBackgroundColor_003, testing::ext::TestSize.Level1) 978 { 979 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, 980 startOptions->SetStartOptionsStartWindowBackgroundColor("")); 981 } 982 983 // Test cases 984 // Test SetStartOptionsStartWindowBackgroundColor function 985 /** 986 * @tc.name: SetStartOptionsStartWindowBackgroundColor_004 987 * @tc.desc: test class StartOptions number function 988 * @tc.type: FUNC 989 */ 990 HWTEST_F(StartOptionsImplTest, SetStartOptionsStartWindowBackgroundColor_004, testing::ext::TestSize.Level1) 991 { 992 startOptions->options.startWindowOption = nullptr; 993 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, 994 startOptions->SetStartOptionsStartWindowBackgroundColor("FFFFFF")); 995 } 996 997 // Test cases 998 // Test GetStartOptionsStartWindowBackgroundColor function 999 /** 1000 * @tc.name: GetStartOptionsStartWindowBackgroundColor_001 1001 * @tc.desc: test class StartOptions number function 1002 * @tc.type: FUNC 1003 */ 1004 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowBackgroundColor_001, testing::ext::TestSize.Level1) 1005 { 1006 // Arrange 1007 startOptions->options.startWindowOption = nullptr; 1008 char* startWindowBackgroundColor = nullptr; 1009 size_t size = 0; 1010 1011 // Act 1012 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowBackgroundColor( 1013 &startWindowBackgroundColor, size); 1014 1015 // Assert 1016 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, result); 1017 } 1018 1019 // Test cases 1020 // Test GetStartOptionsStartWindowBackgroundColor function 1021 /** 1022 * @tc.name: GetStartOptionsStartWindowBackgroundColor_002 1023 * @tc.desc: test class StartOptions number function 1024 * @tc.type: FUNC 1025 */ 1026 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowBackgroundColor_002, testing::ext::TestSize.Level1) 1027 { 1028 // Arrange 1029 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 1030 startOptions->options.startWindowOption->hasStartWindow = true; 1031 startOptions->options.startWindowOption->startWindowBackgroundColor = "red"; 1032 char* startWindowBackgroundColor = const_cast<char*>("blue"); 1033 size_t size = 0; 1034 1035 // Act 1036 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowBackgroundColor( 1037 &startWindowBackgroundColor, size); 1038 1039 // Assert 1040 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, result); 1041 } 1042 1043 // Test cases 1044 // Test GetStartOptionsStartWindowBackgroundColor function 1045 /** 1046 * @tc.name: GetStartOptionsStartWindowBackgroundColor_003 1047 * @tc.desc: test class StartOptions number function 1048 * @tc.type: FUNC 1049 */ 1050 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowBackgroundColor_003, testing::ext::TestSize.Level1) 1051 { 1052 // Arrange 1053 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 1054 startOptions->options.startWindowOption->hasStartWindow = true; 1055 startOptions->options.startWindowOption->startWindowBackgroundColor = "red"; 1056 char* startWindowBackgroundColor = nullptr; 1057 size_t size = 0; 1058 1059 // Act 1060 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowBackgroundColor( 1061 &startWindowBackgroundColor, size); 1062 1063 // Assert 1064 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, result); 1065 EXPECT_EQ(0, strcmp(startWindowBackgroundColor, "red")); 1066 EXPECT_EQ(3, size); 1067 } 1068 1069 // Test cases 1070 // Test GetStartOptionsStartWindowBackgroundColor function 1071 /** 1072 * @tc.name: GetStartOptionsStartWindowBackgroundColor_004 1073 * @tc.desc: test class StartOptions number function 1074 * @tc.type: FUNC 1075 */ 1076 HWTEST_F(StartOptionsImplTest, GetStartOptionsStartWindowBackgroundColor_004, testing::ext::TestSize.Level1) 1077 { 1078 // Arrange 1079 startOptions->options.startWindowOption = std::make_shared<OHOS::AAFwk::StartWindowOption>(); 1080 startOptions->options.startWindowOption->hasStartWindow = false; 1081 char* startWindowBackgroundColor = nullptr; 1082 size_t size = 0; 1083 1084 // Act 1085 AbilityRuntime_ErrorCode result = startOptions->GetStartOptionsStartWindowBackgroundColor( 1086 &startWindowBackgroundColor, size); 1087 1088 // Assert 1089 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, result); 1090 EXPECT_EQ(startWindowBackgroundColor, nullptr); 1091 EXPECT_EQ(size, 0); 1092 } 1093 1094 // Test cases 1095 // Test SetStartOptionsSupportedWindowModes function 1096 /** 1097 * @tc.name: SetStartOptionsSupportedWindowModes_001 1098 * @tc.desc: test class StartOptions number function 1099 * @tc.type: FUNC 1100 */ 1101 HWTEST_F(StartOptionsImplTest, SetStartOptionsSupportedWindowModes_001, testing::ext::TestSize.Level1) 1102 { 1103 AbilityRuntime_SupportedWindowMode* supportedWindowModes = nullptr; 1104 size_t size = 1; 1105 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, 1106 startOptions->SetStartOptionsSupportedWindowModes(supportedWindowModes, size)); 1107 } 1108 1109 // Test cases 1110 // Test SetStartOptionsSupportedWindowModes function 1111 /** 1112 * @tc.name: SetStartOptionsSupportedWindowModes_002 1113 * @tc.desc: test class StartOptions number function 1114 * @tc.type: FUNC 1115 */ 1116 HWTEST_F(StartOptionsImplTest, SetStartOptionsSupportedWindowModes_002, testing::ext::TestSize.Level1) 1117 { 1118 AbilityRuntime_SupportedWindowMode supportedWindowModes[1] = 1119 { ABILITY_RUNTIME_SUPPORTED_WINDOW_MODE_FULL_SCREEN }; 1120 size_t size = 0; 1121 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, 1122 startOptions->SetStartOptionsSupportedWindowModes(supportedWindowModes, size)); 1123 } 1124 1125 // Test cases 1126 // Test SetStartOptionsSupportedWindowModes function 1127 /** 1128 * @tc.name: SetStartOptionsSupportedWindowModes_003 1129 * @tc.desc: test class StartOptions number function 1130 * @tc.type: FUNC 1131 */ 1132 HWTEST_F(StartOptionsImplTest, SetStartOptionsSupportedWindowModes_003, testing::ext::TestSize.Level1) 1133 { 1134 AbilityRuntime_SupportedWindowMode supportedWindowModes[MAX_SUPPOPRT_WINDOW_MODES_SIZE + 1]; 1135 size_t size = MAX_SUPPOPRT_WINDOW_MODES_SIZE + 1; 1136 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, 1137 startOptions->SetStartOptionsSupportedWindowModes(supportedWindowModes, size)); 1138 } 1139 1140 // Test cases 1141 // Test SetStartOptionsSupportedWindowModes function 1142 /** 1143 * @tc.name: SetStartOptionsSupportedWindowModes_004 1144 * @tc.desc: test class StartOptions number function 1145 * @tc.type: FUNC 1146 */ 1147 HWTEST_F(StartOptionsImplTest, SetStartOptionsSupportedWindowModes_004, testing::ext::TestSize.Level1) 1148 { 1149 AbilityRuntime_SupportedWindowMode supportedWindowModes[1] = 1150 { AbilityRuntime_SupportedWindowMode(999) }; // Invalid mode 1151 size_t size = 1; 1152 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, 1153 startOptions->SetStartOptionsSupportedWindowModes(supportedWindowModes, size)); 1154 } 1155 1156 // Test cases 1157 // Test SetStartOptionsSupportedWindowModes function 1158 /** 1159 * @tc.name: SetStartOptionsSupportedWindowModes_005 1160 * @tc.desc: test class StartOptions number function 1161 * @tc.type: FUNC 1162 */ 1163 HWTEST_F(StartOptionsImplTest, SetStartOptionsSupportedWindowModes_005, testing::ext::TestSize.Level1) 1164 { 1165 AbilityRuntime_SupportedWindowMode supportedWindowModes[1] = 1166 { ABILITY_RUNTIME_SUPPORTED_WINDOW_MODE_FULL_SCREEN }; 1167 size_t size = 1; 1168 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, 1169 startOptions->SetStartOptionsSupportedWindowModes(supportedWindowModes, size)); 1170 } 1171 1172 // Test cases 1173 // Test GetStartOptionsSupportedWindowModes function 1174 /** 1175 * @tc.name: GetStartOptionsSupportedWindowModes_001 1176 * @tc.desc: test class StartOptions number function 1177 * @tc.type: FUNC 1178 */ 1179 HWTEST_F(StartOptionsImplTest, GetStartOptionsSupportedWindowModes_001, testing::ext::TestSize.Level1) 1180 { 1181 AbilityRuntime_SupportedWindowMode* supportedWindowModes = nullptr; 1182 size_t size = 0; 1183 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, 1184 startOptions->GetStartOptionsSupportedWindowModes(&supportedWindowModes, size)); 1185 } 1186 1187 // Test cases 1188 // Test GetStartOptionsSupportedWindowModes function 1189 /** 1190 * @tc.name: GetStartOptionsSupportedWindowModes_002 1191 * @tc.desc: test class StartOptions number function 1192 * @tc.type: FUNC 1193 */ 1194 HWTEST_F(StartOptionsImplTest, GetStartOptionsSupportedWindowModes_002, testing::ext::TestSize.Level1) 1195 { 1196 AbilityRuntime_SupportedWindowMode* supportedWindowModes = new AbilityRuntime_SupportedWindowMode; 1197 size_t size = 0; 1198 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, 1199 startOptions->GetStartOptionsSupportedWindowModes(&supportedWindowModes, size)); 1200 delete supportedWindowModes; 1201 } 1202 1203 // Test cases 1204 // Test GetStartOptionsSupportedWindowModes function 1205 /** 1206 * @tc.name: GetStartOptionsSupportedWindowModes_003 1207 * @tc.desc: test class StartOptions number function 1208 * @tc.type: FUNC 1209 */ 1210 HWTEST_F(StartOptionsImplTest, GetStartOptionsSupportedWindowModes_003, testing::ext::TestSize.Level1) 1211 { 1212 AbilityRuntime_SupportedWindowMode* supportedWindowModes = nullptr; 1213 size_t size = 0; 1214 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, 1215 startOptions->GetStartOptionsSupportedWindowModes(&supportedWindowModes, size)); 1216 EXPECT_EQ(0, size); 1217 EXPECT_EQ(nullptr, supportedWindowModes); 1218 } 1219 1220 // Test cases 1221 // Test GetStartOptionsSupportedWindowModes function 1222 /** 1223 * @tc.name: GetStartOptionsSupportedWindowModes_004 1224 * @tc.desc: test class StartOptions number function 1225 * @tc.type: FUNC 1226 */ 1227 HWTEST_F(StartOptionsImplTest, GetStartOptionsSupportedWindowModes_004, testing::ext::TestSize.Level1) 1228 { 1229 startOptions->options.supportWindowModes_.push_back( 1230 static_cast<OHOS::AppExecFwk::SupportWindowMode>(ABILITY_RUNTIME_SUPPORTED_WINDOW_MODE_FULL_SCREEN)); 1231 AbilityRuntime_SupportedWindowMode* supportedWindowModes = nullptr; 1232 size_t size = 0; 1233 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_NO_ERROR, 1234 startOptions->GetStartOptionsSupportedWindowModes(&supportedWindowModes, size)); 1235 EXPECT_EQ(1, size); 1236 EXPECT_NE(nullptr, supportedWindowModes); 1237 EXPECT_EQ(ABILITY_RUNTIME_SUPPORTED_WINDOW_MODE_FULL_SCREEN, supportedWindowModes[0]); 1238 free(supportedWindowModes); 1239 } 1240 1241 // Test cases 1242 // Test GetStartOptionsSupportedWindowModes function 1243 /** 1244 * @tc.name: GetStartOptionsSupportedWindowModes_005 1245 * @tc.desc: test class StartOptions number function 1246 * @tc.type: FUNC 1247 */ 1248 HWTEST_F(StartOptionsImplTest, GetStartOptionsSupportedWindowModes_005, testing::ext::TestSize.Level1) 1249 { 1250 size_t size = 0; 1251 EXPECT_EQ(ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID, 1252 startOptions->GetStartOptionsSupportedWindowModes(nullptr, size)); 1253 } 1254 1255 // Test cases 1256 // Test SetStartOptionsMinWindowWidth function - Normal case 1257 /** 1258 * @tc.name: SetStartOptionsMinWindowWidth_001 1259 * @tc.desc: test class StartOptions number function 1260 * @tc.type: FUNC 1261 */ 1262 HWTEST_F(StartOptionsImplTest, SetStartOptionsMinWindowWidth_001, testing::ext::TestSize.Level1) 1263 { 1264 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsMinWindowWidth_001 begin"); 1265 // Arrange 1266 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1267 1268 // Act 1269 int32_t minWindowWidth = 100; 1270 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsMinWindowWidth(minWindowWidth); 1271 TAG_LOGI(AAFwkTag::TEST, 1272 "SetStartOptionsMinWindowWidth_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1273 resultErrorCode, expectedErrorCode); 1274 1275 // Assert 1276 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1277 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsMinWindowWidth_001 end"); 1278 } 1279 1280 // Test cases 1281 // Test GetStartOptionsMinWindowWidth function - Normal case 1282 /** 1283 * @tc.name: GetStartOptionsMinWindowWidth_001 1284 * @tc.desc: test class StartOptions number function 1285 * @tc.type: FUNC 1286 */ 1287 HWTEST_F(StartOptionsImplTest, GetStartOptionsMinWindowWidth_001, testing::ext::TestSize.Level1) 1288 { 1289 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMinWindowWidth_001 begin"); 1290 // Arrange 1291 int32_t expectedMinWindowWidth = 500; 1292 startOptions->SetStartOptionsMinWindowWidth(expectedMinWindowWidth); 1293 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1294 1295 // Act 1296 int32_t minWindowWidth = 500; 1297 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsMinWindowWidth(minWindowWidth); 1298 TAG_LOGI(AAFwkTag::TEST, 1299 "GetStartOptionsMinWindowWidth_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1300 resultErrorCode, expectedErrorCode); 1301 1302 // Assert 1303 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1304 EXPECT_EQ(expectedMinWindowWidth, minWindowWidth); 1305 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMinWindowWidth_001 end"); 1306 } 1307 1308 // Test cases 1309 // Test GetStartOptionsMinWindowWidth function 1310 /** 1311 * @tc.name: GetStartOptionsMinWindowWidth_002 1312 * @tc.desc: test class StartOptions number function 1313 * @tc.type: FUNC 1314 */ 1315 HWTEST_F(StartOptionsImplTest, GetStartOptionsMinWindowWidth_002, testing::ext::TestSize.Level1) 1316 { 1317 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMinWindowWidth_002 begin"); 1318 // Arrange 1319 int32_t expectedMinWindowWidth = 500; 1320 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1321 1322 // Act 1323 int32_t minWindowWidth = 500; 1324 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsMinWindowWidth(minWindowWidth); 1325 TAG_LOGI(AAFwkTag::TEST, 1326 "GetStartOptionsMinWindowWidth_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1327 resultErrorCode, expectedErrorCode); 1328 1329 // Assert 1330 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1331 EXPECT_EQ(expectedMinWindowWidth, minWindowWidth); 1332 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMinWindowWidth_002 end"); 1333 } 1334 1335 // Test cases 1336 // Test SetStartOptionsMaxWindowWidth function - Normal case 1337 /** 1338 * @tc.name: SetStartOptionsMaxWindowWidth_001 1339 * @tc.desc: test class StartOptions number function 1340 * @tc.type: FUNC 1341 */ 1342 HWTEST_F(StartOptionsImplTest, SetStartOptionsMaxWindowWidth_001, testing::ext::TestSize.Level1) 1343 { 1344 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsMaxWindowWidth_001 begin"); 1345 // Arrange 1346 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1347 1348 // Act 1349 int32_t maxMaxWindowWidth = 100; 1350 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsMaxWindowWidth(maxMaxWindowWidth); 1351 TAG_LOGI(AAFwkTag::TEST, 1352 "SetStartOptionsMaxWindowWidth_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1353 resultErrorCode, expectedErrorCode); 1354 1355 // Assert 1356 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1357 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsMaxWindowWidth_001 end"); 1358 } 1359 1360 // Test cases 1361 // Test GetStartOptionsMaxWindowWidth function - Normal case 1362 /** 1363 * @tc.name: GetStartOptionsMaxWindowWidth_001 1364 * @tc.desc: test class StartOptions number function 1365 * @tc.type: FUNC 1366 */ 1367 HWTEST_F(StartOptionsImplTest, GetStartOptionsMaxWindowWidth_001, testing::ext::TestSize.Level1) 1368 { 1369 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMaxWindowWidth_001 begin"); 1370 // Arrange 1371 int32_t expectedMaxWindowWidth = 500; 1372 startOptions->SetStartOptionsMaxWindowWidth(expectedMaxWindowWidth); 1373 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1374 1375 // Act 1376 int32_t maxWindowWidth = 500; 1377 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsMaxWindowWidth(maxWindowWidth); 1378 TAG_LOGI(AAFwkTag::TEST, 1379 "GetStartOptionsMaxWindowWidth_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1380 resultErrorCode, expectedErrorCode); 1381 1382 // Assert 1383 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1384 EXPECT_EQ(expectedMaxWindowWidth, maxWindowWidth); 1385 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMaxWindowWidth_001 end"); 1386 } 1387 1388 // Test cases 1389 // Test GetStartOptionsMaxWindowWidth function 1390 /** 1391 * @tc.name: GetStartOptionsMaxWindowWidth_002 1392 * @tc.desc: test class StartOptions number function 1393 * @tc.type: FUNC 1394 */ 1395 HWTEST_F(StartOptionsImplTest, GetStartOptionsMaxWindowWidth_002, testing::ext::TestSize.Level1) 1396 { 1397 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMaxWindowWidth_002 begin"); 1398 // Arrange 1399 int32_t expectedMaxWindowWidth = 500; 1400 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1401 1402 // Act 1403 int32_t maxWindowWidth = 500; 1404 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsMaxWindowWidth(maxWindowWidth); 1405 TAG_LOGI(AAFwkTag::TEST, 1406 "GetStartOptionsMaxWindowWidth_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1407 resultErrorCode, expectedErrorCode); 1408 1409 // Assert 1410 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1411 EXPECT_EQ(expectedMaxWindowWidth, maxWindowWidth); 1412 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMaxWindowWidth_002 end"); 1413 } 1414 1415 // Test cases 1416 // Test SetStartOptionsMinWindowHeight function - Normal case 1417 /** 1418 * @tc.name: SetStartOptionsMinWindowHeight_001 1419 * @tc.desc: test class StartOptions number function 1420 * @tc.type: FUNC 1421 */ 1422 HWTEST_F(StartOptionsImplTest, SetStartOptionsMinWindowHeight_001, testing::ext::TestSize.Level1) 1423 { 1424 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsMinWindowHeight_001 begin"); 1425 // Arrange 1426 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1427 1428 // Act 1429 int32_t minWindowHeight = 100; 1430 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsMinWindowHeight(minWindowHeight); 1431 TAG_LOGI(AAFwkTag::TEST, 1432 "SetStartOptionsMinWindowHeight_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1433 resultErrorCode, expectedErrorCode); 1434 1435 // Assert 1436 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1437 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsMinWindowHeight_001 end"); 1438 } 1439 1440 // Test cases 1441 // Test GetStartOptionsMinWindowHeight function - Normal case 1442 /** 1443 * @tc.name: GetStartOptionsMinWindowHeight_001 1444 * @tc.desc: test class StartOptions number function 1445 * @tc.type: FUNC 1446 */ 1447 HWTEST_F(StartOptionsImplTest, GetStartOptionsMinWindowHeight_001, testing::ext::TestSize.Level1) 1448 { 1449 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMinWindowHeight_001 begin"); 1450 // Arrange 1451 int32_t expectedMinWindowHeight = 500; 1452 startOptions->SetStartOptionsMinWindowHeight(expectedMinWindowHeight); 1453 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1454 1455 // Act 1456 int32_t minWindowHeight = 500; 1457 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsMinWindowHeight(minWindowHeight); 1458 TAG_LOGI(AAFwkTag::TEST, 1459 "GetStartOptionsMinWindowHeight_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1460 resultErrorCode, expectedErrorCode); 1461 1462 // Assert 1463 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1464 EXPECT_EQ(expectedMinWindowHeight, minWindowHeight); 1465 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMinWindowHeight_001 end"); 1466 } 1467 1468 // Test cases 1469 // Test GetStartOptionsMinWindowHeight function - Normal case 1470 /** 1471 * @tc.name: GetStartOptionsMinWindowHeight_002 1472 * @tc.desc: test class StartOptions number function 1473 * @tc.type: FUNC 1474 */ 1475 HWTEST_F(StartOptionsImplTest, GetStartOptionsMinWindowHeight_002, testing::ext::TestSize.Level1) 1476 { 1477 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMinWindowHeight_002 begin"); 1478 // Arrange 1479 int32_t expectedMinWindowHeight = 500; 1480 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1481 1482 // Act 1483 int32_t minWindowHeight = 500; 1484 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsMinWindowHeight(minWindowHeight); 1485 TAG_LOGI(AAFwkTag::TEST, 1486 "GetStartOptionsMinWindowHeight_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1487 resultErrorCode, expectedErrorCode); 1488 1489 // Assert 1490 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1491 EXPECT_EQ(expectedMinWindowHeight, minWindowHeight); 1492 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMinWindowHeight_002 end"); 1493 } 1494 1495 // Test cases 1496 // Test SetStartOptionsMaxWindowHeight function - Normal case 1497 /** 1498 * @tc.name: SetStartOptionsMaxWindowHeight_001 1499 * @tc.desc: test class StartOptions number function 1500 * @tc.type: FUNC 1501 */ 1502 HWTEST_F(StartOptionsImplTest, SetStartOptionsMaxWindowHeight_001, testing::ext::TestSize.Level1) 1503 { 1504 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsMaxWindowHeight_001 begin"); 1505 // Arrange 1506 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1507 1508 // Act 1509 int32_t maxWindowHeight = 100; 1510 AbilityRuntime_ErrorCode resultErrorCode = startOptions->SetStartOptionsMaxWindowHeight(maxWindowHeight); 1511 TAG_LOGI(AAFwkTag::TEST, 1512 "SetStartOptionsMaxWindowHeight_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1513 resultErrorCode, expectedErrorCode); 1514 1515 // Assert 1516 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1517 TAG_LOGI(AAFwkTag::TEST, "SetStartOptionsMaxWindowHeight_001 end"); 1518 } 1519 1520 // Test cases 1521 // Test GetStartOptionsMaxWindowHeight function - Normal case 1522 /** 1523 * @tc.name: GetStartOptionsMaxWindowHeight_001 1524 * @tc.desc: test class StartOptions number function 1525 * @tc.type: FUNC 1526 */ 1527 HWTEST_F(StartOptionsImplTest, GetStartOptionsMaxWindowHeight_001, testing::ext::TestSize.Level1) 1528 { 1529 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMaxWindowHeight_001 begin"); 1530 // Arrange 1531 int32_t expectedMaxWindowHeight = 500; 1532 startOptions->SetStartOptionsMaxWindowHeight(expectedMaxWindowHeight); 1533 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1534 1535 // Act 1536 int32_t maxWindowHeight = 500; 1537 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsMaxWindowHeight(maxWindowHeight); 1538 TAG_LOGI(AAFwkTag::TEST, 1539 "GetStartOptionsMaxWindowHeight_001 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1540 resultErrorCode, expectedErrorCode); 1541 1542 // Assert 1543 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1544 EXPECT_EQ(expectedMaxWindowHeight, maxWindowHeight); 1545 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMaxWindowHeight_001 end"); 1546 } 1547 1548 // Test cases 1549 // Test GetStartOptionsMaxWindowHeight function - Normal case 1550 /** 1551 * @tc.name: GetStartOptionsMaxWindowHeight_002 1552 * @tc.desc: test class StartOptions number function 1553 * @tc.type: FUNC 1554 */ 1555 HWTEST_F(StartOptionsImplTest, GetStartOptionsMaxWindowHeight_002, testing::ext::TestSize.Level1) 1556 { 1557 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMaxWindowHeight_002 begin"); 1558 // Arrange 1559 int32_t expectedMaxWindowHeight = 500; 1560 AbilityRuntime_ErrorCode expectedErrorCode = ABILITY_RUNTIME_ERROR_CODE_NO_ERROR; 1561 1562 // Act 1563 int32_t maxWindowHeight = 500; 1564 AbilityRuntime_ErrorCode resultErrorCode = startOptions->GetStartOptionsMaxWindowHeight(maxWindowHeight); 1565 TAG_LOGI(AAFwkTag::TEST, 1566 "GetStartOptionsMaxWindowHeight_002 resultErrorCode=%{public}d,expectedErrorCode=%{public}d", 1567 resultErrorCode, expectedErrorCode); 1568 1569 // Assert 1570 EXPECT_EQ(expectedErrorCode, resultErrorCode); 1571 EXPECT_EQ(expectedMaxWindowHeight, maxWindowHeight); 1572 TAG_LOGI(AAFwkTag::TEST, "GetStartOptionsMaxWindowHeight_002 end"); 1573 } 1574