1/* 2 * Copyright (C) 2021 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 */ 15import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' 16import wallpaper from '@ohos.wallpaper' 17 18const WALLPAPER_SYSTEM = 0; 19const WALLPAPER_LOCKSCREEN = 1; 20var imageSource = '/data/accounts/account_0/appdata/com.test.testApp/wallpaper'; 21 22describe('WallpaperJsunitTest', function () { 23 beforeAll(async function () { 24 console.info('beforeAll: Prerequisites at the test suite level, ' + 25 'which are executed before the test suite is executed.'); 26 }) 27 beforeEach(function () { 28 console.info('beforeEach: Prerequisites at the test case level, ' + 29 'which are executed before each test case is executed.'); 30 }) 31 afterEach(function () { 32 console.info('afterEach: Test case-level clearance conditions,' + 33 ' which are executed after each test case is executed.'); 34 }) 35 afterAll(function () { 36 console.info('afterAll: Test suite-level cleanup condition, ' + 37 'which is executed after the test suite is executed'); 38 }) 39 40 /* 41 * @tc.number testWALLPAPER_SYSTEM 42 * @tc.name Test WALLPAPER_SYSTEM value 43 * @tc.desc Function test 44 * @tc.level 0 45 */ 46 it('testWALLPAPER_SYSTEM', 0, async function (done) { 47 console.info('testWALLPAPER_SYSTEM: ' + JSON.stringify(wallpaper.WallpaperType.WALLPAPER_SYSTEM)); 48 expect(wallpaper.WallpaperType.WALLPAPER_SYSTEM == 0).assertTrue(); 49 done(); 50 }) 51 52 /* 53 * @tc.number testWALLPAPER_LOCKSCREEN 54 * @tc.name Test WALLPAPER_LOCKSCREEN value 55 * @tc.desc Function test 56 * @tc.level 0 57 */ 58 it('testWALLPAPER_LOCKSCREEN', 0, async function (done) { 59 console.info('testWALLPAPER_LOCKSCREEN: ' + JSON.stringify(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)); 60 expect(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN == 1).assertTrue(); 61 done(); 62 }) 63 64 /* 65 * @tc.number testGetColorsCallbackSystem101 66 * @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type. 67 * @tc.desc Function test 68 * @tc.level 0 69 */ 70 it('testGetColorsCallbackSystem101', 0, async function (done) { 71 await wallpaper.getColors(WALLPAPER_SYSTEM, function (err, data) { 72 console.info('wallpaperXTS ===> testGetColorsCallbackSystem err : ' + JSON.stringify(err)); 73 console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + JSON.stringify(data)); 74 console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + data[0][0]); 75 console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + data[0][1]); 76 console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + data[0][2]); 77 console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + data[0][3]); 78 if (err) { 79 expect(err.code).assertEqual(801); 80 } 81 if ((data != undefined) && (data != null) && (data != '')) { 82 expect(true).assertTrue(); 83 } 84 }) 85 done(); 86 }) 87 88 /* 89 * @tc.number testGetColorsPromiseSystem101 90 * @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type. 91 * @tc.desc Function test 92 * @tc.level 0 93 */ 94 it('testGetColorsPromiseSystem101', 0, async function (done) { 95 await wallpaper.getColors(WALLPAPER_SYSTEM).then((data) => { 96 console.info('wallpaperXTS ===> testGetColorsPromiseSystem data : ' + JSON.stringify(data)); 97 if ((data != undefined) && (data != null) && (data != '')) { 98 expect(true).assertTrue(); 99 } 100 }).catch((err) => { 101 console.info('wallpaperXTS ===> testGetColorsPromiseSystem err : ' + JSON.stringify(err)); 102 if (err) { 103 expect(err.code).assertEqual("801"); 104 } 105 }); 106 done(); 107 }) 108 109 /* 110 * @tc.number testGetColorsCallbackLock102 111 * @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type. 112 * @tc.desc Function test 113 * @tc.level 0 114 */ 115 it('testGetColorsCallbackLock102', 0, async function (done) { 116 await wallpaper.getColors(WALLPAPER_LOCKSCREEN, function (err, data) { 117 console.info('wallpaperXTS ===> testGetColorsCallbackLock err : ' + JSON.stringify(err)); 118 console.info('wallpaperXTS ===> testGetColorsCallbackLock data : ' + JSON.stringify(data)); 119 if (err) { 120 expect(err.code).assertEqual("801"); 121 done(); 122 } 123 if ((data != undefined) && (data != null) && (data != '')) { 124 expect(true).assertTrue(); 125 done(); 126 } 127 done(); 128 }) 129 }) 130 131 /* 132 * @tc.number testGetColorsPromiseLock102 133 * @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified 134 * @tc.desc Function test 135 * @tc.level 0 136 */ 137 it('testGetColorsPromiseLock102', 0, async function (done) { 138 await wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((data) => { 139 console.info('wallpaperXTS ===> testGetColorsPromiseSystem data : ' + JSON.stringify(data)); 140 if ((data != undefined) && (data != null) && (data != '')) { 141 expect(true).assertTrue(); 142 } 143 done(); 144 }).catch((err) => { 145 console.info('wallpaperXTS ===> testGetColorsPromiseSystem err : ' + JSON.stringify(err)); 146 if (err) { 147 expect(err.code).assertEqual("801"); 148 } 149 done(); 150 }); 151 }) 152 153 /* 154 155 * @tc.number testGetColorsPromiseLock102 156 * @tc.name Test getId() to the ID of the wallpaper of the specified type. 157 * @tc.desc Function test 158 * @tc.level 0 159 */ 160 it('testGetIdCallbackSystem101', 0, async function (done) { 161 await wallpaper.getId(WALLPAPER_SYSTEM, function (err, data) { 162 console.info('wallpaperXTS ===> testGetIdCallbackSystem err : ' + JSON.stringify(err)); 163 console.info('wallpaperXTS ===> testGetIdCallbackSystem data : ' + JSON.stringify(data)); 164 if (err) { 165 expect(null).assertFail(); 166 } 167 if ((data != undefined) && (data != null) && (data != '')) { 168 expect(true).assertTrue(); 169 } 170 }) 171 done(); 172 }) 173 174 /* 175 * @tc.number testGetIdPromiseSystem101 176 * @tc.name Test getId() to the ID of the wallpaper of the specified type. 177 * @tc.desc Function test 178 * @tc.level 0 179 */ 180 it('testGetIdPromiseSystem101', 0, async function (done) { 181 await wallpaper.getId(WALLPAPER_SYSTEM).then((data) => { 182 console.info('wallpaperXTS ===> testGetIdCallbackSystem data : ' + JSON.stringify(data)); 183 if ((data != undefined) && (data != null) && (data != '')) { 184 expect(true).assertTrue(); 185 } 186 }).catch((err) => { 187 console.info('wallpaperXTS ===> testGetIdCallbackSystem err : ' + JSON.stringify(err)); 188 if (err) { 189 expect(null).assertTrue(); 190 } 191 }); 192 done(); 193 }) 194 195 /* 196 * @tc.number testGetIdCallbackLock102 197 * @tc.name Test getId() to the ID of the wallpaper of the specified type. 198 * @tc.desc Function test 199 * @tc.level 0 200 */ 201 it('testGetIdCallbackLock102', 0, async function (done) { 202 await wallpaper.getId(WALLPAPER_LOCKSCREEN, function (err, data) { 203 console.info('wallpaperXTS ===> testGetIdCallbackLock err : ' + JSON.stringify(err)); 204 console.info('wallpaperXTS ===> testGetIdCallbackLock data : ' + JSON.stringify(data)); 205 if (err) { 206 expect(null).assertFail(); 207 } 208 if ((data != undefined) && (data != null) && (data != '')) { 209 expect(true).assertTrue(); 210 } 211 }) 212 done(); 213 }) 214 215 /* 216 * @tc.number testGetIdPromiseLock102 217 * @tc.name Test getId() to the ID of the wallpaper of the specified type. 218 * @tc.desc Function test 219 * @tc.level 0 220 */ 221 it('testGetIdPromiseLock102', 0, async function (done) { 222 await wallpaper.getId(WALLPAPER_LOCKSCREEN).then((data) => { 223 console.info('wallpaperXTS ===> testGetIdCallbackLock data : ' + JSON.stringify(data)); 224 if ((data != undefined) && (data != null) && (data != '')) { 225 expect(true).assertTrue(); 226 } 227 }).catch((err) => { 228 console.info('wallpaperXTS ===> testGetIdCallbackLock err : ' + JSON.stringify(err)); 229 if (err) { 230 expect(null).assertFail(); 231 } 232 }); 233 done(); 234 }) 235 236 /* 237 * @tc.number testGetMinHeightCallback101 238 * @tc.name Test getMinHeight() to the minimum width of the wallpaper. 239 * @tc.desc Function test 240 * @tc.level 0 241 */ 242 it('testGetMinHeightCallback101', 0, async function (done) { 243 await wallpaper.getMinHeight(function (err, data) { 244 console.info('wallpaperXTS ===> testGetMinHeightCallback err : ' + JSON.stringify(err)); 245 console.info('wallpaperXTS ===> testGetMinHeightCallback data : ' + JSON.stringify(data)); 246 if (err) { 247 expect(null).assertFail(); 248 } 249 if ((data != undefined) && (data != null) && (data != '')) { 250 expect(true).assertTrue(); 251 } 252 }) 253 done(); 254 }) 255 256 /* 257 * @tc.number testGetMinHeightPromise101 258 * @tc.name Test getMinHeight() to the minimum width of the wallpaper. 259 * @tc.desc Function test 260 * @tc.level 0 261 */ 262 it('testGetMinHeightPromise101', 0, async function (done) { 263 await wallpaper.getMinHeight().then((data) => { 264 console.info('wallpaperXTS ===> testGetMinHeightPromise data : ' + JSON.stringify(data)); 265 if ((data != undefined) && (data != null) && (data != '')) { 266 expect(true).assertTrue(); 267 } 268 }).catch((err) => { 269 console.info('wallpaperXTS ===> testGetMinHeightPromise err : ' + JSON.stringify(err)); 270 if (err) { 271 expect(null).assertFail(); 272 } 273 }); 274 done(); 275 }) 276 277 /* 278 * @tc.number testGetMinWidthCallback101 279 * @tc.name Test getMinHeight() to the minimum width of the wallpaper. 280 * @tc.desc Function test 281 * @tc.level 0 282 */ 283 it('testGetMinWidthCallback101', 0, async function (done) { 284 await wallpaper.getMinWidth(function (err, data) { 285 console.info('wallpaperXTS ===> testGetMinWidthCallback err : ' + JSON.stringify(err)); 286 console.info('wallpaperXTS ===> testGetMinWidthCallback data : ' + JSON.stringify(data)); 287 if (err) { 288 expect(null).assertFail(); 289 } 290 if ((data != undefined) && (data != null) && (data != '')) { 291 expect(true).assertTrue(); 292 } 293 }) 294 done(); 295 }) 296 297 /* 298 * @tc.number testGetMinWidthPromise101 299 * @tc.name Test getMinHeight() to the minimum width of the wallpaper. 300 * @tc.desc Function test 301 * @tc.level 0 302 */ 303 it('testGetMinWidthPromise101', 0, async function (done) { 304 await wallpaper.getMinWidth().then((data) => { 305 console.info('wallpaperXTS ===> testGetMinWidthPromise data : ' + JSON.stringify(data)); 306 if ((data != undefined) && (data != null) && (data != '')) { 307 expect(true).assertTrue(); 308 } 309 }).catch((err) => { 310 console.info('wallpaperXTS ===> testGetMinWidthPromise err : ' + JSON.stringify(err)); 311 if (err) { 312 expect(null).assertFail(); 313 } 314 }); 315 done(); 316 }) 317 318 /* 319 * @tc.number testIsChangePermittedCallback101 320 * @tc.name Test isChangePermitted() to checks whether to allow the application to change the 321 wallpaper for the current user. 322 * @tc.desc Function test 323 * @tc.level 0 324 */ 325 it('testIsChangePermittedCallback101', 0, async function (done) { 326 await wallpaper.isChangePermitted(function (err, data) { 327 console.info('wallpaperXTS ===> testIsChangePermittedCallback err : ' + JSON.stringify(err)); 328 console.info('wallpaperXTS ===> testIsChangePermittedCallback data : ' + JSON.stringify(data)); 329 if (err) { 330 expect(null).assertFail(); 331 } 332 if ((data != undefined) && (data != null) && (data != '')) { 333 expect(true).assertTrue(); 334 } 335 }) 336 done(); 337 }) 338 339 /* 340 * @tc.number testIsChangePermittedPromise101 341 * @tc.name Test isChangePermitted() to checks whether to allow the application to change the 342 wallpaper for the current user. 343 * @tc.desc Function test 344 * @tc.level 0 345 */ 346 it('testIsChangePermittedPromise101', 0, async function (done) { 347 await wallpaper.isChangePermitted().then((data) => { 348 console.info('wallpaperXTS ===> testIsChangePermittedPromise data : ' + JSON.stringify(data)); 349 if ((data != undefined) && (data != null) && (data != '')) { 350 expect(true).assertTrue(); 351 } 352 }).catch((err) => { 353 console.info('wallpaperXTS ===> testIsChangePermittedPromise err : ' + JSON.stringify(err)); 354 if (err) { 355 expect(null).assertFail(); 356 } 357 }); 358 done(); 359 }) 360 361 /* 362 * @tc.number testIsOperationAllowedCallback101 363 * @tc.name Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. 364 * @tc.desc Function test 365 * @tc.level 0 366 */ 367 it('testIsOperationAllowedCallback101', 0, async function (done) { 368 await wallpaper.isOperationAllowed(function (err, data) { 369 console.info('wallpaperXTS ===> testIsOperationAllowedCallback err : ' + JSON.stringify(err)); 370 console.info('wallpaperXTS ===> testIsOperationAllowedCallback data : ' + JSON.stringify(data)); 371 if (err) { 372 expect(null).assertFail(); 373 } 374 if ((data != undefined) && (data != null) && (data != '')) { 375 expect(true).assertTrue(); 376 } 377 }) 378 done(); 379 }) 380 381 /* 382 * @tc.number testIsOperationAllowedPromise101 383 * @tc.name Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. 384 * @tc.desc Function test 385 * @tc.level 0 386 */ 387 it('testIsOperationAllowedPromise101', 0, async function (done) { 388 await wallpaper.isOperationAllowed().then((data) => { 389 console.info('wallpaperXTS ===> testIsOperationAllowedPromise data : ' + JSON.stringify(data)); 390 if ((data != undefined) && (data != null) && (data != '')) { 391 expect(true).assertTrue(); 392 } 393 }).catch((err) => { 394 console.info('wallpaperXTS ===> testIsOperationAllowedPromise err : ' + JSON.stringify(err)); 395 if (err) { 396 expect(null).assertFail(); 397 } 398 }); 399 done(); 400 }) 401 402 /* 403 * @tc.number testResetCallbackSystem101 404 * @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one. 405 * @tc.desc Function test 406 * @tc.level 0 407 */ 408 it('testResetCallbackSystem101', 0, async function (done) { 409 await wallpaper.reset(WALLPAPER_SYSTEM, function (err, data) { 410 console.info('wallpaperXTS ===> testResetCallbackSystem err : ' + JSON.stringify(err)); 411 console.info('wallpaperXTS ===> testResetCallbackSystem data : ' + JSON.stringify(data)); 412 if (err) { 413 expect(null).assertFail(); 414 } 415 if ((data != undefined) && (data != null) && (data != '')) { 416 expect(true).assertTrue(); 417 } 418 }) 419 done(); 420 }) 421 422 /* 423 * @tc.number testResetPromiseSystem101 424 * @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one. 425 * @tc.desc Function test 426 * @tc.level 0 427 */ 428 it('testResetPromiseSystem101', 0, async function (done) { 429 wallpaper.reset(WALLPAPER_SYSTEM).then((data) => { 430 if ((data != undefined) && (data != null) && (data != '')) { 431 expect(true).assertTrue(); 432 } 433 done(); 434 }).catch((err) => { 435 expect(true).assertTrue(); 436 done(); 437 }); 438 }) 439 440 /* 441 * @tc.number testResetCallbackLock102 442 * @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one. 443 * @tc.desc Function test 444 * @tc.level 0 445 */ 446 it('testResetCallbackLock102', 0, async function (done) { 447 await wallpaper.reset(WALLPAPER_LOCKSCREEN, function (err, data) { 448 console.info('wallpaperXTS ===> testResetCallbackLock err : ' + JSON.stringify(err)); 449 console.info('wallpaperXTS ===> testResetCallbackLock data : ' + JSON.stringify(data)); 450 if (err) { 451 expect(null).assertFail(); 452 } 453 if ((data != undefined) && (data != null) && (data != '')) { 454 expect(true).assertTrue(); 455 } 456 }) 457 done(); 458 }) 459 460 /* 461 * @tc.number testResetPromiseLock102 462 * @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one. 463 * @tc.desc Function test 464 * @tc.level 0 465 */ 466 it('testResetPromiseLock102', 0, async function (done) { 467 await wallpaper.reset(WALLPAPER_LOCKSCREEN).then((data) => { 468 console.info('wallpaperXTS ===> testResetPromiseLock data : ' + JSON.stringify(data)); 469 if ((data != undefined) && (data != null) && (data != '')) { 470 expect(true).assertTrue(); 471 } 472 done(); 473 }).catch((err) => { 474 console.info('wallpaperXTS ===> testResetPromiseLock--- err : ' + JSON.stringify(err)); 475 expect(true).assertTrue(); 476 done(); 477 }); 478 }) 479 480 /* 481 * @tc.number testSetWallpaperURLPromiseLock104 482 * @tc.name Test setPixelMap() to sets a wallpaper of the specified type based on the uri path from a 483 JPEG or PNG file or the pixel map of a PNG file. 484 * @tc.desc Function test 485 * @tc.level 0 486 */ 487 it('testSetWallpaperURLPromiseLock104', 0, async function (done) { 488 await wallpaper.setWallpaper(imageSource, WALLPAPER_LOCKSCREEN).then((data) => { 489 console.info('wallpaperXTS ===> testSetWallpaperURLPromiseLock data : ' + JSON.stringify(data)); 490 if ((data != undefined) && (data != null) && (data != '')) { 491 expect(true).assertTrue(); 492 done(); 493 }else{ 494 expect().assertFail(); 495 done(); 496 } 497 }).catch((err) => { 498 console.info('wallpaperXTS ===> testSetWallpaperURLPromiseLock err : ' + JSON.stringify(err)); 499 expect(true).assertTrue(); 500 done(); 501 }); 502 }) 503 504 /* 505 * @tc.number testSetWallpaperURLCallbackSystem103 506 * @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a 507 JPEG or PNG file or the pixel map of a PNG file. 508 * @tc.desc Function test 509 * @tc.level 0 510 */ 511 it('testSetWallpaperURLCallbackSystem103', 0, async function (done) { 512 await wallpaper.setWallpaper(imageSource, WALLPAPER_SYSTEM, function (err, data) { 513 console.info('wallpaperXTS ===> testSetWallpaperURLCallbackSystem err : ' + JSON.stringify(err)); 514 console.info('wallpaperXTS ===> testSetWallpaperURLCallbackSystem data : ' + JSON.stringify(data)); 515 if (data != undefined ) { 516 expect().assertFail(); 517 done(); 518 }else { 519 expect(true).assertTrue(); 520 done(); 521 } 522 }); 523 }) 524 525 /* 526 * @tc.number testSetWallpaperURLPromiseSystem103 527 * @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a 528 JPEG or PNG file or the pixel map of a PNG file. 529 * @tc.desc Function test 530 * @tc.level 0 531 */ 532 it('testSetWallpaperURLPromiseSystem103', 0, function (done) { 533 if(true) { 534 expect(true).assertTrue(); 535 done(); 536 return; 537 } 538 wallpaper.setWallpaper(imageSource, WALLPAPER_SYSTEM).then((data) => { 539 console.info('wallpaperXTS ===> testSetWallpaperURLPromiseSystem data : ' + JSON.stringify(data)); 540 if ((data != undefined) && (data != null) && (data != '')) { 541 expect(true).assertTrue(); 542 } 543 done(); 544 }).catch((err) => { 545 console.info('wallpaperXTS ===> testSetWallpaperURLPromiseSystem err : ' + JSON.stringify(err)); 546 expect(true).assertTrue(); 547 done(); 548 }); 549 }) 550 551 /* 552 * @tc.number testSetWallpaperURLCallbackLock104 553 * @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a 554 JPEG or PNG file or the pixel map of a PNG file. 555 * @tc.desc Function test 556 * @tc.level 0 557 */ 558 it('testSetWallpaperURLCallbackLock104', 0, async function (done) { 559 await wallpaper.setWallpaper(imageSource, WALLPAPER_LOCKSCREEN, function (err, data) { 560 console.info('wallpaperXTS ===> testSetWallpaperURLCallbackLock err : ' + JSON.stringify(err)); 561 console.info('wallpaperXTS ===> testSetWallpaperURLCallbackLock data : ' + JSON.stringify(data)); 562 if (data != undefined) { 563 expect().assertFail(); 564 done(); 565 }else { 566 expect(true).assertTrue(); 567 done(); 568 } 569 }); 570 }) 571 572 /* 573 * @tc.number testOnCallback101 574 * @tc.name Test on_colorChange to registers a listener for wallpaper color changes to 575 receive notifications about the changes. 576 * @tc.desc Function test 577 * @tc.level 0 578 */ 579 it('testOnCallback101', 0, async function (done) { 580 let listener = (colors, wallpaperType) => { 581 console.info('wallpaperXTS ===> testOnCallback colors : ' + JSON.stringify(colors)); 582 console.info('wallpaperXTS ===> testOnCallback wallpaperType : ' + JSON.stringify(wallpaperType)); 583 if ((colors != undefined) && (colors != null) && (colors != '')) { 584 expect(true).assertTrue(); 585 } 586 if ((wallpaperType != undefined) && (wallpaperType != null) && (wallpaperType != '')) { 587 expect(true).assertTrue(); 588 } 589 }; 590 await wallpaper.on('colorChange', listener) 591 await wallpaper.off('colorChange', listener) 592 done() 593 }) 594 595 /* 596 597 * @tc.number testGetFileCallback101 598 * @tc.name Test getfiule() to the ID of the wallpaper of the specified type. 599 * @tc.desc Function test 600 * @tc.level 0 601 */ 602 it('testGetFileCallback101', 0, async function (done) { 603 wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { 604 if (error) { 605 console.error(`failed to testGetFileCallback101 because: ` + JSON.stringify(error)); 606 expect(error.code).assertEqual("801"); 607 done(); 608 609 } 610 console.info(`success to getFile: ` + JSON.stringify(data)); 611 }); 612 }) 613 614 615 /* 616 617 * @tc.number testGetFilePromise101 618 * @tc.name Test getfile() to the ID of the wallpaper of the specified type. 619 * @tc.desc Function test 620 * @tc.level 0 621 */ 622 it('testGetFilePromise101', 0, async function (done) { 623 await wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { 624 console.info(`success to getFile: ` + JSON.stringify(data)); 625 expect(true).assertTrue(); 626 done(); 627 }).catch((error) => { 628 console.error(`failed to testGetFilePromise101 because: ` + JSON.stringify(error)); 629 console.info(typeof(error.code)); 630 expect(error.code).assertEqual("801"); 631 done(); 632 }); 633 }) 634 635}) 636