1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the 'License'); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an 'AS IS' BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15// @ts-nocheck 16import wallpaper from '@ohos.wallpaper' 17import image from '@ohos.multimedia.image' 18import fileio from '@ohos.fileio' 19import bundleManager from "@ohos.bundle.bundleManager" 20 21import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' 22 23const WALLPAPER_SYSTEM = wallpaper.WallpaperType.WALLPAPER_SYSTEM; 24const WALLPAPER_LOCKSCREEN = wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN; 25const INVALID_WALLPAPER_TYPE = 2; 26const NORMAL = wallpaper.FoldState.NORMAL; 27const UNFOLD_1 = wallpaper.FoldState.UNFOLD_1; 28const UNFOLD_2 = wallpaper.FoldState.UNFOLD_2; 29const UNFOLD_ONCE_STATE = wallpaper.FoldState.UNFOLD_ONCE_STATE; 30const UNFOLD_TWICE_STATE = wallpaper.FoldState.UNFOLD_TWICE_STATE; 31const INVALID_FOLDSTATE = 30; 32const PORT = wallpaper.RotateState.PORT; 33const LAND = wallpaper.RotateState.LAND; 34const PORTRAIT = wallpaper.RotateState.PORTRAIT; 35const LANDSCAPE = wallpaper.RotateState.LANDSCAPE; 36const INVALID_ROTATESTATE = 20; 37const DEFAULT_WALLPAPER_ID = -1; 38const PARAMETER_ERROR = 401; 39const PARAMETER_ERROR_MESSAGE = "BusinessError 401: Parameter error."; 40const PARAMETER_COUNT = "Mandatory parameters are left unspecified."; 41const WALLPAPERTYPE_PARAMETER_TYPE = "The type must be WallpaperType, parameter range must be " + 42 "WALLPAPER_LOCKSCREEN or WALLPAPER_SYSTEM."; 43const FOLDSTATE_PARAMETER_TYPE = "The type must be FoldState, parameter range must be " + 44 "NORMAL or UNFOLD_ONCE_STATE or UNFOLD_TWICE_STATE."; 45const ROTATESTATE_PARAMETER_TYPE = "The type must be RotateState, parameter range must be " + 46 "PORTRAIT or LANDSCAPE."; 47const URI = "/data/storage/el2/base/haps/js.jpeg"; 48const URI_ZIP = "/system/etc/test.zip"; 49const URI_30FPS_3S_MP4 = "/system/etc/30fps_3s.mp4"; 50const URI_15FPS_7S_MP4 = "/system/etc/15fps_7s.mp4"; 51const URI_30FPS_3S_MOV = "/system/etc/30fps_3s.mov"; 52 53const SHOW_SYSTEM_SCREEN = "SHOW_SYSTEMSCREEN"; 54const SHOW_LOCK_SCREEN = "SHOW_LOCKSCREEN"; 55const BUNDLE_NAME = "com.ohos.sceneboard"; 56 57describe('WallpaperJSTest', function () { 58 beforeAll(async function () { 59 // input testsuite setup step,setup invoked before all testcases 60 console.info('beforeAll called') 61 await createTempImage(); 62 }) 63 beforeEach(function () { 64 // input testcase setup step,setup invoked before each testcases 65 console.info('beforeEach called') 66 }) 67 afterEach(function () { 68 // input testcase teardown step,teardown invoked after each testcases 69 console.info('afterEach called') 70 }) 71 afterAll(async function () { 72 // input testsuite teardown step,teardown invoked after all testcases 73 console.info('afterAll called') 74 await wallpaper.restore(WALLPAPER_SYSTEM); 75 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 76 }) 77 78 async function createTempImage() { 79 let pixelMap = await createTempPixelMap(); 80 const imagePackerApi = image.createImagePacker(); 81 let packOpts = {format: "image/jpeg", quality: 98}; 82 imagePackerApi.packing(pixelMap, packOpts, (err, data) => { 83 if (err) { 84 console.info(`packing error: ${err}`) 85 } else { 86 let fd = fileio.openSync(URI, 0o2 | 0o100, 0o666); 87 let ret = fileio.writeSync(fd, data); 88 fileio.close(fd); 89 console.log(`file write ret: ${ret}`); 90 } 91 }) 92 } 93 94 async function createTempPixelMap() { 95 const color = new ArrayBuffer(96); 96 let opts = {editable: true, pixelFormat: 3, size: {height: 4, width: 6}}; 97 let pixelMap = await image.createPixelMap(color, opts); 98 return pixelMap; 99 } 100 101 function isBundleNameExists() { 102 try { 103 bundleManager.getBundleInfo(BUNDLE_NAME, bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT, (e) => { 104 if (e) { 105 console.info(`getBundleInfo error ${e.code}`); 106 return false; 107 } else { 108 console.info(`Wallpaper : getBundleInfo is success`); 109 return true; 110 } 111 }) 112 } catch (error) { 113 console.info(`getBundleInfo error ${error.code}`); 114 return false; 115 } 116 117 } 118 119 /** 120 * @tc.name: getColorsSyncTest001 121 * @tc.desc: Test getColorsSync() to gets WALLPAPER_SYSTEM Colors by syncing. 122 * @tc.type: FUNC 123 * @tc.require: issueI5UHRG 124 */ 125 it('getColorsSyncTest001', 0, function () { 126 try { 127 let data = wallpaper.getColorsSync(WALLPAPER_SYSTEM); 128 console.info(`getColorsSyncTest001 data : ${data}`); 129 if (data !== undefined) { 130 expect(true).assertTrue(); 131 } 132 } catch (error) { 133 console.info(`getColorsSyncTest001 error ${error}`); 134 expect(null).assertFail(); 135 } 136 }) 137 138 139 /** 140 * @tc.name: getColorsSyncTest002 141 * @tc.desc: Test getColorsSync() to gets WALLPAPER_LOCKSCREEN Colors by syncing. 142 * @tc.type: FUNC 143 * @tc.require: issueI5UHRG 144 */ 145 it('getColorsSyncTest002', 0, function () { 146 try { 147 let data = wallpaper.getColorsSync(WALLPAPER_LOCKSCREEN); 148 console.info(`getColorsSyncTest002 data : ${data}`); 149 if (data !== undefined) { 150 expect(true).assertTrue(); 151 } 152 } catch (error) { 153 console.info(`getColorsSyncTest002 error : ${error}`); 154 expect(null).assertFail(); 155 } 156 }) 157 158 /** 159 * @tc.name: getColorsSyncTest003 160 * @tc.desc: Test getColorsSync() throw parameter error. 161 * @tc.type: FUNC 162 * @tc.require: issueI5UHRG 163 */ 164 it('getColorsSyncTest003', 0, function () { 165 try { 166 let data = wallpaper.getColorsSync(INVALID_WALLPAPER_TYPE); 167 console.info(`getColorsSyncTest003 data : ${data}`); 168 expect(null).assertFail(); 169 } catch (error) { 170 console.info(`getColorsSyncTest003 error : ${error}`); 171 expect(error.code === PARAMETER_ERROR).assertTrue() 172 } 173 }) 174 175 /** 176 * @tc.name: getColorsSyncTest004 177 * @tc.desc: Test getColorsSync() throw parameter error. 178 * @tc.type: FUNC 179 * @tc.require: issueI5UHRG 180 */ 181 it('getColorsSyncTest004', 0, function () { 182 try { 183 let data = wallpaper.getColorsSync(); 184 console.info(`getColorsSyncTest004 data : ${data}`); 185 expect(null).assertFail(); 186 } catch (error) { 187 console.info(`getColorsSyncTest004 error : ${error}`); 188 expect(error.code === PARAMETER_ERROR).assertTrue() 189 } 190 }) 191 192 /** 193 * @tc.name: getMinHeightSyncTest001 194 * @tc.desc: Test getMinHeightSync() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. 195 * @tc.type: FUNC test 196 * @tc.require: issueI5UHRG 197 */ 198 it('getMinHeightSyncTest001', 0, function () { 199 let data = wallpaper.getMinHeightSync(); 200 console.info(`getMinHeightSyncTest001 data : ${data}`); 201 if (data !== undefined) { 202 expect(true).assertTrue(); 203 } else { 204 expect(null).assertFail() 205 } 206 }) 207 208 /** 209 * @tc.name: getMinWidthSyncTest001 210 * @tc.desc: Test getMinWidthSync() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. 211 * @tc.type: FUNC test 212 * @tc.require: issueI5UHRG 213 */ 214 it('getMinWidthSyncTest001', 0, function () { 215 let data = wallpaper.getMinWidthSync(); 216 console.info(`getMinWidthSyncTest001 data : ${data}`); 217 if (data !== undefined) { 218 expect(true).assertTrue(); 219 } else { 220 expect(null).assertFail() 221 } 222 }) 223 224 /** 225 * @tc.name: restoreCallbackSystemTest001 226 * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. 227 * @tc.type: FUNC test 228 * @tc.require: issueI5UHRG 229 */ 230 it('restoreCallbackSystemTest001', 0, async function (done) { 231 try { 232 wallpaper.restore(WALLPAPER_SYSTEM, function (err) { 233 if (err) { 234 console.info(`restoreCallbackSystemTest001 err : ${err}`); 235 expect(null).assertFail() 236 } else { 237 expect(true).assertTrue(); 238 } 239 done(); 240 }) 241 242 } catch (error) { 243 console.info(`restoreCallbackSystemTest001 err : ${error}`); 244 expect(null).assertFail(); 245 done(); 246 } 247 248 }) 249 250 /** 251 * @tc.name: restorePromiseSystemTest002 252 * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. 253 * @tc.type: FUNC test 254 * @tc.require: issueI5UHRG 255 */ 256 it('restorePromiseSystemTest002', 0, async function (done) { 257 try { 258 wallpaper.restore(WALLPAPER_SYSTEM).then(() => { 259 expect(true).assertTrue(); 260 done(); 261 }).catch((err) => { 262 console.info(`restorePromiseSystemTest002 err : ${err}`); 263 expect(null).assertFail(); 264 done(); 265 }); 266 } catch (error) { 267 expect(null).assertFail(); 268 done(); 269 } 270 }) 271 272 /** 273 * @tc.name: restoreCallbackLockTest003 274 * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. 275 * @tc.type: FUNC test 276 * @tc.require: issueI5UHRG 277 */ 278 it('restoreCallbackLockTest003', 0, async function (done) { 279 try { 280 wallpaper.restore(WALLPAPER_LOCKSCREEN, function (err) { 281 if (err) { 282 expect(null).assertFail(); 283 console.info(`restore CallbackLockTest003 fail : ${err}`); 284 } else { 285 expect(true).assertTrue(); 286 } 287 done(); 288 }) 289 } catch (error) { 290 expect(null).assertFail(); 291 console.info(`restore CallbackLockTest003 fail : ${error}`); 292 done(); 293 } 294 }) 295 296 /** 297 * @tc.name: restorePromiseLockTest004 298 * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. 299 * @tc.type: FUNC test 300 * @tc.require: issueI5UHRG 301 */ 302 it('restorePromiseLockTest004', 0, async function (done) { 303 try { 304 wallpaper.restore(WALLPAPER_LOCKSCREEN).then(() => { 305 expect(true).assertTrue(); 306 done(); 307 }).catch((err) => { 308 console.info(`restorePromiseLockTest004 err : ${err}`); 309 expect(null).assertFail(); 310 done(); 311 }); 312 } catch (error) { 313 expect(null).assertFail(); 314 done(); 315 } 316 }) 317 318 /** 319 * @tc.name: restoreCallbackThrowErrorTest005 320 * @tc.desc: Test restore() throw parameter error. 321 * @tc.type: FUNC test 322 * @tc.require: issueI5UHRG 323 */ 324 it('restoreCallbackThrowErrorTest005', 0, async function (done) { 325 try { 326 wallpaper.restore(INVALID_WALLPAPER_TYPE, function (err) { 327 if (err) { 328 expect(err.code === PARAMETER_ERROR).assertTrue() 329 console.info(`restore CallbackThrowErrorTest005 fail : ${err}`); 330 } else { 331 expect(null).assertFail(); 332 } 333 done(); 334 }) 335 } catch (error) { 336 expect(null).assertFail(); 337 console.info(`restore CallbackThrowErrorTest005 fail : ${error}`); 338 done(); 339 } 340 }) 341 342 /** 343 * @tc.name: restoreCallbackThrowErrorTest006 344 * @tc.desc: Test restore() throw parameter error. 345 * @tc.type: FUNC test 346 * @tc.require: issueI5UHRG 347 */ 348 it('restoreCallbackThrowErrorTest006', 0, async function (done) { 349 try { 350 wallpaper.restore(function (err) { 351 if (err) { 352 expect(null).assertFail(); 353 console.info(`restore CallbackThrowErrorTest006 fail : ${err}`); 354 } else { 355 expect(null).assertFail(); 356 } 357 done(); 358 }) 359 } catch (error) { 360 expect(error.code === PARAMETER_ERROR).assertTrue() 361 console.info(`restore CallbackThrowErrorTest006 fail : ${error}`); 362 done(); 363 } 364 }) 365 366 /** 367 * @tc.name: restorePromiseThrowErrorTest007 368 * @tc.desc: Test restore() throw parameter error. 369 * @tc.type: FUNC test 370 * @tc.require: issueI5UHRG 371 */ 372 it('restorePromiseThrowErrorTest007', 0, async function (done) { 373 try { 374 wallpaper.restore(INVALID_WALLPAPER_TYPE).then(() => { 375 expect(null).assertFail(); 376 done(); 377 }).catch((err) => { 378 console.info(`restorePromiseThrowErrorTest007 err : ${err}`); 379 expect(err.code === PARAMETER_ERROR).assertTrue() 380 done(); 381 }); 382 } catch (error) { 383 expect(null).assertFail(); 384 done(); 385 } 386 }) 387 388 /** 389 * @tc.name: restorePromiseThrowErrorTest008 390 * @tc.desc: Test restore() throw parameter error. 391 * @tc.type: FUNC test 392 * @tc.require: issueI5UHRG 393 */ 394 it('restorePromiseThrowErrorTest008', 0, async function (done) { 395 try { 396 wallpaper.restore().then(() => { 397 expect(null).assertFail(); 398 done(); 399 }).catch((err) => { 400 console.info(`restorePromiseThrowErrorTest008 err : ${err}`); 401 expect(null).assertFail(); 402 done(); 403 }); 404 } catch (error) { 405 expect(error.code === PARAMETER_ERROR).assertTrue() 406 done(); 407 } 408 }) 409 410 /** 411 * @tc.name: getImagePromiseLockTest001 412 * @tc.desc: Test getImage() to gets a PixelMap of the specified type. 413 * @tc.type: FUNC test 414 * @tc.require: issueI5UHRG 415 */ 416 it('getImagePromiseLockTest001', 0, async function (done) { 417 try { 418 wallpaper.getImage(WALLPAPER_LOCKSCREEN).then((data) => { 419 console.info(`getImagePromiseLockTest001 data : ${data}`); 420 if (data !== undefined) { 421 expect(true).assertTrue(); 422 } 423 done(); 424 }).catch((err) => { 425 console.info(`getImagePromiseLockTest001 err : ${err}`); 426 expect(null).assertFail(); 427 done(); 428 }); 429 } catch (error) { 430 expect(null).assertFail(); 431 done(); 432 } 433 }) 434 435 /** 436 * @tc.name: getImageCallbackSystemTest002 437 * @tc.desc: Test getImage() to gets a PixelMap of the specified type. 438 * @tc.type: FUNC test 439 * @tc.require: issueI5UHRG 440 */ 441 it('getImageCallbackSystemTest002', 0, async function (done) { 442 try { 443 wallpaper.getImage(WALLPAPER_SYSTEM, function (err, data) { 444 if (err) { 445 expect(null).assertFail(); 446 console.info(`get Image CallbackSystemTest002 fail : ${err}`); 447 } else { 448 console.info(`get Image CallbackSystemTest002 data : ${data}`); 449 if (data !== undefined) { 450 expect(true).assertTrue(); 451 } 452 } 453 done(); 454 }); 455 } catch (error) { 456 expect(null).assertFail(); 457 console.info(`get Image CallbackSystemTest002 fail : ${error}`); 458 done(); 459 } 460 }) 461 462 /** 463 * @tc.name: getImagePromiseSystemTest003 464 * @tc.desc: Test getImage() to gets a PixelMap of the specified type. 465 * @tc.type: FUNC test 466 * @tc.require: issueI5UHRG 467 */ 468 it('getImagePromiseSystemTest003', 0, async function (done) { 469 try { 470 wallpaper.getImage(WALLPAPER_SYSTEM).then((data) => { 471 console.info(`getImagePromiseSystemTest003 data : ${data}`); 472 if (data !== undefined) { 473 expect(true).assertTrue(); 474 } 475 done(); 476 }).catch((err) => { 477 console.info(`getImagePromiseSystemTest003 err : ${err}`); 478 expect(null).assertFail(); 479 done(); 480 }); 481 } catch (error) { 482 expect(null).assertFail(); 483 done(); 484 } 485 }) 486 487 /** 488 * @tc.name: getImageCallbackLockTest004 489 * @tc.desc: Test getImage() to gets a PixelMap of the specified type. 490 * @tc.type: FUNC test 491 * @tc.require: issueI5UHRG 492 */ 493 it('getImageCallbackLockTest004', 0, async function (done) { 494 try { 495 wallpaper.getImage(WALLPAPER_LOCKSCREEN, function (err, data) { 496 if (err) { 497 expect(null).assertFail(); 498 console.info(`get Image CallbackLockTest004 fail : ${err}`); 499 } else { 500 console.info(`get Image CallbackLockTest004 data : ${data}`); 501 if (data !== undefined) { 502 expect(true).assertTrue(); 503 } 504 } 505 done(); 506 }); 507 } catch (error) { 508 expect(null).assertFail(); 509 console.info(`get Image CallbackLockTest004 fail : ${error}`); 510 done(); 511 } 512 }) 513 514 /** 515 * @tc.name: getImageCallbackThrowErrorTest005 516 * @tc.desc: Test getImage() throw parameter error. 517 * @tc.type: FUNC test 518 * @tc.require: issueI5UHRG 519 */ 520 it('getImageCallbackThrowErrorTest005', 0, async function (done) { 521 try { 522 wallpaper.getImage(INVALID_WALLPAPER_TYPE, function (err, data) { 523 console.error(`getImageCallbackThrowErrorTest005 err : ${err}`); 524 console.error(`getImageCallbackThrowErrorTest005 data : ${data}`); 525 expect(null).assertTrue(); 526 done(); 527 }) 528 } catch (error) { 529 console.info(`getImageCallbackThrowErrorTest005 error : ${error}`); 530 expect(error.code === PARAMETER_ERROR).assertTrue(); 531 expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); 532 done(); 533 } 534 }) 535 536 /** 537 * @tc.name: getImageCallbackThrowErrorTest006 538 * @tc.desc: Test getImage() throw parameter error. 539 * @tc.type: FUNC test 540 * @tc.require: issueI5UHRG 541 */ 542 it('getImageCallbackThrowErrorTest006', 0, async function (done) { 543 try { 544 wallpaper.getImage(function (err, data) { 545 if (err) { 546 console.info(`getImageCallbackThrowErrorTest006 err : ${err}`); 547 expect(null).assertFail(); 548 } else { 549 console.info(`getImageCallbackThrowErrorTest006 data : ${data}`); 550 if (data !== undefined) { 551 expect(null).assertFail(); 552 } 553 } 554 done(); 555 }) 556 } catch (error) { 557 expect(error.code === PARAMETER_ERROR).assertTrue() 558 done(); 559 } 560 }) 561 562 /** 563 * @tc.name: getImagePromiseThrowErrorTest007 564 * @tc.desc: Test getImage() throw parameter error. 565 * @tc.type: FUNC test 566 * @tc.require: issueI5UHRG 567 */ 568 it('getImagePromiseThrowErrorTest007', 0, async function (done) { 569 try { 570 wallpaper.getImage(INVALID_WALLPAPER_TYPE).then((data) => { 571 console.error(`getImagePromiseThrowErrorTest007 data : ${data}`); 572 expect(null).assertTrue(); 573 done(); 574 }).catch((err) => { 575 console.error(`getImagePromiseThrowErrorTest007 err : ${err}`); 576 expect(null).assertTrue(); 577 done(); 578 }); 579 } catch (error) { 580 console.info(`getImagePromiseThrowErrorTest007 error : ${error}`); 581 expect(error.code === PARAMETER_ERROR).assertTrue(); 582 expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); 583 done(); 584 } 585 }) 586 587 /** 588 * @tc.name: getImagePromiseThrowErrorTest008 589 * @tc.desc: Test getImage() throw parameter error. 590 * @tc.type: FUNC test 591 * @tc.require: issueI5UHRG 592 */ 593 it('getImagePromiseThrowErrorTest008', 0, async function (done) { 594 try { 595 wallpaper.getImage().then((data) => { 596 console.info(`getImagePromiseThrowErrorTest008 data : ${data}`); 597 if (data !== undefined) { 598 expect(null).assertFail(); 599 } 600 done(); 601 }).catch((err) => { 602 console.info(`getImagePromiseThrowErrorTest008 err : ${err}`); 603 expect(null).assertFail(); 604 done(); 605 }); 606 } catch (error) { 607 expect(error.code === PARAMETER_ERROR).assertTrue() 608 done(); 609 } 610 }) 611 612 /** 613 * @tc.name: getCorrespondWallpaperTest001 614 * @tc.desc: Test getCorrespondWallpaper() with normal argc 000. 615 * @tc.type: FUNC 616 */ 617 it('getCorrespondWallpaperTest001', 0, async function (done) { 618 try { 619 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, PORT).then((data) => { 620 console.info(`getCorrespondWallpaperTest001 data : ${data}`); 621 expect(data !== undefined && data !== null).assertTrue(); 622 done(); 623 }).catch((err) => { 624 console.error(`getCorrespondWallpaperTest001 err : ${err}`); 625 expect(null).assertTrue(); 626 done(); 627 }); 628 } catch (error) { 629 console.error(`getCorrespondWallpaperTest001 error : ${error}`); 630 expect(null).assertTrue(); 631 done(); 632 } 633 }) 634 635 /** 636 * @tc.name: getCorrespondWallpaperTest002 637 * @tc.desc: Test getCorrespondWallpaper() with normal argc 001. 638 * @tc.type: FUNC 639 */ 640 it('getCorrespondWallpaperTest002', 0, async function (done) { 641 try { 642 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, LAND).then((data) => { 643 console.info(`getCorrespondWallpaperTest002 data : ${data}`); 644 expect(data !== undefined && data !== null).assertTrue(); 645 done(); 646 }).catch((err) => { 647 console.error(`getCorrespondWallpaperTest002 err : ${err}`); 648 expect(null).assertTrue(); 649 done(); 650 }); 651 } catch (error) { 652 console.error(`getCorrespondWallpaperTest002 error : ${error}`); 653 expect(null).assertTrue(); 654 done(); 655 } 656 }) 657 658 /** 659 * @tc.name: getCorrespondWallpaperTest003 660 * @tc.desc: Test getCorrespondWallpaper() with normal argc 010. 661 * @tc.type: FUNC 662 */ 663 it('getCorrespondWallpaperTest003', 0, async function (done) { 664 try { 665 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_1, PORT).then((data) => { 666 console.info(`getCorrespondWallpaperTest003 data : ${data}`); 667 expect(data !== undefined && data !== null).assertTrue(); 668 done(); 669 }).catch((err) => { 670 console.error(`getCorrespondWallpaperTest003 err : ${err}`); 671 expect(null).assertTrue(); 672 done(); 673 }); 674 } catch (error) { 675 console.error(`getCorrespondWallpaperTest003 error : ${error}`); 676 expect(null).assertTrue(); 677 done(); 678 } 679 }) 680 681 /** 682 * @tc.name: getCorrespondWallpaperTest004 683 * @tc.desc: Test getCorrespondWallpaper() with normal argc 011. 684 * @tc.type: FUNC 685 */ 686 it('getCorrespondWallpaperTest004', 0, async function (done) { 687 try { 688 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_1, LAND).then((data) => { 689 console.info(`getCorrespondWallpaperTest004 data : ${data}`); 690 expect(data !== undefined && data !== null).assertTrue(); 691 done(); 692 }).catch((err) => { 693 console.error(`getCorrespondWallpaperTest004 err : ${err}`); 694 expect(null).assertTrue(); 695 done(); 696 }); 697 } catch (error) { 698 console.error(`getCorrespondWallpaperTest004 error : ${error}`); 699 expect(null).assertTrue(); 700 done(); 701 } 702 }) 703 704 /** 705 * @tc.name: getCorrespondWallpaperTest005 706 * @tc.desc: Test getCorrespondWallpaper() with normal argc 020. 707 * @tc.type: FUNC 708 */ 709 it('getCorrespondWallpaperTest005', 0, async function (done) { 710 try { 711 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_2, PORT).then((data) => { 712 console.info(`getCorrespondWallpaperTest005 data : ${data}`); 713 expect(data !== undefined && data !== null).assertTrue(); 714 done(); 715 }).catch((err) => { 716 console.error(`getCorrespondWallpaperTest005 err : ${err}`); 717 expect(null).assertTrue(); 718 done(); 719 }); 720 } catch (error) { 721 console.error(`getCorrespondWallpaperTest005 error : ${error}`); 722 expect(null).assertTrue(); 723 done(); 724 } 725 }) 726 727 /** 728 * @tc.name: getCorrespondWallpaperTest006 729 * @tc.desc: Test getCorrespondWallpaper() with normal argc 021. 730 * @tc.type: FUNC 731 */ 732 it('getCorrespondWallpaperTest006', 0, async function (done) { 733 try { 734 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_2, LAND).then((data) => { 735 console.info(`getCorrespondWallpaperTest006 data : ${data}`); 736 expect(data !== undefined && data !== null).assertTrue(); 737 done(); 738 }).catch((err) => { 739 console.error(`getCorrespondWallpaperTest006 err : ${err}`); 740 expect(null).assertTrue(); 741 done(); 742 }); 743 } catch (error) { 744 console.error(`getCorrespondWallpaperTest006 error : ${error}`); 745 expect(null).assertTrue(); 746 done(); 747 } 748 }) 749 750 /** 751 * @tc.name: getCorrespondWallpaperTest007 752 * @tc.desc: Test getCorrespondWallpaper() with normal argc 100. 753 * @tc.type: FUNC 754 */ 755 it('getCorrespondWallpaperTest007', 0, async function (done) { 756 try { 757 wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, NORMAL, PORT).then((data) => { 758 console.info(`getCorrespondWallpaperTest007 data : ${data}`); 759 expect(data !== undefined && data !== null).assertTrue(); 760 done(); 761 }).catch((err) => { 762 console.error(`getCorrespondWallpaperTest007 err : ${err}`); 763 expect(null).assertTrue(); 764 done(); 765 }); 766 } catch (error) { 767 console.error(`getCorrespondWallpaperTest007 error : ${error}`); 768 expect(null).assertTrue(); 769 done(); 770 } 771 }) 772 /** 773 * @tc.name: getCorrespondWallpaperTest008 774 * @tc.desc: Test getCorrespondWallpaper() with normal argc 101. 775 * @tc.type: FUNC 776 */ 777 it('getCorrespondWallpaperTest008', 0, async function (done) { 778 try { 779 wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, NORMAL, LAND).then((data) => { 780 console.info(`getCorrespondWallpaperTest008 data : ${data}`); 781 expect(data !== undefined && data !== null).assertTrue(); 782 done(); 783 }).catch((err) => { 784 console.error(`getCorrespondWallpaperTest008 err : ${err}`); 785 expect(null).assertTrue(); 786 done(); 787 }); 788 } catch (error) { 789 console.error(`getCorrespondWallpaperTest008 error : ${error}`); 790 expect(null).assertTrue(); 791 done(); 792 } 793 }) 794 /** 795 * @tc.name: getCorrespondWallpaperTest009 796 * @tc.desc: Test getCorrespondWallpaper() with normal argc 110. 797 * @tc.type: FUNC 798 */ 799 it('getCorrespondWallpaperTest009', 0, async function (done) { 800 try { 801 wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1, PORT).then((data) => { 802 console.info(`getCorrespondWallpaperTest009 data : ${data}`); 803 expect(data !== undefined && data !== null).assertTrue(); 804 done(); 805 }).catch((err) => { 806 console.error(`getCorrespondWallpaperTest009 err : ${err}`); 807 expect(null).assertTrue(); 808 done(); 809 }); 810 } catch (error) { 811 console.error(`getCorrespondWallpaperTest009 error : ${error}`); 812 expect(null).assertTrue(); 813 done(); 814 } 815 }) 816 817 /** 818 * @tc.name: getCorrespondWallpaperTest010 819 * @tc.desc: Test getCorrespondWallpaper() with normal argc 111. 820 * @tc.type: FUNC 821 */ 822 it('getCorrespondWallpaperTest010', 0, async function (done) { 823 try { 824 wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1, LAND).then((data) => { 825 console.info(`getCorrespondWallpaperTest010 data : ${data}`); 826 expect(data !== undefined && data !== null).assertTrue(); 827 done(); 828 }).catch((err) => { 829 console.error(`getCorrespondWallpaperTest010 err : ${err}`); 830 expect(null).assertTrue(); 831 done(); 832 }); 833 } catch (error) { 834 console.error(`getCorrespondWallpaperTest010 error : ${error}`); 835 expect(null).assertTrue(); 836 done(); 837 } 838 }) 839 840 /** 841 * @tc.name: getCorrespondWallpaperTest011 842 * @tc.desc: Test getCorrespondWallpaper() with normal argc 120. 843 * @tc.type: FUNC 844 */ 845 it('getCorrespondWallpaperTest011', 0, async function (done) { 846 try { 847 wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_2, PORT).then((data) => { 848 console.info(`getCorrespondWallpaperTest011 data : ${data}`); 849 expect(data !== undefined && data !== null).assertTrue(); 850 done(); 851 }).catch((err) => { 852 console.error(`getCorrespondWallpaperTest011 err : ${err}`); 853 expect(null).assertTrue(); 854 done(); 855 }); 856 } catch (error) { 857 console.error(`getCorrespondWallpaperTest011 error : ${error}`); 858 expect(null).assertTrue(); 859 done(); 860 } 861 }) 862 863 /** 864 * @tc.name: getCorrespondWallpaperTest012 865 * @tc.desc: Test getCorrespondWallpaper() with normal argc 121. 866 * @tc.type: FUNC 867 */ 868 it('getCorrespondWallpaperTest012', 0, async function (done) { 869 try { 870 wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_2, LAND).then((data) => { 871 console.info(`getCorrespondWallpaperTest012 data : ${data}`); 872 expect(data !== undefined && data !== null).assertTrue(); 873 done(); 874 }).catch((err) => { 875 console.error(`getCorrespondWallpaperTest012 err : ${err}`); 876 expect(null).assertTrue(); 877 done(); 878 }); 879 } catch (error) { 880 console.error(`getCorrespondWallpaperTest012 error : ${error}`); 881 expect(null).assertTrue(); 882 done(); 883 } 884 }) 885 886 /** 887 * @tc.name: getCorrespondWallpaperTest013 888 * @tc.desc: Test getCorrespondWallpaper() lack of argc. 889 * @tc.type: FUNC 890 */ 891 it('getCorrespondWallpaperTest013', 0, async function (done) { 892 try { 893 wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1).then((data) => { 894 console.error(`getCorrespondWallpaperTest013 data : ${data}`); 895 expect(null).assertTrue(); 896 done(); 897 }).catch((err) => { 898 console.error(`getCorrespondWallpaperTest013 err : ${err}`); 899 expect(null).assertTrue(); 900 done(); 901 }); 902 } catch (error) { 903 console.info(`getCorrespondWallpaperTest013 error : ${error}`); 904 expect(error.code === PARAMETER_ERROR).assertTrue(); 905 expect(error.message === PARAMETER_ERROR_MESSAGE + PARAMETER_COUNT).assertTrue(); 906 done(); 907 } 908 }) 909 910 /** 911 * @tc.name: getCorrespondWallpaperTest014 912 * @tc.desc: Test getCorrespondWallpaper() with invalid wallpaper type. 913 * @tc.type: FUNC 914 */ 915 it('getCorrespondWallpaperTest014', 0, async function (done) { 916 try { 917 wallpaper.getCorrespondWallpaper(INVALID_WALLPAPER_TYPE, UNFOLD_2, LAND).then((data) => { 918 console.error(`getCorrespondWallpaperTest014 data : ${data}`); 919 expect(null).assertTrue(); 920 done(); 921 }).catch((err) => { 922 console.error(`getCorrespondWallpaperTest014 err : ${err}`); 923 expect(null).assertTrue(); 924 done(); 925 }); 926 } catch (error) { 927 console.info(`getCorrespondWallpaperTest014 error : ${error}`); 928 expect(error.code === PARAMETER_ERROR).assertTrue(); 929 expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); 930 done(); 931 } 932 }) 933 934 /** 935 * @tc.name: getCorrespondWallpaperTest015 936 * @tc.desc: Test getCorrespondWallpaper() with invalid foldstate. 937 * @tc.type: FUNC 938 */ 939 it('getCorrespondWallpaperTest015', 0, async function (done) { 940 try { 941 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, INVALID_FOLDSTATE, PORT).then((data) => { 942 console.error(`getCorrespondWallpaperTest015 data : ${data}`); 943 expect(null).assertTrue(); 944 done(); 945 }).catch((err) => { 946 console.error(`getCorrespondWallpaperTest015 err : ${err}`); 947 expect(null).assertTrue(); 948 done(); 949 }); 950 } catch (error) { 951 console.info(`getCorrespondWallpaperTest015 error : ${error}`); 952 expect(error.code === PARAMETER_ERROR).assertTrue(); 953 expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); 954 done(); 955 } 956 }) 957 958 /** 959 * @tc.name: getCorrespondWallpaperTest016 960 * @tc.desc: Test getCorrespondWallpaper() with invalid rotatestate. 961 * @tc.type: FUNC 962 */ 963 it('getCorrespondWallpaperTest016', 0, async function (done) { 964 try { 965 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, INVALID_ROTATESTATE).then((data) => { 966 console.error(`getCorrespondWallpaperTest016 data : ${data}`); 967 expect(null).assertTrue(); 968 done(); 969 }).catch((err) => { 970 console.error(`getCorrespondWallpaperTest016 err : ${err}`); 971 expect(null).assertTrue(); 972 done(); 973 }); 974 } catch (error) { 975 console.info(`getCorrespondWallpaperTest016 error : ${error}`); 976 expect(error.code === PARAMETER_ERROR).assertTrue(); 977 expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); 978 done(); 979 } 980 }) 981 982 /** 983 * @tc.name: getCorrespondWallpaperTest017 984 * @tc.desc: Test getCorrespondWallpaper() with invalid wallpaper type. 985 * @tc.type: FUNC 986 */ 987 it('getCorrespondWallpaperTest017', 0, async function (done) { 988 try { 989 wallpaper.getCorrespondWallpaper("INVALID_TYPE", NORMAL, PORT).then((data) => { 990 console.error(`getCorrespondWallpaperTest017 data : ${data}`); 991 expect(null).assertTrue(); 992 done(); 993 }).catch((err) => { 994 console.error(`getCorrespondWallpaperTest017 err : ${err}`); 995 expect(null).assertTrue(); 996 done(); 997 }); 998 } catch (error) { 999 console.info(`getCorrespondWallpaperTest017 error : ${error}`); 1000 expect(error.code === PARAMETER_ERROR).assertTrue(); 1001 expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); 1002 done(); 1003 } 1004 }) 1005 1006 /** 1007 * @tc.name: getCorrespondWallpaperTest018 1008 * @tc.desc: Test getCorrespondWallpaper() to get wallpaper. 1009 * @tc.type: FUNC 1010 */ 1011 it('getCorrespondWallpaperTest018', 0, async function (done) { 1012 try { 1013 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, "INVALID_TYPE", PORT).then((data) => { 1014 console.error(`getCorrespondWallpaperTest018 data : ${data}`); 1015 expect(null).assertTrue(); 1016 done(); 1017 }).catch((err) => { 1018 console.error(`getCorrespondWallpaperTest018 err : ${err}`); 1019 expect(null).assertTrue(); 1020 done(); 1021 }); 1022 } catch (error) { 1023 console.info(`getCorrespondWallpaperTest018 error : ${error}`); 1024 expect(error.code === PARAMETER_ERROR).assertTrue(); 1025 expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); 1026 done(); 1027 } 1028 }) 1029 1030 /** 1031 * @tc.name: getCorrespondWallpaperTest019 1032 * @tc.desc: Test getCorrespondWallpaper() to get wallpaper. 1033 * @tc.type: FUNC 1034 */ 1035 it('getCorrespondWallpaperTest019', 0, async function (done) { 1036 try { 1037 wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, "INVALID_TYPE").then((data) => { 1038 console.error(`getCorrespondWallpaperTest019 data : ${data}`); 1039 expect(null).assertTrue(); 1040 done(); 1041 }).catch((err) => { 1042 console.error(`getCorrespondWallpaperTest019 err : ${err}`); 1043 expect(null).assertTrue(); 1044 done(); 1045 }); 1046 } catch (error) { 1047 console.info(`getCorrespondWallpaperTest019 error : ${error}`); 1048 expect(error.code === PARAMETER_ERROR).assertTrue(); 1049 expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); 1050 done(); 1051 } 1052 }) 1053 /** 1054 * @tc.name: getWallpaperByStateTest001 1055 * @tc.desc: Test getWallpaperByState() with normal argc 000. 1056 * @tc.type: FUNC 1057 */ 1058 it('getWallpaperByStateTest001', 0, async function (done) { 1059 try { 1060 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, PORTRAIT).then((data) => { 1061 console.info(`getWallpaperByStateTest001 data : ${data}`); 1062 expect(data !== undefined && data !== null).assertTrue(); 1063 done(); 1064 }).catch((err) => { 1065 console.error(`getWallpaperByStateTest001 err : ${err}`); 1066 expect(null).assertTrue(); 1067 done(); 1068 }); 1069 } catch (error) { 1070 console.error(`getWallpaperByStateTest001 error : ${error}`); 1071 expect(null).assertTrue(); 1072 done(); 1073 } 1074 }) 1075 1076 /** 1077 * @tc.name: getWallpaperByStateTest002 1078 * @tc.desc: Test getWallpaperByState() with normal argc 001. 1079 * @tc.type: FUNC 1080 */ 1081 it('getWallpaperByStateTest002', 0, async function (done) { 1082 try { 1083 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, LANDSCAPE).then((data) => { 1084 console.info(`getWallpaperByStateTest002 data : ${data}`); 1085 expect(data !== undefined && data !== null).assertTrue(); 1086 done(); 1087 }).catch((err) => { 1088 console.error(`getWallpaperByStateTest002 err : ${err}`); 1089 expect(null).assertTrue(); 1090 done(); 1091 }); 1092 } catch (error) { 1093 console.error(`getWallpaperByStateTest002 error : ${error}`); 1094 expect(null).assertTrue(); 1095 done(); 1096 } 1097 }) 1098 1099 /** 1100 * @tc.name: getWallpaperByStateTest003 1101 * @tc.desc: Test getWallpaperByState() with normal argc 010. 1102 * @tc.type: FUNC 1103 */ 1104 it('getWallpaperByStateTest003', 0, async function (done) { 1105 try { 1106 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_ONCE_STATE, PORTRAIT).then((data) => { 1107 console.info(`getWallpaperByStateTest003 data : ${data}`); 1108 expect(data !== undefined && data !== null).assertTrue(); 1109 done(); 1110 }).catch((err) => { 1111 console.error(`getWallpaperByStateTest003 err : ${err}`); 1112 expect(null).assertTrue(); 1113 done(); 1114 }); 1115 } catch (error) { 1116 console.error(`getWallpaperByStateTest003 error : ${error}`); 1117 expect(null).assertTrue(); 1118 done(); 1119 } 1120 }) 1121 1122 /** 1123 * @tc.name: getWallpaperByStateTest004 1124 * @tc.desc: Test getWallpaperByState() with normal argc 011. 1125 * @tc.type: FUNC 1126 */ 1127 it('getWallpaperByStateTest004', 0, async function (done) { 1128 try { 1129 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_ONCE_STATE, LANDSCAPE).then((data) => { 1130 console.info(`getWallpaperByStateTest004 data : ${data}`); 1131 expect(data !== undefined && data !== null).assertTrue(); 1132 done(); 1133 }).catch((err) => { 1134 console.error(`getWallpaperByStateTest004 err : ${err}`); 1135 expect(null).assertTrue(); 1136 done(); 1137 }); 1138 } catch (error) { 1139 console.error(`getWallpaperByStateTest004 error : ${error}`); 1140 expect(null).assertTrue(); 1141 done(); 1142 } 1143 }) 1144 1145 /** 1146 * @tc.name: getWallpaperByStateTest005 1147 * @tc.desc: Test getWallpaperByState() with normal argc 020. 1148 * @tc.type: FUNC 1149 */ 1150 it('getWallpaperByStateTest005', 0, async function (done) { 1151 try { 1152 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_TWICE_STATE, PORTRAIT).then((data) => { 1153 console.info(`getWallpaperByStateTest005 data : ${data}`); 1154 expect(data !== undefined && data !== null).assertTrue(); 1155 done(); 1156 }).catch((err) => { 1157 console.error(`getWallpaperByStateTest005 err : ${err}`); 1158 expect(null).assertTrue(); 1159 done(); 1160 }); 1161 } catch (error) { 1162 console.error(`getWallpaperByStateTest005 error : ${error}`); 1163 expect(null).assertTrue(); 1164 done(); 1165 } 1166 }) 1167 1168 /** 1169 * @tc.name: getWallpaperByStateTest006 1170 * @tc.desc: Test getWallpaperByState() with normal argc 021. 1171 * @tc.type: FUNC 1172 */ 1173 it('getWallpaperByStateTest006', 0, async function (done) { 1174 try { 1175 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { 1176 console.info(`getWallpaperByStateTest006 data : ${data}`); 1177 expect(data !== undefined && data !== null).assertTrue(); 1178 done(); 1179 }).catch((err) => { 1180 console.error(`getWallpaperByStateTest006 err : ${err}`); 1181 expect(null).assertTrue(); 1182 done(); 1183 }); 1184 } catch (error) { 1185 console.error(`getWallpaperByStateTest006 error : ${error}`); 1186 expect(null).assertTrue(); 1187 done(); 1188 } 1189 }) 1190 1191 /** 1192 * @tc.name: getWallpaperByStateTest007 1193 * @tc.desc: Test getWallpaperByState() with normal argc 100. 1194 * @tc.type: FUNC 1195 */ 1196 it('getWallpaperByStateTest007', 0, async function (done) { 1197 try { 1198 wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, NORMAL, PORTRAIT).then((data) => { 1199 console.info(`getWallpaperByStateTest007 data : ${data}`); 1200 expect(data !== undefined && data !== null).assertTrue(); 1201 done(); 1202 }).catch((err) => { 1203 console.error(`getWallpaperByStateTest007 err : ${err}`); 1204 expect(null).assertTrue(); 1205 done(); 1206 }); 1207 } catch (error) { 1208 console.error(`getWallpaperByStateTest007 error : ${error}`); 1209 expect(null).assertTrue(); 1210 done(); 1211 } 1212 }) 1213 /** 1214 * @tc.name: getWallpaperByStateTest008 1215 * @tc.desc: Test getWallpaperByState() with normal argc 101. 1216 * @tc.type: FUNC 1217 */ 1218 it('getWallpaperByStateTest008', 0, async function (done) { 1219 try { 1220 wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, NORMAL, LANDSCAPE).then((data) => { 1221 console.info(`getWallpaperByStateTest008 data : ${data}`); 1222 expect(data !== undefined && data !== null).assertTrue(); 1223 done(); 1224 }).catch((err) => { 1225 console.error(`getWallpaperByStateTest008 err : ${err}`); 1226 expect(null).assertTrue(); 1227 done(); 1228 }); 1229 } catch (error) { 1230 console.error(`getWallpaperByStateTest008 error : ${error}`); 1231 expect(null).assertTrue(); 1232 done(); 1233 } 1234 }) 1235 /** 1236 * @tc.name: getWallpaperByStateTest009 1237 * @tc.desc: Test getWallpaperByState() with normal argc 110. 1238 * @tc.type: FUNC 1239 */ 1240 it('getWallpaperByStateTest009', 0, async function (done) { 1241 try { 1242 wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE, PORTRAIT).then((data) => { 1243 console.info(`getWallpaperByStateTest009 data : ${data}`); 1244 expect(data !== undefined && data !== null).assertTrue(); 1245 done(); 1246 }).catch((err) => { 1247 console.error(`getWallpaperByStateTest009 err : ${err}`); 1248 expect(null).assertTrue(); 1249 done(); 1250 }); 1251 } catch (error) { 1252 console.error(`getWallpaperByStateTest009 error : ${error}`); 1253 expect(null).assertTrue(); 1254 done(); 1255 } 1256 }) 1257 1258 /** 1259 * @tc.name: getWallpaperByStateTest010 1260 * @tc.desc: Test getWallpaperByState() with normal argc 111. 1261 * @tc.type: FUNC 1262 */ 1263 it('getWallpaperByStateTest010', 0, async function (done) { 1264 try { 1265 wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE, LANDSCAPE).then((data) => { 1266 console.info(`getWallpaperByStateTest010 data : ${data}`); 1267 expect(data !== undefined && data !== null).assertTrue(); 1268 done(); 1269 }).catch((err) => { 1270 console.error(`getWallpaperByStateTest010 err : ${err}`); 1271 expect(null).assertTrue(); 1272 done(); 1273 }); 1274 } catch (error) { 1275 console.error(`getWallpaperByStateTest010 error : ${error}`); 1276 expect(null).assertTrue(); 1277 done(); 1278 } 1279 }) 1280 1281 /** 1282 * @tc.name: getWallpaperByStateTest011 1283 * @tc.desc: Test getWallpaperByState() with normal argc 120. 1284 * @tc.type: FUNC 1285 */ 1286 it('getWallpaperByStateTest011', 0, async function (done) { 1287 try { 1288 wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_TWICE_STATE, PORTRAIT).then((data) => { 1289 console.info(`getWallpaperByStateTest011 data : ${data}`); 1290 expect(data !== undefined && data !== null).assertTrue(); 1291 done(); 1292 }).catch((err) => { 1293 console.error(`getWallpaperByStateTest011 err : ${err}`); 1294 expect(null).assertTrue(); 1295 done(); 1296 }); 1297 } catch (error) { 1298 console.error(`getWallpaperByStateTest011 error : ${error}`); 1299 expect(null).assertTrue(); 1300 done(); 1301 } 1302 }) 1303 1304 /** 1305 * @tc.name: getWallpaperByStateTest012 1306 * @tc.desc: Test getWallpaperByState() with normal argc 121. 1307 * @tc.type: FUNC 1308 */ 1309 it('getWallpaperByStateTest012', 0, async function (done) { 1310 try { 1311 wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { 1312 console.info(`getWallpaperByStateTest012 data : ${data}`); 1313 expect(data !== undefined && data !== null).assertTrue(); 1314 done(); 1315 }).catch((err) => { 1316 console.error(`getWallpaperByStateTest012 err : ${err}`); 1317 expect(null).assertTrue(); 1318 done(); 1319 }); 1320 } catch (error) { 1321 console.error(`getWallpaperByStateTest012 error : ${error}`); 1322 expect(null).assertTrue(); 1323 done(); 1324 } 1325 }) 1326 1327 /** 1328 * @tc.name: getWallpaperByStateTest013 1329 * @tc.desc: Test getWallpaperByState() lack of argc. 1330 * @tc.type: FUNC 1331 */ 1332 it('getWallpaperByStateTest013', 0, async function (done) { 1333 try { 1334 wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE).then((data) => { 1335 console.error(`getWallpaperByStateTest013 data : ${data}`); 1336 expect(null).assertTrue(); 1337 done(); 1338 }).catch((err) => { 1339 console.error(`getWallpaperByStateTest013 err : ${err}`); 1340 expect(null).assertTrue(); 1341 done(); 1342 }); 1343 } catch (error) { 1344 console.info(`getWallpaperByStateTest013 error : ${error}`); 1345 expect(error.code === PARAMETER_ERROR).assertTrue(); 1346 expect(error.message === PARAMETER_ERROR_MESSAGE + PARAMETER_COUNT).assertTrue(); 1347 done(); 1348 } 1349 }) 1350 1351 /** 1352 * @tc.name: getWallpaperByStateTest014 1353 * @tc.desc: Test getWallpaperByState() with invalid wallpaper type. 1354 * @tc.type: FUNC 1355 */ 1356 it('getWallpaperByStateTest014', 0, async function (done) { 1357 try { 1358 wallpaper.getWallpaperByState(INVALID_WALLPAPER_TYPE, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { 1359 console.error(`getWallpaperByStateTest014 data : ${data}`); 1360 expect(null).assertTrue(); 1361 done(); 1362 }).catch((err) => { 1363 console.error(`getWallpaperByStateTest014 err : ${err}`); 1364 expect(null).assertTrue(); 1365 done(); 1366 }); 1367 } catch (error) { 1368 console.info(`getWallpaperByStateTest014 error : ${error}`); 1369 expect(error.code === PARAMETER_ERROR).assertTrue(); 1370 expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); 1371 done(); 1372 } 1373 }) 1374 1375 /** 1376 * @tc.name: getWallpaperByStateTest015 1377 * @tc.desc: Test getWallpaperByState() with invalid foldstate. 1378 * @tc.type: FUNC 1379 */ 1380 it('getWallpaperByStateTest015', 0, async function (done) { 1381 try { 1382 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, INVALID_FOLDSTATE, PORTRAIT).then((data) => { 1383 console.error(`getWallpaperByStateTest015 data : ${data}`); 1384 expect(null).assertTrue(); 1385 done(); 1386 }).catch((err) => { 1387 console.error(`getWallpaperByStateTest015 err : ${err}`); 1388 expect(null).assertTrue(); 1389 done(); 1390 }); 1391 } catch (error) { 1392 console.info(`getWallpaperByStateTest015 error : ${error}`); 1393 expect(error.code === PARAMETER_ERROR).assertTrue(); 1394 expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); 1395 done(); 1396 } 1397 }) 1398 1399 /** 1400 * @tc.name: getWallpaperByStateTest016 1401 * @tc.desc: Test getWallpaperByState() with invalid rotatestate. 1402 * @tc.type: FUNC 1403 */ 1404 it('getWallpaperByStateTest016', 0, async function (done) { 1405 try { 1406 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, INVALID_ROTATESTATE).then((data) => { 1407 console.error(`getWallpaperByStateTest016 data : ${data}`); 1408 expect(null).assertTrue(); 1409 done(); 1410 }).catch((err) => { 1411 console.error(`getWallpaperByStateTest016 err : ${err}`); 1412 expect(null).assertTrue(); 1413 done(); 1414 }); 1415 } catch (error) { 1416 console.info(`getWallpaperByStateTest016 error : ${error}`); 1417 expect(error.code === PARAMETER_ERROR).assertTrue(); 1418 expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); 1419 done(); 1420 } 1421 }) 1422 1423 /** 1424 * @tc.name: getWallpaperByStateTest017 1425 * @tc.desc: Test getWallpaperByState() with invalid wallpaper type. 1426 * @tc.type: FUNC 1427 */ 1428 it('getWallpaperByStateTest017', 0, async function (done) { 1429 try { 1430 wallpaper.getWallpaperByState("INVALID_TYPE", NORMAL, PORTRAIT).then((data) => { 1431 console.error(`getWallpaperByStateTest017 data : ${data}`); 1432 expect(null).assertTrue(); 1433 done(); 1434 }).catch((err) => { 1435 console.error(`getWallpaperByStateTest017 err : ${err}`); 1436 expect(null).assertTrue(); 1437 done(); 1438 }); 1439 } catch (error) { 1440 console.info(`getWallpaperByStateTest017 error : ${error}`); 1441 expect(error.code === PARAMETER_ERROR).assertTrue(); 1442 expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); 1443 done(); 1444 } 1445 }) 1446 1447 /** 1448 * @tc.name: getWallpaperByStateTest018 1449 * @tc.desc: Test getWallpaperByState() to get wallpaper. 1450 * @tc.type: FUNC 1451 */ 1452 it('getWallpaperByStateTest018', 0, async function (done) { 1453 try { 1454 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, "INVALID_TYPE", PORTRAIT).then((data) => { 1455 console.error(`getWallpaperByStateTest018 data : ${data}`); 1456 expect(null).assertTrue(); 1457 done(); 1458 }).catch((err) => { 1459 console.error(`getWallpaperByStateTest018 err : ${err}`); 1460 expect(null).assertTrue(); 1461 done(); 1462 }); 1463 } catch (error) { 1464 console.info(`getWallpaperByStateTest018 error : ${error}`); 1465 expect(error.code === PARAMETER_ERROR).assertTrue(); 1466 expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); 1467 done(); 1468 } 1469 }) 1470 1471 /** 1472 * @tc.name: getWallpaperByStateTest019 1473 * @tc.desc: Test getWallpaperByState() to get wallpaper. 1474 * @tc.type: FUNC 1475 */ 1476 it('getWallpaperByStateTest019', 0, async function (done) { 1477 try { 1478 wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, "INVALID_TYPE").then((data) => { 1479 console.error(`getWallpaperByStateTest019 data : ${data}`); 1480 expect(null).assertTrue(); 1481 done(); 1482 }).catch((err) => { 1483 console.error(`getWallpaperByStateTest019 err : ${err}`); 1484 expect(null).assertTrue(); 1485 done(); 1486 }); 1487 } catch (error) { 1488 console.info(`getWallpaperByStateTest019 error : ${error}`); 1489 expect(error.code === PARAMETER_ERROR).assertTrue(); 1490 expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); 1491 done(); 1492 } 1493 }) 1494 1495 /** 1496 * @tc.name: setImageURIPromiseLockTest001 1497 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a 1498 * JPEG or PNG file or the pixel map of a PNG file. 1499 * @tc.type: FUNC test 1500 * @tc.require: issueI5UHRG 1501 */ 1502 it('setImageURIPromiseLockTest001', 0, async function (done) { 1503 try { 1504 wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN).then(async () => { 1505 expect(true).assertTrue(); 1506 done(); 1507 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1508 }).catch((err) => { 1509 console.info(`setImageURIPromiseLockTest001 err : ${err}`); 1510 expect(null).assertFail(); 1511 done(); 1512 }); 1513 } catch (error) { 1514 expect(null).assertFail(); 1515 done(); 1516 } 1517 }) 1518 1519 /** 1520 * @tc.name: setImageURICallbackSystemTest002 1521 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a 1522 * JPEG or PNG file or the pixel map of a PNG file. 1523 * @tc.type: FUNC test 1524 * @tc.require: issueI5UHRG 1525 */ 1526 it('setImageURICallbackSystemTest002', 0, async function (done) { 1527 try { 1528 wallpaper.setImage(URI, WALLPAPER_SYSTEM, async function (err) { 1529 if (err) { 1530 expect(null).assertFail(); 1531 console.info(`set Image URI CallbackSystemTest002 fail : ${err}`); 1532 } else { 1533 expect(true).assertTrue(); 1534 } 1535 done(); 1536 await wallpaper.restore(WALLPAPER_SYSTEM); 1537 }); 1538 } catch (error) { 1539 expect(null).assertFail(); 1540 console.info(`set Image URI CallbackSystemTest002 fail : ${error}`); 1541 done(); 1542 } 1543 }) 1544 1545 /** 1546 * @tc.name: setImageURIPromiseSystemTest003 1547 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a 1548 * JPEG or PNG file or the pixel map of a PNG file. 1549 * @tc.type: FUNC test 1550 * @tc.require: issueI5UHRG 1551 */ 1552 it('setImageURIPromiseSystemTest003', 0, async function (done) { 1553 try { 1554 wallpaper.setImage(URI, WALLPAPER_SYSTEM).then(async () => { 1555 expect(true).assertTrue(); 1556 done(); 1557 await wallpaper.restore(WALLPAPER_SYSTEM); 1558 }).catch((err) => { 1559 console.info(`setImageURIPromiseSystemTest003 err : ${err}`); 1560 expect(null).assertFail(); 1561 done(); 1562 }); 1563 } catch (error) { 1564 expect(null).assertFail(); 1565 done(); 1566 } 1567 }) 1568 1569 /** 1570 * @tc.name: setImageURICallbackLockTest004 1571 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a 1572 * JPEG or PNG file or the pixel map of a PNG file. 1573 * @tc.type: FUNC test 1574 * @tc.require: issueI5UHRG 1575 */ 1576 it('setImageURICallbackLockTest004', 0, async function (done) { 1577 try { 1578 wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN, async function (err) { 1579 if (err) { 1580 console.info(`setImageURICallbackLockTest004 err : ${err}`); 1581 expect(null).assertFail(); 1582 } else { 1583 expect(true).assertTrue(); 1584 } 1585 done(); 1586 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1587 }); 1588 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1589 } catch (error) { 1590 expect(null).assertFail(); 1591 done(); 1592 } 1593 }) 1594 1595 /** 1596 * @tc.name: setImageMapPromiseLockTest005 1597 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. 1598 * @tc.type: FUNC test 1599 * @tc.require: issueI5UHRG 1600 */ 1601 it('setImageMapPromiseLockTest005', 0, async function (done) { 1602 try { 1603 let pixelMap = await createTempPixelMap(); 1604 wallpaper.setImage(pixelMap, WALLPAPER_LOCKSCREEN).then(async () => { 1605 expect(true).assertTrue(); 1606 done(); 1607 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1608 }).catch((err) => { 1609 console.info(`setImageMapPromiseLockTest005 err : ${err}`); 1610 expect(null).assertFail(); 1611 done(); 1612 }); 1613 } catch (error) { 1614 expect(null).assertFail(); 1615 done(); 1616 } 1617 }) 1618 1619 /** 1620 * @tc.name: setImageMapCallbackSystemTest006 1621 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. 1622 * @tc.type: FUNC test 1623 * @tc.require: issueI5UHRG 1624 */ 1625 it('setImageMapCallbackSystemTest006', 0, async function (done) { 1626 try { 1627 let pixelMap = await createTempPixelMap(); 1628 wallpaper.setImage(pixelMap, WALLPAPER_SYSTEM, async function (err) { 1629 if (err) { 1630 expect(null).assertFail(); 1631 console.info(`set ImageMap CallbackSystemTest006 fail : ${err}`); 1632 } else { 1633 expect(true).assertTrue(); 1634 } 1635 done(); 1636 await wallpaper.restore(WALLPAPER_SYSTEM); 1637 }); 1638 } catch (error) { 1639 expect(null).assertFail(); 1640 console.info(`set ImageMap CallbackSystemTest006 fail : ${error}`); 1641 done(); 1642 } 1643 }) 1644 1645 /** 1646 * @tc.name: setImageMapPromiseSystemTest007 1647 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. 1648 * @tc.type: FUNC test 1649 * @tc.require: issueI5UHRG 1650 */ 1651 it('setImageMapPromiseSystemTest007', 0, async function (done) { 1652 try { 1653 let pixelMap = await createTempPixelMap(); 1654 wallpaper.setImage(pixelMap, WALLPAPER_SYSTEM).then(async () => { 1655 expect(true).assertTrue(); 1656 done(); 1657 await wallpaper.restore(WALLPAPER_SYSTEM); 1658 }).catch((err) => { 1659 console.info(`setImageMapPromiseSystemTest007 err : ${err}`); 1660 expect(null).assertFail(); 1661 done(); 1662 }); 1663 } catch (error) { 1664 expect(null).assertFail(); 1665 done(); 1666 } 1667 }) 1668 1669 /** 1670 * @tc.name: setImageMapCallbackLockTest008 1671 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. 1672 * @tc.type: FUNC test 1673 * @tc.require: issueI5UHRG 1674 */ 1675 it('setImageMapCallbackLockTest008', 0, async function (done) { 1676 try { 1677 let pixelMap = await createTempPixelMap(); 1678 wallpaper.setImage(pixelMap, WALLPAPER_LOCKSCREEN, async function (err) { 1679 if (err) { 1680 expect(null).assertFail(); 1681 console.info(`set ImageMap CallbackLockTest008 fail : ${err}`); 1682 } else { 1683 expect(true).assertTrue(); 1684 } 1685 done(); 1686 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1687 }); 1688 } catch (error) { 1689 expect(null).assertFail(); 1690 console.info(`set ImageMap CallbackLockTest008 fail : ${error}`); 1691 done(); 1692 } 1693 }) 1694 1695 /** 1696 * @tc.name: setImageCallbackThrowErrorTest009 1697 * @tc.desc: Test setImage() throw parameter error. 1698 * @tc.type: FUNC test 1699 * @tc.require: issueI5UHRG 1700 */ 1701 it('setImageCallbackThrowErrorTest009', 0, async function (done) { 1702 try { 1703 wallpaper.setImage(URI, INVALID_WALLPAPER_TYPE, function (err) { 1704 if (err) { 1705 expect(err.code === PARAMETER_ERROR).assertTrue() 1706 console.info(`set Image CallbackThrowErrorTest009 fail : ${err}`); 1707 } else { 1708 expect(null).assertFail(); 1709 } 1710 done(); 1711 }) 1712 } catch (error) { 1713 expect(null).assertFail(); 1714 console.info(`set Image CallbackThrowErrorTest009 fail : ${error}`); 1715 done(); 1716 } 1717 }) 1718 1719 /** 1720 * @tc.name: setImageCallbackThrowErrorTest010 1721 * @tc.desc: Test setImage() throw parameter error. 1722 * @tc.type: FUNC test 1723 * @tc.require: issueI5UHRG 1724 */ 1725 it('setImageCallbackThrowErrorTest010', 0, async function (done) { 1726 try { 1727 wallpaper.setImage(URI, function (err) { 1728 if (err) { 1729 expect(null).assertFail(); 1730 console.info(`set Image CallbackThrowErrorTest010 fail : ${err}`); 1731 } else { 1732 expect(null).assertFail(); 1733 } 1734 done(); 1735 }) 1736 } catch (error) { 1737 expect(error.code === PARAMETER_ERROR).assertTrue() 1738 console.info(`set Image CallbackThrowErrorTest010 fail : ${error}`); 1739 done(); 1740 } 1741 }) 1742 1743 /** 1744 * @tc.name: setImagePromiseThrowErrorTest011 1745 * @tc.desc: Test setImage() throw parameter error. 1746 * @tc.type: FUNC test 1747 * @tc.require: issueI5UHRG 1748 */ 1749 it('setImagePromiseThrowErrorTest011', 0, async function (done) { 1750 try { 1751 wallpaper.setImage(URI, INVALID_WALLPAPER_TYPE).then(() => { 1752 expect(null).assertFail(); 1753 done(); 1754 }).catch((err) => { 1755 console.info(`setImagePromiseThrowErrorTest011 err : ${err}`); 1756 expect(err.code === PARAMETER_ERROR).assertTrue() 1757 done(); 1758 }); 1759 } catch (error) { 1760 expect(null).assertFail(); 1761 done(); 1762 } 1763 }) 1764 1765 /** 1766 * @tc.name: setImagePromiseThrowErrorTest012 1767 * @tc.desc: Test setImage() throw parameter error. 1768 * @tc.type: FUNC test 1769 * @tc.require: issueI5UHRG 1770 */ 1771 it('setImagePromiseThrowErrorTest012', 0, async function (done) { 1772 try { 1773 wallpaper.setImage().then(() => { 1774 expect(null).assertFail(); 1775 done(); 1776 }).catch((err) => { 1777 console.info(`setImagePromiseThrowErrorTest012 err : ${err}`); 1778 expect(null).assertFail(); 1779 done(); 1780 }); 1781 } catch (error) { 1782 expect(error.code === PARAMETER_ERROR).assertTrue() 1783 done(); 1784 } 1785 }) 1786 1787 /** 1788 * @tc.name: setWallpaperMapPromiseLockTest001 1789 * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. 1790 * @tc.type: FUNC test 1791 * @tc.require: issueI5UHRG 1792 */ 1793 it('setWallpaperMapPromiseLockTest001', 0, async function (done) { 1794 try { 1795 let pixelMap = await createTempPixelMap(); 1796 wallpaper.setWallpaper(pixelMap, WALLPAPER_LOCKSCREEN).then(async () => { 1797 expect(true).assertTrue(); 1798 done(); 1799 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1800 }).catch((err) => { 1801 console.info(`setWallpaperMapPromiseLockTest001 err : ${err}`); 1802 expect(null).assertFail(); 1803 done(); 1804 }); 1805 } catch (error) { 1806 expect(null).assertFail(); 1807 done(); 1808 } 1809 }) 1810 1811 /** 1812 * @tc.name: setWallpaperMapCallbackSystemTest002 1813 * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. 1814 * @tc.type: FUNC test 1815 * @tc.require: issueI5UHRG 1816 */ 1817 it('setWallpaperMapCallbackSystemTest002', 0, async function (done) { 1818 try { 1819 let pixelMap = await createTempPixelMap(); 1820 wallpaper.setWallpaper(pixelMap, WALLPAPER_SYSTEM, async function (err) { 1821 if (err) { 1822 expect(null).assertFail(); 1823 console.info(`set Wallpaper Map CallbackSystemTest002 fail : ${err}`); 1824 } else { 1825 expect(true).assertTrue(); 1826 } 1827 done(); 1828 await wallpaper.restore(WALLPAPER_SYSTEM); 1829 }); 1830 } catch (error) { 1831 expect(null).assertFail(); 1832 console.info(`set Wallpaper Map CallbackSystemTest002 fail : ${error}`); 1833 done(); 1834 } 1835 }) 1836 1837 /** 1838 * @tc.name: setWallpaperMapPromiseSystemTest003 1839 * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. 1840 * @tc.type: FUNC test 1841 * @tc.require: issueI5UHRG 1842 */ 1843 it('setWallpaperMapPromiseSystemTest003', 0, async function (done) { 1844 try { 1845 let pixelMap = await createTempPixelMap(); 1846 wallpaper.setWallpaper(pixelMap, WALLPAPER_SYSTEM).then(async () => { 1847 expect(true).assertTrue(); 1848 done(); 1849 await wallpaper.restore(WALLPAPER_SYSTEM); 1850 }).catch((err) => { 1851 console.info(`setWallpaperMapPromiseSystemTest003 err : ${err}`); 1852 expect(null).assertFail(); 1853 done(); 1854 }); 1855 } catch (error) { 1856 expect(null).assertFail(); 1857 done(); 1858 } 1859 }) 1860 1861 /** 1862 * @tc.name: setWallpaperMapCallbackLockTest004 1863 * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. 1864 * @tc.type: FUNC test 1865 * @tc.require: issueI5UHRG 1866 */ 1867 it('setWallpaperMapCallbackLockTest004', 0, async function (done) { 1868 try { 1869 let pixelMap = await createTempPixelMap(); 1870 wallpaper.setWallpaper(pixelMap, WALLPAPER_LOCKSCREEN, async function (err) { 1871 if (err) { 1872 expect(null).assertFail(); 1873 console.info(`set Wallpaper Map CallbackLockTest004 fail : ${err}`); 1874 } else { 1875 expect(true).assertTrue(); 1876 } 1877 done(); 1878 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1879 }); 1880 } catch (error) { 1881 expect(null).assertFail(); 1882 console.info(`set Wallpaper Map CallbackLockTest004 fail : ${error}`); 1883 done(); 1884 } 1885 }) 1886 1887 1888 /** 1889 * @tc.name: getPixelMapPromiseLockTest001 1890 * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. 1891 * @tc.type: FUNC test 1892 * @tc.require: issueI5UHRG 1893 */ 1894 it('getPixelMapPromiseLockTest001', 0, async function (done) { 1895 try { 1896 wallpaper.getPixelMap(WALLPAPER_LOCKSCREEN).then((data) => { 1897 if (data !== undefined) { 1898 expect(true).assertTrue(); 1899 } 1900 done(); 1901 }).catch((err) => { 1902 console.info(`getPixelMapPromiseLockTest001 err : ${err}`); 1903 expect(null).assertFail(); 1904 done(); 1905 }); 1906 } catch (error) { 1907 expect(null).assertFail(); 1908 done(); 1909 } 1910 }) 1911 1912 /** 1913 * @tc.name: getPixelMapCallbackSystemTest002 1914 * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. 1915 * @tc.type: FUNC test 1916 * @tc.require: issueI5UHRG 1917 */ 1918 it('getPixelMapCallbackSystemTest002', 0, async function (done) { 1919 try { 1920 wallpaper.getPixelMap(WALLPAPER_SYSTEM, function (err, data) { 1921 if (err) { 1922 expect(null).assertFail(); 1923 console.info(`get Pixel Map CallbackSystemTest002 fail : ${err}`); 1924 } else { 1925 if (data !== undefined) { 1926 expect(true).assertTrue(); 1927 } 1928 } 1929 done(); 1930 }); 1931 } catch (error) { 1932 expect(null).assertFail(); 1933 console.info(`get Pixel MapCallbackSystemTest002 fail : ${error}`); 1934 done(); 1935 } 1936 }) 1937 1938 /** 1939 * @tc.name: getPixelMapPromiseSystemTest003 1940 * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. 1941 * @tc.type: FUNC test 1942 * @tc.require: issueI5UHRG 1943 */ 1944 it('getPixelMapPromiseSystemTest003', 0, async function (done) { 1945 try { 1946 wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => { 1947 if (data !== undefined) { 1948 expect(true).assertTrue(); 1949 } 1950 done(); 1951 }).catch((err) => { 1952 console.info(`getPixelMapPromiseSystemTest003 err : ${err}`); 1953 expect(null).assertFail(); 1954 done(); 1955 }); 1956 } catch (error) { 1957 expect(null).assertFail(); 1958 done(); 1959 } 1960 }) 1961 1962 /** 1963 * @tc.name: getPixelMapCallbackLockTest004 1964 * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. 1965 * @tc.type: FUNC test 1966 * @tc.require: issueI5UHRG 1967 */ 1968 it('getPixelMapCallbackLockTest004', 0, async function (done) { 1969 try { 1970 wallpaper.getPixelMap(WALLPAPER_LOCKSCREEN, function (err, data) { 1971 if (err) { 1972 expect(null).assertFail(); 1973 console.info(`get Pixel Map CallbackLockTest004 fail : ${err}`); 1974 } else { 1975 if (data !== undefined) { 1976 expect(true).assertTrue(); 1977 } 1978 } 1979 done(); 1980 }); 1981 } catch (error) { 1982 expect(null).assertFail(); 1983 console.info(`get Pixel Map CallbackLockTest004 fail : ${error}`); 1984 done(); 1985 } 1986 }) 1987 1988 /** 1989 * @tc.name: resetCallbackSystemTest001 1990 * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. 1991 * @tc.type: FUNC test 1992 * @tc.require: issueI5UHRG 1993 */ 1994 it('resetCallbackSystemTest001', 0, async function (done) { 1995 try { 1996 wallpaper.reset(WALLPAPER_SYSTEM, function (err) { 1997 if (err) { 1998 expect(null).assertFail() 1999 console.info(`reset CallbackSystemTest001 fail : ${err}`); 2000 } else { 2001 expect(true).assertTrue(); 2002 } 2003 done(); 2004 }) 2005 2006 } catch (error) { 2007 expect(null).assertFail(); 2008 console.info(`reset CallbackSystemTest001 fail : ${error}`); 2009 done(); 2010 } 2011 2012 }) 2013 2014 /** 2015 * @tc.name: resetPromiseSystemTest002 2016 * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. 2017 * @tc.type: FUNC test 2018 * @tc.require: issueI5UHRG 2019 */ 2020 it('resetPromiseSystemTest002', 0, async function (done) { 2021 try { 2022 wallpaper.reset(WALLPAPER_SYSTEM).then(() => { 2023 expect(true).assertTrue(); 2024 done(); 2025 }).catch((err) => { 2026 console.info(`resetPromiseSystemTest002 err : ${err}`); 2027 expect(null).assertFail(); 2028 done(); 2029 }); 2030 } catch (error) { 2031 expect(null).assertFail(); 2032 done(); 2033 } 2034 }) 2035 2036 /** 2037 * @tc.name: resetCallbackLockTest003 2038 * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. 2039 * @tc.type: FUNC test 2040 * @tc.require: issueI5UHRG 2041 */ 2042 it('resetCallbackLockTest003', 0, async function (done) { 2043 try { 2044 wallpaper.reset(WALLPAPER_LOCKSCREEN, function (err) { 2045 if (err) { 2046 expect(null).assertFail(); 2047 console.info(`reset CallbackLockTest003 fail : ${err}`); 2048 } else { 2049 expect(true).assertTrue(); 2050 } 2051 done(); 2052 }) 2053 } catch (error) { 2054 expect(null).assertFail(); 2055 console.info(`reset CallbackLockTest003 fail : ${error}`); 2056 done(); 2057 } 2058 }) 2059 2060 /** 2061 * @tc.name: resetPromiseLockTest004 2062 * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. 2063 * @tc.type: FUNC test 2064 * @tc.require: issueI5UHRG 2065 */ 2066 it('resetPromiseLockTest004', 0, async function (done) { 2067 try { 2068 wallpaper.reset(WALLPAPER_LOCKSCREEN).then(() => { 2069 expect(true).assertTrue(); 2070 done(); 2071 }).catch((err) => { 2072 console.info(`resetPromiseLockTest004 err : ${err}`); 2073 expect(null).assertFail(); 2074 done(); 2075 }); 2076 } catch (error) { 2077 expect(null).assertFail(); 2078 done(); 2079 } 2080 }) 2081 2082 /** 2083 * @tc.name: isOperationAllowedCallbackTest001 2084 * @tc.desc: Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. 2085 * @tc.type: FUNC test 2086 * @tc.require: issueI5UHRG 2087 */ 2088 it('isOperationAllowedCallbackTest001', 0, async function (done) { 2089 try { 2090 wallpaper.isOperationAllowed(function (err, data) { 2091 if (err) { 2092 console.info(`isOperationAllowedCallbackTest001 err : ${err}`); 2093 expect(null).assertFail(); 2094 } else { 2095 console.info(`isOperationAllowedCallbackTest001 data : ${data}`); 2096 expect(true).assertTrue(); 2097 } 2098 done(); 2099 }) 2100 } catch (error) { 2101 expect(null).assertFail(); 2102 done(); 2103 } 2104 }) 2105 2106 /** 2107 * @tc.name: isOperationAllowedPromiseTest002 2108 * @tc.desc: Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. 2109 * @tc.type: FUNC test 2110 * @tc.require: issueI5UHRG 2111 */ 2112 it('isOperationAllowedPromiseTest002', 0, async function (done) { 2113 try { 2114 wallpaper.isOperationAllowed().then((data) => { 2115 console.info(`isOperationAllowedPromiseTest002 data : ${data}`); 2116 expect(true).assertTrue(); 2117 done(); 2118 }).catch((err) => { 2119 console.info(`isOperationAllowedPromiseTest002 err : ${err}`); 2120 expect(null).assertFail(); 2121 done(); 2122 }); 2123 } catch (error) { 2124 expect(null).assertFail(); 2125 done(); 2126 } 2127 }) 2128 2129 /** 2130 * @tc.name: isChangePermittedCallbackTest001 2131 * @tc.desc: Test isChangePermitted() to checks whether to allow the application to change the 2132 * wallpaper for the current user. 2133 * @tc.type: FUNC test 2134 * @tc.require: issueI5UHRG 2135 */ 2136 it('isChangePermittedCallbackTest001', 0, async function (done) { 2137 try { 2138 wallpaper.isChangePermitted(function (err, data) { 2139 if (err) { 2140 console.info(`isChangePermittedCallbackTest001 err : ${err}`); 2141 expect(null).assertFail(); 2142 } else { 2143 console.info(`isChangePermittedCallbackTest001 data : ${data}`); 2144 expect(true).assertTrue(); 2145 } 2146 done(); 2147 }) 2148 } catch (error) { 2149 expect(null).assertFail(); 2150 done(); 2151 } 2152 }) 2153 2154 /** 2155 * @tc.name: isChangePermittedPromiseTest002 2156 * @tc.desc: Test isChangePermitted() to checks whether to allow the application to change the 2157 * wallpaper for the current user. 2158 * @tc.type: FUNC test 2159 * @tc.require: issueI5UHRG 2160 */ 2161 it('isChangePermittedPromiseTest002', 0, async function (done) { 2162 try { 2163 wallpaper.isChangePermitted().then((data) => { 2164 console.info(`isChangePermittedPromiseTest002 data : ${data}`); 2165 expect(true).assertTrue(); 2166 done(); 2167 }).catch((err) => { 2168 console.info(`isChangePermittedPromiseTest002 err : ${err}`); 2169 expect(null).assertFail(); 2170 done(); 2171 }); 2172 } catch (error) { 2173 expect(null).assertFail(); 2174 done(); 2175 } 2176 }) 2177 2178 /** 2179 * @tc.name: getMinWidthCallbackTest001 2180 * @tc.desc: Test getMinWidth() to gets the minWidth of the WALLPAPER_SYSTEM of the specified type. 2181 * @tc.type: FUNC test 2182 * @tc.require: issueI5UHRG 2183 */ 2184 it('getMinWidthCallbackTest001', 0, async function (done) { 2185 try { 2186 wallpaper.getMinWidth(function (err, data) { 2187 if (err) { 2188 console.info(`getMinWidthCallbackTest001 err : ${err}`); 2189 expect(null).assertFail(); 2190 } else { 2191 console.info(`getMinWidthCallbackTest001 data : ${data}`); 2192 expect(true).assertTrue(); 2193 } 2194 done(); 2195 }) 2196 } catch (error) { 2197 expect(null).assertFail(); 2198 done(); 2199 } 2200 }) 2201 2202 /** 2203 * @tc.name: getMinWidthPromiseTest002 2204 * @tc.desc: Test getMinWidth() to gets the minWidth of the WALLPAPER_SYSTEM of the specified type. 2205 * @tc.type: FUNC test 2206 * @tc.require: issueI5UHRG 2207 */ 2208 it('getMinWidthPromiseTest002', 0, async function (done) { 2209 try { 2210 wallpaper.getMinWidth().then((data) => { 2211 console.info(`getMinWidthPromiseTest002 data : ${data}`); 2212 expect(true).assertTrue(); 2213 done(); 2214 }).catch((err) => { 2215 console.info(`getMinWidthPromiseTest002 err : ${err}`); 2216 expect(null).assertFail(); 2217 done(); 2218 }); 2219 } catch (error) { 2220 expect(null).assertFail(); 2221 done(); 2222 } 2223 }) 2224 2225 /** 2226 * @tc.name: getMinHeightCallbackTest001 2227 * @tc.desc: Test getMinHeight() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. 2228 * @tc.type: FUNC test 2229 * @tc.require: issueI5UHRG 2230 */ 2231 it('getMinHeightCallbackTest001', 0, async function (done) { 2232 try { 2233 wallpaper.getMinHeight(function (err, data) { 2234 if (err) { 2235 console.info(`getMinHeightCallbackTest001 err : ${err}`); 2236 expect(null).assertFail(); 2237 } else { 2238 console.info(`getMinHeightCallbackTest001 data : ${data}`); 2239 expect(true).assertTrue(); 2240 } 2241 done(); 2242 }) 2243 } catch (error) { 2244 expect(null).assertFail(); 2245 done(); 2246 } 2247 }) 2248 2249 /** 2250 * @tc.name: getMinHeightPromiseTest002 2251 * @tc.desc: Test getMinHeight() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. 2252 * @tc.type: FUNC test 2253 * @tc.require: issueI5UHRG 2254 */ 2255 it('getMinHeightPromiseTest002', 0, async function (done) { 2256 try { 2257 wallpaper.getMinHeight().then((data) => { 2258 console.info(`getMinHeightPromiseTest002 data : ${data}`); 2259 expect(true).assertTrue(); 2260 done(); 2261 }).catch((err) => { 2262 console.info(`getMinHeightPromiseTest002 err : ${err}`); 2263 expect(null).assertFail(); 2264 done(); 2265 }); 2266 } catch (error) { 2267 expect(null).assertFail(); 2268 done(); 2269 } 2270 }) 2271 2272 /** 2273 * @tc.name: getFileCallbackTest001 2274 * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. 2275 * @tc.type: FUNC test 2276 * @tc.require: issueI5UHRG 2277 */ 2278 it('getFileCallbackTest001', 0, async function (done) { 2279 try { 2280 wallpaper.getFile(WALLPAPER_SYSTEM, function (err, data) { 2281 if (err) { 2282 console.info(`getFileCallbackTest001 err : ${err}`); 2283 expect(null).assertFail(); 2284 } else { 2285 console.info(`getFileCallbackTest001 data : ${data}`); 2286 expect(true).assertTrue(); 2287 } 2288 done(); 2289 }) 2290 } catch (error) { 2291 expect(null).assertFail(); 2292 done(); 2293 } 2294 }) 2295 2296 /** 2297 * @tc.name: getFilePromiseTest002 2298 * @tc.desc: Test getFile() to get the File of the wallpaper of the specified type. 2299 * @tc.type: FUNC test 2300 * @tc.require: issueI5UHRG 2301 */ 2302 it('getFilePromiseTest002', 0, async function (done) { 2303 try { 2304 wallpaper.getFile(WALLPAPER_SYSTEM).then((data) => { 2305 console.info(`getFilePromiseTest002 data : ${data}`); 2306 expect(true).assertTrue(); 2307 done(); 2308 }).catch((err) => { 2309 console.info(`getFilePromiseTest002 err : ${err}`); 2310 expect(null).assertFail(); 2311 done(); 2312 }); 2313 } catch (error) { 2314 expect(null).assertFail(); 2315 done(); 2316 } 2317 }) 2318 2319 /** 2320 * @tc.name: getFileCallbackTest003 2321 * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. 2322 * @tc.type: FUNC test 2323 * @tc.require: issueI5UHRG 2324 */ 2325 it('getFileCallbackTest003', 0, async function (done) { 2326 try { 2327 wallpaper.getFile(WALLPAPER_LOCKSCREEN, function (err, data) { 2328 if (err) { 2329 console.info(`getFileCallbackTest003 err : ${err}`); 2330 expect(null).assertFail(); 2331 } else { 2332 console.info(`getFileCallbackTest003 data : ${data}`); 2333 expect(true).assertTrue(); 2334 } 2335 done(); 2336 }) 2337 } catch (error) { 2338 expect(null).assertFail(); 2339 done(); 2340 } 2341 }) 2342 2343 /** 2344 * @tc.name: getFilePromiseTest004 2345 * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. 2346 * @tc.type: FUNC test 2347 * @tc.require: issueI5UHRG 2348 */ 2349 it('getFilePromiseTest004', 0, async function (done) { 2350 try { 2351 wallpaper.getFile(WALLPAPER_LOCKSCREEN).then((data) => { 2352 console.info(`getFilePromiseTest004 data : ${data}`); 2353 expect(true).assertTrue(); 2354 done(); 2355 }).catch((err) => { 2356 console.info(`getFilePromiseTest004 err : ${err}`); 2357 expect(null).assertFail(); 2358 done(); 2359 }); 2360 } catch (error) { 2361 expect(null).assertFail(); 2362 done(); 2363 } 2364 }) 2365 2366 /** 2367 * @tc.name: getIdCallbackTest001 2368 * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. 2369 * @tc.type: FUNC test 2370 * @tc.require: issueI5UHRG 2371 */ 2372 it('getIdCallbackTest001', 0, async function (done) { 2373 try { 2374 wallpaper.getId(WALLPAPER_SYSTEM, function (err, data) { 2375 if (err) { 2376 console.info(`getIdCallbackTest001 err : ${err}`); 2377 expect(null).assertFail(); 2378 } else { 2379 console.info(`getIdCallbackTest001 data ${data}`); 2380 expect(true).assertTrue(); 2381 } 2382 done(); 2383 }) 2384 } catch (error) { 2385 expect(null).assertFail(); 2386 done(); 2387 } 2388 }) 2389 2390 /** 2391 * @tc.name: getIdPromiseTest002 2392 * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. 2393 * @tc.type: FUNC test 2394 * @tc.require: issueI5UHRG 2395 */ 2396 it('getIdPromiseTest002', 0, async function (done) { 2397 try { 2398 wallpaper.getId(WALLPAPER_SYSTEM).then((data) => { 2399 console.info(`getIdPromiseTest002 data ${data}`); 2400 expect(true).assertTrue(); 2401 done(); 2402 }).catch((err) => { 2403 console.info(`getIdPromiseTest002 err ${err}`); 2404 expect(null).assertFail(); 2405 done(); 2406 }); 2407 } catch (error) { 2408 expect(null).assertFail(); 2409 done(); 2410 } 2411 }) 2412 2413 /** 2414 * @tc.name: getIdCallbackTest003 2415 * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. 2416 * @tc.type: FUNC test 2417 * @tc.require: issueI5UHRG 2418 */ 2419 it('getIdCallbackTest003', 0, async function (done) { 2420 try { 2421 wallpaper.getId(WALLPAPER_LOCKSCREEN, function (err, data) { 2422 if (err) { 2423 console.info(`getIdCallbackTest003 err ${err}`); 2424 expect(null).assertFail(); 2425 } else { 2426 console.info(`getIdCallbackTest003 data ${data}`); 2427 expect(true).assertTrue(); 2428 } 2429 done(); 2430 }) 2431 } catch (error) { 2432 expect(null).assertFail(); 2433 done(); 2434 } 2435 }) 2436 2437 /** 2438 * @tc.name: getIdPromiseTest004 2439 * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. 2440 * @tc.type: FUNC test 2441 * @tc.require: issueI5UHRG 2442 */ 2443 it('getIdPromiseTest004', 0, async function (done) { 2444 try { 2445 wallpaper.getId(WALLPAPER_LOCKSCREEN).then((data) => { 2446 console.info(`getIdCallbackTest003 data ${data}`); 2447 expect(true).assertTrue(); 2448 done(); 2449 }).catch((err) => { 2450 console.info(`getIdCallbackTest003 err ${err}`); 2451 expect(null).assertFail(); 2452 done(); 2453 }); 2454 } catch (error) { 2455 expect(null).assertFail(); 2456 done(); 2457 } 2458 }) 2459 2460 /** 2461 * @tc.name: getColorsCallbackTest001 2462 * @tc.desc: Test getColors() to gets WALLPAPER_SYSTEM Colors. 2463 * @tc.type: FUNC test 2464 * @tc.require: issueI5UHRG 2465 */ 2466 it('getColorsCallbackTest001', 0, async function (done) { 2467 try { 2468 wallpaper.getColors(WALLPAPER_SYSTEM, function (err, data) { 2469 if (err) { 2470 console.info(`getColorsCallbackTest001 err ${err}`); 2471 expect(null).assertFail(); 2472 } else { 2473 console.info(`getColorsCallbackTest001 data ${data}`); 2474 expect(true).assertTrue(); 2475 } 2476 done(); 2477 }) 2478 } catch (error) { 2479 expect(null).assertFail(); 2480 done(); 2481 } 2482 }) 2483 2484 /** 2485 * @tc.name: getColorsPromiseTest002 2486 * @tc.desc: Test getColors() to gets WALLPAPER_SYSTEM Colors. 2487 * @tc.type: FUNC test 2488 * @tc.require: issueI5UHRG 2489 */ 2490 it('getColorsPromiseTest002', 0, async function (done) { 2491 try { 2492 wallpaper.getColors(WALLPAPER_SYSTEM).then((data) => { 2493 console.info(`getColorsPromiseTest002 data ${data}`); 2494 expect(true).assertTrue(); 2495 done(); 2496 }).catch((err) => { 2497 console.info(`getColorsPromiseTest002 err ${err}`); 2498 expect(null).assertFail(); 2499 done(); 2500 }); 2501 } catch (error) { 2502 expect(null).assertFail(); 2503 done(); 2504 } 2505 }) 2506 2507 /** 2508 * @tc.name: getColorsCallbackTest003 2509 * @tc.desc: Test getColors() to gets WALLPAPER_LOCKSCREEN Colors. 2510 * @tc.type: FUNC test 2511 * @tc.require: issueI5UHRG 2512 */ 2513 it('getColorsCallbackTest003', 0, async function (done) { 2514 try { 2515 wallpaper.getColors(WALLPAPER_LOCKSCREEN, function (err, data) { 2516 if (err) { 2517 console.info(`getColorsCallbackTest003 err ${err}`); 2518 expect(null).assertFail(); 2519 } else { 2520 console.info(`getColorsCallbackTest003 data ${data}`); 2521 expect(true).assertTrue(); 2522 } 2523 done(); 2524 }) 2525 } catch (error) { 2526 expect(null).assertFail(); 2527 done(); 2528 } 2529 }) 2530 2531 /** 2532 * @tc.name: getColorsPromiseTest004 2533 * @tc.desc: Test getColors() to gets WALLPAPER_LOCKSCREEN Colors. 2534 * @tc.type: FUNC test 2535 * @tc.require: issueI5UHRG 2536 */ 2537 it('getColorsPromiseTest004', 0, async function (done) { 2538 try { 2539 wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((data) => { 2540 console.info(`getColorsPromiseTest004 data ${data}`); 2541 expect(true).assertTrue(); 2542 done(); 2543 }).catch((err) => { 2544 console.info(`getColorsPromiseTest004 err ${err}`); 2545 expect(null).assertFail(); 2546 done(); 2547 }); 2548 } catch (error) { 2549 expect(null).assertFail(); 2550 done(); 2551 } 2552 }) 2553 2554 /** 2555 * @tc.name: onCallbackTest001 2556 * @tc.desc: Test on_colorChange to registers a listener for wallpaper color changes to 2557 * receive notifications about the changes. 2558 * @tc.type: FUNC test 2559 * @tc.require: issueI5UHRG 2560 */ 2561 it('onCallbackTest001', 0, async function (done) { 2562 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 2563 try { 2564 wallpaper.on('colorChange', (colors, wallpaperType) => { 2565 console.info(`onCallbackTest001 colors : ${colors}`); 2566 expect(colors != null).assertTrue(); 2567 expect(wallpaperType != null).assertTrue(); 2568 wallpaper.off('colorChange'); 2569 done(); 2570 }) 2571 } catch (error) { 2572 console.info(`onCallbackTest001 error : ${error.message}`); 2573 expect(null).assertFail(); 2574 done(); 2575 } 2576 await wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN); 2577 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 2578 }) 2579 2580 /** 2581 * @tc.name: onCallbackTest002 2582 * @tc.desc: Test on_wallpaperChange to registers a listener for wallpaper changes to 2583 * receive notifications about the changes. 2584 * @tc.type: FUNC test 2585 * @tc.require: issueI5UHRG 2586 */ 2587 it('onCallbackTest002', 0, async function (done) { 2588 await wallpaper.restore(WALLPAPER_SYSTEM); 2589 try { 2590 wallpaper.on('wallpaperChange', (wallpaperType, resourceType) => { 2591 expect(wallpaperType != null).assertTrue(); 2592 expect(resourceType != null).assertTrue(); 2593 wallpaper.off('wallpaperChange'); 2594 done(); 2595 }) 2596 } catch (error) { 2597 console.info(`onCallbackTest002 error : ${error.message}`); 2598 expect(null).assertFail(); 2599 done(); 2600 } 2601 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 2602 await wallpaper.restore(WALLPAPER_SYSTEM); 2603 }) 2604 2605 /** 2606 * @tc.name: onCallbackTest003 2607 * @tc.desc: Test to register not exist event 2608 * @tc.type: FUNC test 2609 * @tc.require: issueI5UHRG 2610 */ 2611 it('onCallbackTest003', 0, async function (done) { 2612 await wallpaper.restore(WALLPAPER_SYSTEM); 2613 try { 2614 wallpaper.on('wallpaperChangeX', (wallpaperType, resourceType) => { 2615 expect(null).assertFail(); 2616 done(); 2617 }) 2618 } catch (error) { 2619 console.info(`onCallbackTest003 error : ${error.message}`); 2620 expect(error.code === PARAMETER_ERROR).assertTrue(); 2621 done(); 2622 } 2623 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 2624 await wallpaper.restore(WALLPAPER_SYSTEM); 2625 }) 2626 2627 /** 2628 * @tc.name: onCallbackTest004 2629 * @tc.desc: Test on_wallpaperChange to registers a listener for wallpaper changes to 2630 * receive notifications about the changes. 2631 * @tc.type: FUNC test 2632 * @tc.require: issueI7AAMU 2633 */ 2634 it('onCallbackTest004', 0, async function (done) { 2635 await wallpaper.restore(WALLPAPER_SYSTEM); 2636 try { 2637 wallpaper.on('wallpaperChange', async (wallpaperType, resourceType, uri) => { 2638 expect(wallpaperType != null).assertTrue(); 2639 expect(resourceType != null).assertTrue(); 2640 expect(uri !== "").assertTrue(); 2641 wallpaper.off('wallpaperChange'); 2642 done(); 2643 await wallpaper.restore(WALLPAPER_SYSTEM); 2644 }) 2645 if (isBundleNameExists()) { 2646 await wallpaper.setCustomWallpaper(URI, WALLPAPER_SYSTEM); 2647 } else { 2648 wallpaper.off('wallpaperChange'); 2649 expect(true).assertTrue(); 2650 done(); 2651 } 2652 } catch (error) { 2653 console.info(`onCallbackTest004 error : ${error.message}`); 2654 expect(null).assertFail(); 2655 done(); 2656 } 2657 }) 2658 2659 /** 2660 * @tc.name: offCallbackTest001 2661 * @tc.desc: Test off_colorChange to log off a listener for wallpaper color changes to 2662 * receive notifications about the changes. 2663 * @tc.type: FUNC test 2664 * @tc.require: issueI5UHRG 2665 */ 2666 it('offCallbackTest001', 0, async function (done) { 2667 let callbackTimes = 0; 2668 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 2669 try { 2670 wallpaper.on('colorChange', async (colors, wallpaperType) => { 2671 console.info(`offCallbackTest001 colors : ${colors}`); 2672 callbackTimes = callbackTimes + 1; 2673 wallpaper.off('colorChange'); 2674 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 2675 await wallpaper.restore(WALLPAPER_SYSTEM); 2676 expect(callbackTimes === 1).assertTrue(); 2677 done(); 2678 }) 2679 } catch (error) { 2680 console.info(`offCallbackTest001 error : ${error}`); 2681 expect(null).assertFail(); 2682 done(); 2683 } 2684 await wallpaper.restore(WALLPAPER_SYSTEM); 2685 }) 2686 2687 /** 2688 * @tc.name: offCallbackTest002 2689 * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to 2690 * receive notifications about the changes. 2691 * @tc.type: FUNC test 2692 * @tc.require: issueI5UHRG 2693 */ 2694 it('offCallbackTest002', 0, async function (done) { 2695 let callbackTimes = 0; 2696 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 2697 try { 2698 wallpaper.on('wallpaperChange', async (wallpaperType, resourceType) => { 2699 expect(wallpaperType != null).assertTrue(); 2700 expect(resourceType != null).assertTrue(); 2701 callbackTimes = callbackTimes + 1; 2702 wallpaper.off('wallpaperChange', async (wallpaperType, resourceType) => { 2703 }) 2704 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 2705 await wallpaper.restore(WALLPAPER_SYSTEM); 2706 expect(callbackTimes === 1).assertTrue(); 2707 done(); 2708 }) 2709 } catch (error) { 2710 console.info(`offCallbackTest002 error : ${error.message}`); 2711 expect(null).assertFail(); 2712 done(); 2713 } 2714 await wallpaper.restore(WALLPAPER_SYSTEM); 2715 }) 2716 2717 /** 2718 * @tc.name: offCallbackTest003 2719 * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to 2720 * receive notifications about the changes. 2721 * @tc.type: FUNC test 2722 * @tc.require: issueI5UHRG 2723 */ 2724 it('offCallbackTest003', 0, async function (done) { 2725 try { 2726 wallpaper.off('wallpaperChange', async (wallpaperType, resourceType) => { 2727 }, 'other'); 2728 expect(true).assertTrue(); 2729 done(); 2730 } catch (error) { 2731 console.info(`offCallbackTest003 error : ${error.message}`); 2732 expect(null).assertFail(); 2733 done(); 2734 } 2735 }) 2736 2737 /** 2738 * @tc.name: offCallbackTest004 2739 * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to 2740 * receive notifications about the changes. 2741 * @tc.type: FUNC test 2742 * @tc.require: issueI5UHRG 2743 */ 2744 it('offCallbackTest004', 0, async function (done) { 2745 try { 2746 wallpaper.off('wallpaperChange'); 2747 expect(true).assertTrue(); 2748 done(); 2749 } catch (error) { 2750 console.info(`offCallbackTest004 error : ${error.message}`); 2751 expect(null).assertFail(); 2752 done(); 2753 } 2754 }) 2755 2756 /** 2757 * @tc.name: offCallbackTest005 2758 * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to 2759 * receive notifications about the changes. 2760 * @tc.type: FUNC test 2761 * @tc.require: issueI5UHRG 2762 */ 2763 it('offCallbackTest005', 0, async function (done) { 2764 try { 2765 wallpaper.off('wallpaperChange', 'other'); 2766 expect(null).assertFail(); 2767 done(); 2768 } catch (error) { 2769 console.info(`offCallbackTest005 error : ${error.message}`); 2770 expect(error.code === PARAMETER_ERROR).assertTrue(); 2771 done(); 2772 } 2773 }) 2774 2775 /** 2776 * @tc.name: offCallbackTest006 2777 * @tc.desc: Test not exist event wallpaperChangeX to off 2778 * @tc.type: FUNC test 2779 * @tc.require: issueI5UHRG 2780 */ 2781 it('offCallbackTest006', 0, async function (done) { 2782 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 2783 try { 2784 wallpaper.off('wallpaperChangeX'); 2785 expect(null).assertFail(); 2786 done(); 2787 } catch (error) { 2788 console.info(`offCallbackTest006 error : ${error.message}`); 2789 expect(error.code === PARAMETER_ERROR).assertTrue(); 2790 done(); 2791 } 2792 await wallpaper.restore(WALLPAPER_SYSTEM); 2793 }) 2794 2795 /** 2796 * @tc.name: setVideoTest001 2797 * @tc.desc: Test setVideo to set live wallpaper. 2798 * @tc.type: FUNC test 2799 * @tc.require: issueI6R07J 2800 */ 2801 it('setVideoTest001', 0, async function (done) { 2802 try { 2803 wallpaper.setVideo(URI_30FPS_3S_MP4, WALLPAPER_SYSTEM, (error) => { 2804 if (error != undefined) { 2805 console.info(`setVideoTest001 error : ${error}`); 2806 expect(null).assertFail(); 2807 } else { 2808 expect(true).assertTrue(); 2809 wallpaper.reset(WALLPAPER_SYSTEM); 2810 } 2811 done(); 2812 }) 2813 } catch (error) { 2814 console.info(`setVideoTest001 error : ${error}`); 2815 expect(null).assertFail(); 2816 done(); 2817 } 2818 }) 2819 2820 /** 2821 * @tc.name: setVideoTest002 2822 * @tc.desc: Test setVideo to set live wallpaper. 2823 * @tc.type: FUNC test 2824 * @tc.require: issueI6R07J 2825 */ 2826 it('setVideoTest002', 0, async function (done) { 2827 try { 2828 wallpaper.setVideo(URI_30FPS_3S_MOV, WALLPAPER_SYSTEM, (error) => { 2829 if (error != undefined) { 2830 console.info(`setVideoTest002 error : ${error}`); 2831 expect(true).assertTrue(); 2832 } else { 2833 expect(null).assertFail(); 2834 } 2835 done(); 2836 }) 2837 } catch (error) { 2838 console.info(`setVideoTest002 error : ${error}`); 2839 expect(null).assertFail(); 2840 done(); 2841 } 2842 }) 2843 2844 /** 2845 * @tc.name: setVideoTest003 2846 * @tc.desc: Test setVideo to set live wallpaper. 2847 * @tc.type: FUNC test 2848 * @tc.require: issueI6R07J 2849 */ 2850 it('setVideoTest003', 0, async function (done) { 2851 try { 2852 wallpaper.setVideo(URI_15FPS_7S_MP4, WALLPAPER_SYSTEM, (error) => { 2853 if (error != undefined) { 2854 console.info(`setVideoTest002 error : ${error}`); 2855 expect(true).assertTrue(); 2856 } else { 2857 expect(null).assertFail(); 2858 } 2859 done(); 2860 }) 2861 } catch (error) { 2862 console.info(`setVideoTest003 error : ${error}`); 2863 expect(null).assertFail(); 2864 done(); 2865 } 2866 }) 2867 2868 /** 2869 * @tc.name: setVideoTest004 2870 * @tc.desc: Test setVideo to set live wallpaper. 2871 * @tc.type: FUNC test 2872 * @tc.require: issueI6R07J 2873 */ 2874 it('setVideoTest004', 0, async function (done) { 2875 try { 2876 wallpaper.setVideo(URI_30FPS_3S_MP4, WALLPAPER_LOCKSCREEN, (error) => { 2877 if (error != undefined) { 2878 console.info(`setVideoTest004 error : ${error}`); 2879 expect(null).assertFail(); 2880 } else { 2881 expect(true).assertTrue(); 2882 wallpaper.reset(WALLPAPER_LOCKSCREEN); 2883 } 2884 done(); 2885 }) 2886 } catch (error) { 2887 console.info(`setVideoTest004 error : ${error}`); 2888 expect(null).assertFail(); 2889 done(); 2890 } 2891 }) 2892 2893 /** 2894 * @tc.name: setVideoTest005 2895 * @tc.desc: Test setVideo to set live wallpaper. 2896 * @tc.type: FUNC test 2897 * @tc.require: issueI6R07J 2898 */ 2899 it('setVideoTest005', 0, async function (done) { 2900 try { 2901 wallpaper.setVideo(URI_30FPS_3S_MOV, WALLPAPER_LOCKSCREEN, (error) => { 2902 if (error != undefined) { 2903 console.info(`setVideoTest005 error : ${error}`); 2904 expect(true).assertTrue(); 2905 } else { 2906 expect(null).assertFail(); 2907 } 2908 done(); 2909 }) 2910 } catch (error) { 2911 console.info(`setVideoTest005 error : ${error}`); 2912 expect(null).assertFail(); 2913 done(); 2914 } 2915 }) 2916 2917 /** 2918 * @tc.name: setVideoTest006 2919 * @tc.desc: Test setVideo to set live wallpaper. 2920 * @tc.type: FUNC test 2921 * @tc.require: issueI6R07J 2922 */ 2923 it('setVideoTest006', 0, async function (done) { 2924 try { 2925 wallpaper.setVideo(URI_15FPS_7S_MP4, WALLPAPER_LOCKSCREEN, (error) => { 2926 if (error != undefined) { 2927 console.info(`setVideoTest006 error : ${error}`); 2928 expect(true).assertTrue(); 2929 } else { 2930 expect(null).assertFail(); 2931 } 2932 done(); 2933 }) 2934 } catch (error) { 2935 console.info(`setVideoTest006 error : ${error}`); 2936 expect(null).assertFail(); 2937 done(); 2938 } 2939 }) 2940 2941 /** 2942 * @tc.name: setCustomWallpaperCallbackTest001 2943 * @tc.desc: Test setCustomWallpaper to set a custom system wallpaper. 2944 * @tc.type: FUNC test 2945 * @tc.require: issueI7AAMU 2946 */ 2947 it('setCustomWallpaperTest001', 0, async function (done) { 2948 try { 2949 wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_SYSTEM, (error) => { 2950 if (isBundleNameExists()) { 2951 if (error !== undefined) { 2952 expect(null).assertFail(); 2953 console.info(`set CustomWallpaperTest001 fail : ${error}`); 2954 } else { 2955 expect(true).assertTrue(); 2956 wallpaper.reset(WALLPAPER_SYSTEM); 2957 } 2958 } else { 2959 expect(true).assertTrue(); 2960 } 2961 done(); 2962 }) 2963 } catch (error) { 2964 expect(null).assertFail(); 2965 console.info(`set Custom WallpaperTest001 fail : ${error}`); 2966 done(); 2967 } 2968 }) 2969 2970 /** 2971 * @tc.name: setCustomWallpaperPromiseTest002 2972 * @tc.desc: Test setCustomWallpaper to sets a custom system wallpaper. 2973 * @tc.type: FUNC test 2974 * @tc.require: issueI7AAMU 2975 */ 2976 it('setCustomWallpaperPromiseTest002', 0, async function (done) { 2977 try { 2978 wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_SYSTEM).then(async () => { 2979 expect(true).assertTrue(); 2980 done(); 2981 await wallpaper.restore(WALLPAPER_SYSTEM); 2982 }).catch((err) => { 2983 if (isBundleNameExists()) { 2984 expect(null).assertFail(); 2985 console.info(`set Custom WallpaperPromiseTest002 fail : ${err}`); 2986 done(); 2987 } else { 2988 expect(true).assertTrue(); 2989 done(); 2990 } 2991 }); 2992 } catch (error) { 2993 expect(null).assertFail(); 2994 console.info(`set Custom WallpaperPromiseTest002 fail : ${error}`); 2995 done(); 2996 } 2997 }) 2998 2999 /** 3000 * @tc.name: setCustomWallpaperCallbackTest003 3001 * @tc.desc: Test setCustomWallpaper to sets a custom lockscreen wallpaper. 3002 * @tc.type: FUNC test 3003 * @tc.require: issueI7AAMU 3004 */ 3005 it('setCustomWallpaperCallbackTest003', 0, async function (done) { 3006 try { 3007 wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_LOCKSCREEN, (error) => { 3008 if (isBundleNameExists()) { 3009 if (error !== undefined) { 3010 expect(null).assertFail(); 3011 console.info(`set Custom WallpaperCallbackTest003 fail : ${error}`); 3012 } else { 3013 expect(true).assertTrue(); 3014 wallpaper.reset(WALLPAPER_SYSTEM); 3015 } 3016 } else { 3017 expect(true).assertTrue(); 3018 } 3019 done(); 3020 }) 3021 } catch (error) { 3022 expect(null).assertFail(); 3023 console.info(`set Custom WallpaperCallbackTest003 fail : ${error}`); 3024 done(); 3025 } 3026 }) 3027 3028 /** 3029 * @tc.name: setCustomWallpaperPromiseTest004 3030 * @tc.desc: Test setCustomWallpaper to sets a custom lockscreen wallpaper. 3031 * @tc.type: FUNC test 3032 * @tc.require: issueI7AAMU 3033 */ 3034 it('setCustomWallpaperPromiseTest004', 0, async function (done) { 3035 try { 3036 wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_LOCKSCREEN).then(async () => { 3037 expect(true).assertTrue(); 3038 done(); 3039 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 3040 }).catch((err) => { 3041 if (isBundleNameExists()) { 3042 expect(null).assertFail(); 3043 console.info(`set Custom WallpaperPromiseTest004 fail : ${err}`); 3044 done(); 3045 } else { 3046 expect(true).assertTrue(); 3047 done(); 3048 } 3049 }); 3050 } catch (error) { 3051 expect(null).assertFail(); 3052 console.info(`set Custom WallpaperPromiseTest004 fail : ${error}`); 3053 done(); 3054 } 3055 }) 3056 3057 /** 3058 * @tc.name: setCustomWallpaperCallbackThrowErrorTest005 3059 * @tc.desc: Test setCustomWallpaper throw parameter error. 3060 * @tc.type: FUNC test 3061 * @tc.require: issueI7AAMU 3062 */ 3063 it('setCustomCallbackThrowErrorTest005', 0, async function (done) { 3064 try { 3065 wallpaper.setCustomWallpaper(URI_ZIP, INVALID_WALLPAPER_TYPE, function (err) { 3066 if (err) { 3067 expect(err.code === PARAMETER_ERROR).assertTrue() 3068 console.info(`set Custom CallbackThrowErrorTest005 fail : ${err}`); 3069 } else { 3070 expect(null).assertFail(); 3071 } 3072 done(); 3073 }) 3074 } catch (error) { 3075 expect(null).assertFail(); 3076 console.info(`set Custom CallbackThrowErrorTest005 fail : ${error}`); 3077 done(); 3078 } 3079 }) 3080 3081 /** 3082 * @tc.name: setCustomWallpaperCallbackThrowErrorTest006 3083 * @tc.desc: Test setImage() throw parameter error. 3084 * @tc.type: FUNC test 3085 * @tc.require: issueI7AAMU 3086 */ 3087 it('setCustomWallpaperCallbackThrowErrorTest006', 0, async function (done) { 3088 try { 3089 wallpaper.setCustomWallpaper(URI_ZIP, function (err) { 3090 if (err) { 3091 console.info(`setCustomWallpaperCallbackThrowErrorTest006 err : ${err}`); 3092 expect(null).assertFail(); 3093 } else { 3094 expect(null).assertFail(); 3095 } 3096 done(); 3097 }) 3098 } catch (error) { 3099 expect(error.code === PARAMETER_ERROR).assertTrue() 3100 done(); 3101 } 3102 }) 3103 3104 /** 3105 * @tc.name: setCustomWallpaperPromiseThrowErrorTest007 3106 * @tc.desc: Test setCustomWallpaper throw parameter error. 3107 * @tc.type: FUNC test 3108 * @tc.require: issueI7AAMU 3109 */ 3110 it('setCustomWallpaperPromiseThrowErrorTest007', 0, async function (done) { 3111 try { 3112 wallpaper.setCustomWallpaper(URI_ZIP, INVALID_WALLPAPER_TYPE).then(() => { 3113 expect(null).assertFail(); 3114 done(); 3115 }).catch((err) => { 3116 console.info(`setCustomWallpaperPromiseThrowErrorTest007 err : ${err}`); 3117 expect(err.code === PARAMETER_ERROR).assertTrue() 3118 done(); 3119 }); 3120 } catch (error) { 3121 expect(null).assertFail(); 3122 done(); 3123 } 3124 }) 3125 3126 /** 3127 * @tc.name: setCustomWallpaperPromiseThrowErrorTest008 3128 * @tc.desc: Test setCustomWallpaper throw parameter error. 3129 * @tc.type: FUNC test 3130 * @tc.require: issueI7AAMU 3131 */ 3132 it('setCustomWallpaperPromiseThrowErrorTest008', 0, async function (done) { 3133 try { 3134 wallpaper.setCustomWallpaper().then(() => { 3135 expect(null).assertFail(); 3136 done(); 3137 }).catch((err) => { 3138 console.info(`setCustomWallpaperPromiseThrowErrorTest008 err : ${err}`); 3139 expect(null).assertFail(); 3140 done(); 3141 }); 3142 } catch (error) { 3143 expect(error.code === PARAMETER_ERROR).assertTrue() 3144 done(); 3145 } 3146 }) 3147 3148 /** 3149 * @tc.name: setAllWallpapersThrowErrorTest001 3150 * @tc.desc: Test setAllWallpapers throw parameter error, parameter count error 3151 * @tc.type: FUNC test 3152 * @tc.require: 3153 */ 3154 it('setAllWallpapersThrowErrorTest001', 0, async function (done) { 3155 try { 3156 wallpaper.setAllWallpapers(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { 3157 expect(null).assertFail(); 3158 done(); 3159 }).catch((err) => { 3160 console.info(`setAllWallpapersThrowErrorTest001 err : ${err}`); 3161 expect(null).assertFail(); 3162 done(); 3163 }); 3164 } catch (error) { 3165 console.info(`setAllWallpapersThrowErrorTest001 error : ${error}`); 3166 expect(error.code === PARAMETER_ERROR).assertTrue() 3167 done(); 3168 } 3169 }) 3170 3171 /** 3172 * @tc.name: setAllWallpapersThrowErrorTest002 3173 * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperType range error 3174 * @tc.type: FUNC test 3175 * @tc.require: 3176 */ 3177 it('setAllWallpapersThrowErrorTest002', 0, async function (done) { 3178 const wallpaperInfo1 = { 3179 foldState: wallpaper.FoldState.NORMAL, 3180 rotateState: wallpaper.RotateState.PORT, 3181 source: URI 3182 } 3183 let wallpaperInfos = [wallpaperInfo1]; 3184 try { 3185 wallpaper.setAllWallpapers(wallpaperInfos, 2).then(() => { 3186 expect(null).assertFail(); 3187 done(); 3188 }).catch((err) => { 3189 console.info(`setAllWallpapersThrowErrorTest002 err : ${err}`); 3190 expect(null).assertFail(); 3191 done(); 3192 }); 3193 } catch (error) { 3194 console.info(`setAllWallpapersThrowErrorTest002 error : ${error}`); 3195 expect(error.code === PARAMETER_ERROR).assertTrue() 3196 done(); 3197 } 3198 }) 3199 3200 /** 3201 * @tc.name: setAllWallpapersThrowErrorTest003 3202 * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperInfo source error 3203 * @tc.type: FUNC test 3204 * @tc.require: 3205 */ 3206 it('setAllWallpapersThrowErrorTest003', 0, async function (done) { 3207 const wallpaperInfo1 = { 3208 foldState: wallpaper.FoldState.NORMAL, 3209 rotateState: wallpaper.RotateState.PORT, 3210 source: URI_ZIP 3211 } 3212 let wallpaperInfos = [wallpaperInfo1]; 3213 try { 3214 wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { 3215 expect(null).assertFail(); 3216 done(); 3217 }).catch((err) => { 3218 console.info(`setAllWallpapersThrowErrorTest003 err : ${err}`); 3219 expect(err.code === PARAMETER_ERROR).assertTrue() 3220 done(); 3221 }); 3222 } catch (error) { 3223 console.info(`setAllWallpapersThrowErrorTest003 error : ${error}`); 3224 expect(error.code === PARAMETER_ERROR).assertTrue() 3225 done(); 3226 } 3227 }) 3228 3229 /** 3230 * @tc.name: setAllWallpapersTest001 3231 * @tc.desc: Test setAllWallpapers. 3232 * @tc.type: FUNC test 3233 * @tc.require: 3234 */ 3235 it('setAllWallpapersTest001', 0, async function (done) { 3236 const wallpaperInfo1 = { 3237 foldState: wallpaper.FoldState.NORMAL, 3238 rotateState: wallpaper.RotateState.PORT, 3239 source: URI 3240 } 3241 let wallpaperInfos = [wallpaperInfo1]; 3242 try { 3243 wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(async () => { 3244 expect(true).assertTrue(); 3245 done(); 3246 await wallpaper.restore(WALLPAPER_SYSTEM); 3247 }).catch((err) => { 3248 console.info(`setAllWallpapersTest001 fail : ${err}`); 3249 done(); 3250 }); 3251 } catch (error) { 3252 expect(null).assertFail(); 3253 console.info(`setAllWallpapersTest001 fail : ${error}`); 3254 done(); 3255 } 3256 }) 3257 3258 /** 3259 * @tc.name: setAllWallpapersTest002 3260 * @tc.desc: Test setAllWallpapers. 3261 * @tc.type: FUNC test 3262 * @tc.require: 3263 */ 3264 it('setAllWallpapersTest002', 0, async function (done) { 3265 const wallpaperInfo1 = { 3266 foldState: wallpaper.FoldState.NORMAL, 3267 rotateState: wallpaper.RotateState.PORT, 3268 source: URI 3269 } 3270 const wallpaperInfo2 = { 3271 foldState: wallpaper.FoldState.UNFOLD_1, 3272 rotateState: wallpaper.RotateState.LAND, 3273 source: URI 3274 } 3275 let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2]; 3276 try { 3277 wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { 3278 expect(true).assertTrue(); 3279 done(); 3280 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 3281 }).catch((err) => { 3282 console.info(`setAllWallpapersTest002 fail : ${err}`); 3283 done(); 3284 }); 3285 } catch (error) { 3286 expect(null).assertFail(); 3287 console.info(`setAllWallpapersTest002 fail : ${error}`); 3288 done(); 3289 } 3290 }) 3291 3292 /** 3293 * @tc.name: setAllWallpapersTest003 3294 * @tc.desc: Test setAllWallpapers. 3295 * @tc.type: FUNC test 3296 * @tc.require: 3297 */ 3298 it('setAllWallpapersTest003', 0, async function (done) { 3299 const wallpaperInfo1 = { 3300 foldState: wallpaper.FoldState.NORMAL, 3301 rotateState: wallpaper.RotateState.PORT, 3302 source: URI 3303 } 3304 const wallpaperInfo2 = { 3305 foldState: wallpaper.FoldState.UNFOLD_1, 3306 rotateState: wallpaper.RotateState.LAND, 3307 source: URI 3308 } 3309 const wallpaperInfo3 = { 3310 foldState: wallpaper.FoldState.UNFOLD_2, 3311 rotateState: wallpaper.RotateState.PORT, 3312 source: URI 3313 } 3314 const wallpaperInfo4 = { 3315 foldState: wallpaper.FoldState.UNFOLD_2, 3316 rotateState: wallpaper.RotateState.LAND, 3317 source: URI 3318 } 3319 let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2, wallpaperInfo3, wallpaperInfo4]; 3320 try { 3321 wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { 3322 expect(true).assertTrue(); 3323 done(); 3324 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 3325 }).catch((err) => { 3326 console.info(`setAllWallpapersTest003 fail : ${err}`); 3327 done(); 3328 }); 3329 } catch (error) { 3330 expect(null).assertFail(); 3331 console.info(`setAllWallpapersTest003 fail : ${error}`); 3332 done(); 3333 } 3334 }) 3335 /** 3336 * @tc.name: setAllWallpapersThrowErrorTest001tmp 3337 * @tc.desc: Test setAllWallpapers throw parameter error, parameter count error 3338 * @tc.type: FUNC test 3339 * @tc.require: 3340 */ 3341 it('setAllWallpapersThrowErrorTest001tmp', 0, async function (done) { 3342 try { 3343 wallpaper.setAllWallpapers(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { 3344 expect(null).assertFail(); 3345 done(); 3346 }).catch((err) => { 3347 console.info(`setAllWallpapersThrowErrorTest001tmp err : ${err}`); 3348 expect(null).assertFail(); 3349 done(); 3350 }); 3351 } catch (error) { 3352 console.info(`setAllWallpapersThrowErrorTest001tmp error : ${error}`); 3353 expect(error.code === PARAMETER_ERROR).assertTrue() 3354 done(); 3355 } 3356 }) 3357 3358 /** 3359 * @tc.name: setAllWallpapersThrowErrorTest002tmp 3360 * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperType range error 3361 * @tc.type: FUNC test 3362 * @tc.require: 3363 */ 3364 it('setAllWallpapersThrowErrorTest002tmp', 0, async function (done) { 3365 const wallpaperInfo1 = { 3366 foldState: wallpaper.FoldState.NORMAL, 3367 rotateState: wallpaper.RotateState.PORT, 3368 source: URI 3369 } 3370 let wallpaperInfos = [wallpaperInfo1]; 3371 try { 3372 wallpaper.setAllWallpapers(wallpaperInfos, 2).then(() => { 3373 expect(null).assertFail(); 3374 done(); 3375 }).catch((err) => { 3376 console.info(`setAllWallpapersThrowErrorTest002tmp err : ${err}`); 3377 expect(null).assertFail(); 3378 done(); 3379 }); 3380 } catch (error) { 3381 console.info(`setAllWallpapersThrowErrorTest002tmp error : ${error}`); 3382 expect(error.code === PARAMETER_ERROR).assertTrue() 3383 done(); 3384 } 3385 }) 3386 3387 /** 3388 * @tc.name: setAllWallpapersThrowErrorTest003tmp 3389 * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperInfo source error 3390 * @tc.type: FUNC test 3391 * @tc.require: 3392 */ 3393 it('setAllWallpapersThrowErrorTest003tmp', 0, async function (done) { 3394 const wallpaperInfo1 = { 3395 foldState: wallpaper.FoldState.NORMAL, 3396 rotateState: wallpaper.RotateState.PORTRAIT, 3397 source: URI_ZIP 3398 } 3399 let wallpaperInfos = [wallpaperInfo1]; 3400 try { 3401 wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { 3402 expect(null).assertFail(); 3403 done(); 3404 }).catch((err) => { 3405 console.info(`setAllWallpapersThrowErrorTest003tmp err : ${err}`); 3406 expect(err.code === PARAMETER_ERROR).assertTrue() 3407 done(); 3408 }); 3409 } catch (error) { 3410 console.info(`setAllWallpapersThrowErrorTest003tmp error : ${error}`); 3411 expect(error.code === PARAMETER_ERROR).assertTrue() 3412 done(); 3413 } 3414 }) 3415 3416 /** 3417 * @tc.name: setAllWallpapersTest001tmp 3418 * @tc.desc: Test setAllWallpapers. 3419 * @tc.type: FUNC test 3420 * @tc.require: 3421 */ 3422 it('setAllWallpapersTest001tmp', 0, async function (done) { 3423 const wallpaperInfo1 = { 3424 foldState: wallpaper.FoldState.NORMAL, 3425 rotateState: wallpaper.RotateState.PORTRAIT, 3426 source: URI 3427 } 3428 let wallpaperInfos = [wallpaperInfo1]; 3429 try { 3430 wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(async () => { 3431 expect(true).assertTrue(); 3432 done(); 3433 await wallpaper.restore(WALLPAPER_SYSTEM); 3434 }).catch((err) => { 3435 console.info(`setAllWallpapersTest001tmp fail : ${err}`); 3436 done(); 3437 }); 3438 } catch (error) { 3439 expect(null).assertFail(); 3440 console.info(`setAllWallpapersTest001tmp fail : ${error}`); 3441 done(); 3442 } 3443 }) 3444 3445 /** 3446 * @tc.name: setAllWallpapersTest002tmp 3447 * @tc.desc: Test setAllWallpapers. 3448 * @tc.type: FUNC test 3449 * @tc.require: 3450 */ 3451 it('setAllWallpapersTest002tmp', 0, async function (done) { 3452 const wallpaperInfo1 = { 3453 foldState: wallpaper.FoldState.NORMAL, 3454 rotateState: wallpaper.RotateState.PORTRAIT, 3455 source: URI 3456 } 3457 const wallpaperInfo2 = { 3458 foldState: wallpaper.FoldState.UNFOLD_ONCE_STATE, 3459 rotateState: wallpaper.RotateState.LAND, 3460 source: URI 3461 } 3462 let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2]; 3463 try { 3464 wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { 3465 expect(true).assertTrue(); 3466 done(); 3467 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 3468 }).catch((err) => { 3469 console.info(`setAllWallpapersTest002tmp fail : ${err}`); 3470 done(); 3471 }); 3472 } catch (error) { 3473 expect(null).assertFail(); 3474 console.info(`setAllWallpapersTest002tmp fail : ${error}`); 3475 done(); 3476 } 3477 }) 3478 3479 /** 3480 * @tc.name: setAllWallpapersTest003tmp 3481 * @tc.desc: Test setAllWallpapers. 3482 * @tc.type: FUNC test 3483 * @tc.require: 3484 */ 3485 it('setAllWallpapersTest003tmp', 0, async function (done) { 3486 const wallpaperInfo1 = { 3487 foldState: wallpaper.FoldState.NORMAL, 3488 rotateState: wallpaper.RotateState.PORTRAIT, 3489 source: URI 3490 } 3491 const wallpaperInfo2 = { 3492 foldState: wallpaper.FoldState.UNFOLD_ONCE_STATE, 3493 rotateState: wallpaper.RotateState.LANDSCAPE, 3494 source: URI 3495 } 3496 const wallpaperInfo3 = { 3497 foldState: wallpaper.FoldState.UNFOLD_TWICE_STATE, 3498 rotateState: wallpaper.RotateState.PORTRAIT, 3499 source: URI 3500 } 3501 const wallpaperInfo4 = { 3502 foldState: wallpaper.FoldState.UNFOLD_TWICE_STATE, 3503 rotateState: wallpaper.RotateState.LANDSCAPE, 3504 source: URI 3505 } 3506 let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2, wallpaperInfo3, wallpaperInfo4]; 3507 try { 3508 wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { 3509 expect(true).assertTrue(); 3510 done(); 3511 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 3512 }).catch((err) => { 3513 console.info(`setAllWallpapersTest003tmp fail : ${err}`); 3514 done(); 3515 }); 3516 } catch (error) { 3517 expect(null).assertFail(); 3518 console.info(`setAllWallpapersTest003tmp fail : ${error}`); 3519 done(); 3520 } 3521 }) 3522}) 3523