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 = 0; 24const WALLPAPER_LOCKSCREEN = 1; 25const INVALID_WALLPAPER_TYPE = 2; 26const DEFAULT_WALLPAPER_ID = -1; 27const PARAMETER_ERROR = 401; 28const URI = "/data/storage/el2/base/haps/js.jpeg"; 29const URI_ZIP = "/system/etc/test.zip"; 30const URI_30FPS_3S_MP4 = "/system/etc/30fps_3s.mp4"; 31const URI_15FPS_7S_MP4 = "/system/etc/15fps_7s.mp4"; 32const URI_30FPS_3S_MOV = "/system/etc/30fps_3s.mov"; 33 34const SHOW_SYSTEM_SCREEN = "SHOW_SYSTEMSCREEN"; 35const SHOW_LOCK_SCREEN = "SHOW_LOCKSCREEN"; 36const BUNDLE_NAME = "com.ohos.sceneboard"; 37 38describe('WallpaperJSTest', function () { 39 beforeAll(async function () { 40 // input testsuite setup step,setup invoked before all testcases 41 console.info('beforeAll called') 42 await createTempImage(); 43 }) 44 beforeEach(function () { 45 // input testcase setup step,setup invoked before each testcases 46 console.info('beforeEach called') 47 }) 48 afterEach(function () { 49 // input testcase teardown step,teardown invoked after each testcases 50 console.info('afterEach called') 51 }) 52 afterAll(async function () { 53 // input testsuite teardown step,teardown invoked after all testcases 54 console.info('afterAll called') 55 await wallpaper.restore(WALLPAPER_SYSTEM); 56 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 57 }) 58 59 async function createTempImage() { 60 let pixelMap = await createTempPixelMap(); 61 const imagePackerApi = image.createImagePacker(); 62 let packOpts = {format: "image/jpeg", quality: 98}; 63 imagePackerApi.packing(pixelMap, packOpts, (err, data) => { 64 if (err) { 65 console.info(`packing error: ${err}`) 66 } else { 67 let fd = fileio.openSync(URI, 0o2 | 0o100, 0o666); 68 let ret = fileio.writeSync(fd, data); 69 fileio.close(fd); 70 console.log(`file write ret: ${ret}`); 71 } 72 }) 73 } 74 75 async function createTempPixelMap() { 76 const color = new ArrayBuffer(96); 77 let opts = {editable: true, pixelFormat: 3, size: {height: 4, width: 6}}; 78 let pixelMap = await image.createPixelMap(color, opts); 79 return pixelMap; 80 } 81 82 function isBundleNameExists() { 83 try { 84 bundleManager.getBundleInfo(BUNDLE_NAME, bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT, (e) => { 85 if (e) { 86 console.info(`getBundleInfo error ${e.code}`); 87 return false; 88 } else { 89 console.info(`Wallpaper : getBundleInfo is success`); 90 return true; 91 } 92 }) 93 } catch (error) { 94 console.info(`getBundleInfo error ${error.code}`); 95 return false; 96 } 97 98 } 99 100 /** 101 * @tc.name: getColorsSyncTest001 102 * @tc.desc: Test getColorsSync() to gets WALLPAPER_SYSTEM Colors by syncing. 103 * @tc.type: FUNC 104 * @tc.require: issueI5UHRG 105 */ 106 it('getColorsSyncTest001', 0, function () { 107 try { 108 let data = wallpaper.getColorsSync(WALLPAPER_SYSTEM); 109 console.info(`getColorsSyncTest001 data : ${data}`); 110 if (data !== undefined) { 111 expect(true).assertTrue(); 112 } 113 } catch (error) { 114 console.info(`getColorsSyncTest001 error ${error}`); 115 expect(null).assertFail(); 116 } 117 }) 118 119 120 /** 121 * @tc.name: getColorsSyncTest002 122 * @tc.desc: Test getColorsSync() to gets WALLPAPER_LOCKSCREEN Colors by syncing. 123 * @tc.type: FUNC 124 * @tc.require: issueI5UHRG 125 */ 126 it('getColorsSyncTest002', 0, function () { 127 try { 128 let data = wallpaper.getColorsSync(WALLPAPER_LOCKSCREEN); 129 console.info(`getColorsSyncTest002 data : ${data}`); 130 if (data !== undefined) { 131 expect(true).assertTrue(); 132 } 133 } catch (error) { 134 console.info(`getColorsSyncTest002 error : ${error}`); 135 expect(null).assertFail(); 136 } 137 }) 138 139 /** 140 * @tc.name: getColorsSyncTest003 141 * @tc.desc: Test getColorsSync() throw parameter error. 142 * @tc.type: FUNC 143 * @tc.require: issueI5UHRG 144 */ 145 it('getColorsSyncTest003', 0, function () { 146 try { 147 let data = wallpaper.getColorsSync(INVALID_WALLPAPER_TYPE); 148 console.info(`getColorsSyncTest003 data : ${data}`); 149 expect(null).assertFail(); 150 } catch (error) { 151 console.info(`getColorsSyncTest003 error : ${error}`); 152 expect(error.code === PARAMETER_ERROR).assertTrue() 153 } 154 }) 155 156 /** 157 * @tc.name: getColorsSyncTest004 158 * @tc.desc: Test getColorsSync() throw parameter error. 159 * @tc.type: FUNC 160 * @tc.require: issueI5UHRG 161 */ 162 it('getColorsSyncTest004', 0, function () { 163 try { 164 let data = wallpaper.getColorsSync(); 165 console.info(`getColorsSyncTest004 data : ${data}`); 166 expect(null).assertFail(); 167 } catch (error) { 168 console.info(`getColorsSyncTest004 error : ${error}`); 169 expect(error.code === PARAMETER_ERROR).assertTrue() 170 } 171 }) 172 173 /** 174 * @tc.name: getMinHeightSyncTest001 175 * @tc.desc: Test getMinHeightSync() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. 176 * @tc.type: FUNC test 177 * @tc.require: issueI5UHRG 178 */ 179 it('getMinHeightSyncTest001', 0, function () { 180 let data = wallpaper.getMinHeightSync(); 181 console.info(`getMinHeightSyncTest001 data : ${data}`); 182 if (data !== undefined) { 183 expect(true).assertTrue(); 184 } else { 185 expect(null).assertFail() 186 } 187 }) 188 189 /** 190 * @tc.name: getMinWidthSyncTest001 191 * @tc.desc: Test getMinWidthSync() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. 192 * @tc.type: FUNC test 193 * @tc.require: issueI5UHRG 194 */ 195 it('getMinWidthSyncTest001', 0, function () { 196 let data = wallpaper.getMinWidthSync(); 197 console.info(`getMinWidthSyncTest001 data : ${data}`); 198 if (data !== undefined) { 199 expect(true).assertTrue(); 200 } else { 201 expect(null).assertFail() 202 } 203 }) 204 205 /** 206 * @tc.name: restoreCallbackSystemTest001 207 * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. 208 * @tc.type: FUNC test 209 * @tc.require: issueI5UHRG 210 */ 211 it('restoreCallbackSystemTest001', 0, async function (done) { 212 try { 213 wallpaper.restore(WALLPAPER_SYSTEM, function (err) { 214 if (err) { 215 console.info(`restoreCallbackSystemTest001 err : ${err}`); 216 expect(null).assertFail() 217 } else { 218 expect(true).assertTrue(); 219 } 220 done(); 221 }) 222 223 } catch (error) { 224 console.info(`restoreCallbackSystemTest001 err : ${error}`); 225 expect(null).assertFail(); 226 done(); 227 } 228 229 }) 230 231 /** 232 * @tc.name: restorePromiseSystemTest002 233 * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. 234 * @tc.type: FUNC test 235 * @tc.require: issueI5UHRG 236 */ 237 it('restorePromiseSystemTest002', 0, async function (done) { 238 try { 239 wallpaper.restore(WALLPAPER_SYSTEM).then(() => { 240 expect(true).assertTrue(); 241 done(); 242 }).catch((err) => { 243 console.info(`restorePromiseSystemTest002 err : ${err}`); 244 expect(null).assertFail(); 245 done(); 246 }); 247 } catch (error) { 248 expect(null).assertFail(); 249 done(); 250 } 251 }) 252 253 /** 254 * @tc.name: restoreCallbackLockTest003 255 * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. 256 * @tc.type: FUNC test 257 * @tc.require: issueI5UHRG 258 */ 259 it('restoreCallbackLockTest003', 0, async function (done) { 260 try { 261 wallpaper.restore(WALLPAPER_LOCKSCREEN, function (err) { 262 if (err) { 263 expect(null).assertFail(); 264 console.info(`restore CallbackLockTest003 fail : ${err}`); 265 } else { 266 expect(true).assertTrue(); 267 } 268 done(); 269 }) 270 } catch (error) { 271 expect(null).assertFail(); 272 console.info(`restore CallbackLockTest003 fail : ${error}`); 273 done(); 274 } 275 }) 276 277 /** 278 * @tc.name: restorePromiseLockTest004 279 * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. 280 * @tc.type: FUNC test 281 * @tc.require: issueI5UHRG 282 */ 283 it('restorePromiseLockTest004', 0, async function (done) { 284 try { 285 wallpaper.restore(WALLPAPER_LOCKSCREEN).then(() => { 286 expect(true).assertTrue(); 287 done(); 288 }).catch((err) => { 289 console.info(`restorePromiseLockTest004 err : ${err}`); 290 expect(null).assertFail(); 291 done(); 292 }); 293 } catch (error) { 294 expect(null).assertFail(); 295 done(); 296 } 297 }) 298 299 /** 300 * @tc.name: restoreCallbackThrowErrorTest005 301 * @tc.desc: Test restore() throw parameter error. 302 * @tc.type: FUNC test 303 * @tc.require: issueI5UHRG 304 */ 305 it('restoreCallbackThrowErrorTest005', 0, async function (done) { 306 try { 307 wallpaper.restore(INVALID_WALLPAPER_TYPE, function (err) { 308 if (err) { 309 expect(err.code === PARAMETER_ERROR).assertTrue() 310 console.info(`restore CallbackThrowErrorTest005 fail : ${err}`); 311 } else { 312 expect(null).assertFail(); 313 } 314 done(); 315 }) 316 } catch (error) { 317 expect(null).assertFail(); 318 console.info(`restore CallbackThrowErrorTest005 fail : ${error}`); 319 done(); 320 } 321 }) 322 323 /** 324 * @tc.name: restoreCallbackThrowErrorTest006 325 * @tc.desc: Test restore() throw parameter error. 326 * @tc.type: FUNC test 327 * @tc.require: issueI5UHRG 328 */ 329 it('restoreCallbackThrowErrorTest006', 0, async function (done) { 330 try { 331 wallpaper.restore(function (err) { 332 if (err) { 333 expect(null).assertFail(); 334 console.info(`restore CallbackThrowErrorTest006 fail : ${err}`); 335 } else { 336 expect(null).assertFail(); 337 } 338 done(); 339 }) 340 } catch (error) { 341 expect(error.code === PARAMETER_ERROR).assertTrue() 342 console.info(`restore CallbackThrowErrorTest006 fail : ${error}`); 343 done(); 344 } 345 }) 346 347 /** 348 * @tc.name: restorePromiseThrowErrorTest007 349 * @tc.desc: Test restore() throw parameter error. 350 * @tc.type: FUNC test 351 * @tc.require: issueI5UHRG 352 */ 353 it('restorePromiseThrowErrorTest007', 0, async function (done) { 354 try { 355 wallpaper.restore(INVALID_WALLPAPER_TYPE).then(() => { 356 expect(null).assertFail(); 357 done(); 358 }).catch((err) => { 359 console.info(`restorePromiseThrowErrorTest007 err : ${err}`); 360 expect(err.code === PARAMETER_ERROR).assertTrue() 361 done(); 362 }); 363 } catch (error) { 364 expect(null).assertFail(); 365 done(); 366 } 367 }) 368 369 /** 370 * @tc.name: restorePromiseThrowErrorTest008 371 * @tc.desc: Test restore() throw parameter error. 372 * @tc.type: FUNC test 373 * @tc.require: issueI5UHRG 374 */ 375 it('restorePromiseThrowErrorTest008', 0, async function (done) { 376 try { 377 wallpaper.restore().then(() => { 378 expect(null).assertFail(); 379 done(); 380 }).catch((err) => { 381 console.info(`restorePromiseThrowErrorTest008 err : ${err}`); 382 expect(null).assertFail(); 383 done(); 384 }); 385 } catch (error) { 386 expect(error.code === PARAMETER_ERROR).assertTrue() 387 done(); 388 } 389 }) 390 391 /** 392 * @tc.name: getImagePromiseLockTest001 393 * @tc.desc: Test getImage() to gets a PixelMap of the specified type. 394 * @tc.type: FUNC test 395 * @tc.require: issueI5UHRG 396 */ 397 it('getImagePromiseLockTest001', 0, async function (done) { 398 try { 399 wallpaper.getImage(WALLPAPER_LOCKSCREEN).then((data) => { 400 console.info(`getImagePromiseLockTest001 data : ${data}`); 401 if (data !== undefined) { 402 expect(true).assertTrue(); 403 } 404 done(); 405 }).catch((err) => { 406 console.info(`getImagePromiseLockTest001 err : ${err}`); 407 expect(null).assertFail(); 408 done(); 409 }); 410 } catch (error) { 411 expect(null).assertFail(); 412 done(); 413 } 414 }) 415 416 /** 417 * @tc.name: getImageCallbackSystemTest002 418 * @tc.desc: Test getImage() to gets a PixelMap of the specified type. 419 * @tc.type: FUNC test 420 * @tc.require: issueI5UHRG 421 */ 422 it('getImageCallbackSystemTest002', 0, async function (done) { 423 try { 424 wallpaper.getImage(WALLPAPER_SYSTEM, function (err, data) { 425 if (err) { 426 expect(null).assertFail(); 427 console.info(`get Image CallbackSystemTest002 fail : ${err}`); 428 } else { 429 console.info(`get Image CallbackSystemTest002 data : ${data}`); 430 if (data !== undefined) { 431 expect(true).assertTrue(); 432 } 433 } 434 done(); 435 }); 436 } catch (error) { 437 expect(null).assertFail(); 438 console.info(`get Image CallbackSystemTest002 fail : ${error}`); 439 done(); 440 } 441 }) 442 443 /** 444 * @tc.name: getImagePromiseSystemTest003 445 * @tc.desc: Test getImage() to gets a PixelMap of the specified type. 446 * @tc.type: FUNC test 447 * @tc.require: issueI5UHRG 448 */ 449 it('getImagePromiseSystemTest003', 0, async function (done) { 450 try { 451 wallpaper.getImage(WALLPAPER_SYSTEM).then((data) => { 452 console.info(`getImagePromiseSystemTest003 data : ${data}`); 453 if (data !== undefined) { 454 expect(true).assertTrue(); 455 } 456 done(); 457 }).catch((err) => { 458 console.info(`getImagePromiseSystemTest003 err : ${err}`); 459 expect(null).assertFail(); 460 done(); 461 }); 462 } catch (error) { 463 expect(null).assertFail(); 464 done(); 465 } 466 }) 467 468 /** 469 * @tc.name: getImageCallbackLockTest004 470 * @tc.desc: Test getImage() to gets a PixelMap of the specified type. 471 * @tc.type: FUNC test 472 * @tc.require: issueI5UHRG 473 */ 474 it('getImageCallbackLockTest004', 0, async function (done) { 475 try { 476 wallpaper.getImage(WALLPAPER_LOCKSCREEN, function (err, data) { 477 if (err) { 478 expect(null).assertFail(); 479 console.info(`get Image CallbackLockTest004 fail : ${err}`); 480 } else { 481 console.info(`get Image CallbackLockTest004 data : ${data}`); 482 if (data !== undefined) { 483 expect(true).assertTrue(); 484 } 485 } 486 done(); 487 }); 488 } catch (error) { 489 expect(null).assertFail(); 490 console.info(`get Image CallbackLockTest004 fail : ${error}`); 491 done(); 492 } 493 }) 494 495 /** 496 * @tc.name: getImageCallbackThrowErrorTest005 497 * @tc.desc: Test getImage() throw parameter error. 498 * @tc.type: FUNC test 499 * @tc.require: issueI5UHRG 500 */ 501 it('getImageCallbackThrowErrorTest005', 0, async function (done) { 502 try { 503 wallpaper.getImage(INVALID_WALLPAPER_TYPE, function (err, data) { 504 if (err) { 505 console.info(`getImageCallbackThrowErrorTest005 err : ${err}`); 506 expect(err.code === PARAMETER_ERROR).assertTrue() 507 } else { 508 console.info(`getImageCallbackThrowErrorTest005 data : ${data}`); 509 if (data !== undefined) { 510 expect(null).assertFail(); 511 } 512 } 513 done(); 514 }) 515 } catch (error) { 516 expect(null).assertFail(); 517 done(); 518 } 519 }) 520 521 /** 522 * @tc.name: getImageCallbackThrowErrorTest006 523 * @tc.desc: Test getImage() throw parameter error. 524 * @tc.type: FUNC test 525 * @tc.require: issueI5UHRG 526 */ 527 it('getImageCallbackThrowErrorTest006', 0, async function (done) { 528 try { 529 wallpaper.getImage(function (err, data) { 530 if (err) { 531 console.info(`getImageCallbackThrowErrorTest006 err : ${err}`); 532 expect(null).assertFail(); 533 } else { 534 console.info(`getImageCallbackThrowErrorTest006 data : ${data}`); 535 if (data !== undefined) { 536 expect(null).assertFail(); 537 } 538 } 539 done(); 540 }) 541 } catch (error) { 542 expect(error.code === PARAMETER_ERROR).assertTrue() 543 done(); 544 } 545 }) 546 547 /** 548 * @tc.name: getImagePromiseThrowErrorTest007 549 * @tc.desc: Test getImage() throw parameter error. 550 * @tc.type: FUNC test 551 * @tc.require: issueI5UHRG 552 */ 553 it('getImagePromiseThrowErrorTest007', 0, async function (done) { 554 try { 555 wallpaper.getImage(INVALID_WALLPAPER_TYPE).then((data) => { 556 console.info(`getImagePromiseThrowErrorTest007 data : ${data}`); 557 if (data !== undefined) { 558 expect(null).assertFail(); 559 } 560 done(); 561 }).catch((err) => { 562 console.info(`getImagePromiseThrowErrorTest007 err : ${err}`); 563 expect(err.code === PARAMETER_ERROR).assertTrue() 564 done(); 565 }); 566 } catch (error) { 567 expect(null).assertFail(); 568 done(); 569 } 570 }) 571 572 /** 573 * @tc.name: getImagePromiseThrowErrorTest008 574 * @tc.desc: Test getImage() throw parameter error. 575 * @tc.type: FUNC test 576 * @tc.require: issueI5UHRG 577 */ 578 it('getImagePromiseThrowErrorTest008', 0, async function (done) { 579 try { 580 wallpaper.getImage().then((data) => { 581 console.info(`getImagePromiseThrowErrorTest008 data : ${data}`); 582 if (data !== undefined) { 583 expect(null).assertFail(); 584 } 585 done(); 586 }).catch((err) => { 587 console.info(`getImagePromiseThrowErrorTest008 err : ${err}`); 588 expect(null).assertFail(); 589 done(); 590 }); 591 } catch (error) { 592 expect(error.code === PARAMETER_ERROR).assertTrue() 593 done(); 594 } 595 }) 596 597 /** 598 * @tc.name: setImageURIPromiseLockTest001 599 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a 600 * JPEG or PNG file or the pixel map of a PNG file. 601 * @tc.type: FUNC test 602 * @tc.require: issueI5UHRG 603 */ 604 it('setImageURIPromiseLockTest001', 0, async function (done) { 605 try { 606 wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN).then(async () => { 607 expect(true).assertTrue(); 608 done(); 609 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 610 }).catch((err) => { 611 console.info(`setImageURIPromiseLockTest001 err : ${err}`); 612 expect(null).assertFail(); 613 done(); 614 }); 615 } catch (error) { 616 expect(null).assertFail(); 617 done(); 618 } 619 }) 620 621 /** 622 * @tc.name: setImageURICallbackSystemTest002 623 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a 624 * JPEG or PNG file or the pixel map of a PNG file. 625 * @tc.type: FUNC test 626 * @tc.require: issueI5UHRG 627 */ 628 it('setImageURICallbackSystemTest002', 0, async function (done) { 629 try { 630 wallpaper.setImage(URI, WALLPAPER_SYSTEM, async function (err) { 631 if (err) { 632 expect(null).assertFail(); 633 console.info(`set Image URI CallbackSystemTest002 fail : ${err}`); 634 } else { 635 expect(true).assertTrue(); 636 } 637 done(); 638 await wallpaper.restore(WALLPAPER_SYSTEM); 639 }); 640 } catch (error) { 641 expect(null).assertFail(); 642 console.info(`set Image URI CallbackSystemTest002 fail : ${error}`); 643 done(); 644 } 645 }) 646 647 /** 648 * @tc.name: setImageURIPromiseSystemTest003 649 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a 650 * JPEG or PNG file or the pixel map of a PNG file. 651 * @tc.type: FUNC test 652 * @tc.require: issueI5UHRG 653 */ 654 it('setImageURIPromiseSystemTest003', 0, async function (done) { 655 try { 656 wallpaper.setImage(URI, WALLPAPER_SYSTEM).then(async () => { 657 expect(true).assertTrue(); 658 done(); 659 await wallpaper.restore(WALLPAPER_SYSTEM); 660 }).catch((err) => { 661 console.info(`setImageURIPromiseSystemTest003 err : ${err}`); 662 expect(null).assertFail(); 663 done(); 664 }); 665 } catch (error) { 666 expect(null).assertFail(); 667 done(); 668 } 669 }) 670 671 /** 672 * @tc.name: setImageURICallbackLockTest004 673 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a 674 * JPEG or PNG file or the pixel map of a PNG file. 675 * @tc.type: FUNC test 676 * @tc.require: issueI5UHRG 677 */ 678 it('setImageURICallbackLockTest004', 0, async function (done) { 679 try { 680 wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN, async function (err) { 681 if (err) { 682 console.info(`setImageURICallbackLockTest004 err : ${err}`); 683 expect(null).assertFail(); 684 } else { 685 expect(true).assertTrue(); 686 } 687 done(); 688 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 689 }); 690 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 691 } catch (error) { 692 expect(null).assertFail(); 693 done(); 694 } 695 }) 696 697 /** 698 * @tc.name: setImageMapPromiseLockTest005 699 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. 700 * @tc.type: FUNC test 701 * @tc.require: issueI5UHRG 702 */ 703 it('setImageMapPromiseLockTest005', 0, async function (done) { 704 try { 705 let pixelMap = await createTempPixelMap(); 706 wallpaper.setImage(pixelMap, WALLPAPER_LOCKSCREEN).then(async () => { 707 expect(true).assertTrue(); 708 done(); 709 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 710 }).catch((err) => { 711 console.info(`setImageMapPromiseLockTest005 err : ${err}`); 712 expect(null).assertFail(); 713 done(); 714 }); 715 } catch (error) { 716 expect(null).assertFail(); 717 done(); 718 } 719 }) 720 721 /** 722 * @tc.name: setImageMapCallbackSystemTest006 723 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. 724 * @tc.type: FUNC test 725 * @tc.require: issueI5UHRG 726 */ 727 it('setImageMapCallbackSystemTest006', 0, async function (done) { 728 try { 729 let pixelMap = await createTempPixelMap(); 730 wallpaper.setImage(pixelMap, WALLPAPER_SYSTEM, async function (err) { 731 if (err) { 732 expect(null).assertFail(); 733 console.info(`set ImageMap CallbackSystemTest006 fail : ${err}`); 734 } else { 735 expect(true).assertTrue(); 736 } 737 done(); 738 await wallpaper.restore(WALLPAPER_SYSTEM); 739 }); 740 } catch (error) { 741 expect(null).assertFail(); 742 console.info(`set ImageMap CallbackSystemTest006 fail : ${error}`); 743 done(); 744 } 745 }) 746 747 /** 748 * @tc.name: setImageMapPromiseSystemTest007 749 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. 750 * @tc.type: FUNC test 751 * @tc.require: issueI5UHRG 752 */ 753 it('setImageMapPromiseSystemTest007', 0, async function (done) { 754 try { 755 let pixelMap = await createTempPixelMap(); 756 wallpaper.setImage(pixelMap, WALLPAPER_SYSTEM).then(async () => { 757 expect(true).assertTrue(); 758 done(); 759 await wallpaper.restore(WALLPAPER_SYSTEM); 760 }).catch((err) => { 761 console.info(`setImageMapPromiseSystemTest007 err : ${err}`); 762 expect(null).assertFail(); 763 done(); 764 }); 765 } catch (error) { 766 expect(null).assertFail(); 767 done(); 768 } 769 }) 770 771 /** 772 * @tc.name: setImageMapCallbackLockTest008 773 * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. 774 * @tc.type: FUNC test 775 * @tc.require: issueI5UHRG 776 */ 777 it('setImageMapCallbackLockTest008', 0, async function (done) { 778 try { 779 let pixelMap = await createTempPixelMap(); 780 wallpaper.setImage(pixelMap, WALLPAPER_LOCKSCREEN, async function (err) { 781 if (err) { 782 expect(null).assertFail(); 783 console.info(`set ImageMap CallbackLockTest008 fail : ${err}`); 784 } else { 785 expect(true).assertTrue(); 786 } 787 done(); 788 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 789 }); 790 } catch (error) { 791 expect(null).assertFail(); 792 console.info(`set ImageMap CallbackLockTest008 fail : ${error}`); 793 done(); 794 } 795 }) 796 797 /** 798 * @tc.name: setImageCallbackThrowErrorTest009 799 * @tc.desc: Test setImage() throw parameter error. 800 * @tc.type: FUNC test 801 * @tc.require: issueI5UHRG 802 */ 803 it('setImageCallbackThrowErrorTest009', 0, async function (done) { 804 try { 805 wallpaper.setImage(URI, INVALID_WALLPAPER_TYPE, function (err) { 806 if (err) { 807 expect(err.code === PARAMETER_ERROR).assertTrue() 808 console.info(`set Image CallbackThrowErrorTest009 fail : ${err}`); 809 } else { 810 expect(null).assertFail(); 811 } 812 done(); 813 }) 814 } catch (error) { 815 expect(null).assertFail(); 816 console.info(`set Image CallbackThrowErrorTest009 fail : ${error}`); 817 done(); 818 } 819 }) 820 821 /** 822 * @tc.name: setImageCallbackThrowErrorTest010 823 * @tc.desc: Test setImage() throw parameter error. 824 * @tc.type: FUNC test 825 * @tc.require: issueI5UHRG 826 */ 827 it('setImageCallbackThrowErrorTest010', 0, async function (done) { 828 try { 829 wallpaper.setImage(URI, function (err) { 830 if (err) { 831 expect(null).assertFail(); 832 console.info(`set Image CallbackThrowErrorTest010 fail : ${err}`); 833 } else { 834 expect(null).assertFail(); 835 } 836 done(); 837 }) 838 } catch (error) { 839 expect(error.code === PARAMETER_ERROR).assertTrue() 840 console.info(`set Image CallbackThrowErrorTest010 fail : ${error}`); 841 done(); 842 } 843 }) 844 845 /** 846 * @tc.name: setImagePromiseThrowErrorTest011 847 * @tc.desc: Test setImage() throw parameter error. 848 * @tc.type: FUNC test 849 * @tc.require: issueI5UHRG 850 */ 851 it('setImagePromiseThrowErrorTest011', 0, async function (done) { 852 try { 853 wallpaper.setImage(URI, INVALID_WALLPAPER_TYPE).then(() => { 854 expect(null).assertFail(); 855 done(); 856 }).catch((err) => { 857 console.info(`setImagePromiseThrowErrorTest011 err : ${err}`); 858 expect(err.code === PARAMETER_ERROR).assertTrue() 859 done(); 860 }); 861 } catch (error) { 862 expect(null).assertFail(); 863 done(); 864 } 865 }) 866 867 /** 868 * @tc.name: setImagePromiseThrowErrorTest012 869 * @tc.desc: Test setImage() throw parameter error. 870 * @tc.type: FUNC test 871 * @tc.require: issueI5UHRG 872 */ 873 it('setImagePromiseThrowErrorTest012', 0, async function (done) { 874 try { 875 wallpaper.setImage().then(() => { 876 expect(null).assertFail(); 877 done(); 878 }).catch((err) => { 879 console.info(`setImagePromiseThrowErrorTest012 err : ${err}`); 880 expect(null).assertFail(); 881 done(); 882 }); 883 } catch (error) { 884 expect(error.code === PARAMETER_ERROR).assertTrue() 885 done(); 886 } 887 }) 888 889 /** 890 * @tc.name: setWallpaperMapPromiseLockTest001 891 * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. 892 * @tc.type: FUNC test 893 * @tc.require: issueI5UHRG 894 */ 895 it('setWallpaperMapPromiseLockTest001', 0, async function (done) { 896 try { 897 let pixelMap = await createTempPixelMap(); 898 wallpaper.setWallpaper(pixelMap, WALLPAPER_LOCKSCREEN).then(async () => { 899 expect(true).assertTrue(); 900 done(); 901 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 902 }).catch((err) => { 903 console.info(`setWallpaperMapPromiseLockTest001 err : ${err}`); 904 expect(null).assertFail(); 905 done(); 906 }); 907 } catch (error) { 908 expect(null).assertFail(); 909 done(); 910 } 911 }) 912 913 /** 914 * @tc.name: setWallpaperMapCallbackSystemTest002 915 * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. 916 * @tc.type: FUNC test 917 * @tc.require: issueI5UHRG 918 */ 919 it('setWallpaperMapCallbackSystemTest002', 0, async function (done) { 920 try { 921 let pixelMap = await createTempPixelMap(); 922 wallpaper.setWallpaper(pixelMap, WALLPAPER_SYSTEM, async function (err) { 923 if (err) { 924 expect(null).assertFail(); 925 console.info(`set Wallpaper Map CallbackSystemTest002 fail : ${err}`); 926 } else { 927 expect(true).assertTrue(); 928 } 929 done(); 930 await wallpaper.restore(WALLPAPER_SYSTEM); 931 }); 932 } catch (error) { 933 expect(null).assertFail(); 934 console.info(`set Wallpaper Map CallbackSystemTest002 fail : ${error}`); 935 done(); 936 } 937 }) 938 939 /** 940 * @tc.name: setWallpaperMapPromiseSystemTest003 941 * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. 942 * @tc.type: FUNC test 943 * @tc.require: issueI5UHRG 944 */ 945 it('setWallpaperMapPromiseSystemTest003', 0, async function (done) { 946 try { 947 let pixelMap = await createTempPixelMap(); 948 wallpaper.setWallpaper(pixelMap, WALLPAPER_SYSTEM).then(async () => { 949 expect(true).assertTrue(); 950 done(); 951 await wallpaper.restore(WALLPAPER_SYSTEM); 952 }).catch((err) => { 953 console.info(`setWallpaperMapPromiseSystemTest003 err : ${err}`); 954 expect(null).assertFail(); 955 done(); 956 }); 957 } catch (error) { 958 expect(null).assertFail(); 959 done(); 960 } 961 }) 962 963 /** 964 * @tc.name: setWallpaperMapCallbackLockTest004 965 * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. 966 * @tc.type: FUNC test 967 * @tc.require: issueI5UHRG 968 */ 969 it('setWallpaperMapCallbackLockTest004', 0, async function (done) { 970 try { 971 let pixelMap = await createTempPixelMap(); 972 wallpaper.setWallpaper(pixelMap, WALLPAPER_LOCKSCREEN, async function (err) { 973 if (err) { 974 expect(null).assertFail(); 975 console.info(`set Wallpaper Map CallbackLockTest004 fail : ${err}`); 976 } else { 977 expect(true).assertTrue(); 978 } 979 done(); 980 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 981 }); 982 } catch (error) { 983 expect(null).assertFail(); 984 console.info(`set Wallpaper Map CallbackLockTest004 fail : ${error}`); 985 done(); 986 } 987 }) 988 989 990 /** 991 * @tc.name: getPixelMapPromiseLockTest001 992 * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. 993 * @tc.type: FUNC test 994 * @tc.require: issueI5UHRG 995 */ 996 it('getPixelMapPromiseLockTest001', 0, async function (done) { 997 try { 998 wallpaper.getPixelMap(WALLPAPER_LOCKSCREEN).then((data) => { 999 if (data !== undefined) { 1000 expect(true).assertTrue(); 1001 } 1002 done(); 1003 }).catch((err) => { 1004 console.info(`getPixelMapPromiseLockTest001 err : ${err}`); 1005 expect(null).assertFail(); 1006 done(); 1007 }); 1008 } catch (error) { 1009 expect(null).assertFail(); 1010 done(); 1011 } 1012 }) 1013 1014 /** 1015 * @tc.name: getPixelMapCallbackSystemTest002 1016 * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. 1017 * @tc.type: FUNC test 1018 * @tc.require: issueI5UHRG 1019 */ 1020 it('getPixelMapCallbackSystemTest002', 0, async function (done) { 1021 try { 1022 wallpaper.getPixelMap(WALLPAPER_SYSTEM, function (err, data) { 1023 if (err) { 1024 expect(null).assertFail(); 1025 console.info(`get Pixel Map CallbackSystemTest002 fail : ${err}`); 1026 } else { 1027 if (data !== undefined) { 1028 expect(true).assertTrue(); 1029 } 1030 } 1031 done(); 1032 }); 1033 } catch (error) { 1034 expect(null).assertFail(); 1035 console.info(`get Pixel MapCallbackSystemTest002 fail : ${error}`); 1036 done(); 1037 } 1038 }) 1039 1040 /** 1041 * @tc.name: getPixelMapPromiseSystemTest003 1042 * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. 1043 * @tc.type: FUNC test 1044 * @tc.require: issueI5UHRG 1045 */ 1046 it('getPixelMapPromiseSystemTest003', 0, async function (done) { 1047 try { 1048 wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => { 1049 if (data !== undefined) { 1050 expect(true).assertTrue(); 1051 } 1052 done(); 1053 }).catch((err) => { 1054 console.info(`getPixelMapPromiseSystemTest003 err : ${err}`); 1055 expect(null).assertFail(); 1056 done(); 1057 }); 1058 } catch (error) { 1059 expect(null).assertFail(); 1060 done(); 1061 } 1062 }) 1063 1064 /** 1065 * @tc.name: getPixelMapCallbackLockTest004 1066 * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. 1067 * @tc.type: FUNC test 1068 * @tc.require: issueI5UHRG 1069 */ 1070 it('getPixelMapCallbackLockTest004', 0, async function (done) { 1071 try { 1072 wallpaper.getPixelMap(WALLPAPER_LOCKSCREEN, function (err, data) { 1073 if (err) { 1074 expect(null).assertFail(); 1075 console.info(`get Pixel Map CallbackLockTest004 fail : ${err}`); 1076 } else { 1077 if (data !== undefined) { 1078 expect(true).assertTrue(); 1079 } 1080 } 1081 done(); 1082 }); 1083 } catch (error) { 1084 expect(null).assertFail(); 1085 console.info(`get Pixel Map CallbackLockTest004 fail : ${error}`); 1086 done(); 1087 } 1088 }) 1089 1090 /** 1091 * @tc.name: resetCallbackSystemTest001 1092 * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. 1093 * @tc.type: FUNC test 1094 * @tc.require: issueI5UHRG 1095 */ 1096 it('resetCallbackSystemTest001', 0, async function (done) { 1097 try { 1098 wallpaper.reset(WALLPAPER_SYSTEM, function (err) { 1099 if (err) { 1100 expect(null).assertFail() 1101 console.info(`reset CallbackSystemTest001 fail : ${err}`); 1102 } else { 1103 expect(true).assertTrue(); 1104 } 1105 done(); 1106 }) 1107 1108 } catch (error) { 1109 expect(null).assertFail(); 1110 console.info(`reset CallbackSystemTest001 fail : ${error}`); 1111 done(); 1112 } 1113 1114 }) 1115 1116 /** 1117 * @tc.name: resetPromiseSystemTest002 1118 * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. 1119 * @tc.type: FUNC test 1120 * @tc.require: issueI5UHRG 1121 */ 1122 it('resetPromiseSystemTest002', 0, async function (done) { 1123 try { 1124 wallpaper.reset(WALLPAPER_SYSTEM).then(() => { 1125 expect(true).assertTrue(); 1126 done(); 1127 }).catch((err) => { 1128 console.info(`resetPromiseSystemTest002 err : ${err}`); 1129 expect(null).assertFail(); 1130 done(); 1131 }); 1132 } catch (error) { 1133 expect(null).assertFail(); 1134 done(); 1135 } 1136 }) 1137 1138 /** 1139 * @tc.name: resetCallbackLockTest003 1140 * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. 1141 * @tc.type: FUNC test 1142 * @tc.require: issueI5UHRG 1143 */ 1144 it('resetCallbackLockTest003', 0, async function (done) { 1145 try { 1146 wallpaper.reset(WALLPAPER_LOCKSCREEN, function (err) { 1147 if (err) { 1148 expect(null).assertFail(); 1149 console.info(`reset CallbackLockTest003 fail : ${err}`); 1150 } else { 1151 expect(true).assertTrue(); 1152 } 1153 done(); 1154 }) 1155 } catch (error) { 1156 expect(null).assertFail(); 1157 console.info(`reset CallbackLockTest003 fail : ${error}`); 1158 done(); 1159 } 1160 }) 1161 1162 /** 1163 * @tc.name: resetPromiseLockTest004 1164 * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. 1165 * @tc.type: FUNC test 1166 * @tc.require: issueI5UHRG 1167 */ 1168 it('resetPromiseLockTest004', 0, async function (done) { 1169 try { 1170 wallpaper.reset(WALLPAPER_LOCKSCREEN).then(() => { 1171 expect(true).assertTrue(); 1172 done(); 1173 }).catch((err) => { 1174 console.info(`resetPromiseLockTest004 err : ${err}`); 1175 expect(null).assertFail(); 1176 done(); 1177 }); 1178 } catch (error) { 1179 expect(null).assertFail(); 1180 done(); 1181 } 1182 }) 1183 1184 /** 1185 * @tc.name: isOperationAllowedCallbackTest001 1186 * @tc.desc: Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. 1187 * @tc.type: FUNC test 1188 * @tc.require: issueI5UHRG 1189 */ 1190 it('isOperationAllowedCallbackTest001', 0, async function (done) { 1191 try { 1192 wallpaper.isOperationAllowed(function (err, data) { 1193 if (err) { 1194 console.info(`isOperationAllowedCallbackTest001 err : ${err}`); 1195 expect(null).assertFail(); 1196 } else { 1197 console.info(`isOperationAllowedCallbackTest001 data : ${data}`); 1198 expect(true).assertTrue(); 1199 } 1200 done(); 1201 }) 1202 } catch (error) { 1203 expect(null).assertFail(); 1204 done(); 1205 } 1206 }) 1207 1208 /** 1209 * @tc.name: isOperationAllowedPromiseTest002 1210 * @tc.desc: Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. 1211 * @tc.type: FUNC test 1212 * @tc.require: issueI5UHRG 1213 */ 1214 it('isOperationAllowedPromiseTest002', 0, async function (done) { 1215 try { 1216 wallpaper.isOperationAllowed().then((data) => { 1217 console.info(`isOperationAllowedPromiseTest002 data : ${data}`); 1218 expect(true).assertTrue(); 1219 done(); 1220 }).catch((err) => { 1221 console.info(`isOperationAllowedPromiseTest002 err : ${err}`); 1222 expect(null).assertFail(); 1223 done(); 1224 }); 1225 } catch (error) { 1226 expect(null).assertFail(); 1227 done(); 1228 } 1229 }) 1230 1231 /** 1232 * @tc.name: isChangePermittedCallbackTest001 1233 * @tc.desc: Test isChangePermitted() to checks whether to allow the application to change the 1234 * wallpaper for the current user. 1235 * @tc.type: FUNC test 1236 * @tc.require: issueI5UHRG 1237 */ 1238 it('isChangePermittedCallbackTest001', 0, async function (done) { 1239 try { 1240 wallpaper.isChangePermitted(function (err, data) { 1241 if (err) { 1242 console.info(`isChangePermittedCallbackTest001 err : ${err}`); 1243 expect(null).assertFail(); 1244 } else { 1245 console.info(`isChangePermittedCallbackTest001 data : ${data}`); 1246 expect(true).assertTrue(); 1247 } 1248 done(); 1249 }) 1250 } catch (error) { 1251 expect(null).assertFail(); 1252 done(); 1253 } 1254 }) 1255 1256 /** 1257 * @tc.name: isChangePermittedPromiseTest002 1258 * @tc.desc: Test isChangePermitted() to checks whether to allow the application to change the 1259 * wallpaper for the current user. 1260 * @tc.type: FUNC test 1261 * @tc.require: issueI5UHRG 1262 */ 1263 it('isChangePermittedPromiseTest002', 0, async function (done) { 1264 try { 1265 wallpaper.isChangePermitted().then((data) => { 1266 console.info(`isChangePermittedPromiseTest002 data : ${data}`); 1267 expect(true).assertTrue(); 1268 done(); 1269 }).catch((err) => { 1270 console.info(`isChangePermittedPromiseTest002 err : ${err}`); 1271 expect(null).assertFail(); 1272 done(); 1273 }); 1274 } catch (error) { 1275 expect(null).assertFail(); 1276 done(); 1277 } 1278 }) 1279 1280 /** 1281 * @tc.name: getMinWidthCallbackTest001 1282 * @tc.desc: Test getMinWidth() to gets the minWidth of the WALLPAPER_SYSTEM of the specified type. 1283 * @tc.type: FUNC test 1284 * @tc.require: issueI5UHRG 1285 */ 1286 it('getMinWidthCallbackTest001', 0, async function (done) { 1287 try { 1288 wallpaper.getMinWidth(function (err, data) { 1289 if (err) { 1290 console.info(`getMinWidthCallbackTest001 err : ${err}`); 1291 expect(null).assertFail(); 1292 } else { 1293 console.info(`getMinWidthCallbackTest001 data : ${data}`); 1294 expect(true).assertTrue(); 1295 } 1296 done(); 1297 }) 1298 } catch (error) { 1299 expect(null).assertFail(); 1300 done(); 1301 } 1302 }) 1303 1304 /** 1305 * @tc.name: getMinWidthPromiseTest002 1306 * @tc.desc: Test getMinWidth() to gets the minWidth of the WALLPAPER_SYSTEM of the specified type. 1307 * @tc.type: FUNC test 1308 * @tc.require: issueI5UHRG 1309 */ 1310 it('getMinWidthPromiseTest002', 0, async function (done) { 1311 try { 1312 wallpaper.getMinWidth().then((data) => { 1313 console.info(`getMinWidthPromiseTest002 data : ${data}`); 1314 expect(true).assertTrue(); 1315 done(); 1316 }).catch((err) => { 1317 console.info(`getMinWidthPromiseTest002 err : ${err}`); 1318 expect(null).assertFail(); 1319 done(); 1320 }); 1321 } catch (error) { 1322 expect(null).assertFail(); 1323 done(); 1324 } 1325 }) 1326 1327 /** 1328 * @tc.name: getMinHeightCallbackTest001 1329 * @tc.desc: Test getMinHeight() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. 1330 * @tc.type: FUNC test 1331 * @tc.require: issueI5UHRG 1332 */ 1333 it('getMinHeightCallbackTest001', 0, async function (done) { 1334 try { 1335 wallpaper.getMinHeight(function (err, data) { 1336 if (err) { 1337 console.info(`getMinHeightCallbackTest001 err : ${err}`); 1338 expect(null).assertFail(); 1339 } else { 1340 console.info(`getMinHeightCallbackTest001 data : ${data}`); 1341 expect(true).assertTrue(); 1342 } 1343 done(); 1344 }) 1345 } catch (error) { 1346 expect(null).assertFail(); 1347 done(); 1348 } 1349 }) 1350 1351 /** 1352 * @tc.name: getMinHeightPromiseTest002 1353 * @tc.desc: Test getMinHeight() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. 1354 * @tc.type: FUNC test 1355 * @tc.require: issueI5UHRG 1356 */ 1357 it('getMinHeightPromiseTest002', 0, async function (done) { 1358 try { 1359 wallpaper.getMinHeight().then((data) => { 1360 console.info(`getMinHeightPromiseTest002 data : ${data}`); 1361 expect(true).assertTrue(); 1362 done(); 1363 }).catch((err) => { 1364 console.info(`getMinHeightPromiseTest002 err : ${err}`); 1365 expect(null).assertFail(); 1366 done(); 1367 }); 1368 } catch (error) { 1369 expect(null).assertFail(); 1370 done(); 1371 } 1372 }) 1373 1374 /** 1375 * @tc.name: getFileCallbackTest001 1376 * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. 1377 * @tc.type: FUNC test 1378 * @tc.require: issueI5UHRG 1379 */ 1380 it('getFileCallbackTest001', 0, async function (done) { 1381 try { 1382 wallpaper.getFile(WALLPAPER_SYSTEM, function (err, data) { 1383 if (err) { 1384 console.info(`getFileCallbackTest001 err : ${err}`); 1385 expect(null).assertFail(); 1386 } else { 1387 console.info(`getFileCallbackTest001 data : ${data}`); 1388 expect(true).assertTrue(); 1389 } 1390 done(); 1391 }) 1392 } catch (error) { 1393 expect(null).assertFail(); 1394 done(); 1395 } 1396 }) 1397 1398 /** 1399 * @tc.name: getFilePromiseTest002 1400 * @tc.desc: Test getFile() to get the File of the wallpaper of the specified type. 1401 * @tc.type: FUNC test 1402 * @tc.require: issueI5UHRG 1403 */ 1404 it('getFilePromiseTest002', 0, async function (done) { 1405 try { 1406 wallpaper.getFile(WALLPAPER_SYSTEM).then((data) => { 1407 console.info(`getFilePromiseTest002 data : ${data}`); 1408 expect(true).assertTrue(); 1409 done(); 1410 }).catch((err) => { 1411 console.info(`getFilePromiseTest002 err : ${err}`); 1412 expect(null).assertFail(); 1413 done(); 1414 }); 1415 } catch (error) { 1416 expect(null).assertFail(); 1417 done(); 1418 } 1419 }) 1420 1421 /** 1422 * @tc.name: getFileCallbackTest003 1423 * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. 1424 * @tc.type: FUNC test 1425 * @tc.require: issueI5UHRG 1426 */ 1427 it('getFileCallbackTest003', 0, async function (done) { 1428 try { 1429 wallpaper.getFile(WALLPAPER_LOCKSCREEN, function (err, data) { 1430 if (err) { 1431 console.info(`getFileCallbackTest003 err : ${err}`); 1432 expect(null).assertFail(); 1433 } else { 1434 console.info(`getFileCallbackTest003 data : ${data}`); 1435 expect(true).assertTrue(); 1436 } 1437 done(); 1438 }) 1439 } catch (error) { 1440 expect(null).assertFail(); 1441 done(); 1442 } 1443 }) 1444 1445 /** 1446 * @tc.name: getFilePromiseTest004 1447 * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. 1448 * @tc.type: FUNC test 1449 * @tc.require: issueI5UHRG 1450 */ 1451 it('getFilePromiseTest004', 0, async function (done) { 1452 try { 1453 wallpaper.getFile(WALLPAPER_LOCKSCREEN).then((data) => { 1454 console.info(`getFilePromiseTest004 data : ${data}`); 1455 expect(true).assertTrue(); 1456 done(); 1457 }).catch((err) => { 1458 console.info(`getFilePromiseTest004 err : ${err}`); 1459 expect(null).assertFail(); 1460 done(); 1461 }); 1462 } catch (error) { 1463 expect(null).assertFail(); 1464 done(); 1465 } 1466 }) 1467 1468 /** 1469 * @tc.name: getIdCallbackTest001 1470 * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. 1471 * @tc.type: FUNC test 1472 * @tc.require: issueI5UHRG 1473 */ 1474 it('getIdCallbackTest001', 0, async function (done) { 1475 try { 1476 wallpaper.getId(WALLPAPER_SYSTEM, function (err, data) { 1477 if (err) { 1478 console.info(`getIdCallbackTest001 err : ${err}`); 1479 expect(null).assertFail(); 1480 } else { 1481 console.info(`getIdCallbackTest001 data ${data}`); 1482 expect(true).assertTrue(); 1483 } 1484 done(); 1485 }) 1486 } catch (error) { 1487 expect(null).assertFail(); 1488 done(); 1489 } 1490 }) 1491 1492 /** 1493 * @tc.name: getIdPromiseTest002 1494 * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. 1495 * @tc.type: FUNC test 1496 * @tc.require: issueI5UHRG 1497 */ 1498 it('getIdPromiseTest002', 0, async function (done) { 1499 try { 1500 wallpaper.getId(WALLPAPER_SYSTEM).then((data) => { 1501 console.info(`getIdPromiseTest002 data ${data}`); 1502 expect(true).assertTrue(); 1503 done(); 1504 }).catch((err) => { 1505 console.info(`getIdPromiseTest002 err ${err}`); 1506 expect(null).assertFail(); 1507 done(); 1508 }); 1509 } catch (error) { 1510 expect(null).assertFail(); 1511 done(); 1512 } 1513 }) 1514 1515 /** 1516 * @tc.name: getIdCallbackTest003 1517 * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. 1518 * @tc.type: FUNC test 1519 * @tc.require: issueI5UHRG 1520 */ 1521 it('getIdCallbackTest003', 0, async function (done) { 1522 try { 1523 wallpaper.getId(WALLPAPER_LOCKSCREEN, function (err, data) { 1524 if (err) { 1525 console.info(`getIdCallbackTest003 err ${err}`); 1526 expect(null).assertFail(); 1527 } else { 1528 console.info(`getIdCallbackTest003 data ${data}`); 1529 expect(true).assertTrue(); 1530 } 1531 done(); 1532 }) 1533 } catch (error) { 1534 expect(null).assertFail(); 1535 done(); 1536 } 1537 }) 1538 1539 /** 1540 * @tc.name: getIdPromiseTest004 1541 * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. 1542 * @tc.type: FUNC test 1543 * @tc.require: issueI5UHRG 1544 */ 1545 it('getIdPromiseTest004', 0, async function (done) { 1546 try { 1547 wallpaper.getId(WALLPAPER_LOCKSCREEN).then((data) => { 1548 console.info(`getIdCallbackTest003 data ${data}`); 1549 expect(true).assertTrue(); 1550 done(); 1551 }).catch((err) => { 1552 console.info(`getIdCallbackTest003 err ${err}`); 1553 expect(null).assertFail(); 1554 done(); 1555 }); 1556 } catch (error) { 1557 expect(null).assertFail(); 1558 done(); 1559 } 1560 }) 1561 1562 /** 1563 * @tc.name: getColorsCallbackTest001 1564 * @tc.desc: Test getColors() to gets WALLPAPER_SYSTEM Colors. 1565 * @tc.type: FUNC test 1566 * @tc.require: issueI5UHRG 1567 */ 1568 it('getColorsCallbackTest001', 0, async function (done) { 1569 try { 1570 wallpaper.getColors(WALLPAPER_SYSTEM, function (err, data) { 1571 if (err) { 1572 console.info(`getColorsCallbackTest001 err ${err}`); 1573 expect(null).assertFail(); 1574 } else { 1575 console.info(`getColorsCallbackTest001 data ${data}`); 1576 expect(true).assertTrue(); 1577 } 1578 done(); 1579 }) 1580 } catch (error) { 1581 expect(null).assertFail(); 1582 done(); 1583 } 1584 }) 1585 1586 /** 1587 * @tc.name: getColorsPromiseTest002 1588 * @tc.desc: Test getColors() to gets WALLPAPER_SYSTEM Colors. 1589 * @tc.type: FUNC test 1590 * @tc.require: issueI5UHRG 1591 */ 1592 it('getColorsPromiseTest002', 0, async function (done) { 1593 try { 1594 wallpaper.getColors(WALLPAPER_SYSTEM).then((data) => { 1595 console.info(`getColorsPromiseTest002 data ${data}`); 1596 expect(true).assertTrue(); 1597 done(); 1598 }).catch((err) => { 1599 console.info(`getColorsPromiseTest002 err ${err}`); 1600 expect(null).assertFail(); 1601 done(); 1602 }); 1603 } catch (error) { 1604 expect(null).assertFail(); 1605 done(); 1606 } 1607 }) 1608 1609 /** 1610 * @tc.name: getColorsCallbackTest003 1611 * @tc.desc: Test getColors() to gets WALLPAPER_LOCKSCREEN Colors. 1612 * @tc.type: FUNC test 1613 * @tc.require: issueI5UHRG 1614 */ 1615 it('getColorsCallbackTest003', 0, async function (done) { 1616 try { 1617 wallpaper.getColors(WALLPAPER_LOCKSCREEN, function (err, data) { 1618 if (err) { 1619 console.info(`getColorsCallbackTest003 err ${err}`); 1620 expect(null).assertFail(); 1621 } else { 1622 console.info(`getColorsCallbackTest003 data ${data}`); 1623 expect(true).assertTrue(); 1624 } 1625 done(); 1626 }) 1627 } catch (error) { 1628 expect(null).assertFail(); 1629 done(); 1630 } 1631 }) 1632 1633 /** 1634 * @tc.name: getColorsPromiseTest004 1635 * @tc.desc: Test getColors() to gets WALLPAPER_LOCKSCREEN Colors. 1636 * @tc.type: FUNC test 1637 * @tc.require: issueI5UHRG 1638 */ 1639 it('getColorsPromiseTest004', 0, async function (done) { 1640 try { 1641 wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((data) => { 1642 console.info(`getColorsPromiseTest004 data ${data}`); 1643 expect(true).assertTrue(); 1644 done(); 1645 }).catch((err) => { 1646 console.info(`getColorsPromiseTest004 err ${err}`); 1647 expect(null).assertFail(); 1648 done(); 1649 }); 1650 } catch (error) { 1651 expect(null).assertFail(); 1652 done(); 1653 } 1654 }) 1655 1656 /** 1657 * @tc.name: onCallbackTest001 1658 * @tc.desc: Test on_colorChange to registers a listener for wallpaper color changes to 1659 * receive notifications about the changes. 1660 * @tc.type: FUNC test 1661 * @tc.require: issueI5UHRG 1662 */ 1663 it('onCallbackTest001', 0, async function (done) { 1664 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1665 try { 1666 wallpaper.on('colorChange', (colors, wallpaperType) => { 1667 console.info(`onCallbackTest001 colors : ${colors}`); 1668 expect(colors != null).assertTrue(); 1669 expect(wallpaperType != null).assertTrue(); 1670 wallpaper.off('colorChange'); 1671 done(); 1672 }) 1673 } catch (error) { 1674 console.info(`onCallbackTest001 error : ${error.message}`); 1675 expect(null).assertFail(); 1676 done(); 1677 } 1678 await wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN); 1679 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 1680 }) 1681 1682 /** 1683 * @tc.name: onCallbackTest002 1684 * @tc.desc: Test on_wallpaperChange to registers a listener for wallpaper changes to 1685 * receive notifications about the changes. 1686 * @tc.type: FUNC test 1687 * @tc.require: issueI5UHRG 1688 */ 1689 it('onCallbackTest002', 0, async function (done) { 1690 await wallpaper.restore(WALLPAPER_SYSTEM); 1691 try { 1692 wallpaper.on('wallpaperChange', (wallpaperType, resourceType) => { 1693 expect(wallpaperType != null).assertTrue(); 1694 expect(resourceType != null).assertTrue(); 1695 wallpaper.off('wallpaperChange'); 1696 done(); 1697 }) 1698 } catch (error) { 1699 console.info(`onCallbackTest002 error : ${error.message}`); 1700 expect(null).assertFail(); 1701 done(); 1702 } 1703 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 1704 await wallpaper.restore(WALLPAPER_SYSTEM); 1705 }) 1706 1707 /** 1708 * @tc.name: onCallbackTest003 1709 * @tc.desc: Test to register not exist event 1710 * @tc.type: FUNC test 1711 * @tc.require: issueI5UHRG 1712 */ 1713 it('onCallbackTest003', 0, async function (done) { 1714 await wallpaper.restore(WALLPAPER_SYSTEM); 1715 try { 1716 wallpaper.on('wallpaperChangeX', (wallpaperType, resourceType) => { 1717 expect(null).assertFail(); 1718 done(); 1719 }) 1720 } catch (error) { 1721 console.info(`onCallbackTest003 error : ${error.message}`); 1722 expect(error.code === PARAMETER_ERROR).assertTrue(); 1723 done(); 1724 } 1725 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 1726 await wallpaper.restore(WALLPAPER_SYSTEM); 1727 }) 1728 1729 /** 1730 * @tc.name: onCallbackTest004 1731 * @tc.desc: Test on_wallpaperChange to registers a listener for wallpaper changes to 1732 * receive notifications about the changes. 1733 * @tc.type: FUNC test 1734 * @tc.require: issueI7AAMU 1735 */ 1736 it('onCallbackTest004', 0, async function (done) { 1737 await wallpaper.restore(WALLPAPER_SYSTEM); 1738 try { 1739 wallpaper.on('wallpaperChange', async (wallpaperType, resourceType, uri) => { 1740 expect(wallpaperType != null).assertTrue(); 1741 expect(resourceType != null).assertTrue(); 1742 expect(uri !== "").assertTrue(); 1743 wallpaper.off('wallpaperChange'); 1744 done(); 1745 await wallpaper.restore(WALLPAPER_SYSTEM); 1746 }) 1747 if (isBundleNameExists()) { 1748 await wallpaper.setCustomWallpaper(URI, WALLPAPER_SYSTEM); 1749 } else { 1750 wallpaper.off('wallpaperChange'); 1751 expect(true).assertTrue(); 1752 done(); 1753 } 1754 } catch (error) { 1755 console.info(`onCallbackTest004 error : ${error.message}`); 1756 expect(null).assertFail(); 1757 done(); 1758 } 1759 }) 1760 1761 /** 1762 * @tc.name: offCallbackTest001 1763 * @tc.desc: Test off_colorChange to log off a listener for wallpaper color changes to 1764 * receive notifications about the changes. 1765 * @tc.type: FUNC test 1766 * @tc.require: issueI5UHRG 1767 */ 1768 it('offCallbackTest001', 0, async function (done) { 1769 let callbackTimes = 0; 1770 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 1771 try { 1772 wallpaper.on('colorChange', async (colors, wallpaperType) => { 1773 console.info(`offCallbackTest001 colors : ${colors}`); 1774 callbackTimes = callbackTimes + 1; 1775 wallpaper.off('colorChange'); 1776 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 1777 await wallpaper.restore(WALLPAPER_SYSTEM); 1778 expect(callbackTimes === 1).assertTrue(); 1779 done(); 1780 }) 1781 } catch (error) { 1782 console.info(`offCallbackTest001 error : ${error}`); 1783 expect(null).assertFail(); 1784 done(); 1785 } 1786 await wallpaper.restore(WALLPAPER_SYSTEM); 1787 }) 1788 1789 /** 1790 * @tc.name: offCallbackTest002 1791 * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to 1792 * receive notifications about the changes. 1793 * @tc.type: FUNC test 1794 * @tc.require: issueI5UHRG 1795 */ 1796 it('offCallbackTest002', 0, async function (done) { 1797 let callbackTimes = 0; 1798 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 1799 try { 1800 wallpaper.on('wallpaperChange', async (wallpaperType, resourceType) => { 1801 expect(wallpaperType != null).assertTrue(); 1802 expect(resourceType != null).assertTrue(); 1803 callbackTimes = callbackTimes + 1; 1804 wallpaper.off('wallpaperChange', async (wallpaperType, resourceType) => { 1805 }) 1806 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 1807 await wallpaper.restore(WALLPAPER_SYSTEM); 1808 expect(callbackTimes === 1).assertTrue(); 1809 done(); 1810 }) 1811 } catch (error) { 1812 console.info(`offCallbackTest002 error : ${error.message}`); 1813 expect(null).assertFail(); 1814 done(); 1815 } 1816 await wallpaper.restore(WALLPAPER_SYSTEM); 1817 }) 1818 1819 /** 1820 * @tc.name: offCallbackTest003 1821 * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to 1822 * receive notifications about the changes. 1823 * @tc.type: FUNC test 1824 * @tc.require: issueI5UHRG 1825 */ 1826 it('offCallbackTest003', 0, async function (done) { 1827 try { 1828 wallpaper.off('wallpaperChange', async (wallpaperType, resourceType) => { 1829 }, 'other'); 1830 expect(true).assertTrue(); 1831 done(); 1832 } catch (error) { 1833 console.info(`offCallbackTest003 error : ${error.message}`); 1834 expect(null).assertFail(); 1835 done(); 1836 } 1837 }) 1838 1839 /** 1840 * @tc.name: offCallbackTest004 1841 * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to 1842 * receive notifications about the changes. 1843 * @tc.type: FUNC test 1844 * @tc.require: issueI5UHRG 1845 */ 1846 it('offCallbackTest004', 0, async function (done) { 1847 try { 1848 wallpaper.off('wallpaperChange'); 1849 expect(true).assertTrue(); 1850 done(); 1851 } catch (error) { 1852 console.info(`offCallbackTest004 error : ${error.message}`); 1853 expect(null).assertFail(); 1854 done(); 1855 } 1856 }) 1857 1858 /** 1859 * @tc.name: offCallbackTest005 1860 * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to 1861 * receive notifications about the changes. 1862 * @tc.type: FUNC test 1863 * @tc.require: issueI5UHRG 1864 */ 1865 it('offCallbackTest005', 0, async function (done) { 1866 try { 1867 wallpaper.off('wallpaperChange', 'other'); 1868 expect(null).assertFail(); 1869 done(); 1870 } catch (error) { 1871 console.info(`offCallbackTest005 error : ${error.message}`); 1872 expect(error.code === PARAMETER_ERROR).assertTrue(); 1873 done(); 1874 } 1875 }) 1876 1877 /** 1878 * @tc.name: offCallbackTest006 1879 * @tc.desc: Test not exist event wallpaperChangeX to off 1880 * @tc.type: FUNC test 1881 * @tc.require: issueI5UHRG 1882 */ 1883 it('offCallbackTest006', 0, async function (done) { 1884 await wallpaper.setImage(URI, WALLPAPER_SYSTEM); 1885 try { 1886 wallpaper.off('wallpaperChangeX'); 1887 expect(null).assertFail(); 1888 done(); 1889 } catch (error) { 1890 console.info(`offCallbackTest006 error : ${error.message}`); 1891 expect(error.code === PARAMETER_ERROR).assertTrue(); 1892 done(); 1893 } 1894 await wallpaper.restore(WALLPAPER_SYSTEM); 1895 }) 1896 1897 /** 1898 * @tc.name: setVideoTest001 1899 * @tc.desc: Test setVideo to set live wallpaper. 1900 * @tc.type: FUNC test 1901 * @tc.require: issueI6R07J 1902 */ 1903 it('setVideoTest001', 0, async function (done) { 1904 try { 1905 wallpaper.setVideo(URI_30FPS_3S_MP4, WALLPAPER_SYSTEM, (error) => { 1906 if (error != undefined) { 1907 console.info(`setVideoTest001 error : ${error}`); 1908 expect(null).assertFail(); 1909 } else { 1910 expect(true).assertTrue(); 1911 wallpaper.reset(WALLPAPER_SYSTEM); 1912 } 1913 done(); 1914 }) 1915 } catch (error) { 1916 console.info(`setVideoTest001 error : ${error}`); 1917 expect(null).assertFail(); 1918 done(); 1919 } 1920 }) 1921 1922 /** 1923 * @tc.name: setVideoTest002 1924 * @tc.desc: Test setVideo to set live wallpaper. 1925 * @tc.type: FUNC test 1926 * @tc.require: issueI6R07J 1927 */ 1928 it('setVideoTest002', 0, async function (done) { 1929 try { 1930 wallpaper.setVideo(URI_30FPS_3S_MOV, WALLPAPER_SYSTEM, (error) => { 1931 if (error != undefined) { 1932 console.info(`setVideoTest002 error : ${error}`); 1933 expect(true).assertTrue(); 1934 } else { 1935 expect(null).assertFail(); 1936 } 1937 done(); 1938 }) 1939 } catch (error) { 1940 console.info(`setVideoTest002 error : ${error}`); 1941 expect(null).assertFail(); 1942 done(); 1943 } 1944 }) 1945 1946 /** 1947 * @tc.name: setVideoTest003 1948 * @tc.desc: Test setVideo to set live wallpaper. 1949 * @tc.type: FUNC test 1950 * @tc.require: issueI6R07J 1951 */ 1952 it('setVideoTest003', 0, async function (done) { 1953 try { 1954 wallpaper.setVideo(URI_15FPS_7S_MP4, WALLPAPER_SYSTEM, (error) => { 1955 if (error != undefined) { 1956 console.info(`setVideoTest002 error : ${error}`); 1957 expect(true).assertTrue(); 1958 } else { 1959 expect(null).assertFail(); 1960 } 1961 done(); 1962 }) 1963 } catch (error) { 1964 console.info(`setVideoTest003 error : ${error}`); 1965 expect(null).assertFail(); 1966 done(); 1967 } 1968 }) 1969 1970 /** 1971 * @tc.name: setVideoTest004 1972 * @tc.desc: Test setVideo to set live wallpaper. 1973 * @tc.type: FUNC test 1974 * @tc.require: issueI6R07J 1975 */ 1976 it('setVideoTest004', 0, async function (done) { 1977 try { 1978 wallpaper.setVideo(URI_30FPS_3S_MP4, WALLPAPER_LOCKSCREEN, (error) => { 1979 if (error != undefined) { 1980 console.info(`setVideoTest004 error : ${error}`); 1981 expect(null).assertFail(); 1982 } else { 1983 expect(true).assertTrue(); 1984 wallpaper.reset(WALLPAPER_LOCKSCREEN); 1985 } 1986 done(); 1987 }) 1988 } catch (error) { 1989 console.info(`setVideoTest004 error : ${error}`); 1990 expect(null).assertFail(); 1991 done(); 1992 } 1993 }) 1994 1995 /** 1996 * @tc.name: setVideoTest005 1997 * @tc.desc: Test setVideo to set live wallpaper. 1998 * @tc.type: FUNC test 1999 * @tc.require: issueI6R07J 2000 */ 2001 it('setVideoTest005', 0, async function (done) { 2002 try { 2003 wallpaper.setVideo(URI_30FPS_3S_MOV, WALLPAPER_LOCKSCREEN, (error) => { 2004 if (error != undefined) { 2005 console.info(`setVideoTest005 error : ${error}`); 2006 expect(true).assertTrue(); 2007 } else { 2008 expect(null).assertFail(); 2009 } 2010 done(); 2011 }) 2012 } catch (error) { 2013 console.info(`setVideoTest005 error : ${error}`); 2014 expect(null).assertFail(); 2015 done(); 2016 } 2017 }) 2018 2019 /** 2020 * @tc.name: setVideoTest006 2021 * @tc.desc: Test setVideo to set live wallpaper. 2022 * @tc.type: FUNC test 2023 * @tc.require: issueI6R07J 2024 */ 2025 it('setVideoTest006', 0, async function (done) { 2026 try { 2027 wallpaper.setVideo(URI_15FPS_7S_MP4, WALLPAPER_LOCKSCREEN, (error) => { 2028 if (error != undefined) { 2029 console.info(`setVideoTest006 error : ${error}`); 2030 expect(true).assertTrue(); 2031 } else { 2032 expect(null).assertFail(); 2033 } 2034 done(); 2035 }) 2036 } catch (error) { 2037 console.info(`setVideoTest006 error : ${error}`); 2038 expect(null).assertFail(); 2039 done(); 2040 } 2041 }) 2042 2043 /** 2044 * @tc.name: setCustomWallpaperCallbackTest001 2045 * @tc.desc: Test setCustomWallpaper to set a custom system wallpaper. 2046 * @tc.type: FUNC test 2047 * @tc.require: issueI7AAMU 2048 */ 2049 it('setCustomWallpaperTest001', 0, async function (done) { 2050 try { 2051 wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_SYSTEM, (error) => { 2052 if (isBundleNameExists()) { 2053 if (error !== undefined) { 2054 expect(null).assertFail(); 2055 console.info(`set CustomWallpaperTest001 fail : ${error}`); 2056 } else { 2057 expect(true).assertTrue(); 2058 wallpaper.reset(WALLPAPER_SYSTEM); 2059 } 2060 } else { 2061 expect(true).assertTrue(); 2062 } 2063 done(); 2064 }) 2065 } catch (error) { 2066 expect(null).assertFail(); 2067 console.info(`set Custom WallpaperTest001 fail : ${error}`); 2068 done(); 2069 } 2070 }) 2071 2072 /** 2073 * @tc.name: setCustomWallpaperPromiseTest002 2074 * @tc.desc: Test setCustomWallpaper to sets a custom system wallpaper. 2075 * @tc.type: FUNC test 2076 * @tc.require: issueI7AAMU 2077 */ 2078 it('setCustomWallpaperPromiseTest002', 0, async function (done) { 2079 try { 2080 wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_SYSTEM).then(async () => { 2081 expect(true).assertTrue(); 2082 done(); 2083 await wallpaper.restore(WALLPAPER_SYSTEM); 2084 }).catch((err) => { 2085 if (isBundleNameExists()) { 2086 expect(null).assertFail(); 2087 console.info(`set Custom WallpaperPromiseTest002 fail : ${err}`); 2088 done(); 2089 } else { 2090 expect(true).assertTrue(); 2091 done(); 2092 } 2093 }); 2094 } catch (error) { 2095 expect(null).assertFail(); 2096 console.info(`set Custom WallpaperPromiseTest002 fail : ${error}`); 2097 done(); 2098 } 2099 }) 2100 2101 /** 2102 * @tc.name: setCustomWallpaperCallbackTest003 2103 * @tc.desc: Test setCustomWallpaper to sets a custom lockscreen wallpaper. 2104 * @tc.type: FUNC test 2105 * @tc.require: issueI7AAMU 2106 */ 2107 it('setCustomWallpaperCallbackTest003', 0, async function (done) { 2108 try { 2109 wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_LOCKSCREEN, (error) => { 2110 if (isBundleNameExists()) { 2111 if (error !== undefined) { 2112 expect(null).assertFail(); 2113 console.info(`set Custom WallpaperCallbackTest003 fail : ${error}`); 2114 } else { 2115 expect(true).assertTrue(); 2116 wallpaper.reset(WALLPAPER_SYSTEM); 2117 } 2118 } else { 2119 expect(true).assertTrue(); 2120 } 2121 done(); 2122 }) 2123 } catch (error) { 2124 expect(null).assertFail(); 2125 console.info(`set Custom WallpaperCallbackTest003 fail : ${error}`); 2126 done(); 2127 } 2128 }) 2129 2130 /** 2131 * @tc.name: setCustomWallpaperPromiseTest004 2132 * @tc.desc: Test setCustomWallpaper to sets a custom lockscreen wallpaper. 2133 * @tc.type: FUNC test 2134 * @tc.require: issueI7AAMU 2135 */ 2136 it('setCustomWallpaperPromiseTest004', 0, async function (done) { 2137 try { 2138 wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_LOCKSCREEN).then(async () => { 2139 expect(true).assertTrue(); 2140 done(); 2141 await wallpaper.restore(WALLPAPER_LOCKSCREEN); 2142 }).catch((err) => { 2143 if (isBundleNameExists()) { 2144 expect(null).assertFail(); 2145 console.info(`set Custom WallpaperPromiseTest004 fail : ${err}`); 2146 done(); 2147 } else { 2148 expect(true).assertTrue(); 2149 done(); 2150 } 2151 }); 2152 } catch (error) { 2153 expect(null).assertFail(); 2154 console.info(`set Custom WallpaperPromiseTest004 fail : ${error}`); 2155 done(); 2156 } 2157 }) 2158 2159 /** 2160 * @tc.name: setCustomWallpaperCallbackThrowErrorTest005 2161 * @tc.desc: Test setCustomWallpaper throw parameter error. 2162 * @tc.type: FUNC test 2163 * @tc.require: issueI7AAMU 2164 */ 2165 it('setCustomCallbackThrowErrorTest005', 0, async function (done) { 2166 try { 2167 wallpaper.setCustomWallpaper(URI_ZIP, INVALID_WALLPAPER_TYPE, function (err) { 2168 if (err) { 2169 expect(err.code === PARAMETER_ERROR).assertTrue() 2170 console.info(`set Custom CallbackThrowErrorTest005 fail : ${err}`); 2171 } else { 2172 expect(null).assertFail(); 2173 } 2174 done(); 2175 }) 2176 } catch (error) { 2177 expect(null).assertFail(); 2178 console.info(`set Custom CallbackThrowErrorTest005 fail : ${error}`); 2179 done(); 2180 } 2181 }) 2182 2183 /** 2184 * @tc.name: setCustomWallpaperCallbackThrowErrorTest006 2185 * @tc.desc: Test setImage() throw parameter error. 2186 * @tc.type: FUNC test 2187 * @tc.require: issueI7AAMU 2188 */ 2189 it('setCustomWallpaperCallbackThrowErrorTest006', 0, async function (done) { 2190 try { 2191 wallpaper.setCustomWallpaper(URI_ZIP, function (err) { 2192 if (err) { 2193 console.info(`setCustomWallpaperCallbackThrowErrorTest006 err : ${err}`); 2194 expect(null).assertFail(); 2195 } else { 2196 expect(null).assertFail(); 2197 } 2198 done(); 2199 }) 2200 } catch (error) { 2201 expect(error.code === PARAMETER_ERROR).assertTrue() 2202 done(); 2203 } 2204 }) 2205 2206 /** 2207 * @tc.name: setCustomWallpaperPromiseThrowErrorTest007 2208 * @tc.desc: Test setCustomWallpaper throw parameter error. 2209 * @tc.type: FUNC test 2210 * @tc.require: issueI7AAMU 2211 */ 2212 it('setCustomWallpaperPromiseThrowErrorTest007', 0, async function (done) { 2213 try { 2214 wallpaper.setCustomWallpaper(URI_ZIP, INVALID_WALLPAPER_TYPE).then(() => { 2215 expect(null).assertFail(); 2216 done(); 2217 }).catch((err) => { 2218 console.info(`setCustomWallpaperPromiseThrowErrorTest007 err : ${err}`); 2219 expect(err.code === PARAMETER_ERROR).assertTrue() 2220 done(); 2221 }); 2222 } catch (error) { 2223 expect(null).assertFail(); 2224 done(); 2225 } 2226 }) 2227 2228 /** 2229 * @tc.name: setCustomWallpaperPromiseThrowErrorTest008 2230 * @tc.desc: Test setCustomWallpaper throw parameter error. 2231 * @tc.type: FUNC test 2232 * @tc.require: issueI7AAMU 2233 */ 2234 it('setCustomWallpaperPromiseThrowErrorTest008', 0, async function (done) { 2235 try { 2236 wallpaper.setCustomWallpaper().then(() => { 2237 expect(null).assertFail(); 2238 done(); 2239 }).catch((err) => { 2240 console.info(`setCustomWallpaperPromiseThrowErrorTest008 err : ${err}`); 2241 expect(null).assertFail(); 2242 done(); 2243 }); 2244 } catch (error) { 2245 expect(error.code === PARAMETER_ERROR).assertTrue() 2246 done(); 2247 } 2248 }) 2249}) 2250