diff --git a/OAT.xml b/OAT.xml index 3abd8653bd1ce9526ff17cf966434cb4fdc04879..e388389d629111617cf289bf3ed1b964f9b25ff6 100644 --- a/OAT.xml +++ b/OAT.xml @@ -61,9 +61,9 @@ Note:If the text contains special characters, please escape them according to th - - diff --git a/bundle.json b/bundle.json index 0f65e9c3ebfed1916367d53b686efcc45b191438..3b73c3bc7c710dc8341a862e1e148df42b13c27b 100644 --- a/bundle.json +++ b/bundle.json @@ -81,8 +81,8 @@ ], "test": [ "//base/theme/wallpaper_mgr/test:unittest", - "//base/theme/wallpaper_mgr/test/unittest/js/src/wallpaper_js:unittest", - "//base/theme/wallpaper_mgr/test/fuzztest:fuzztest" + "//base/theme/wallpaper_mgr/test/fuzztest:fuzztest", + "//base/theme/wallpaper_mgr/frameworks/js/napi/test:unittest" ] }, "hisysevent_config": [ diff --git a/frameworks/js/napi/test/BUILD.gn b/frameworks/js/napi/test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..090b9add52463c3e90d0ba63ad05308c45110ddf --- /dev/null +++ b/frameworks/js/napi/test/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") + +#################################group######################################### +group("unittest") { + testonly = true + deps = [] + + deps += [ "unittest/src/wallpaper_js:unittest" ] +} +############################################################################### diff --git a/test/unittest/js/resource/ohos_test.xml b/frameworks/js/napi/test/unittest/resource/ohos_test.xml similarity index 100% rename from test/unittest/js/resource/ohos_test.xml rename to frameworks/js/napi/test/unittest/resource/ohos_test.xml diff --git a/test/unittest/js/resource/wallpaper_lock.JPG b/frameworks/js/napi/test/unittest/resource/wallpaper_lock.JPG similarity index 100% rename from test/unittest/js/resource/wallpaper_lock.JPG rename to frameworks/js/napi/test/unittest/resource/wallpaper_lock.JPG diff --git a/test/unittest/js/resource/wallpaper_system.JPG b/frameworks/js/napi/test/unittest/resource/wallpaper_system.JPG similarity index 100% rename from test/unittest/js/resource/wallpaper_system.JPG rename to frameworks/js/napi/test/unittest/resource/wallpaper_system.JPG diff --git a/test/unittest/js/src/signature/openharmony_sx.p7b b/frameworks/js/napi/test/unittest/src/signature/openharmony_sx.p7b similarity index 100% rename from test/unittest/js/src/signature/openharmony_sx.p7b rename to frameworks/js/napi/test/unittest/src/signature/openharmony_sx.p7b diff --git a/test/unittest/js/src/wallpaper_js/BUILD.gn b/frameworks/js/napi/test/unittest/src/wallpaper_js/BUILD.gn similarity index 95% rename from test/unittest/js/src/wallpaper_js/BUILD.gn rename to frameworks/js/napi/test/unittest/src/wallpaper_js/BUILD.gn index f934c016df66ac6b24f61e90f2d7e608b3669590..e516bac1a768fb4aeab8f3734e54bafb8aefc5b5 100644 --- a/test/unittest/js/src/wallpaper_js/BUILD.gn +++ b/frameworks/js/napi/test/unittest/src/wallpaper_js/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../wallpaper.gni") +import("../../../../../../../wallpaper.gni") ohos_js_unittest("WallpaperJSTest") { module_out_path = "theme/wallpaperJsTest" diff --git a/test/unittest/js/src/wallpaper_js/Wallpaper.test.js b/frameworks/js/napi/test/unittest/src/wallpaper_js/Wallpaper.test.js similarity index 99% rename from test/unittest/js/src/wallpaper_js/Wallpaper.test.js rename to frameworks/js/napi/test/unittest/src/wallpaper_js/Wallpaper.test.js index 6f91a4e1584f2c6612cd556e01c1d55363d1f717..0640f4eea553fd9ba3f8e3ba177aaa4047c38672 100644 --- a/test/unittest/js/src/wallpaper_js/Wallpaper.test.js +++ b/frameworks/js/napi/test/unittest/src/wallpaper_js/Wallpaper.test.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Huawei Device Co., Ltd. + * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -75,23 +75,6 @@ describe('WallpaperJSTest', function () { await wallpaper.restore(WALLPAPER_LOCKSCREEN); }) - function isBundleNameExists() { - try { - bundleManager.getBundleInfo(BUNDLE_NAME, bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT, (e) => { - if (e) { - console.info(`getBundleInfo error ${e.code}`); - return false; - } else { - console.info(`Wallpaper : getBundleInfo is success`); - return true; - } - }) - } catch (error) { - console.info(`getBundleInfo error ${error.code}`); - return false; - } - } - async function createTempImage() { let pixelMap = await createTempPixelMap(); const imagePackerApi = image.createImagePacker(); @@ -115,82 +98,189 @@ describe('WallpaperJSTest', function () { return pixelMap; } + function isBundleNameExists() { + try { + bundleManager.getBundleInfo(BUNDLE_NAME, bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT, (e) => { + if (e) { + console.info(`getBundleInfo error ${e.code}`); + return false; + } else { + console.info(`Wallpaper : getBundleInfo is success`); + return true; + } + }) + } catch (error) { + console.info(`getBundleInfo error ${error.code}`); + return false; + } + + } + + /** + * @tc.name: getColorsSyncTest001 + * @tc.desc: Test getColorsSync() to gets WALLPAPER_SYSTEM Colors by syncing. + * @tc.type: FUNC + * @tc.require: issueI5UHRG + */ + it('getColorsSyncTest001', 0, function () { + try { + let data = wallpaper.getColorsSync(WALLPAPER_SYSTEM); + console.info(`getColorsSyncTest001 data : ${data}`); + if (data !== undefined) { + expect(true).assertTrue(); + } + } catch (error) { + console.info(`getColorsSyncTest001 error ${error}`); + expect(null).assertFail(); + } + }) + /** - * @tc.name: setCustomWallpaperCallbackTest001 - * @tc.desc: Test setCustomWallpaper to set a custom system wallpaper. + * @tc.name: getColorsSyncTest002 + * @tc.desc: Test getColorsSync() to gets WALLPAPER_LOCKSCREEN Colors by syncing. + * @tc.type: FUNC + * @tc.require: issueI5UHRG + */ + it('getColorsSyncTest002', 0, function () { + try { + let data = wallpaper.getColorsSync(WALLPAPER_LOCKSCREEN); + console.info(`getColorsSyncTest002 data : ${data}`); + if (data !== undefined) { + expect(true).assertTrue(); + } + } catch (error) { + console.info(`getColorsSyncTest002 error : ${error}`); + expect(null).assertFail(); + } + }) + + /** + * @tc.name: getColorsSyncTest003 + * @tc.desc: Test getColorsSync() throw parameter error. + * @tc.type: FUNC + * @tc.require: issueI5UHRG + */ + it('getColorsSyncTest003', 0, function () { + try { + let data = wallpaper.getColorsSync(INVALID_WALLPAPER_TYPE); + console.info(`getColorsSyncTest003 data : ${data}`); + expect(null).assertFail(); + } catch (error) { + console.info(`getColorsSyncTest003 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() + } + }) + + /** + * @tc.name: getColorsSyncTest004 + * @tc.desc: Test getColorsSync() throw parameter error. + * @tc.type: FUNC + * @tc.require: issueI5UHRG + */ + it('getColorsSyncTest004', 0, function () { + try { + let data = wallpaper.getColorsSync(); + console.info(`getColorsSyncTest004 data : ${data}`); + expect(null).assertFail(); + } catch (error) { + console.info(`getColorsSyncTest004 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() + } + }) + + /** + * @tc.name: getMinHeightSyncTest001 + * @tc.desc: Test getMinHeightSync() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. * @tc.type: FUNC test - * @tc.require: issueI7AAMU + * @tc.require: issueI5UHRG */ - it('setCustomWallpaperTest001', 0, async function (done) { + it('getMinHeightSyncTest001', 0, function () { + let data = wallpaper.getMinHeightSync(); + console.info(`getMinHeightSyncTest001 data : ${data}`); + if (data !== undefined) { + expect(true).assertTrue(); + } else { + expect(null).assertFail() + } + }) + + /** + * @tc.name: getMinWidthSyncTest001 + * @tc.desc: Test getMinWidthSync() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG + */ + it('getMinWidthSyncTest001', 0, function () { + let data = wallpaper.getMinWidthSync(); + console.info(`getMinWidthSyncTest001 data : ${data}`); + if (data !== undefined) { + expect(true).assertTrue(); + } else { + expect(null).assertFail() + } + }) + + /** + * @tc.name: restoreCallbackSystemTest001 + * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG + */ + it('restoreCallbackSystemTest001', 0, async function (done) { try { - wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_SYSTEM, (error) => { - if (isBundleNameExists()) { - if (error !== undefined) { - expect(null).assertFail(); - console.info(`set CustomWallpaperTest001 fail : ${error}`); - } else { - expect(true).assertTrue(); - wallpaper.reset(WALLPAPER_SYSTEM); - } + wallpaper.restore(WALLPAPER_SYSTEM, function (err) { + if (err) { + console.info(`restoreCallbackSystemTest001 err : ${err}`); + expect(null).assertFail() } else { expect(true).assertTrue(); } done(); }) + } catch (error) { + console.info(`restoreCallbackSystemTest001 err : ${error}`); expect(null).assertFail(); - console.info(`set Custom WallpaperTest001 fail : ${error}`); done(); } + }) /** - * @tc.name: setCustomWallpaperPromiseTest002 - * @tc.desc: Test setCustomWallpaper to sets a custom system wallpaper. + * @tc.name: restorePromiseSystemTest002 + * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. * @tc.type: FUNC test - * @tc.require: issueI7AAMU + * @tc.require: issueI5UHRG */ - it('setCustomWallpaperPromiseTest002', 0, async function (done) { + it('restorePromiseSystemTest002', 0, async function (done) { try { - wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_SYSTEM).then(async () => { + wallpaper.restore(WALLPAPER_SYSTEM).then(() => { expect(true).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - if (isBundleNameExists()) { - expect(null).assertFail(); - console.info(`set Custom WallpaperPromiseTest002 fail : ${err}`); - done(); - } else { - expect(true).assertTrue(); - done(); - } + console.info(`restorePromiseSystemTest002 err : ${err}`); + expect(null).assertFail(); + done(); }); } catch (error) { expect(null).assertFail(); - console.info(`set Custom WallpaperPromiseTest002 fail : ${error}`); done(); } }) /** - * @tc.name: setCustomWallpaperCallbackTest003 - * @tc.desc: Test setCustomWallpaper to sets a custom lockscreen wallpaper. + * @tc.name: restoreCallbackLockTest003 + * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. * @tc.type: FUNC test - * @tc.require: issueI7AAMU + * @tc.require: issueI5UHRG */ - it('setCustomWallpaperCallbackTest003', 0, async function (done) { + it('restoreCallbackLockTest003', 0, async function (done) { try { - wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_LOCKSCREEN, (error) => { - if (isBundleNameExists()) { - if (error !== undefined) { - expect(null).assertFail(); - console.info(`set Custom WallpaperCallbackTest003 fail : ${error}`); - } else { - expect(true).assertTrue(); - wallpaper.reset(WALLPAPER_SYSTEM); - } + wallpaper.restore(WALLPAPER_LOCKSCREEN, function (err) { + if (err) { + expect(null).assertFail(); + console.info(`restore CallbackLockTest003 fail : ${err}`); } else { expect(true).assertTrue(); } @@ -198,52 +288,45 @@ describe('WallpaperJSTest', function () { }) } catch (error) { expect(null).assertFail(); - console.info(`set Custom WallpaperCallbackTest003 fail : ${error}`); + console.info(`restore CallbackLockTest003 fail : ${error}`); done(); } }) /** - * @tc.name: setCustomWallpaperPromiseTest004 - * @tc.desc: Test setCustomWallpaper to sets a custom lockscreen wallpaper. + * @tc.name: restorePromiseLockTest004 + * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. * @tc.type: FUNC test - * @tc.require: issueI7AAMU + * @tc.require: issueI5UHRG */ - it('setCustomWallpaperPromiseTest004', 0, async function (done) { + it('restorePromiseLockTest004', 0, async function (done) { try { - wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_LOCKSCREEN).then(async () => { + wallpaper.restore(WALLPAPER_LOCKSCREEN).then(() => { expect(true).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - if (isBundleNameExists()) { - expect(null).assertFail(); - console.info(`set Custom WallpaperPromiseTest004 fail : ${err}`); - done(); - } else { - expect(true).assertTrue(); - done(); - } + console.info(`restorePromiseLockTest004 err : ${err}`); + expect(null).assertFail(); + done(); }); } catch (error) { expect(null).assertFail(); - console.info(`set Custom WallpaperPromiseTest004 fail : ${error}`); done(); } }) /** - * @tc.name: setCustomWallpaperCallbackThrowErrorTest005 - * @tc.desc: Test setCustomWallpaper throw parameter error. + * @tc.name: restoreCallbackThrowErrorTest005 + * @tc.desc: Test restore() throw parameter error. * @tc.type: FUNC test - * @tc.require: issueI7AAMU + * @tc.require: issueI5UHRG */ - it('setCustomCallbackThrowErrorTest005', 0, async function (done) { + it('restoreCallbackThrowErrorTest005', 0, async function (done) { try { - wallpaper.setCustomWallpaper(URI_ZIP, INVALID_WALLPAPER_TYPE, function (err) { + wallpaper.restore(INVALID_WALLPAPER_TYPE, function (err) { if (err) { expect(err.code === PARAMETER_ERROR).assertTrue() - console.info(`set Custom CallbackThrowErrorTest005 fail : ${err}`); + console.info(`restore CallbackThrowErrorTest005 fail : ${err}`); } else { expect(null).assertFail(); } @@ -251,23 +334,23 @@ describe('WallpaperJSTest', function () { }) } catch (error) { expect(null).assertFail(); - console.info(`set Custom CallbackThrowErrorTest005 fail : ${error}`); + console.info(`restore CallbackThrowErrorTest005 fail : ${error}`); done(); } }) /** - * @tc.name: setCustomWallpaperCallbackThrowErrorTest006 - * @tc.desc: Test setImage() throw parameter error. + * @tc.name: restoreCallbackThrowErrorTest006 + * @tc.desc: Test restore() throw parameter error. * @tc.type: FUNC test - * @tc.require: issueI7AAMU + * @tc.require: issueI5UHRG */ - it('setCustomWallpaperCallbackThrowErrorTest006', 0, async function (done) { + it('restoreCallbackThrowErrorTest006', 0, async function (done) { try { - wallpaper.setCustomWallpaper(URI_ZIP, function (err) { + wallpaper.restore(function (err) { if (err) { - console.info(`setCustomWallpaperCallbackThrowErrorTest006 err : ${err}`); expect(null).assertFail(); + console.info(`restore CallbackThrowErrorTest006 fail : ${err}`); } else { expect(null).assertFail(); } @@ -275,23 +358,24 @@ describe('WallpaperJSTest', function () { }) } catch (error) { expect(error.code === PARAMETER_ERROR).assertTrue() + console.info(`restore CallbackThrowErrorTest006 fail : ${error}`); done(); } }) /** - * @tc.name: setCustomWallpaperPromiseThrowErrorTest007 - * @tc.desc: Test setCustomWallpaper throw parameter error. + * @tc.name: restorePromiseThrowErrorTest007 + * @tc.desc: Test restore() throw parameter error. * @tc.type: FUNC test - * @tc.require: issueI7AAMU + * @tc.require: issueI5UHRG */ - it('setCustomWallpaperPromiseThrowErrorTest007', 0, async function (done) { + it('restorePromiseThrowErrorTest007', 0, async function (done) { try { - wallpaper.setCustomWallpaper(URI_ZIP, INVALID_WALLPAPER_TYPE).then(() => { + wallpaper.restore(INVALID_WALLPAPER_TYPE).then(() => { expect(null).assertFail(); done(); }).catch((err) => { - console.info(`setCustomWallpaperPromiseThrowErrorTest007 err : ${err}`); + console.info(`restorePromiseThrowErrorTest007 err : ${err}`); expect(err.code === PARAMETER_ERROR).assertTrue() done(); }); @@ -302,18 +386,18 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setCustomWallpaperPromiseThrowErrorTest008 - * @tc.desc: Test setCustomWallpaper throw parameter error. + * @tc.name: restorePromiseThrowErrorTest008 + * @tc.desc: Test restore() throw parameter error. * @tc.type: FUNC test - * @tc.require: issueI7AAMU + * @tc.require: issueI5UHRG */ - it('setCustomWallpaperPromiseThrowErrorTest008', 0, async function (done) { + it('restorePromiseThrowErrorTest008', 0, async function (done) { try { - wallpaper.setCustomWallpaper().then(() => { + wallpaper.restore().then(() => { expect(null).assertFail(); done(); }).catch((err) => { - console.info(`setCustomWallpaperPromiseThrowErrorTest008 err : ${err}`); + console.info(`restorePromiseThrowErrorTest008 err : ${err}`); expect(null).assertFail(); done(); }); @@ -324,1189 +408,1036 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setAllWallpapersThrowErrorTest001 - * @tc.desc: Test setAllWallpapers throw parameter error, parameter count error + * @tc.name: getImagePromiseLockTest001 + * @tc.desc: Test getImage() to gets a PixelMap of the specified type. * @tc.type: FUNC test - * @tc.require: + * @tc.require: issueI5UHRG */ - it('setAllWallpapersThrowErrorTest001', 0, async function (done) { + it('getImagePromiseLockTest001', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { - expect(null).assertFail(); + wallpaper.getImage(WALLPAPER_LOCKSCREEN).then((data) => { + console.info(`getImagePromiseLockTest001 data : ${data}`); + if (data !== undefined) { + expect(true).assertTrue(); + } done(); }).catch((err) => { - console.info(`setAllWallpapersThrowErrorTest001 err : ${err}`); + console.info(`getImagePromiseLockTest001 err : ${err}`); expect(null).assertFail(); done(); }); } catch (error) { - console.info(`setAllWallpapersThrowErrorTest001 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue() + expect(null).assertFail(); done(); } }) /** - * @tc.name: setAllWallpapersThrowErrorTest002 - * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperType range error + * @tc.name: getImageCallbackSystemTest002 + * @tc.desc: Test getImage() to gets a PixelMap of the specified type. * @tc.type: FUNC test - * @tc.require: + * @tc.require: issueI5UHRG */ - it('setAllWallpapersThrowErrorTest002', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORT, - source: URI - } - let wallpaperInfos = [wallpaperInfo1]; + it('getImageCallbackSystemTest002', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, 2).then(() => { - expect(null).assertFail(); - done(); - }).catch((err) => { - console.info(`setAllWallpapersThrowErrorTest002 err : ${err}`); - expect(null).assertFail(); + wallpaper.getImage(WALLPAPER_SYSTEM, function (err, data) { + if (err) { + expect(null).assertFail(); + console.info(`get Image CallbackSystemTest002 fail : ${err}`); + } else { + console.info(`get Image CallbackSystemTest002 data : ${data}`); + if (data !== undefined) { + expect(true).assertTrue(); + } + } done(); }); } catch (error) { - console.info(`setAllWallpapersThrowErrorTest002 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue() + expect(null).assertFail(); + console.info(`get Image CallbackSystemTest002 fail : ${error}`); done(); } }) /** - * @tc.name: setAllWallpapersThrowErrorTest003 - * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperInfo source error + * @tc.name: getImagePromiseSystemTest003 + * @tc.desc: Test getImage() to gets a PixelMap of the specified type. * @tc.type: FUNC test - * @tc.require: + * @tc.require: issueI5UHRG */ - it('setAllWallpapersThrowErrorTest003', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORT, - source: URI_ZIP - } - let wallpaperInfos = [wallpaperInfo1]; + it('getImagePromiseSystemTest003', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { - expect(null).assertFail(); + wallpaper.getImage(WALLPAPER_SYSTEM).then((data) => { + console.info(`getImagePromiseSystemTest003 data : ${data}`); + if (data !== undefined) { + expect(true).assertTrue(); + } done(); }).catch((err) => { - console.info(`setAllWallpapersThrowErrorTest003 err : ${err}`); - expect(err.code === PARAMETER_ERROR).assertTrue() + console.info(`getImagePromiseSystemTest003 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.info(`setAllWallpapersThrowErrorTest003 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue() + expect(null).assertFail(); done(); } }) /** - * @tc.name: setAllWallpapersTest001 - * @tc.desc: Test setAllWallpapers. + * @tc.name: getImageCallbackLockTest004 + * @tc.desc: Test getImage() to gets a PixelMap of the specified type. * @tc.type: FUNC test - * @tc.require: + * @tc.require: issueI5UHRG */ - it('setAllWallpapersTest001', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORT, - source: URI - } - let wallpaperInfos = [wallpaperInfo1]; + it('getImageCallbackLockTest004', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(async () => { - expect(true).assertTrue(); - done(); - await wallpaper.restore(WALLPAPER_SYSTEM); - }).catch((err) => { - console.info(`setAllWallpapersTest001 fail : ${err}`); + wallpaper.getImage(WALLPAPER_LOCKSCREEN, function (err, data) { + if (err) { + expect(null).assertFail(); + console.info(`get Image CallbackLockTest004 fail : ${err}`); + } else { + console.info(`get Image CallbackLockTest004 data : ${data}`); + if (data !== undefined) { + expect(true).assertTrue(); + } + } done(); }); } catch (error) { expect(null).assertFail(); - console.info(`setAllWallpapersTest001 fail : ${error}`); + console.info(`get Image CallbackLockTest004 fail : ${error}`); done(); } }) /** - * @tc.name: setAllWallpapersTest002 - * @tc.desc: Test setAllWallpapers. + * @tc.name: getImageCallbackThrowErrorTest005 + * @tc.desc: Test getImage() throw parameter error. * @tc.type: FUNC test - * @tc.require: + * @tc.require: issueI5UHRG */ - it('setAllWallpapersTest002', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORT, - source: URI - } - const wallpaperInfo2 = { - foldState: wallpaper.FoldState.UNFOLD_1, - rotateState: wallpaper.RotateState.LAND, - source: URI - } - let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2]; + it('getImageCallbackThrowErrorTest005', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { - expect(true).assertTrue(); - done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); - }).catch((err) => { - console.info(`setAllWallpapersTest002 fail : ${err}`); + wallpaper.getImage(INVALID_WALLPAPER_TYPE, function (err, data) { + console.error(`getImageCallbackThrowErrorTest005 err : ${err}`); + console.error(`getImageCallbackThrowErrorTest005 data : ${data}`); + expect(null).assertTrue(); done(); - }); + }) } catch (error) { - expect(null).assertFail(); - console.info(`setAllWallpapersTest002 fail : ${error}`); + console.info(`getImageCallbackThrowErrorTest005 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: setAllWallpapersTest003 - * @tc.desc: Test setAllWallpapers. + * @tc.name: getImageCallbackThrowErrorTest006 + * @tc.desc: Test getImage() throw parameter error. * @tc.type: FUNC test - * @tc.require: + * @tc.require: issueI5UHRG */ - it('setAllWallpapersTest003', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORT, - source: URI - } - const wallpaperInfo2 = { - foldState: wallpaper.FoldState.UNFOLD_1, - rotateState: wallpaper.RotateState.LAND, - source: URI - } - const wallpaperInfo3 = { - foldState: wallpaper.FoldState.UNFOLD_2, - rotateState: wallpaper.RotateState.PORT, - source: URI - } - const wallpaperInfo4 = { - foldState: wallpaper.FoldState.UNFOLD_2, - rotateState: wallpaper.RotateState.LAND, - source: URI - } - let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2, wallpaperInfo3, wallpaperInfo4]; + it('getImageCallbackThrowErrorTest006', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { - expect(true).assertTrue(); - done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); - }).catch((err) => { - console.info(`setAllWallpapersTest003 fail : ${err}`); + wallpaper.getImage(function (err, data) { + if (err) { + console.info(`getImageCallbackThrowErrorTest006 err : ${err}`); + expect(null).assertFail(); + } else { + console.info(`getImageCallbackThrowErrorTest006 data : ${data}`); + if (data !== undefined) { + expect(null).assertFail(); + } + } done(); - }); + }) } catch (error) { - expect(null).assertFail(); - console.info(`setAllWallpapersTest003 fail : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } }) + /** - * @tc.name: setAllWallpapersThrowErrorTest001tmp - * @tc.desc: Test setAllWallpapers throw parameter error, parameter count error + * @tc.name: getImagePromiseThrowErrorTest007 + * @tc.desc: Test getImage() throw parameter error. * @tc.type: FUNC test - * @tc.require: + * @tc.require: issueI5UHRG */ - it('setAllWallpapersThrowErrorTest001tmp', 0, async function (done) { + it('getImagePromiseThrowErrorTest007', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { - expect(null).assertFail(); + wallpaper.getImage(INVALID_WALLPAPER_TYPE).then((data) => { + console.error(`getImagePromiseThrowErrorTest007 data : ${data}`); + expect(null).assertTrue(); done(); }).catch((err) => { - console.info(`setAllWallpapersThrowErrorTest001tmp err : ${err}`); - expect(null).assertFail(); + console.error(`getImagePromiseThrowErrorTest007 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - console.info(`setAllWallpapersThrowErrorTest001tmp error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue() + console.info(`getImagePromiseThrowErrorTest007 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: setAllWallpapersThrowErrorTest002tmp - * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperType range error + * @tc.name: getImagePromiseThrowErrorTest008 + * @tc.desc: Test getImage() throw parameter error. * @tc.type: FUNC test - * @tc.require: + * @tc.require: issueI5UHRG */ - it('setAllWallpapersThrowErrorTest002tmp', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORT, - source: URI - } - let wallpaperInfos = [wallpaperInfo1]; + it('getImagePromiseThrowErrorTest008', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, 2).then(() => { - expect(null).assertFail(); + wallpaper.getImage().then((data) => { + console.info(`getImagePromiseThrowErrorTest008 data : ${data}`); + if (data !== undefined) { + expect(null).assertFail(); + } done(); }).catch((err) => { - console.info(`setAllWallpapersThrowErrorTest002tmp err : ${err}`); + console.info(`getImagePromiseThrowErrorTest008 err : ${err}`); expect(null).assertFail(); done(); }); } catch (error) { - console.info(`setAllWallpapersThrowErrorTest002tmp error : ${error}`); expect(error.code === PARAMETER_ERROR).assertTrue() done(); } }) /** - * @tc.name: setAllWallpapersThrowErrorTest003tmp - * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperInfo source error - * @tc.type: FUNC test - * @tc.require: + * @tc.name: getCorrespondWallpaperTest001 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 000. + * @tc.type: FUNC */ - it('setAllWallpapersThrowErrorTest003tmp', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORTRAIT, - source: URI_ZIP - } - let wallpaperInfos = [wallpaperInfo1]; + it('getCorrespondWallpaperTest001', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { - expect(null).assertFail(); + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, PORT).then((data) => { + console.info(`getCorrespondWallpaperTest001 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.info(`setAllWallpapersThrowErrorTest003tmp err : ${err}`); - expect(err.code === PARAMETER_ERROR).assertTrue() + console.error(`getCorrespondWallpaperTest001 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - console.info(`setAllWallpapersThrowErrorTest003tmp error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue() + console.error(`getCorrespondWallpaperTest001 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: setAllWallpapersTest001tmp - * @tc.desc: Test setAllWallpapers. - * @tc.type: FUNC test - * @tc.require: + * @tc.name: getCorrespondWallpaperTest002 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 001. + * @tc.type: FUNC */ - it('setAllWallpapersTest001tmp', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORTRAIT, - source: URI - } - let wallpaperInfos = [wallpaperInfo1]; + it('getCorrespondWallpaperTest002', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(async () => { - expect(true).assertTrue(); + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, LAND).then((data) => { + console.info(`getCorrespondWallpaperTest002 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - console.info(`setAllWallpapersTest001tmp fail : ${err}`); + console.error(`getCorrespondWallpaperTest002 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); - console.info(`setAllWallpapersTest001tmp fail : ${error}`); + console.error(`getCorrespondWallpaperTest002 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: setAllWallpapersTest002tmp - * @tc.desc: Test setAllWallpapers. - * @tc.type: FUNC test - * @tc.require: + * @tc.name: getCorrespondWallpaperTest003 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 010. + * @tc.type: FUNC */ - it('setAllWallpapersTest002tmp', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORTRAIT, - source: URI - } - const wallpaperInfo2 = { - foldState: wallpaper.FoldState.UNFOLD_ONCE_STATE, - rotateState: wallpaper.RotateState.LAND, - source: URI - } - let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2]; + it('getCorrespondWallpaperTest003', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { - expect(true).assertTrue(); + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_1, PORT).then((data) => { + console.info(`getCorrespondWallpaperTest003 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.info(`setAllWallpapersTest002tmp fail : ${err}`); + console.error(`getCorrespondWallpaperTest003 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); - console.info(`setAllWallpapersTest002tmp fail : ${error}`); + console.error(`getCorrespondWallpaperTest003 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: setAllWallpapersTest003tmp - * @tc.desc: Test setAllWallpapers. - * @tc.type: FUNC test - * @tc.require: + * @tc.name: getCorrespondWallpaperTest004 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 011. + * @tc.type: FUNC */ - it('setAllWallpapersTest003tmp', 0, async function (done) { - const wallpaperInfo1 = { - foldState: wallpaper.FoldState.NORMAL, - rotateState: wallpaper.RotateState.PORTRAIT, - source: URI - } - const wallpaperInfo2 = { - foldState: wallpaper.FoldState.UNFOLD_ONCE_STATE, - rotateState: wallpaper.RotateState.LANDSCAPE, - source: URI - } - const wallpaperInfo3 = { - foldState: wallpaper.FoldState.UNFOLD_TWICE_STATE, - rotateState: wallpaper.RotateState.PORTRAIT, - source: URI - } - const wallpaperInfo4 = { - foldState: wallpaper.FoldState.UNFOLD_TWICE_STATE, - rotateState: wallpaper.RotateState.LANDSCAPE, - source: URI - } - let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2, wallpaperInfo3, wallpaperInfo4]; + it('getCorrespondWallpaperTest004', 0, async function (done) { try { - wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { - expect(true).assertTrue(); + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_1, LAND).then((data) => { + console.info(`getCorrespondWallpaperTest004 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.info(`setAllWallpapersTest003tmp fail : ${err}`); + console.error(`getCorrespondWallpaperTest004 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); - console.info(`setAllWallpapersTest003tmp fail : ${error}`); + console.error(`getCorrespondWallpaperTest004 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: getColorsSyncTest001 - * @tc.desc: Test getColorsSync() to gets WALLPAPER_SYSTEM Colors by syncing. - * @tc.type: FUNC - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest005 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 020. + * @tc.type: FUNC */ - it('getColorsSyncTest001', 0, function () { + it('getCorrespondWallpaperTest005', 0, async function (done) { try { - let data = wallpaper.getColorsSync(WALLPAPER_SYSTEM); - console.info(`getColorsSyncTest001 data : ${data}`); - if (data !== undefined) { - expect(true).assertTrue(); - } + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_2, PORT).then((data) => { + console.info(`getCorrespondWallpaperTest005 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); + done(); + }).catch((err) => { + console.error(`getCorrespondWallpaperTest005 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - console.info(`getColorsSyncTest001 error ${error}`); - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest005 error : ${error}`); + expect(null).assertTrue(); + done(); } }) - /** - * @tc.name: getColorsSyncTest002 - * @tc.desc: Test getColorsSync() to gets WALLPAPER_LOCKSCREEN Colors by syncing. - * @tc.type: FUNC - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest006 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 021. + * @tc.type: FUNC */ - it('getColorsSyncTest002', 0, function () { + it('getCorrespondWallpaperTest006', 0, async function (done) { try { - let data = wallpaper.getColorsSync(WALLPAPER_LOCKSCREEN); - console.info(`getColorsSyncTest002 data : ${data}`); - if (data !== undefined) { - expect(true).assertTrue(); - } + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_2, LAND).then((data) => { + console.info(`getCorrespondWallpaperTest006 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); + done(); + }).catch((err) => { + console.error(`getCorrespondWallpaperTest006 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - console.info(`getColorsSyncTest002 error : ${error}`); - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest006 error : ${error}`); + expect(null).assertTrue(); + done(); } }) /** - * @tc.name: getColorsSyncTest003 - * @tc.desc: Test getColorsSync() throw parameter error. - * @tc.type: FUNC - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest007 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 100. + * @tc.type: FUNC */ - it('getColorsSyncTest003', 0, function () { + it('getCorrespondWallpaperTest007', 0, async function (done) { try { - let data = wallpaper.getColorsSync(INVALID_WALLPAPER_TYPE); - console.info(`getColorsSyncTest003 data : ${data}`); - expect(null).assertFail(); + wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, NORMAL, PORT).then((data) => { + console.info(`getCorrespondWallpaperTest007 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); + done(); + }).catch((err) => { + console.error(`getCorrespondWallpaperTest007 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - console.info(`getColorsSyncTest003 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue() + console.error(`getCorrespondWallpaperTest007 error : ${error}`); + expect(null).assertTrue(); + done(); } }) - /** - * @tc.name: getColorsSyncTest004 - * @tc.desc: Test getColorsSync() throw parameter error. - * @tc.type: FUNC - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest008 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 101. + * @tc.type: FUNC */ - it('getColorsSyncTest004', 0, function () { + it('getCorrespondWallpaperTest008', 0, async function (done) { try { - let data = wallpaper.getColorsSync(); - console.info(`getColorsSyncTest004 data : ${data}`); - expect(null).assertFail(); + wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, NORMAL, LAND).then((data) => { + console.info(`getCorrespondWallpaperTest008 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); + done(); + }).catch((err) => { + console.error(`getCorrespondWallpaperTest008 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - console.info(`getColorsSyncTest004 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue() - } - }) - - /** - * @tc.name: getMinHeightSyncTest001 - * @tc.desc: Test getMinHeightSync() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG - */ - it('getMinHeightSyncTest001', 0, function () { - let data = wallpaper.getMinHeightSync(); - console.info(`getMinHeightSyncTest001 data : ${data}`); - if (data !== undefined) { - expect(true).assertTrue(); - } else { - expect(null).assertFail() - } - }) - - /** - * @tc.name: getMinWidthSyncTest001 - * @tc.desc: Test getMinWidthSync() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG - */ - it('getMinWidthSyncTest001', 0, function () { - let data = wallpaper.getMinWidthSync(); - console.info(`getMinWidthSyncTest001 data : ${data}`); - if (data !== undefined) { - expect(true).assertTrue(); - } else { - expect(null).assertFail() + console.error(`getCorrespondWallpaperTest008 error : ${error}`); + expect(null).assertTrue(); + done(); } }) - /** - * @tc.name: restoreCallbackSystemTest001 - * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest009 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 110. + * @tc.type: FUNC */ - it('restoreCallbackSystemTest001', 0, async function (done) { + it('getCorrespondWallpaperTest009', 0, async function (done) { try { - wallpaper.restore(WALLPAPER_SYSTEM, function (err) { - if (err) { - console.info(`restoreCallbackSystemTest001 err : ${err}`); - expect(null).assertFail() - } else { - expect(true).assertTrue(); - } + wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1, PORT).then((data) => { + console.info(`getCorrespondWallpaperTest009 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); - }) - + }).catch((err) => { + console.error(`getCorrespondWallpaperTest009 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - console.info(`restoreCallbackSystemTest001 err : ${error}`); - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest009 error : ${error}`); + expect(null).assertTrue(); done(); } - }) /** - * @tc.name: restorePromiseSystemTest002 - * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest010 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 111. + * @tc.type: FUNC */ - it('restorePromiseSystemTest002', 0, async function (done) { + it('getCorrespondWallpaperTest010', 0, async function (done) { try { - wallpaper.restore(WALLPAPER_SYSTEM).then(() => { - expect(true).assertTrue(); + wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1, LAND).then((data) => { + console.info(`getCorrespondWallpaperTest010 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.info(`restorePromiseSystemTest002 err : ${err}`); - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest010 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest010 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: restoreCallbackLockTest003 - * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest011 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 120. + * @tc.type: FUNC */ - it('restoreCallbackLockTest003', 0, async function (done) { + it('getCorrespondWallpaperTest011', 0, async function (done) { try { - wallpaper.restore(WALLPAPER_LOCKSCREEN, function (err) { - if (err) { - expect(null).assertFail(); - console.info(`restore CallbackLockTest003 fail : ${err}`); - } else { - expect(true).assertTrue(); - } + wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_2, PORT).then((data) => { + console.info(`getCorrespondWallpaperTest011 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); - }) + }).catch((err) => { + console.error(`getCorrespondWallpaperTest011 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - expect(null).assertFail(); - console.info(`restore CallbackLockTest003 fail : ${error}`); + console.error(`getCorrespondWallpaperTest011 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: restorePromiseLockTest004 - * @tc.desc: Test restore() to removes a wallpaper of the specified type and restores the default one. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest012 + * @tc.desc: Test getCorrespondWallpaper() with normal argc 121. + * @tc.type: FUNC */ - it('restorePromiseLockTest004', 0, async function (done) { + it('getCorrespondWallpaperTest012', 0, async function (done) { try { - wallpaper.restore(WALLPAPER_LOCKSCREEN).then(() => { - expect(true).assertTrue(); + wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_2, LAND).then((data) => { + console.info(`getCorrespondWallpaperTest012 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.info(`restorePromiseLockTest004 err : ${err}`); - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest012 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest012 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: restoreCallbackThrowErrorTest005 - * @tc.desc: Test restore() throw parameter error. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest013 + * @tc.desc: Test getCorrespondWallpaper() lack of argc. + * @tc.type: FUNC */ - it('restoreCallbackThrowErrorTest005', 0, async function (done) { + it('getCorrespondWallpaperTest013', 0, async function (done) { try { - wallpaper.restore(INVALID_WALLPAPER_TYPE, function (err) { - if (err) { - expect(err.code === PARAMETER_ERROR).assertTrue() - console.info(`restore CallbackThrowErrorTest005 fail : ${err}`); - } else { - expect(null).assertFail(); - } + wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1).then((data) => { + console.error(`getCorrespondWallpaperTest013 data : ${data}`); + expect(null).assertTrue(); done(); - }) + }).catch((err) => { + console.error(`getCorrespondWallpaperTest013 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - expect(null).assertFail(); - console.info(`restore CallbackThrowErrorTest005 fail : ${error}`); + console.info(`getCorrespondWallpaperTest013 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + PARAMETER_COUNT).assertTrue(); done(); } }) /** - * @tc.name: restoreCallbackThrowErrorTest006 - * @tc.desc: Test restore() throw parameter error. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest014 + * @tc.desc: Test getCorrespondWallpaper() with invalid wallpaper type. + * @tc.type: FUNC */ - it('restoreCallbackThrowErrorTest006', 0, async function (done) { + it('getCorrespondWallpaperTest014', 0, async function (done) { try { - wallpaper.restore(function (err) { - if (err) { - expect(null).assertFail(); - console.info(`restore CallbackThrowErrorTest006 fail : ${err}`); - } else { - expect(null).assertFail(); - } + wallpaper.getCorrespondWallpaper(INVALID_WALLPAPER_TYPE, UNFOLD_2, LAND).then((data) => { + console.error(`getCorrespondWallpaperTest014 data : ${data}`); + expect(null).assertTrue(); done(); - }) + }).catch((err) => { + console.error(`getCorrespondWallpaperTest014 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - expect(error.code === PARAMETER_ERROR).assertTrue() - console.info(`restore CallbackThrowErrorTest006 fail : ${error}`); + console.info(`getCorrespondWallpaperTest014 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: restorePromiseThrowErrorTest007 - * @tc.desc: Test restore() throw parameter error. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest015 + * @tc.desc: Test getCorrespondWallpaper() with invalid foldstate. + * @tc.type: FUNC */ - it('restorePromiseThrowErrorTest007', 0, async function (done) { + it('getCorrespondWallpaperTest015', 0, async function (done) { try { - wallpaper.restore(INVALID_WALLPAPER_TYPE).then(() => { - expect(null).assertFail(); + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, INVALID_FOLDSTATE, PORT).then((data) => { + console.error(`getCorrespondWallpaperTest015 data : ${data}`); + expect(null).assertTrue(); done(); }).catch((err) => { - console.info(`restorePromiseThrowErrorTest007 err : ${err}`); - expect(err.code === PARAMETER_ERROR).assertTrue() + console.error(`getCorrespondWallpaperTest015 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); + console.info(`getCorrespondWallpaperTest015 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: restorePromiseThrowErrorTest008 - * @tc.desc: Test restore() throw parameter error. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest016 + * @tc.desc: Test getCorrespondWallpaper() with invalid rotatestate. + * @tc.type: FUNC */ - it('restorePromiseThrowErrorTest008', 0, async function (done) { + it('getCorrespondWallpaperTest016', 0, async function (done) { try { - wallpaper.restore().then(() => { - expect(null).assertFail(); + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, INVALID_ROTATESTATE).then((data) => { + console.error(`getCorrespondWallpaperTest016 data : ${data}`); + expect(null).assertTrue(); done(); }).catch((err) => { - console.info(`restorePromiseThrowErrorTest008 err : ${err}`); - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest016 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(error.code === PARAMETER_ERROR).assertTrue() + console.info(`getCorrespondWallpaperTest016 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: getImagePromiseLockTest001 - * @tc.desc: Test getImage() to gets a PixelMap of the specified type. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest017 + * @tc.desc: Test getCorrespondWallpaper() with invalid wallpaper type. + * @tc.type: FUNC */ - it('getImagePromiseLockTest001', 0, async function (done) { + it('getCorrespondWallpaperTest017', 0, async function (done) { try { - wallpaper.getImage(WALLPAPER_LOCKSCREEN).then((data) => { - console.info(`getImagePromiseLockTest001 data : ${data}`); - if (data !== undefined) { - expect(true).assertTrue(); - } + wallpaper.getCorrespondWallpaper("INVALID_TYPE", NORMAL, PORT).then((data) => { + console.error(`getCorrespondWallpaperTest017 data : ${data}`); + expect(null).assertTrue(); done(); }).catch((err) => { - console.info(`getImagePromiseLockTest001 err : ${err}`); - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest017 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); + console.info(`getCorrespondWallpaperTest017 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: getImageCallbackSystemTest002 - * @tc.desc: Test getImage() to gets a PixelMap of the specified type. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest018 + * @tc.desc: Test getCorrespondWallpaper() to get wallpaper. + * @tc.type: FUNC */ - it('getImageCallbackSystemTest002', 0, async function (done) { + it('getCorrespondWallpaperTest018', 0, async function (done) { try { - wallpaper.getImage(WALLPAPER_SYSTEM, function (err, data) { - if (err) { - expect(null).assertFail(); - console.info(`get Image CallbackSystemTest002 fail : ${err}`); - } else { - console.info(`get Image CallbackSystemTest002 data : ${data}`); - if (data !== undefined) { - expect(true).assertTrue(); - } - } + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, "INVALID_TYPE", PORT).then((data) => { + console.error(`getCorrespondWallpaperTest018 data : ${data}`); + expect(null).assertTrue(); + done(); + }).catch((err) => { + console.error(`getCorrespondWallpaperTest018 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); - console.info(`get Image CallbackSystemTest002 fail : ${error}`); + console.info(`getCorrespondWallpaperTest018 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: getImagePromiseSystemTest003 - * @tc.desc: Test getImage() to gets a PixelMap of the specified type. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getCorrespondWallpaperTest019 + * @tc.desc: Test getCorrespondWallpaper() to get wallpaper. + * @tc.type: FUNC */ - it('getImagePromiseSystemTest003', 0, async function (done) { + it('getCorrespondWallpaperTest019', 0, async function (done) { try { - wallpaper.getImage(WALLPAPER_SYSTEM).then((data) => { - console.info(`getImagePromiseSystemTest003 data : ${data}`); - if (data !== undefined) { - expect(true).assertTrue(); - } + wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, "INVALID_TYPE").then((data) => { + console.error(`getCorrespondWallpaperTest019 data : ${data}`); + expect(null).assertTrue(); done(); }).catch((err) => { - console.info(`getImagePromiseSystemTest003 err : ${err}`); - expect(null).assertFail(); + console.error(`getCorrespondWallpaperTest019 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(null).assertFail(); + console.info(`getCorrespondWallpaperTest019 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); done(); } }) - /** - * @tc.name: getImageCallbackLockTest004 - * @tc.desc: Test getImage() to gets a PixelMap of the specified type. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getWallpaperByStateTest001 + * @tc.desc: Test getWallpaperByState() with normal argc 000. + * @tc.type: FUNC */ - it('getImageCallbackLockTest004', 0, async function (done) { + it('getWallpaperByStateTest001', 0, async function (done) { try { - wallpaper.getImage(WALLPAPER_LOCKSCREEN, function (err, data) { - if (err) { - expect(null).assertFail(); - console.info(`get Image CallbackLockTest004 fail : ${err}`); - } else { - console.info(`get Image CallbackLockTest004 data : ${data}`); - if (data !== undefined) { - expect(true).assertTrue(); - } - } + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, PORTRAIT).then((data) => { + console.info(`getWallpaperByStateTest001 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); - }); - } catch (error) { - expect(null).assertFail(); - console.info(`get Image CallbackLockTest004 fail : ${error}`); - done(); - } - }) - - /** - * @tc.name: getImageCallbackThrowErrorTest005 - * @tc.desc: Test getImage() throw parameter error. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG - */ - it('getImageCallbackThrowErrorTest005', 0, async function (done) { - try { - wallpaper.getImage(INVALID_WALLPAPER_TYPE, function (err, data) { - console.error(`getImageCallbackThrowErrorTest005 err : ${err}`); - console.error(`getImageCallbackThrowErrorTest005 data : ${data}`); + }).catch((err) => { + console.error(`getWallpaperByStateTest001 err : ${err}`); expect(null).assertTrue(); done(); - }) + }); } catch (error) { - console.info(`getImageCallbackThrowErrorTest005 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); + console.error(`getWallpaperByStateTest001 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: getImageCallbackThrowErrorTest006 - * @tc.desc: Test getImage() throw parameter error. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getWallpaperByStateTest002 + * @tc.desc: Test getWallpaperByState() with normal argc 001. + * @tc.type: FUNC */ - it('getImageCallbackThrowErrorTest006', 0, async function (done) { + it('getWallpaperByStateTest002', 0, async function (done) { try { - wallpaper.getImage(function (err, data) { - if (err) { - console.info(`getImageCallbackThrowErrorTest006 err : ${err}`); - expect(null).assertFail(); - } else { - console.info(`getImageCallbackThrowErrorTest006 data : ${data}`); - if (data !== undefined) { - expect(null).assertFail(); - } - } + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, LANDSCAPE).then((data) => { + console.info(`getWallpaperByStateTest002 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); - }) + }).catch((err) => { + console.error(`getWallpaperByStateTest002 err : ${err}`); + expect(null).assertTrue(); + done(); + }); } catch (error) { - expect(error.code === PARAMETER_ERROR).assertTrue() + console.error(`getWallpaperByStateTest002 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: getImagePromiseThrowErrorTest007 - * @tc.desc: Test getImage() throw parameter error. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getWallpaperByStateTest003 + * @tc.desc: Test getWallpaperByState() with normal argc 010. + * @tc.type: FUNC */ - it('getImagePromiseThrowErrorTest007', 0, async function (done) { + it('getWallpaperByStateTest003', 0, async function (done) { try { - wallpaper.getImage(INVALID_WALLPAPER_TYPE).then((data) => { - console.error(`getImagePromiseThrowErrorTest007 data : ${data}`); - expect(null).assertTrue(); + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_ONCE_STATE, PORTRAIT).then((data) => { + console.info(`getWallpaperByStateTest003 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getImagePromiseThrowErrorTest007 err : ${err}`); + console.error(`getWallpaperByStateTest003 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.info(`getImagePromiseThrowErrorTest007 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); + console.error(`getWallpaperByStateTest003 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: getImagePromiseThrowErrorTest008 - * @tc.desc: Test getImage() throw parameter error. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.name: getWallpaperByStateTest004 + * @tc.desc: Test getWallpaperByState() with normal argc 011. + * @tc.type: FUNC */ - it('getImagePromiseThrowErrorTest008', 0, async function (done) { + it('getWallpaperByStateTest004', 0, async function (done) { try { - wallpaper.getImage().then((data) => { - console.info(`getImagePromiseThrowErrorTest008 data : ${data}`); - if (data !== undefined) { - expect(null).assertFail(); - } + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_ONCE_STATE, LANDSCAPE).then((data) => { + console.info(`getWallpaperByStateTest004 data : ${data}`); + expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.info(`getImagePromiseThrowErrorTest008 err : ${err}`); - expect(null).assertFail(); + console.error(`getWallpaperByStateTest004 err : ${err}`); + expect(null).assertTrue(); done(); }); } catch (error) { - expect(error.code === PARAMETER_ERROR).assertTrue() + console.error(`getWallpaperByStateTest004 error : ${error}`); + expect(null).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest001 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 000. + * @tc.name: getWallpaperByStateTest005 + * @tc.desc: Test getWallpaperByState() with normal argc 020. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest001', 0, async function (done) { + it('getWallpaperByStateTest005', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, PORT).then((data) => { - console.info(`getCorrespondWallpaperTest001 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_TWICE_STATE, PORTRAIT).then((data) => { + console.info(`getWallpaperByStateTest005 data : ${data}`); expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest001 err : ${err}`); + console.error(`getWallpaperByStateTest005 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest001 error : ${error}`); + console.error(`getWallpaperByStateTest005 error : ${error}`); expect(null).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest002 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 001. + * @tc.name: getWallpaperByStateTest006 + * @tc.desc: Test getWallpaperByState() with normal argc 021. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest002', 0, async function (done) { + it('getWallpaperByStateTest006', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, LAND).then((data) => { - console.info(`getCorrespondWallpaperTest002 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { + console.info(`getWallpaperByStateTest006 data : ${data}`); expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest002 err : ${err}`); + console.error(`getWallpaperByStateTest006 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest002 error : ${error}`); + console.error(`getWallpaperByStateTest006 error : ${error}`); expect(null).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest003 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 010. + * @tc.name: getWallpaperByStateTest007 + * @tc.desc: Test getWallpaperByState() with normal argc 100. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest003', 0, async function (done) { + it('getWallpaperByStateTest007', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_1, PORT).then((data) => { - console.info(`getCorrespondWallpaperTest003 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, NORMAL, PORTRAIT).then((data) => { + console.info(`getWallpaperByStateTest007 data : ${data}`); expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest003 err : ${err}`); + console.error(`getWallpaperByStateTest007 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest003 error : ${error}`); + console.error(`getWallpaperByStateTest007 error : ${error}`); expect(null).assertTrue(); done(); } }) - /** - * @tc.name: getCorrespondWallpaperTest004 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 011. + * @tc.name: getWallpaperByStateTest008 + * @tc.desc: Test getWallpaperByState() with normal argc 101. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest004', 0, async function (done) { + it('getWallpaperByStateTest008', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_1, LAND).then((data) => { - console.info(`getCorrespondWallpaperTest004 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, NORMAL, LANDSCAPE).then((data) => { + console.info(`getWallpaperByStateTest008 data : ${data}`); expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest004 err : ${err}`); + console.error(`getWallpaperByStateTest008 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest004 error : ${error}`); + console.error(`getWallpaperByStateTest008 error : ${error}`); expect(null).assertTrue(); done(); } }) - /** - * @tc.name: getCorrespondWallpaperTest005 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 020. + * @tc.name: getWallpaperByStateTest009 + * @tc.desc: Test getWallpaperByState() with normal argc 110. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest005', 0, async function (done) { + it('getWallpaperByStateTest009', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_2, PORT).then((data) => { - console.info(`getCorrespondWallpaperTest005 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE, PORTRAIT).then((data) => { + console.info(`getWallpaperByStateTest009 data : ${data}`); expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest005 err : ${err}`); + console.error(`getWallpaperByStateTest009 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest005 error : ${error}`); + console.error(`getWallpaperByStateTest009 error : ${error}`); expect(null).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest006 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 021. + * @tc.name: getWallpaperByStateTest010 + * @tc.desc: Test getWallpaperByState() with normal argc 111. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest006', 0, async function (done) { + it('getWallpaperByStateTest010', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, UNFOLD_2, LAND).then((data) => { - console.info(`getCorrespondWallpaperTest006 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE, LANDSCAPE).then((data) => { + console.info(`getWallpaperByStateTest010 data : ${data}`); expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest006 err : ${err}`); + console.error(`getWallpaperByStateTest010 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest006 error : ${error}`); + console.error(`getWallpaperByStateTest010 error : ${error}`); expect(null).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest007 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 100. - * @tc.type: FUNC - */ - it('getCorrespondWallpaperTest007', 0, async function (done) { - try { - wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, NORMAL, PORT).then((data) => { - console.info(`getCorrespondWallpaperTest007 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getCorrespondWallpaperTest007 err : ${err}`); - expect(null).assertTrue(); - done(); - }); - } catch (error) { - console.error(`getCorrespondWallpaperTest007 error : ${error}`); - expect(null).assertTrue(); - done(); - } - }) - /** - * @tc.name: getCorrespondWallpaperTest008 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 101. + * @tc.name: getWallpaperByStateTest011 + * @tc.desc: Test getWallpaperByState() with normal argc 120. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest008', 0, async function (done) { + it('getWallpaperByStateTest011', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, NORMAL, LAND).then((data) => { - console.info(`getCorrespondWallpaperTest008 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_TWICE_STATE, PORTRAIT).then((data) => { + console.info(`getWallpaperByStateTest011 data : ${data}`); expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest008 err : ${err}`); + console.error(`getWallpaperByStateTest011 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest008 error : ${error}`); + console.error(`getWallpaperByStateTest011 error : ${error}`); expect(null).assertTrue(); done(); } }) + /** - * @tc.name: getCorrespondWallpaperTest009 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 110. + * @tc.name: getWallpaperByStateTest012 + * @tc.desc: Test getWallpaperByState() with normal argc 121. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest009', 0, async function (done) { + it('getWallpaperByStateTest012', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1, PORT).then((data) => { - console.info(`getCorrespondWallpaperTest009 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { + console.info(`getWallpaperByStateTest012 data : ${data}`); expect(data !== undefined && data !== null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest009 err : ${err}`); + console.error(`getWallpaperByStateTest012 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest009 error : ${error}`); + console.error(`getWallpaperByStateTest012 error : ${error}`); expect(null).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest010 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 111. + * @tc.name: getWallpaperByStateTest013 + * @tc.desc: Test getWallpaperByState() lack of argc. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest010', 0, async function (done) { + it('getWallpaperByStateTest013', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1, LAND).then((data) => { - console.info(`getCorrespondWallpaperTest010 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE).then((data) => { + console.error(`getWallpaperByStateTest013 data : ${data}`); + expect(null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest010 err : ${err}`); + console.error(`getWallpaperByStateTest013 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest010 error : ${error}`); - expect(null).assertTrue(); + console.info(`getWallpaperByStateTest013 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + PARAMETER_COUNT).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest011 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 120. + * @tc.name: getWallpaperByStateTest014 + * @tc.desc: Test getWallpaperByState() with invalid wallpaper type. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest011', 0, async function (done) { + it('getWallpaperByStateTest014', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_2, PORT).then((data) => { - console.info(`getCorrespondWallpaperTest011 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + wallpaper.getWallpaperByState(INVALID_WALLPAPER_TYPE, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { + console.error(`getWallpaperByStateTest014 data : ${data}`); + expect(null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest011 err : ${err}`); + console.error(`getWallpaperByStateTest014 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest011 error : ${error}`); - expect(null).assertTrue(); + console.info(`getWallpaperByStateTest014 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest012 - * @tc.desc: Test getCorrespondWallpaper() with normal argc 121. + * @tc.name: getWallpaperByStateTest015 + * @tc.desc: Test getWallpaperByState() with invalid foldstate. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest012', 0, async function (done) { + it('getWallpaperByStateTest015', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_2, LAND).then((data) => { - console.info(`getCorrespondWallpaperTest012 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, INVALID_FOLDSTATE, PORTRAIT).then((data) => { + console.error(`getWallpaperByStateTest015 data : ${data}`); + expect(null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest012 err : ${err}`); + console.error(`getWallpaperByStateTest015 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.error(`getCorrespondWallpaperTest012 error : ${error}`); - expect(null).assertTrue(); + console.info(`getWallpaperByStateTest015 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest013 - * @tc.desc: Test getCorrespondWallpaper() lack of argc. + * @tc.name: getWallpaperByStateTest016 + * @tc.desc: Test getWallpaperByState() with invalid rotatestate. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest013', 0, async function (done) { + it('getWallpaperByStateTest016', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_LOCKSCREEN, UNFOLD_1).then((data) => { - console.error(`getCorrespondWallpaperTest013 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, INVALID_ROTATESTATE).then((data) => { + console.error(`getWallpaperByStateTest016 data : ${data}`); expect(null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest013 err : ${err}`); + console.error(`getWallpaperByStateTest016 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.info(`getCorrespondWallpaperTest013 error : ${error}`); + console.info(`getWallpaperByStateTest016 error : ${error}`); expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + PARAMETER_COUNT).assertTrue(); + expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest014 - * @tc.desc: Test getCorrespondWallpaper() with invalid wallpaper type. + * @tc.name: getWallpaperByStateTest017 + * @tc.desc: Test getWallpaperByState() with invalid wallpaper type. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest014', 0, async function (done) { + it('getWallpaperByStateTest017', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(INVALID_WALLPAPER_TYPE, UNFOLD_2, LAND).then((data) => { - console.error(`getCorrespondWallpaperTest014 data : ${data}`); + wallpaper.getWallpaperByState("INVALID_TYPE", NORMAL, PORTRAIT).then((data) => { + console.error(`getWallpaperByStateTest017 data : ${data}`); expect(null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest014 err : ${err}`); + console.error(`getWallpaperByStateTest017 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.info(`getCorrespondWallpaperTest014 error : ${error}`); + console.info(`getWallpaperByStateTest017 error : ${error}`); expect(error.code === PARAMETER_ERROR).assertTrue(); expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); done(); @@ -1514,23 +1445,23 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: getCorrespondWallpaperTest015 - * @tc.desc: Test getCorrespondWallpaper() with invalid foldstate. + * @tc.name: getWallpaperByStateTest018 + * @tc.desc: Test getWallpaperByState() to get wallpaper. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest015', 0, async function (done) { + it('getWallpaperByStateTest018', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, INVALID_FOLDSTATE, PORT).then((data) => { - console.error(`getCorrespondWallpaperTest015 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, "INVALID_TYPE", PORTRAIT).then((data) => { + console.error(`getWallpaperByStateTest018 data : ${data}`); expect(null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest015 err : ${err}`); + console.error(`getWallpaperByStateTest018 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.info(`getCorrespondWallpaperTest015 error : ${error}`); + console.info(`getWallpaperByStateTest018 error : ${error}`); expect(error.code === PARAMETER_ERROR).assertTrue(); expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); done(); @@ -1538,23 +1469,23 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: getCorrespondWallpaperTest016 - * @tc.desc: Test getCorrespondWallpaper() with invalid rotatestate. + * @tc.name: getWallpaperByStateTest019 + * @tc.desc: Test getWallpaperByState() to get wallpaper. * @tc.type: FUNC */ - it('getCorrespondWallpaperTest016', 0, async function (done) { + it('getWallpaperByStateTest019', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, INVALID_ROTATESTATE).then((data) => { - console.error(`getCorrespondWallpaperTest016 data : ${data}`); + wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, "INVALID_TYPE").then((data) => { + console.error(`getWallpaperByStateTest019 data : ${data}`); expect(null).assertTrue(); done(); }).catch((err) => { - console.error(`getCorrespondWallpaperTest016 err : ${err}`); + console.error(`getWallpaperByStateTest019 err : ${err}`); expect(null).assertTrue(); done(); }); } catch (error) { - console.info(`getCorrespondWallpaperTest016 error : ${error}`); + console.info(`getWallpaperByStateTest019 error : ${error}`); expect(error.code === PARAMETER_ERROR).assertTrue(); expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); done(); @@ -1562,533 +1493,537 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: getCorrespondWallpaperTest017 - * @tc.desc: Test getCorrespondWallpaper() with invalid wallpaper type. - * @tc.type: FUNC + * @tc.name: setImageURIPromiseLockTest001 + * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a + * JPEG or PNG file or the pixel map of a PNG file. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getCorrespondWallpaperTest017', 0, async function (done) { + it('setImageURIPromiseLockTest001', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper("INVALID_TYPE", NORMAL, PORT).then((data) => { - console.error(`getCorrespondWallpaperTest017 data : ${data}`); - expect(null).assertTrue(); + wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN).then(async () => { + expect(true).assertTrue(); done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.error(`getCorrespondWallpaperTest017 err : ${err}`); - expect(null).assertTrue(); + console.info(`setImageURIPromiseLockTest001 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.info(`getCorrespondWallpaperTest017 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); + expect(null).assertFail(); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest018 - * @tc.desc: Test getCorrespondWallpaper() to get wallpaper. - * @tc.type: FUNC + * @tc.name: setImageURICallbackSystemTest002 + * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a + * JPEG or PNG file or the pixel map of a PNG file. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getCorrespondWallpaperTest018', 0, async function (done) { + it('setImageURICallbackSystemTest002', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, "INVALID_TYPE", PORT).then((data) => { - console.error(`getCorrespondWallpaperTest018 data : ${data}`); - expect(null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getCorrespondWallpaperTest018 err : ${err}`); - expect(null).assertTrue(); + wallpaper.setImage(URI, WALLPAPER_SYSTEM, async function (err) { + if (err) { + expect(null).assertFail(); + console.info(`set Image URI CallbackSystemTest002 fail : ${err}`); + } else { + expect(true).assertTrue(); + } done(); + await wallpaper.restore(WALLPAPER_SYSTEM); }); } catch (error) { - console.info(`getCorrespondWallpaperTest018 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); + expect(null).assertFail(); + console.info(`set Image URI CallbackSystemTest002 fail : ${error}`); done(); } }) /** - * @tc.name: getCorrespondWallpaperTest019 - * @tc.desc: Test getCorrespondWallpaper() to get wallpaper. - * @tc.type: FUNC + * @tc.name: setImageURIPromiseSystemTest003 + * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a + * JPEG or PNG file or the pixel map of a PNG file. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getCorrespondWallpaperTest019', 0, async function (done) { + it('setImageURIPromiseSystemTest003', 0, async function (done) { try { - wallpaper.getCorrespondWallpaper(WALLPAPER_SYSTEM, NORMAL, "INVALID_TYPE").then((data) => { - console.error(`getCorrespondWallpaperTest019 data : ${data}`); - expect(null).assertTrue(); + wallpaper.setImage(URI, WALLPAPER_SYSTEM).then(async () => { + expect(true).assertTrue(); done(); + await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - console.error(`getCorrespondWallpaperTest019 err : ${err}`); - expect(null).assertTrue(); + console.info(`setImageURIPromiseSystemTest003 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.info(`getCorrespondWallpaperTest019 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); + expect(null).assertFail(); done(); } }) + /** - * @tc.name: getWallpaperByStateTest001 - * @tc.desc: Test getWallpaperByState() with normal argc 000. - * @tc.type: FUNC + * @tc.name: setImageURICallbackLockTest004 + * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a + * JPEG or PNG file or the pixel map of a PNG file. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest001', 0, async function (done) { + it('setImageURICallbackLockTest004', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, PORTRAIT).then((data) => { - console.info(`getWallpaperByStateTest001 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest001 err : ${err}`); - expect(null).assertTrue(); + wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN, async function (err) { + if (err) { + console.info(`setImageURICallbackLockTest004 err : ${err}`); + expect(null).assertFail(); + } else { + expect(true).assertTrue(); + } done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); }); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); } catch (error) { - console.error(`getWallpaperByStateTest001 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); done(); } }) /** - * @tc.name: getWallpaperByStateTest002 - * @tc.desc: Test getWallpaperByState() with normal argc 001. - * @tc.type: FUNC + * @tc.name: setImageMapPromiseLockTest005 + * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest002', 0, async function (done) { + it('setImageMapPromiseLockTest005', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, LANDSCAPE).then((data) => { - console.info(`getWallpaperByStateTest002 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + let pixelMap = await createTempPixelMap(); + wallpaper.setImage(pixelMap, WALLPAPER_LOCKSCREEN).then(async () => { + expect(true).assertTrue(); done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.error(`getWallpaperByStateTest002 err : ${err}`); - expect(null).assertTrue(); + console.info(`setImageMapPromiseLockTest005 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.error(`getWallpaperByStateTest002 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); done(); } }) /** - * @tc.name: getWallpaperByStateTest003 - * @tc.desc: Test getWallpaperByState() with normal argc 010. - * @tc.type: FUNC + * @tc.name: setImageMapCallbackSystemTest006 + * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest003', 0, async function (done) { + it('setImageMapCallbackSystemTest006', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_ONCE_STATE, PORTRAIT).then((data) => { - console.info(`getWallpaperByStateTest003 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest003 err : ${err}`); - expect(null).assertTrue(); + let pixelMap = await createTempPixelMap(); + wallpaper.setImage(pixelMap, WALLPAPER_SYSTEM, async function (err) { + if (err) { + expect(null).assertFail(); + console.info(`set ImageMap CallbackSystemTest006 fail : ${err}`); + } else { + expect(true).assertTrue(); + } done(); + await wallpaper.restore(WALLPAPER_SYSTEM); }); } catch (error) { - console.error(`getWallpaperByStateTest003 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); + console.info(`set ImageMap CallbackSystemTest006 fail : ${error}`); done(); } }) /** - * @tc.name: getWallpaperByStateTest004 - * @tc.desc: Test getWallpaperByState() with normal argc 011. - * @tc.type: FUNC + * @tc.name: setImageMapPromiseSystemTest007 + * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest004', 0, async function (done) { + it('setImageMapPromiseSystemTest007', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_ONCE_STATE, LANDSCAPE).then((data) => { - console.info(`getWallpaperByStateTest004 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + let pixelMap = await createTempPixelMap(); + wallpaper.setImage(pixelMap, WALLPAPER_SYSTEM).then(async () => { + expect(true).assertTrue(); done(); + await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - console.error(`getWallpaperByStateTest004 err : ${err}`); - expect(null).assertTrue(); + console.info(`setImageMapPromiseSystemTest007 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.error(`getWallpaperByStateTest004 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); done(); } }) /** - * @tc.name: getWallpaperByStateTest005 - * @tc.desc: Test getWallpaperByState() with normal argc 020. - * @tc.type: FUNC + * @tc.name: setImageMapCallbackLockTest008 + * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest005', 0, async function (done) { + it('setImageMapCallbackLockTest008', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_TWICE_STATE, PORTRAIT).then((data) => { - console.info(`getWallpaperByStateTest005 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest005 err : ${err}`); - expect(null).assertTrue(); + let pixelMap = await createTempPixelMap(); + wallpaper.setImage(pixelMap, WALLPAPER_LOCKSCREEN, async function (err) { + if (err) { + expect(null).assertFail(); + console.info(`set ImageMap CallbackLockTest008 fail : ${err}`); + } else { + expect(true).assertTrue(); + } done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); }); } catch (error) { - console.error(`getWallpaperByStateTest005 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); + console.info(`set ImageMap CallbackLockTest008 fail : ${error}`); done(); } }) /** - * @tc.name: getWallpaperByStateTest006 - * @tc.desc: Test getWallpaperByState() with normal argc 021. - * @tc.type: FUNC + * @tc.name: setImageCallbackThrowErrorTest009 + * @tc.desc: Test setImage() throw parameter error. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest006', 0, async function (done) { + it('setImageCallbackThrowErrorTest009', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { - console.info(`getWallpaperByStateTest006 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest006 err : ${err}`); - expect(null).assertTrue(); + wallpaper.setImage(URI, INVALID_WALLPAPER_TYPE, function (err) { + if (err) { + expect(err.code === PARAMETER_ERROR).assertTrue() + console.info(`set Image CallbackThrowErrorTest009 fail : ${err}`); + } else { + expect(null).assertFail(); + } done(); - }); + }) } catch (error) { - console.error(`getWallpaperByStateTest006 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); + console.info(`set Image CallbackThrowErrorTest009 fail : ${error}`); done(); } }) /** - * @tc.name: getWallpaperByStateTest007 - * @tc.desc: Test getWallpaperByState() with normal argc 100. - * @tc.type: FUNC + * @tc.name: setImageCallbackThrowErrorTest010 + * @tc.desc: Test setImage() throw parameter error. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest007', 0, async function (done) { + it('setImageCallbackThrowErrorTest010', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, NORMAL, PORTRAIT).then((data) => { - console.info(`getWallpaperByStateTest007 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest007 err : ${err}`); - expect(null).assertTrue(); + wallpaper.setImage(URI, function (err) { + if (err) { + expect(null).assertFail(); + console.info(`set Image CallbackThrowErrorTest010 fail : ${err}`); + } else { + expect(null).assertFail(); + } done(); - }); + }) } catch (error) { - console.error(`getWallpaperByStateTest007 error : ${error}`); - expect(null).assertTrue(); + expect(error.code === PARAMETER_ERROR).assertTrue() + console.info(`set Image CallbackThrowErrorTest010 fail : ${error}`); done(); } }) + /** - * @tc.name: getWallpaperByStateTest008 - * @tc.desc: Test getWallpaperByState() with normal argc 101. - * @tc.type: FUNC + * @tc.name: setImagePromiseThrowErrorTest011 + * @tc.desc: Test setImage() throw parameter error. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest008', 0, async function (done) { + it('setImagePromiseThrowErrorTest011', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, NORMAL, LANDSCAPE).then((data) => { - console.info(`getWallpaperByStateTest008 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + wallpaper.setImage(URI, INVALID_WALLPAPER_TYPE).then(() => { + expect(null).assertFail(); done(); }).catch((err) => { - console.error(`getWallpaperByStateTest008 err : ${err}`); - expect(null).assertTrue(); + console.info(`setImagePromiseThrowErrorTest011 err : ${err}`); + expect(err.code === PARAMETER_ERROR).assertTrue() done(); }); } catch (error) { - console.error(`getWallpaperByStateTest008 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); done(); } }) + /** - * @tc.name: getWallpaperByStateTest009 - * @tc.desc: Test getWallpaperByState() with normal argc 110. - * @tc.type: FUNC + * @tc.name: setImagePromiseThrowErrorTest012 + * @tc.desc: Test setImage() throw parameter error. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest009', 0, async function (done) { + it('setImagePromiseThrowErrorTest012', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE, PORTRAIT).then((data) => { - console.info(`getWallpaperByStateTest009 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + wallpaper.setImage().then(() => { + expect(null).assertFail(); done(); }).catch((err) => { - console.error(`getWallpaperByStateTest009 err : ${err}`); - expect(null).assertTrue(); + console.info(`setImagePromiseThrowErrorTest012 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.error(`getWallpaperByStateTest009 error : ${error}`); - expect(null).assertTrue(); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } }) /** - * @tc.name: getWallpaperByStateTest010 - * @tc.desc: Test getWallpaperByState() with normal argc 111. - * @tc.type: FUNC - */ - it('getWallpaperByStateTest010', 0, async function (done) { + * @tc.name: setWallpaperMapPromiseLockTest001 + * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG + */ + it('setWallpaperMapPromiseLockTest001', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE, LANDSCAPE).then((data) => { - console.info(`getWallpaperByStateTest010 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + let pixelMap = await createTempPixelMap(); + wallpaper.setWallpaper(pixelMap, WALLPAPER_LOCKSCREEN).then(async () => { + expect(true).assertTrue(); done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.error(`getWallpaperByStateTest010 err : ${err}`); - expect(null).assertTrue(); + console.info(`setWallpaperMapPromiseLockTest001 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.error(`getWallpaperByStateTest010 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); done(); } }) /** - * @tc.name: getWallpaperByStateTest011 - * @tc.desc: Test getWallpaperByState() with normal argc 120. - * @tc.type: FUNC + * @tc.name: setWallpaperMapCallbackSystemTest002 + * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest011', 0, async function (done) { + it('setWallpaperMapCallbackSystemTest002', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_TWICE_STATE, PORTRAIT).then((data) => { - console.info(`getWallpaperByStateTest011 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest011 err : ${err}`); - expect(null).assertTrue(); + let pixelMap = await createTempPixelMap(); + wallpaper.setWallpaper(pixelMap, WALLPAPER_SYSTEM, async function (err) { + if (err) { + expect(null).assertFail(); + console.info(`set Wallpaper Map CallbackSystemTest002 fail : ${err}`); + } else { + expect(true).assertTrue(); + } done(); + await wallpaper.restore(WALLPAPER_SYSTEM); }); } catch (error) { - console.error(`getWallpaperByStateTest011 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); + console.info(`set Wallpaper Map CallbackSystemTest002 fail : ${error}`); done(); } }) /** - * @tc.name: getWallpaperByStateTest012 - * @tc.desc: Test getWallpaperByState() with normal argc 121. - * @tc.type: FUNC + * @tc.name: setWallpaperMapPromiseSystemTest003 + * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest012', 0, async function (done) { + it('setWallpaperMapPromiseSystemTest003', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { - console.info(`getWallpaperByStateTest012 data : ${data}`); - expect(data !== undefined && data !== null).assertTrue(); + let pixelMap = await createTempPixelMap(); + wallpaper.setWallpaper(pixelMap, WALLPAPER_SYSTEM).then(async () => { + expect(true).assertTrue(); done(); + await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - console.error(`getWallpaperByStateTest012 err : ${err}`); - expect(null).assertTrue(); + console.info(`setWallpaperMapPromiseSystemTest003 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.error(`getWallpaperByStateTest012 error : ${error}`); - expect(null).assertTrue(); + expect(null).assertFail(); done(); } }) /** - * @tc.name: getWallpaperByStateTest013 - * @tc.desc: Test getWallpaperByState() lack of argc. - * @tc.type: FUNC + * @tc.name: setWallpaperMapCallbackLockTest004 + * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest013', 0, async function (done) { + it('setWallpaperMapCallbackLockTest004', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_LOCKSCREEN, UNFOLD_ONCE_STATE).then((data) => { - console.error(`getWallpaperByStateTest013 data : ${data}`); - expect(null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest013 err : ${err}`); - expect(null).assertTrue(); + let pixelMap = await createTempPixelMap(); + wallpaper.setWallpaper(pixelMap, WALLPAPER_LOCKSCREEN, async function (err) { + if (err) { + expect(null).assertFail(); + console.info(`set Wallpaper Map CallbackLockTest004 fail : ${err}`); + } else { + expect(true).assertTrue(); + } done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); }); } catch (error) { - console.info(`getWallpaperByStateTest013 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + PARAMETER_COUNT).assertTrue(); + expect(null).assertFail(); + console.info(`set Wallpaper Map CallbackLockTest004 fail : ${error}`); done(); } }) + /** - * @tc.name: getWallpaperByStateTest014 - * @tc.desc: Test getWallpaperByState() with invalid wallpaper type. - * @tc.type: FUNC + * @tc.name: getPixelMapPromiseLockTest001 + * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest014', 0, async function (done) { + it('getPixelMapPromiseLockTest001', 0, async function (done) { try { - wallpaper.getWallpaperByState(INVALID_WALLPAPER_TYPE, UNFOLD_TWICE_STATE, LANDSCAPE).then((data) => { - console.error(`getWallpaperByStateTest014 data : ${data}`); - expect(null).assertTrue(); + wallpaper.getPixelMap(WALLPAPER_LOCKSCREEN).then((data) => { + if (data !== undefined) { + expect(true).assertTrue(); + } done(); }).catch((err) => { - console.error(`getWallpaperByStateTest014 err : ${err}`); - expect(null).assertTrue(); + console.info(`getPixelMapPromiseLockTest001 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.info(`getWallpaperByStateTest014 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); + expect(null).assertFail(); done(); } }) /** - * @tc.name: getWallpaperByStateTest015 - * @tc.desc: Test getWallpaperByState() with invalid foldstate. - * @tc.type: FUNC + * @tc.name: getPixelMapCallbackSystemTest002 + * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest015', 0, async function (done) { + it('getPixelMapCallbackSystemTest002', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, INVALID_FOLDSTATE, PORTRAIT).then((data) => { - console.error(`getWallpaperByStateTest015 data : ${data}`); - expect(null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest015 err : ${err}`); - expect(null).assertTrue(); + wallpaper.getPixelMap(WALLPAPER_SYSTEM, function (err, data) { + if (err) { + expect(null).assertFail(); + console.info(`get Pixel Map CallbackSystemTest002 fail : ${err}`); + } else { + if (data !== undefined) { + expect(true).assertTrue(); + } + } done(); }); } catch (error) { - console.info(`getWallpaperByStateTest015 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); + expect(null).assertFail(); + console.info(`get Pixel MapCallbackSystemTest002 fail : ${error}`); done(); } }) /** - * @tc.name: getWallpaperByStateTest016 - * @tc.desc: Test getWallpaperByState() with invalid rotatestate. - * @tc.type: FUNC + * @tc.name: getPixelMapPromiseSystemTest003 + * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest016', 0, async function (done) { + it('getPixelMapPromiseSystemTest003', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, INVALID_ROTATESTATE).then((data) => { - console.error(`getWallpaperByStateTest016 data : ${data}`); - expect(null).assertTrue(); + wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => { + if (data !== undefined) { + expect(true).assertTrue(); + } done(); }).catch((err) => { - console.error(`getWallpaperByStateTest016 err : ${err}`); - expect(null).assertTrue(); + console.info(`getPixelMapPromiseSystemTest003 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { - console.info(`getWallpaperByStateTest016 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); + expect(null).assertFail(); done(); } }) /** - * @tc.name: getWallpaperByStateTest017 - * @tc.desc: Test getWallpaperByState() with invalid wallpaper type. - * @tc.type: FUNC + * @tc.name: getPixelMapCallbackLockTest004 + * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest017', 0, async function (done) { + it('getPixelMapCallbackLockTest004', 0, async function (done) { try { - wallpaper.getWallpaperByState("INVALID_TYPE", NORMAL, PORTRAIT).then((data) => { - console.error(`getWallpaperByStateTest017 data : ${data}`); - expect(null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest017 err : ${err}`); - expect(null).assertTrue(); + wallpaper.getPixelMap(WALLPAPER_LOCKSCREEN, function (err, data) { + if (err) { + expect(null).assertFail(); + console.info(`get Pixel Map CallbackLockTest004 fail : ${err}`); + } else { + if (data !== undefined) { + expect(true).assertTrue(); + } + } done(); }); } catch (error) { - console.info(`getWallpaperByStateTest017 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + WALLPAPERTYPE_PARAMETER_TYPE).assertTrue(); + expect(null).assertFail(); + console.info(`get Pixel Map CallbackLockTest004 fail : ${error}`); done(); } }) /** - * @tc.name: getWallpaperByStateTest018 - * @tc.desc: Test getWallpaperByState() to get wallpaper. - * @tc.type: FUNC + * @tc.name: resetCallbackSystemTest001 + * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest018', 0, async function (done) { + it('resetCallbackSystemTest001', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, "INVALID_TYPE", PORTRAIT).then((data) => { - console.error(`getWallpaperByStateTest018 data : ${data}`); - expect(null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest018 err : ${err}`); - expect(null).assertTrue(); + wallpaper.reset(WALLPAPER_SYSTEM, function (err) { + if (err) { + expect(null).assertFail() + console.info(`reset CallbackSystemTest001 fail : ${err}`); + } else { + expect(true).assertTrue(); + } done(); - }); + }) + } catch (error) { - console.info(`getWallpaperByStateTest018 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + FOLDSTATE_PARAMETER_TYPE).assertTrue(); + expect(null).assertFail(); + console.info(`reset CallbackSystemTest001 fail : ${error}`); done(); } + }) /** - * @tc.name: getWallpaperByStateTest019 - * @tc.desc: Test getWallpaperByState() to get wallpaper. - * @tc.type: FUNC + * @tc.name: resetPromiseSystemTest002 + * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.type: FUNC test + * @tc.require: issueI5UHRG */ - it('getWallpaperByStateTest019', 0, async function (done) { + it('resetPromiseSystemTest002', 0, async function (done) { try { - wallpaper.getWallpaperByState(WALLPAPER_SYSTEM, NORMAL, "INVALID_TYPE").then((data) => { - console.error(`getWallpaperByStateTest019 data : ${data}`); - expect(null).assertTrue(); - done(); - }).catch((err) => { - console.error(`getWallpaperByStateTest019 err : ${err}`); - expect(null).assertTrue(); - done(); - }); - } catch (error) { - console.info(`getWallpaperByStateTest019 error : ${error}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); - expect(error.message === PARAMETER_ERROR_MESSAGE + ROTATESTATE_PARAMETER_TYPE).assertTrue(); - done(); - } - }) - - /** - * @tc.name: setImageURIPromiseLockTest001 - * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a - * JPEG or PNG file or the pixel map of a PNG file. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG - */ - it('setImageURIPromiseLockTest001', 0, async function (done) { - try { - wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN).then(async () => { + wallpaper.reset(WALLPAPER_SYSTEM).then(() => { expect(true).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.info(`setImageURIPromiseLockTest001 err : ${err}`); + console.info(`resetPromiseSystemTest002 err : ${err}`); expect(null).assertFail(); done(); }); @@ -2099,46 +2034,42 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setImageURICallbackSystemTest002 - * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a - * JPEG or PNG file or the pixel map of a PNG file. + * @tc.name: resetCallbackLockTest003 + * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageURICallbackSystemTest002', 0, async function (done) { + it('resetCallbackLockTest003', 0, async function (done) { try { - wallpaper.setImage(URI, WALLPAPER_SYSTEM, async function (err) { + wallpaper.reset(WALLPAPER_LOCKSCREEN, function (err) { if (err) { expect(null).assertFail(); - console.info(`set Image URI CallbackSystemTest002 fail : ${err}`); + console.info(`reset CallbackLockTest003 fail : ${err}`); } else { expect(true).assertTrue(); } done(); - await wallpaper.restore(WALLPAPER_SYSTEM); - }); + }) } catch (error) { expect(null).assertFail(); - console.info(`set Image URI CallbackSystemTest002 fail : ${error}`); + console.info(`reset CallbackLockTest003 fail : ${error}`); done(); } }) /** - * @tc.name: setImageURIPromiseSystemTest003 - * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a - * JPEG or PNG file or the pixel map of a PNG file. + * @tc.name: resetPromiseLockTest004 + * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageURIPromiseSystemTest003', 0, async function (done) { + it('resetPromiseLockTest004', 0, async function (done) { try { - wallpaper.setImage(URI, WALLPAPER_SYSTEM).then(async () => { + wallpaper.reset(WALLPAPER_LOCKSCREEN).then(() => { expect(true).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - console.info(`setImageURIPromiseSystemTest003 err : ${err}`); + console.info(`resetPromiseLockTest004 err : ${err}`); expect(null).assertFail(); done(); }); @@ -2149,25 +2080,23 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setImageURICallbackLockTest004 - * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on the uri path from a - * JPEG or PNG file or the pixel map of a PNG file. + * @tc.name: isOperationAllowedCallbackTest001 + * @tc.desc: Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageURICallbackLockTest004', 0, async function (done) { + it('isOperationAllowedCallbackTest001', 0, async function (done) { try { - wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN, async function (err) { + wallpaper.isOperationAllowed(function (err, data) { if (err) { - console.info(`setImageURICallbackLockTest004 err : ${err}`); + console.info(`isOperationAllowedCallbackTest001 err : ${err}`); expect(null).assertFail(); } else { + console.info(`isOperationAllowedCallbackTest001 data : ${data}`); expect(true).assertTrue(); } done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); - }); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); + }) } catch (error) { expect(null).assertFail(); done(); @@ -2175,20 +2104,19 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setImageMapPromiseLockTest005 - * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. + * @tc.name: isOperationAllowedPromiseTest002 + * @tc.desc: Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageMapPromiseLockTest005', 0, async function (done) { + it('isOperationAllowedPromiseTest002', 0, async function (done) { try { - let pixelMap = await createTempPixelMap(); - wallpaper.setImage(pixelMap, WALLPAPER_LOCKSCREEN).then(async () => { + wallpaper.isOperationAllowed().then((data) => { + console.info(`isOperationAllowedPromiseTest002 data : ${data}`); expect(true).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.info(`setImageMapPromiseLockTest005 err : ${err}`); + console.info(`isOperationAllowedPromiseTest002 err : ${err}`); expect(null).assertFail(); done(); }); @@ -2199,46 +2127,45 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setImageMapCallbackSystemTest006 - * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. + * @tc.name: isChangePermittedCallbackTest001 + * @tc.desc: Test isChangePermitted() to checks whether to allow the application to change the + * wallpaper for the current user. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageMapCallbackSystemTest006', 0, async function (done) { + it('isChangePermittedCallbackTest001', 0, async function (done) { try { - let pixelMap = await createTempPixelMap(); - wallpaper.setImage(pixelMap, WALLPAPER_SYSTEM, async function (err) { + wallpaper.isChangePermitted(function (err, data) { if (err) { + console.info(`isChangePermittedCallbackTest001 err : ${err}`); expect(null).assertFail(); - console.info(`set ImageMap CallbackSystemTest006 fail : ${err}`); } else { + console.info(`isChangePermittedCallbackTest001 data : ${data}`); expect(true).assertTrue(); } done(); - await wallpaper.restore(WALLPAPER_SYSTEM); - }); + }) } catch (error) { expect(null).assertFail(); - console.info(`set ImageMap CallbackSystemTest006 fail : ${error}`); done(); } }) /** - * @tc.name: setImageMapPromiseSystemTest007 - * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. + * @tc.name: isChangePermittedPromiseTest002 + * @tc.desc: Test isChangePermitted() to checks whether to allow the application to change the + * wallpaper for the current user. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageMapPromiseSystemTest007', 0, async function (done) { + it('isChangePermittedPromiseTest002', 0, async function (done) { try { - let pixelMap = await createTempPixelMap(); - wallpaper.setImage(pixelMap, WALLPAPER_SYSTEM).then(async () => { + wallpaper.isChangePermitted().then((data) => { + console.info(`isChangePermittedPromiseTest002 data : ${data}`); expect(true).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - console.info(`setImageMapPromiseSystemTest007 err : ${err}`); + console.info(`isChangePermittedPromiseTest002 err : ${err}`); expect(null).assertFail(); done(); }); @@ -2249,93 +2176,91 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setImageMapCallbackLockTest008 - * @tc.desc: Test setImage() to sets a wallpaper of the specified type based on Map. + * @tc.name: getMinWidthCallbackTest001 + * @tc.desc: Test getMinWidth() to gets the minWidth of the WALLPAPER_SYSTEM of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageMapCallbackLockTest008', 0, async function (done) { + it('getMinWidthCallbackTest001', 0, async function (done) { try { - let pixelMap = await createTempPixelMap(); - wallpaper.setImage(pixelMap, WALLPAPER_LOCKSCREEN, async function (err) { + wallpaper.getMinWidth(function (err, data) { if (err) { + console.info(`getMinWidthCallbackTest001 err : ${err}`); expect(null).assertFail(); - console.info(`set ImageMap CallbackLockTest008 fail : ${err}`); } else { + console.info(`getMinWidthCallbackTest001 data : ${data}`); expect(true).assertTrue(); } done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); - }); + }) } catch (error) { expect(null).assertFail(); - console.info(`set ImageMap CallbackLockTest008 fail : ${error}`); done(); } }) /** - * @tc.name: setImageCallbackThrowErrorTest009 - * @tc.desc: Test setImage() throw parameter error. + * @tc.name: getMinWidthPromiseTest002 + * @tc.desc: Test getMinWidth() to gets the minWidth of the WALLPAPER_SYSTEM of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageCallbackThrowErrorTest009', 0, async function (done) { + it('getMinWidthPromiseTest002', 0, async function (done) { try { - wallpaper.setImage(URI, INVALID_WALLPAPER_TYPE, function (err) { - if (err) { - expect(err.code === PARAMETER_ERROR).assertTrue() - console.info(`set Image CallbackThrowErrorTest009 fail : ${err}`); - } else { - expect(null).assertFail(); - } + wallpaper.getMinWidth().then((data) => { + console.info(`getMinWidthPromiseTest002 data : ${data}`); + expect(true).assertTrue(); done(); - }) + }).catch((err) => { + console.info(`getMinWidthPromiseTest002 err : ${err}`); + expect(null).assertFail(); + done(); + }); } catch (error) { expect(null).assertFail(); - console.info(`set Image CallbackThrowErrorTest009 fail : ${error}`); done(); } }) /** - * @tc.name: setImageCallbackThrowErrorTest010 - * @tc.desc: Test setImage() throw parameter error. + * @tc.name: getMinHeightCallbackTest001 + * @tc.desc: Test getMinHeight() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImageCallbackThrowErrorTest010', 0, async function (done) { + it('getMinHeightCallbackTest001', 0, async function (done) { try { - wallpaper.setImage(URI, function (err) { + wallpaper.getMinHeight(function (err, data) { if (err) { + console.info(`getMinHeightCallbackTest001 err : ${err}`); expect(null).assertFail(); - console.info(`set Image CallbackThrowErrorTest010 fail : ${err}`); } else { - expect(null).assertFail(); + console.info(`getMinHeightCallbackTest001 data : ${data}`); + expect(true).assertTrue(); } done(); }) } catch (error) { - expect(error.code === PARAMETER_ERROR).assertTrue() - console.info(`set Image CallbackThrowErrorTest010 fail : ${error}`); + expect(null).assertFail(); done(); } }) /** - * @tc.name: setImagePromiseThrowErrorTest011 - * @tc.desc: Test setImage() throw parameter error. + * @tc.name: getMinHeightPromiseTest002 + * @tc.desc: Test getMinHeight() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImagePromiseThrowErrorTest011', 0, async function (done) { + it('getMinHeightPromiseTest002', 0, async function (done) { try { - wallpaper.setImage(URI, INVALID_WALLPAPER_TYPE).then(() => { - expect(null).assertFail(); + wallpaper.getMinHeight().then((data) => { + console.info(`getMinHeightPromiseTest002 data : ${data}`); + expect(true).assertTrue(); done(); }).catch((err) => { - console.info(`setImagePromiseThrowErrorTest011 err : ${err}`); - expect(err.code === PARAMETER_ERROR).assertTrue() + console.info(`getMinHeightPromiseTest002 err : ${err}`); + expect(null).assertFail(); done(); }); } catch (error) { @@ -2345,42 +2270,43 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setImagePromiseThrowErrorTest012 - * @tc.desc: Test setImage() throw parameter error. + * @tc.name: getFileCallbackTest001 + * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setImagePromiseThrowErrorTest012', 0, async function (done) { + it('getFileCallbackTest001', 0, async function (done) { try { - wallpaper.setImage().then(() => { - expect(null).assertFail(); - done(); - }).catch((err) => { - console.info(`setImagePromiseThrowErrorTest012 err : ${err}`); - expect(null).assertFail(); + wallpaper.getFile(WALLPAPER_SYSTEM, function (err, data) { + if (err) { + console.info(`getFileCallbackTest001 err : ${err}`); + expect(null).assertFail(); + } else { + console.info(`getFileCallbackTest001 data : ${data}`); + expect(true).assertTrue(); + } done(); - }); + }) } catch (error) { - expect(error.code === PARAMETER_ERROR).assertTrue() + expect(null).assertFail(); done(); } }) /** - * @tc.name: setWallpaperMapPromiseLockTest001 - * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. + * @tc.name: getFilePromiseTest002 + * @tc.desc: Test getFile() to get the File of the wallpaper of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setWallpaperMapPromiseLockTest001', 0, async function (done) { + it('getFilePromiseTest002', 0, async function (done) { try { - let pixelMap = await createTempPixelMap(); - wallpaper.setWallpaper(pixelMap, WALLPAPER_LOCKSCREEN).then(async () => { + wallpaper.getFile(WALLPAPER_SYSTEM).then((data) => { + console.info(`getFilePromiseTest002 data : ${data}`); expect(true).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.info(`setWallpaperMapPromiseLockTest001 err : ${err}`); + console.info(`getFilePromiseTest002 err : ${err}`); expect(null).assertFail(); done(); }); @@ -2391,46 +2317,43 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setWallpaperMapCallbackSystemTest002 - * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. + * @tc.name: getFileCallbackTest003 + * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setWallpaperMapCallbackSystemTest002', 0, async function (done) { + it('getFileCallbackTest003', 0, async function (done) { try { - let pixelMap = await createTempPixelMap(); - wallpaper.setWallpaper(pixelMap, WALLPAPER_SYSTEM, async function (err) { + wallpaper.getFile(WALLPAPER_LOCKSCREEN, function (err, data) { if (err) { + console.info(`getFileCallbackTest003 err : ${err}`); expect(null).assertFail(); - console.info(`set Wallpaper Map CallbackSystemTest002 fail : ${err}`); } else { + console.info(`getFileCallbackTest003 data : ${data}`); expect(true).assertTrue(); } done(); - await wallpaper.restore(WALLPAPER_SYSTEM); - }); + }) } catch (error) { expect(null).assertFail(); - console.info(`set Wallpaper Map CallbackSystemTest002 fail : ${error}`); done(); } }) /** - * @tc.name: setWallpaperMapPromiseSystemTest003 - * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. + * @tc.name: getFilePromiseTest004 + * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setWallpaperMapPromiseSystemTest003', 0, async function (done) { + it('getFilePromiseTest004', 0, async function (done) { try { - let pixelMap = await createTempPixelMap(); - wallpaper.setWallpaper(pixelMap, WALLPAPER_SYSTEM).then(async () => { + wallpaper.getFile(WALLPAPER_LOCKSCREEN).then((data) => { + console.info(`getFilePromiseTest004 data : ${data}`); expect(true).assertTrue(); done(); - await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - console.info(`setWallpaperMapPromiseSystemTest003 err : ${err}`); + console.info(`getFilePromiseTest004 err : ${err}`); expect(null).assertFail(); done(); }); @@ -2441,47 +2364,43 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: setWallpaperMapCallbackLockTest004 - * @tc.desc: Test setWallpaper() to sets a wallpaper of the specified type based on Map. + * @tc.name: getIdCallbackTest001 + * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('setWallpaperMapCallbackLockTest004', 0, async function (done) { + it('getIdCallbackTest001', 0, async function (done) { try { - let pixelMap = await createTempPixelMap(); - wallpaper.setWallpaper(pixelMap, WALLPAPER_LOCKSCREEN, async function (err) { + wallpaper.getId(WALLPAPER_SYSTEM, function (err, data) { if (err) { + console.info(`getIdCallbackTest001 err : ${err}`); expect(null).assertFail(); - console.info(`set Wallpaper Map CallbackLockTest004 fail : ${err}`); } else { + console.info(`getIdCallbackTest001 data ${data}`); expect(true).assertTrue(); } done(); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); - }); + }) } catch (error) { expect(null).assertFail(); - console.info(`set Wallpaper Map CallbackLockTest004 fail : ${error}`); done(); } }) - /** - * @tc.name: getPixelMapPromiseLockTest001 - * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. + * @tc.name: getIdPromiseTest002 + * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getPixelMapPromiseLockTest001', 0, async function (done) { + it('getIdPromiseTest002', 0, async function (done) { try { - wallpaper.getPixelMap(WALLPAPER_LOCKSCREEN).then((data) => { - if (data !== undefined) { - expect(true).assertTrue(); - } + wallpaper.getId(WALLPAPER_SYSTEM).then((data) => { + console.info(`getIdPromiseTest002 data ${data}`); + expect(true).assertTrue(); done(); }).catch((err) => { - console.info(`getPixelMapPromiseLockTest001 err : ${err}`); + console.info(`getIdPromiseTest002 err ${err}`); expect(null).assertFail(); done(); }); @@ -2492,46 +2411,43 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: getPixelMapCallbackSystemTest002 - * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. + * @tc.name: getIdCallbackTest003 + * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getPixelMapCallbackSystemTest002', 0, async function (done) { + it('getIdCallbackTest003', 0, async function (done) { try { - wallpaper.getPixelMap(WALLPAPER_SYSTEM, function (err, data) { + wallpaper.getId(WALLPAPER_LOCKSCREEN, function (err, data) { if (err) { + console.info(`getIdCallbackTest003 err ${err}`); expect(null).assertFail(); - console.info(`get Pixel Map CallbackSystemTest002 fail : ${err}`); } else { - if (data !== undefined) { - expect(true).assertTrue(); - } + console.info(`getIdCallbackTest003 data ${data}`); + expect(true).assertTrue(); } done(); - }); + }) } catch (error) { expect(null).assertFail(); - console.info(`get Pixel MapCallbackSystemTest002 fail : ${error}`); done(); } }) /** - * @tc.name: getPixelMapPromiseSystemTest003 - * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. + * @tc.name: getIdPromiseTest004 + * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getPixelMapPromiseSystemTest003', 0, async function (done) { + it('getIdPromiseTest004', 0, async function (done) { try { - wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => { - if (data !== undefined) { - expect(true).assertTrue(); - } + wallpaper.getId(WALLPAPER_LOCKSCREEN).then((data) => { + console.info(`getIdCallbackTest003 data ${data}`); + expect(true).assertTrue(); done(); }).catch((err) => { - console.info(`getPixelMapPromiseSystemTest003 err : ${err}`); + console.info(`getIdCallbackTest003 err ${err}`); expect(null).assertFail(); done(); }); @@ -2542,70 +2458,43 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: getPixelMapCallbackLockTest004 - * @tc.desc: Test getPixelMap() to gets a PixelMap of the specified type. + * @tc.name: getColorsCallbackTest001 + * @tc.desc: Test getColors() to gets WALLPAPER_SYSTEM Colors. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getPixelMapCallbackLockTest004', 0, async function (done) { + it('getColorsCallbackTest001', 0, async function (done) { try { - wallpaper.getPixelMap(WALLPAPER_LOCKSCREEN, function (err, data) { + wallpaper.getColors(WALLPAPER_SYSTEM, function (err, data) { if (err) { + console.info(`getColorsCallbackTest001 err ${err}`); expect(null).assertFail(); - console.info(`get Pixel Map CallbackLockTest004 fail : ${err}`); - } else { - if (data !== undefined) { - expect(true).assertTrue(); - } - } - done(); - }); - } catch (error) { - expect(null).assertFail(); - console.info(`get Pixel Map CallbackLockTest004 fail : ${error}`); - done(); - } - }) - - /** - * @tc.name: resetCallbackSystemTest001 - * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. - * @tc.type: FUNC test - * @tc.require: issueI5UHRG - */ - it('resetCallbackSystemTest001', 0, async function (done) { - try { - wallpaper.reset(WALLPAPER_SYSTEM, function (err) { - if (err) { - expect(null).assertFail() - console.info(`reset CallbackSystemTest001 fail : ${err}`); } else { + console.info(`getColorsCallbackTest001 data ${data}`); expect(true).assertTrue(); } done(); }) - } catch (error) { expect(null).assertFail(); - console.info(`reset CallbackSystemTest001 fail : ${error}`); done(); } - }) /** - * @tc.name: resetPromiseSystemTest002 - * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.name: getColorsPromiseTest002 + * @tc.desc: Test getColors() to gets WALLPAPER_SYSTEM Colors. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('resetPromiseSystemTest002', 0, async function (done) { + it('getColorsPromiseTest002', 0, async function (done) { try { - wallpaper.reset(WALLPAPER_SYSTEM).then(() => { + wallpaper.getColors(WALLPAPER_SYSTEM).then((data) => { + console.info(`getColorsPromiseTest002 data ${data}`); expect(true).assertTrue(); done(); }).catch((err) => { - console.info(`resetPromiseSystemTest002 err : ${err}`); + console.info(`getColorsPromiseTest002 err ${err}`); expect(null).assertFail(); done(); }); @@ -2616,42 +2505,43 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: resetCallbackLockTest003 - * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.name: getColorsCallbackTest003 + * @tc.desc: Test getColors() to gets WALLPAPER_LOCKSCREEN Colors. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('resetCallbackLockTest003', 0, async function (done) { + it('getColorsCallbackTest003', 0, async function (done) { try { - wallpaper.reset(WALLPAPER_LOCKSCREEN, function (err) { + wallpaper.getColors(WALLPAPER_LOCKSCREEN, function (err, data) { if (err) { + console.info(`getColorsCallbackTest003 err ${err}`); expect(null).assertFail(); - console.info(`reset CallbackLockTest003 fail : ${err}`); } else { + console.info(`getColorsCallbackTest003 data ${data}`); expect(true).assertTrue(); } done(); }) } catch (error) { expect(null).assertFail(); - console.info(`reset CallbackLockTest003 fail : ${error}`); done(); } }) /** - * @tc.name: resetPromiseLockTest004 - * @tc.desc: Test reset() to removes a wallpaper of the specified type and restores the default one. + * @tc.name: getColorsPromiseTest004 + * @tc.desc: Test getColors() to gets WALLPAPER_LOCKSCREEN Colors. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('resetPromiseLockTest004', 0, async function (done) { + it('getColorsPromiseTest004', 0, async function (done) { try { - wallpaper.reset(WALLPAPER_LOCKSCREEN).then(() => { + wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((data) => { + console.info(`getColorsPromiseTest004 data ${data}`); expect(true).assertTrue(); done(); }).catch((err) => { - console.info(`resetPromiseLockTest004 err : ${err}`); + console.info(`getColorsPromiseTest004 err ${err}`); expect(null).assertFail(); done(); }); @@ -2662,860 +2552,970 @@ describe('WallpaperJSTest', function () { }) /** - * @tc.name: isOperationAllowedCallbackTest001 - * @tc.desc: Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. + * @tc.name: onCallbackTest001 + * @tc.desc: Test on_colorChange to registers a listener for wallpaper color changes to + * receive notifications about the changes. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('isOperationAllowedCallbackTest001', 0, async function (done) { + it('onCallbackTest001', 0, async function (done) { + await wallpaper.restore(WALLPAPER_LOCKSCREEN); try { - wallpaper.isOperationAllowed(function (err, data) { - if (err) { - console.info(`isOperationAllowedCallbackTest001 err : ${err}`); - expect(null).assertFail(); - } else { - console.info(`isOperationAllowedCallbackTest001 data : ${data}`); - expect(true).assertTrue(); - } + wallpaper.on('colorChange', (colors, wallpaperType) => { + console.info(`onCallbackTest001 colors : ${colors}`); + expect(colors != null).assertTrue(); + expect(wallpaperType != null).assertTrue(); + wallpaper.off('colorChange'); done(); }) } catch (error) { + console.info(`onCallbackTest001 error : ${error.message}`); expect(null).assertFail(); done(); } + await wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); }) /** - * @tc.name: isOperationAllowedPromiseTest002 - * @tc.desc: Test isOperationAllowed() to checks whether a user is allowed to set wallpapers. + * @tc.name: onCallbackTest002 + * @tc.desc: Test on_wallpaperChange to registers a listener for wallpaper changes to + * receive notifications about the changes. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('isOperationAllowedPromiseTest002', 0, async function (done) { + it('onCallbackTest002', 0, async function (done) { + await wallpaper.restore(WALLPAPER_SYSTEM); try { - wallpaper.isOperationAllowed().then((data) => { - console.info(`isOperationAllowedPromiseTest002 data : ${data}`); - expect(true).assertTrue(); - done(); - }).catch((err) => { - console.info(`isOperationAllowedPromiseTest002 err : ${err}`); - expect(null).assertFail(); + wallpaper.on('wallpaperChange', (wallpaperType, resourceType) => { + expect(wallpaperType != null).assertTrue(); + expect(resourceType != null).assertTrue(); + wallpaper.off('wallpaperChange'); done(); - }); + }) } catch (error) { + console.info(`onCallbackTest002 error : ${error.message}`); expect(null).assertFail(); done(); } + await wallpaper.setImage(URI, WALLPAPER_SYSTEM); + await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: isChangePermittedCallbackTest001 - * @tc.desc: Test isChangePermitted() to checks whether to allow the application to change the - * wallpaper for the current user. + * @tc.name: onCallbackTest003 + * @tc.desc: Test to register not exist event * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('isChangePermittedCallbackTest001', 0, async function (done) { + it('onCallbackTest003', 0, async function (done) { + await wallpaper.restore(WALLPAPER_SYSTEM); try { - wallpaper.isChangePermitted(function (err, data) { - if (err) { - console.info(`isChangePermittedCallbackTest001 err : ${err}`); - expect(null).assertFail(); - } else { - console.info(`isChangePermittedCallbackTest001 data : ${data}`); - expect(true).assertTrue(); - } + wallpaper.on('wallpaperChangeX', (wallpaperType, resourceType) => { + expect(null).assertFail(); done(); }) } catch (error) { - expect(null).assertFail(); + console.info(`onCallbackTest003 error : ${error.message}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); done(); } + await wallpaper.setImage(URI, WALLPAPER_SYSTEM); + await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: isChangePermittedPromiseTest002 - * @tc.desc: Test isChangePermitted() to checks whether to allow the application to change the - * wallpaper for the current user. + * @tc.name: onCallbackTest004 + * @tc.desc: Test on_wallpaperChange to registers a listener for wallpaper changes to + * receive notifications about the changes. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI7AAMU */ - it('isChangePermittedPromiseTest002', 0, async function (done) { + it('onCallbackTest004', 0, async function (done) { + await wallpaper.restore(WALLPAPER_SYSTEM); try { - wallpaper.isChangePermitted().then((data) => { - console.info(`isChangePermittedPromiseTest002 data : ${data}`); - expect(true).assertTrue(); + wallpaper.on('wallpaperChange', async (wallpaperType, resourceType, uri) => { + expect(wallpaperType != null).assertTrue(); + expect(resourceType != null).assertTrue(); + expect(uri !== "").assertTrue(); + wallpaper.off('wallpaperChange'); done(); - }).catch((err) => { - console.info(`isChangePermittedPromiseTest002 err : ${err}`); - expect(null).assertFail(); + await wallpaper.restore(WALLPAPER_SYSTEM); + }) + if (isBundleNameExists()) { + await wallpaper.setCustomWallpaper(URI, WALLPAPER_SYSTEM); + } else { + wallpaper.off('wallpaperChange'); + expect(true).assertTrue(); done(); - }); + } } catch (error) { + console.info(`onCallbackTest004 error : ${error.message}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getMinWidthCallbackTest001 - * @tc.desc: Test getMinWidth() to gets the minWidth of the WALLPAPER_SYSTEM of the specified type. + * @tc.name: offCallbackTest001 + * @tc.desc: Test off_colorChange to log off a listener for wallpaper color changes to + * receive notifications about the changes. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getMinWidthCallbackTest001', 0, async function (done) { + it('offCallbackTest001', 0, async function (done) { + let callbackTimes = 0; + await wallpaper.setImage(URI, WALLPAPER_SYSTEM); try { - wallpaper.getMinWidth(function (err, data) { - if (err) { - console.info(`getMinWidthCallbackTest001 err : ${err}`); - expect(null).assertFail(); - } else { - console.info(`getMinWidthCallbackTest001 data : ${data}`); - expect(true).assertTrue(); - } - done(); - }) + wallpaper.on('colorChange', async (colors, wallpaperType) => { + console.info(`offCallbackTest001 colors : ${colors}`); + callbackTimes = callbackTimes + 1; + wallpaper.off('colorChange'); + await wallpaper.setImage(URI, WALLPAPER_SYSTEM); + await wallpaper.restore(WALLPAPER_SYSTEM); + expect(callbackTimes === 1).assertTrue(); + done(); + }) } catch (error) { + console.info(`offCallbackTest001 error : ${error}`); expect(null).assertFail(); done(); } + await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: getMinWidthPromiseTest002 - * @tc.desc: Test getMinWidth() to gets the minWidth of the WALLPAPER_SYSTEM of the specified type. + * @tc.name: offCallbackTest002 + * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to + * receive notifications about the changes. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getMinWidthPromiseTest002', 0, async function (done) { + it('offCallbackTest002', 0, async function (done) { + let callbackTimes = 0; + await wallpaper.setImage(URI, WALLPAPER_SYSTEM); try { - wallpaper.getMinWidth().then((data) => { - console.info(`getMinWidthPromiseTest002 data : ${data}`); - expect(true).assertTrue(); - done(); - }).catch((err) => { - console.info(`getMinWidthPromiseTest002 err : ${err}`); - expect(null).assertFail(); + wallpaper.on('wallpaperChange', async (wallpaperType, resourceType) => { + expect(wallpaperType != null).assertTrue(); + expect(resourceType != null).assertTrue(); + callbackTimes = callbackTimes + 1; + wallpaper.off('wallpaperChange', async (wallpaperType, resourceType) => { + }) + await wallpaper.setImage(URI, WALLPAPER_SYSTEM); + await wallpaper.restore(WALLPAPER_SYSTEM); + expect(callbackTimes === 1).assertTrue(); done(); - }); + }) } catch (error) { + console.info(`offCallbackTest002 error : ${error.message}`); expect(null).assertFail(); done(); } + await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: getMinHeightCallbackTest001 - * @tc.desc: Test getMinHeight() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. + * @tc.name: offCallbackTest003 + * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to + * receive notifications about the changes. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getMinHeightCallbackTest001', 0, async function (done) { + it('offCallbackTest003', 0, async function (done) { try { - wallpaper.getMinHeight(function (err, data) { - if (err) { - console.info(`getMinHeightCallbackTest001 err : ${err}`); - expect(null).assertFail(); - } else { - console.info(`getMinHeightCallbackTest001 data : ${data}`); - expect(true).assertTrue(); - } - done(); - }) + wallpaper.off('wallpaperChange', async (wallpaperType, resourceType) => { + }, 'other'); + expect(true).assertTrue(); + done(); } catch (error) { + console.info(`offCallbackTest003 error : ${error.message}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getMinHeightPromiseTest002 - * @tc.desc: Test getMinHeight() to gets the minHeight of the WALLPAPER_SYSTEM of the specified type. + * @tc.name: offCallbackTest004 + * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to + * receive notifications about the changes. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getMinHeightPromiseTest002', 0, async function (done) { + it('offCallbackTest004', 0, async function (done) { try { - wallpaper.getMinHeight().then((data) => { - console.info(`getMinHeightPromiseTest002 data : ${data}`); - expect(true).assertTrue(); - done(); - }).catch((err) => { - console.info(`getMinHeightPromiseTest002 err : ${err}`); - expect(null).assertFail(); - done(); - }); + wallpaper.off('wallpaperChange'); + expect(true).assertTrue(); + done(); } catch (error) { + console.info(`offCallbackTest004 error : ${error.message}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getFileCallbackTest001 - * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. + * @tc.name: offCallbackTest005 + * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to + * receive notifications about the changes. * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getFileCallbackTest001', 0, async function (done) { + it('offCallbackTest005', 0, async function (done) { try { - wallpaper.getFile(WALLPAPER_SYSTEM, function (err, data) { - if (err) { - console.info(`getFileCallbackTest001 err : ${err}`); - expect(null).assertFail(); - } else { - console.info(`getFileCallbackTest001 data : ${data}`); - expect(true).assertTrue(); - } - done(); - }) - } catch (error) { + wallpaper.off('wallpaperChange', 'other'); expect(null).assertFail(); done(); + } catch (error) { + console.info(`offCallbackTest005 error : ${error.message}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + done(); } }) /** - * @tc.name: getFilePromiseTest002 - * @tc.desc: Test getFile() to get the File of the wallpaper of the specified type. + * @tc.name: offCallbackTest006 + * @tc.desc: Test not exist event wallpaperChangeX to off * @tc.type: FUNC test * @tc.require: issueI5UHRG */ - it('getFilePromiseTest002', 0, async function (done) { + it('offCallbackTest006', 0, async function (done) { + await wallpaper.setImage(URI, WALLPAPER_SYSTEM); try { - wallpaper.getFile(WALLPAPER_SYSTEM).then((data) => { - console.info(`getFilePromiseTest002 data : ${data}`); - expect(true).assertTrue(); - done(); - }).catch((err) => { - console.info(`getFilePromiseTest002 err : ${err}`); - expect(null).assertFail(); - done(); - }); - } catch (error) { + wallpaper.off('wallpaperChangeX'); expect(null).assertFail(); done(); + } catch (error) { + console.info(`offCallbackTest006 error : ${error.message}`); + expect(error.code === PARAMETER_ERROR).assertTrue(); + done(); } + await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: getFileCallbackTest003 - * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. + * @tc.name: setVideoTest001 + * @tc.desc: Test setVideo to set live wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI6R07J */ - it('getFileCallbackTest003', 0, async function (done) { + it('setVideoTest001', 0, async function (done) { try { - wallpaper.getFile(WALLPAPER_LOCKSCREEN, function (err, data) { - if (err) { - console.info(`getFileCallbackTest003 err : ${err}`); + wallpaper.setVideo(URI_30FPS_3S_MP4, WALLPAPER_SYSTEM, (error) => { + if (error != undefined) { + console.info(`setVideoTest001 error : ${error}`); expect(null).assertFail(); } else { - console.info(`getFileCallbackTest003 data : ${data}`); expect(true).assertTrue(); + wallpaper.reset(WALLPAPER_SYSTEM); } done(); }) } catch (error) { + console.info(`setVideoTest001 error : ${error}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getFilePromiseTest004 - * @tc.desc: Test getFile() to gets the File of the wallpaper of the specified type. + * @tc.name: setVideoTest002 + * @tc.desc: Test setVideo to set live wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI6R07J */ - it('getFilePromiseTest004', 0, async function (done) { + it('setVideoTest002', 0, async function (done) { try { - wallpaper.getFile(WALLPAPER_LOCKSCREEN).then((data) => { - console.info(`getFilePromiseTest004 data : ${data}`); - expect(true).assertTrue(); - done(); - }).catch((err) => { - console.info(`getFilePromiseTest004 err : ${err}`); - expect(null).assertFail(); + wallpaper.setVideo(URI_30FPS_3S_MOV, WALLPAPER_SYSTEM, (error) => { + if (error != undefined) { + console.info(`setVideoTest002 error : ${error}`); + expect(true).assertTrue(); + } else { + expect(null).assertFail(); + } done(); - }); + }) } catch (error) { + console.info(`setVideoTest002 error : ${error}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getIdCallbackTest001 - * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. + * @tc.name: setVideoTest003 + * @tc.desc: Test setVideo to set live wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI6R07J */ - it('getIdCallbackTest001', 0, async function (done) { + it('setVideoTest003', 0, async function (done) { try { - wallpaper.getId(WALLPAPER_SYSTEM, function (err, data) { - if (err) { - console.info(`getIdCallbackTest001 err : ${err}`); - expect(null).assertFail(); - } else { - console.info(`getIdCallbackTest001 data ${data}`); + wallpaper.setVideo(URI_15FPS_7S_MP4, WALLPAPER_SYSTEM, (error) => { + if (error != undefined) { + console.info(`setVideoTest002 error : ${error}`); expect(true).assertTrue(); + } else { + expect(null).assertFail(); } done(); }) } catch (error) { + console.info(`setVideoTest003 error : ${error}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getIdPromiseTest002 - * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. + * @tc.name: setVideoTest004 + * @tc.desc: Test setVideo to set live wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI6R07J */ - it('getIdPromiseTest002', 0, async function (done) { + it('setVideoTest004', 0, async function (done) { try { - wallpaper.getId(WALLPAPER_SYSTEM).then((data) => { - console.info(`getIdPromiseTest002 data ${data}`); - expect(true).assertTrue(); - done(); - }).catch((err) => { - console.info(`getIdPromiseTest002 err ${err}`); - expect(null).assertFail(); + wallpaper.setVideo(URI_30FPS_3S_MP4, WALLPAPER_LOCKSCREEN, (error) => { + if (error != undefined) { + console.info(`setVideoTest004 error : ${error}`); + expect(null).assertFail(); + } else { + expect(true).assertTrue(); + wallpaper.reset(WALLPAPER_LOCKSCREEN); + } done(); - }); + }) } catch (error) { + console.info(`setVideoTest004 error : ${error}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getIdCallbackTest003 - * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. + * @tc.name: setVideoTest005 + * @tc.desc: Test setVideo to set live wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI6R07J */ - it('getIdCallbackTest003', 0, async function (done) { + it('setVideoTest005', 0, async function (done) { try { - wallpaper.getId(WALLPAPER_LOCKSCREEN, function (err, data) { - if (err) { - console.info(`getIdCallbackTest003 err ${err}`); - expect(null).assertFail(); - } else { - console.info(`getIdCallbackTest003 data ${data}`); + wallpaper.setVideo(URI_30FPS_3S_MOV, WALLPAPER_LOCKSCREEN, (error) => { + if (error != undefined) { + console.info(`setVideoTest005 error : ${error}`); expect(true).assertTrue(); + } else { + expect(null).assertFail(); } done(); }) } catch (error) { + console.info(`setVideoTest005 error : ${error}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getIdPromiseTest004 - * @tc.desc: Test getId() to gets the ID of the wallpaper of the specified type. + * @tc.name: setVideoTest006 + * @tc.desc: Test setVideo to set live wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI6R07J */ - it('getIdPromiseTest004', 0, async function (done) { + it('setVideoTest006', 0, async function (done) { try { - wallpaper.getId(WALLPAPER_LOCKSCREEN).then((data) => { - console.info(`getIdCallbackTest003 data ${data}`); - expect(true).assertTrue(); + wallpaper.setVideo(URI_15FPS_7S_MP4, WALLPAPER_LOCKSCREEN, (error) => { + if (error != undefined) { + console.info(`setVideoTest006 error : ${error}`); + expect(true).assertTrue(); + } else { + expect(null).assertFail(); + } done(); - }).catch((err) => { - console.info(`getIdCallbackTest003 err ${err}`); - expect(null).assertFail(); - done(); - }); + }) } catch (error) { + console.info(`setVideoTest006 error : ${error}`); expect(null).assertFail(); done(); } }) /** - * @tc.name: getColorsCallbackTest001 - * @tc.desc: Test getColors() to gets WALLPAPER_SYSTEM Colors. + * @tc.name: setCustomWallpaperCallbackTest001 + * @tc.desc: Test setCustomWallpaper to set a custom system wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI7AAMU */ - it('getColorsCallbackTest001', 0, async function (done) { + it('setCustomWallpaperTest001', 0, async function (done) { try { - wallpaper.getColors(WALLPAPER_SYSTEM, function (err, data) { - if (err) { - console.info(`getColorsCallbackTest001 err ${err}`); - expect(null).assertFail(); + wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_SYSTEM, (error) => { + if (isBundleNameExists()) { + if (error !== undefined) { + expect(null).assertFail(); + console.info(`set CustomWallpaperTest001 fail : ${error}`); + } else { + expect(true).assertTrue(); + wallpaper.reset(WALLPAPER_SYSTEM); + } } else { - console.info(`getColorsCallbackTest001 data ${data}`); expect(true).assertTrue(); } done(); }) } catch (error) { expect(null).assertFail(); + console.info(`set Custom WallpaperTest001 fail : ${error}`); done(); } }) /** - * @tc.name: getColorsPromiseTest002 - * @tc.desc: Test getColors() to gets WALLPAPER_SYSTEM Colors. + * @tc.name: setCustomWallpaperPromiseTest002 + * @tc.desc: Test setCustomWallpaper to sets a custom system wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI7AAMU */ - it('getColorsPromiseTest002', 0, async function (done) { + it('setCustomWallpaperPromiseTest002', 0, async function (done) { try { - wallpaper.getColors(WALLPAPER_SYSTEM).then((data) => { - console.info(`getColorsPromiseTest002 data ${data}`); + wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_SYSTEM).then(async () => { expect(true).assertTrue(); done(); + await wallpaper.restore(WALLPAPER_SYSTEM); }).catch((err) => { - console.info(`getColorsPromiseTest002 err ${err}`); - expect(null).assertFail(); - done(); + if (isBundleNameExists()) { + expect(null).assertFail(); + console.info(`set Custom WallpaperPromiseTest002 fail : ${err}`); + done(); + } else { + expect(true).assertTrue(); + done(); + } }); } catch (error) { expect(null).assertFail(); + console.info(`set Custom WallpaperPromiseTest002 fail : ${error}`); done(); } }) /** - * @tc.name: getColorsCallbackTest003 - * @tc.desc: Test getColors() to gets WALLPAPER_LOCKSCREEN Colors. + * @tc.name: setCustomWallpaperCallbackTest003 + * @tc.desc: Test setCustomWallpaper to sets a custom lockscreen wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI7AAMU */ - it('getColorsCallbackTest003', 0, async function (done) { + it('setCustomWallpaperCallbackTest003', 0, async function (done) { try { - wallpaper.getColors(WALLPAPER_LOCKSCREEN, function (err, data) { - if (err) { - console.info(`getColorsCallbackTest003 err ${err}`); - expect(null).assertFail(); + wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_LOCKSCREEN, (error) => { + if (isBundleNameExists()) { + if (error !== undefined) { + expect(null).assertFail(); + console.info(`set Custom WallpaperCallbackTest003 fail : ${error}`); + } else { + expect(true).assertTrue(); + wallpaper.reset(WALLPAPER_SYSTEM); + } } else { - console.info(`getColorsCallbackTest003 data ${data}`); expect(true).assertTrue(); } done(); }) } catch (error) { expect(null).assertFail(); + console.info(`set Custom WallpaperCallbackTest003 fail : ${error}`); done(); } }) /** - * @tc.name: getColorsPromiseTest004 - * @tc.desc: Test getColors() to gets WALLPAPER_LOCKSCREEN Colors. + * @tc.name: setCustomWallpaperPromiseTest004 + * @tc.desc: Test setCustomWallpaper to sets a custom lockscreen wallpaper. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI7AAMU */ - it('getColorsPromiseTest004', 0, async function (done) { + it('setCustomWallpaperPromiseTest004', 0, async function (done) { try { - wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((data) => { - console.info(`getColorsPromiseTest004 data ${data}`); + wallpaper.setCustomWallpaper(URI_ZIP, WALLPAPER_LOCKSCREEN).then(async () => { expect(true).assertTrue(); done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); }).catch((err) => { - console.info(`getColorsPromiseTest004 err ${err}`); - expect(null).assertFail(); - done(); + if (isBundleNameExists()) { + expect(null).assertFail(); + console.info(`set Custom WallpaperPromiseTest004 fail : ${err}`); + done(); + } else { + expect(true).assertTrue(); + done(); + } }); } catch (error) { expect(null).assertFail(); + console.info(`set Custom WallpaperPromiseTest004 fail : ${error}`); done(); } }) /** - * @tc.name: onCallbackTest001 - * @tc.desc: Test on_colorChange to registers a listener for wallpaper color changes to - * receive notifications about the changes. + * @tc.name: setCustomWallpaperCallbackThrowErrorTest005 + * @tc.desc: Test setCustomWallpaper throw parameter error. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI7AAMU */ - it('onCallbackTest001', 0, async function (done) { - await wallpaper.restore(WALLPAPER_LOCKSCREEN); + it('setCustomCallbackThrowErrorTest005', 0, async function (done) { try { - wallpaper.on('colorChange', (colors, wallpaperType) => { - console.info(`onCallbackTest001 colors : ${colors}`); - expect(colors != null).assertTrue(); - expect(wallpaperType != null).assertTrue(); - wallpaper.off('colorChange'); + wallpaper.setCustomWallpaper(URI_ZIP, INVALID_WALLPAPER_TYPE, function (err) { + if (err) { + expect(err.code === PARAMETER_ERROR).assertTrue() + console.info(`set Custom CallbackThrowErrorTest005 fail : ${err}`); + } else { + expect(null).assertFail(); + } done(); }) } catch (error) { - console.info(`onCallbackTest001 error : ${error.message}`); expect(null).assertFail(); + console.info(`set Custom CallbackThrowErrorTest005 fail : ${error}`); done(); } - await wallpaper.setImage(URI, WALLPAPER_LOCKSCREEN); - await wallpaper.restore(WALLPAPER_LOCKSCREEN); }) /** - * @tc.name: onCallbackTest002 - * @tc.desc: Test on_wallpaperChange to registers a listener for wallpaper changes to - * receive notifications about the changes. + * @tc.name: setCustomWallpaperCallbackThrowErrorTest006 + * @tc.desc: Test setImage() throw parameter error. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI7AAMU */ - it('onCallbackTest002', 0, async function (done) { - await wallpaper.restore(WALLPAPER_SYSTEM); + it('setCustomWallpaperCallbackThrowErrorTest006', 0, async function (done) { try { - wallpaper.on('wallpaperChange', (wallpaperType, resourceType) => { - expect(wallpaperType != null).assertTrue(); - expect(resourceType != null).assertTrue(); - wallpaper.off('wallpaperChange'); + wallpaper.setCustomWallpaper(URI_ZIP, function (err) { + if (err) { + console.info(`setCustomWallpaperCallbackThrowErrorTest006 err : ${err}`); + expect(null).assertFail(); + } else { + expect(null).assertFail(); + } done(); }) } catch (error) { - console.info(`onCallbackTest002 error : ${error.message}`); - expect(null).assertFail(); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } - await wallpaper.setImage(URI, WALLPAPER_SYSTEM); - await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: onCallbackTest003 - * @tc.desc: Test to register not exist event + * @tc.name: setCustomWallpaperPromiseThrowErrorTest007 + * @tc.desc: Test setCustomWallpaper throw parameter error. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: issueI7AAMU */ - it('onCallbackTest003', 0, async function (done) { - await wallpaper.restore(WALLPAPER_SYSTEM); + it('setCustomWallpaperPromiseThrowErrorTest007', 0, async function (done) { try { - wallpaper.on('wallpaperChangeX', (wallpaperType, resourceType) => { + wallpaper.setCustomWallpaper(URI_ZIP, INVALID_WALLPAPER_TYPE).then(() => { expect(null).assertFail(); done(); - }) + }).catch((err) => { + console.info(`setCustomWallpaperPromiseThrowErrorTest007 err : ${err}`); + expect(err.code === PARAMETER_ERROR).assertTrue() + done(); + }); } catch (error) { - console.info(`onCallbackTest003 error : ${error.message}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(null).assertFail(); done(); } - await wallpaper.setImage(URI, WALLPAPER_SYSTEM); - await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: onCallbackTest004 - * @tc.desc: Test on_wallpaperChange to registers a listener for wallpaper changes to - * receive notifications about the changes. + * @tc.name: setCustomWallpaperPromiseThrowErrorTest008 + * @tc.desc: Test setCustomWallpaper throw parameter error. * @tc.type: FUNC test * @tc.require: issueI7AAMU */ - it('onCallbackTest004', 0, async function (done) { - await wallpaper.restore(WALLPAPER_SYSTEM); + it('setCustomWallpaperPromiseThrowErrorTest008', 0, async function (done) { try { - wallpaper.on('wallpaperChange', async (wallpaperType, resourceType, uri) => { - expect(wallpaperType != null).assertTrue(); - expect(resourceType != null).assertTrue(); - expect(uri !== "").assertTrue(); - wallpaper.off('wallpaperChange'); + wallpaper.setCustomWallpaper().then(() => { + expect(null).assertFail(); done(); - await wallpaper.restore(WALLPAPER_SYSTEM); - }) - if (isBundleNameExists()) { - await wallpaper.setCustomWallpaper(URI, WALLPAPER_SYSTEM); - } else { - wallpaper.off('wallpaperChange'); - expect(true).assertTrue(); + }).catch((err) => { + console.info(`setCustomWallpaperPromiseThrowErrorTest008 err : ${err}`); + expect(null).assertFail(); done(); - } + }); } catch (error) { - console.info(`onCallbackTest004 error : ${error.message}`); - expect(null).assertFail(); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } }) /** - * @tc.name: offCallbackTest001 - * @tc.desc: Test off_colorChange to log off a listener for wallpaper color changes to - * receive notifications about the changes. + * @tc.name: setAllWallpapersThrowErrorTest001 + * @tc.desc: Test setAllWallpapers throw parameter error, parameter count error * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: */ - it('offCallbackTest001', 0, async function (done) { - let callbackTimes = 0; - await wallpaper.setImage(URI, WALLPAPER_SYSTEM); + it('setAllWallpapersThrowErrorTest001', 0, async function (done) { try { - wallpaper.on('colorChange', async (colors, wallpaperType) => { - console.info(`offCallbackTest001 colors : ${colors}`); - callbackTimes = callbackTimes + 1; - wallpaper.off('colorChange'); - await wallpaper.setImage(URI, WALLPAPER_SYSTEM); - await wallpaper.restore(WALLPAPER_SYSTEM); - expect(callbackTimes === 1).assertTrue(); + wallpaper.setAllWallpapers(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + expect(null).assertFail(); done(); - }) + }).catch((err) => { + console.info(`setAllWallpapersThrowErrorTest001 err : ${err}`); + expect(null).assertFail(); + done(); + }); } catch (error) { - console.info(`offCallbackTest001 error : ${error}`); - expect(null).assertFail(); + console.info(`setAllWallpapersThrowErrorTest001 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } - await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: offCallbackTest002 - * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to - * receive notifications about the changes. + * @tc.name: setAllWallpapersThrowErrorTest002 + * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperType range error * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: */ - it('offCallbackTest002', 0, async function (done) { - let callbackTimes = 0; - await wallpaper.setImage(URI, WALLPAPER_SYSTEM); + it('setAllWallpapersThrowErrorTest002', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORT, + source: URI + } + let wallpaperInfos = [wallpaperInfo1]; try { - wallpaper.on('wallpaperChange', async (wallpaperType, resourceType) => { - expect(wallpaperType != null).assertTrue(); - expect(resourceType != null).assertTrue(); - callbackTimes = callbackTimes + 1; - wallpaper.off('wallpaperChange', async (wallpaperType, resourceType) => { - }) - await wallpaper.setImage(URI, WALLPAPER_SYSTEM); - await wallpaper.restore(WALLPAPER_SYSTEM); - expect(callbackTimes === 1).assertTrue(); + wallpaper.setAllWallpapers(wallpaperInfos, 2).then(() => { + expect(null).assertFail(); done(); - }) + }).catch((err) => { + console.info(`setAllWallpapersThrowErrorTest002 err : ${err}`); + expect(null).assertFail(); + done(); + }); } catch (error) { - console.info(`offCallbackTest002 error : ${error.message}`); - expect(null).assertFail(); + console.info(`setAllWallpapersThrowErrorTest002 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } - await wallpaper.restore(WALLPAPER_SYSTEM); }) /** - * @tc.name: offCallbackTest003 - * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to - * receive notifications about the changes. + * @tc.name: setAllWallpapersThrowErrorTest003 + * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperInfo source error * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: */ - it('offCallbackTest003', 0, async function (done) { + it('setAllWallpapersThrowErrorTest003', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORT, + source: URI_ZIP + } + let wallpaperInfos = [wallpaperInfo1]; try { - wallpaper.off('wallpaperChange', async (wallpaperType, resourceType) => { - }, 'other'); - expect(true).assertTrue(); - done(); + wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + expect(null).assertFail(); + done(); + }).catch((err) => { + console.info(`setAllWallpapersThrowErrorTest003 err : ${err}`); + expect(err.code === PARAMETER_ERROR).assertTrue() + done(); + }); } catch (error) { - console.info(`offCallbackTest003 error : ${error.message}`); - expect(null).assertFail(); + console.info(`setAllWallpapersThrowErrorTest003 error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } }) /** - * @tc.name: offCallbackTest004 - * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to - * receive notifications about the changes. + * @tc.name: setAllWallpapersTest001 + * @tc.desc: Test setAllWallpapers. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: */ - it('offCallbackTest004', 0, async function (done) { + it('setAllWallpapersTest001', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORT, + source: URI + } + let wallpaperInfos = [wallpaperInfo1]; try { - wallpaper.off('wallpaperChange'); - expect(true).assertTrue(); - done(); + wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(async () => { + expect(true).assertTrue(); + done(); + await wallpaper.restore(WALLPAPER_SYSTEM); + }).catch((err) => { + console.info(`setAllWallpapersTest001 fail : ${err}`); + done(); + }); } catch (error) { - console.info(`offCallbackTest004 error : ${error.message}`); expect(null).assertFail(); + console.info(`setAllWallpapersTest001 fail : ${error}`); done(); } }) /** - * @tc.name: offCallbackTest005 - * @tc.desc: Test wallpaperChange to log off a listener for wallpaper changes to - * receive notifications about the changes. + * @tc.name: setAllWallpapersTest002 + * @tc.desc: Test setAllWallpapers. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: */ - it('offCallbackTest005', 0, async function (done) { + it('setAllWallpapersTest002', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORT, + source: URI + } + const wallpaperInfo2 = { + foldState: wallpaper.FoldState.UNFOLD_1, + rotateState: wallpaper.RotateState.LAND, + source: URI + } + let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2]; try { - wallpaper.off('wallpaperChange', 'other'); - expect(null).assertFail(); - done(); + wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { + expect(true).assertTrue(); + done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); + }).catch((err) => { + console.info(`setAllWallpapersTest002 fail : ${err}`); + done(); + }); } catch (error) { - console.info(`offCallbackTest005 error : ${error.message}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(null).assertFail(); + console.info(`setAllWallpapersTest002 fail : ${error}`); done(); } }) /** - * @tc.name: offCallbackTest006 - * @tc.desc: Test not exist event wallpaperChangeX to off + * @tc.name: setAllWallpapersTest003 + * @tc.desc: Test setAllWallpapers. * @tc.type: FUNC test - * @tc.require: issueI5UHRG + * @tc.require: */ - it('offCallbackTest006', 0, async function (done) { - await wallpaper.setImage(URI, WALLPAPER_SYSTEM); + it('setAllWallpapersTest003', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORT, + source: URI + } + const wallpaperInfo2 = { + foldState: wallpaper.FoldState.UNFOLD_1, + rotateState: wallpaper.RotateState.LAND, + source: URI + } + const wallpaperInfo3 = { + foldState: wallpaper.FoldState.UNFOLD_2, + rotateState: wallpaper.RotateState.PORT, + source: URI + } + const wallpaperInfo4 = { + foldState: wallpaper.FoldState.UNFOLD_2, + rotateState: wallpaper.RotateState.LAND, + source: URI + } + let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2, wallpaperInfo3, wallpaperInfo4]; try { - wallpaper.off('wallpaperChangeX'); - expect(null).assertFail(); - done(); + wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { + expect(true).assertTrue(); + done(); + await wallpaper.restore(WALLPAPER_LOCKSCREEN); + }).catch((err) => { + console.info(`setAllWallpapersTest003 fail : ${err}`); + done(); + }); } catch (error) { - console.info(`offCallbackTest006 error : ${error.message}`); - expect(error.code === PARAMETER_ERROR).assertTrue(); + expect(null).assertFail(); + console.info(`setAllWallpapersTest003 fail : ${error}`); done(); } - await wallpaper.restore(WALLPAPER_SYSTEM); }) - /** - * @tc.name: setVideoTest001 - * @tc.desc: Test setVideo to set live wallpaper. + * @tc.name: setAllWallpapersThrowErrorTest001tmp + * @tc.desc: Test setAllWallpapers throw parameter error, parameter count error * @tc.type: FUNC test - * @tc.require: issueI6R07J + * @tc.require: */ - it('setVideoTest001', 0, async function (done) { + it('setAllWallpapersThrowErrorTest001tmp', 0, async function (done) { try { - wallpaper.setVideo(URI_30FPS_3S_MP4, WALLPAPER_SYSTEM, (error) => { - if (error != undefined) { - console.info(`setVideoTest001 error : ${error}`); - expect(null).assertFail(); - } else { - expect(true).assertTrue(); - wallpaper.reset(WALLPAPER_SYSTEM); - } + wallpaper.setAllWallpapers(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + expect(null).assertFail(); done(); - }) + }).catch((err) => { + console.info(`setAllWallpapersThrowErrorTest001tmp err : ${err}`); + expect(null).assertFail(); + done(); + }); } catch (error) { - console.info(`setVideoTest001 error : ${error}`); - expect(null).assertFail(); + console.info(`setAllWallpapersThrowErrorTest001tmp error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } }) /** - * @tc.name: setVideoTest002 - * @tc.desc: Test setVideo to set live wallpaper. + * @tc.name: setAllWallpapersThrowErrorTest002tmp + * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperType range error * @tc.type: FUNC test - * @tc.require: issueI6R07J + * @tc.require: */ - it('setVideoTest002', 0, async function (done) { + it('setAllWallpapersThrowErrorTest002tmp', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORT, + source: URI + } + let wallpaperInfos = [wallpaperInfo1]; try { - wallpaper.setVideo(URI_30FPS_3S_MOV, WALLPAPER_SYSTEM, (error) => { - if (error != undefined) { - console.info(`setVideoTest002 error : ${error}`); - expect(true).assertTrue(); - } else { - expect(null).assertFail(); - } + wallpaper.setAllWallpapers(wallpaperInfos, 2).then(() => { + expect(null).assertFail(); done(); - }) + }).catch((err) => { + console.info(`setAllWallpapersThrowErrorTest002tmp err : ${err}`); + expect(null).assertFail(); + done(); + }); } catch (error) { - console.info(`setVideoTest002 error : ${error}`); - expect(null).assertFail(); + console.info(`setAllWallpapersThrowErrorTest002tmp error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } }) /** - * @tc.name: setVideoTest003 - * @tc.desc: Test setVideo to set live wallpaper. + * @tc.name: setAllWallpapersThrowErrorTest003tmp + * @tc.desc: Test setAllWallpapers throw parameter error, wallpaperInfo source error * @tc.type: FUNC test - * @tc.require: issueI6R07J + * @tc.require: */ - it('setVideoTest003', 0, async function (done) { + it('setAllWallpapersThrowErrorTest003tmp', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORTRAIT, + source: URI_ZIP + } + let wallpaperInfos = [wallpaperInfo1]; try { - wallpaper.setVideo(URI_15FPS_7S_MP4, WALLPAPER_SYSTEM, (error) => { - if (error != undefined) { - console.info(`setVideoTest002 error : ${error}`); - expect(true).assertTrue(); - } else { - expect(null).assertFail(); - } + wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + expect(null).assertFail(); done(); - }) + }).catch((err) => { + console.info(`setAllWallpapersThrowErrorTest003tmp err : ${err}`); + expect(err.code === PARAMETER_ERROR).assertTrue() + done(); + }); } catch (error) { - console.info(`setVideoTest003 error : ${error}`); - expect(null).assertFail(); + console.info(`setAllWallpapersThrowErrorTest003tmp error : ${error}`); + expect(error.code === PARAMETER_ERROR).assertTrue() done(); } }) /** - * @tc.name: setVideoTest004 - * @tc.desc: Test setVideo to set live wallpaper. + * @tc.name: setAllWallpapersTest001tmp + * @tc.desc: Test setAllWallpapers. * @tc.type: FUNC test - * @tc.require: issueI6R07J + * @tc.require: */ - it('setVideoTest004', 0, async function (done) { + it('setAllWallpapersTest001tmp', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORTRAIT, + source: URI + } + let wallpaperInfos = [wallpaperInfo1]; try { - wallpaper.setVideo(URI_30FPS_3S_MP4, WALLPAPER_LOCKSCREEN, (error) => { - if (error != undefined) { - console.info(`setVideoTest004 error : ${error}`); - expect(null).assertFail(); - } else { - expect(true).assertTrue(); - wallpaper.reset(WALLPAPER_LOCKSCREEN); - } + wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(async () => { + expect(true).assertTrue(); done(); - }) + await wallpaper.restore(WALLPAPER_SYSTEM); + }).catch((err) => { + console.info(`setAllWallpapersTest001tmp fail : ${err}`); + done(); + }); } catch (error) { - console.info(`setVideoTest004 error : ${error}`); expect(null).assertFail(); + console.info(`setAllWallpapersTest001tmp fail : ${error}`); done(); } }) /** - * @tc.name: setVideoTest005 - * @tc.desc: Test setVideo to set live wallpaper. + * @tc.name: setAllWallpapersTest002tmp + * @tc.desc: Test setAllWallpapers. * @tc.type: FUNC test - * @tc.require: issueI6R07J + * @tc.require: */ - it('setVideoTest005', 0, async function (done) { + it('setAllWallpapersTest002tmp', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORTRAIT, + source: URI + } + const wallpaperInfo2 = { + foldState: wallpaper.FoldState.UNFOLD_ONCE_STATE, + rotateState: wallpaper.RotateState.LAND, + source: URI + } + let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2]; try { - wallpaper.setVideo(URI_30FPS_3S_MOV, WALLPAPER_LOCKSCREEN, (error) => { - if (error != undefined) { - console.info(`setVideoTest005 error : ${error}`); - expect(true).assertTrue(); - } else { - expect(null).assertFail(); - } + wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { + expect(true).assertTrue(); done(); - }) + await wallpaper.restore(WALLPAPER_LOCKSCREEN); + }).catch((err) => { + console.info(`setAllWallpapersTest002tmp fail : ${err}`); + done(); + }); } catch (error) { - console.info(`setVideoTest005 error : ${error}`); expect(null).assertFail(); + console.info(`setAllWallpapersTest002tmp fail : ${error}`); done(); } }) /** - * @tc.name: setVideoTest006 - * @tc.desc: Test setVideo to set live wallpaper. + * @tc.name: setAllWallpapersTest003tmp + * @tc.desc: Test setAllWallpapers. * @tc.type: FUNC test - * @tc.require: issueI6R07J + * @tc.require: */ - it('setVideoTest006', 0, async function (done) { + it('setAllWallpapersTest003tmp', 0, async function (done) { + const wallpaperInfo1 = { + foldState: wallpaper.FoldState.NORMAL, + rotateState: wallpaper.RotateState.PORTRAIT, + source: URI + } + const wallpaperInfo2 = { + foldState: wallpaper.FoldState.UNFOLD_ONCE_STATE, + rotateState: wallpaper.RotateState.LANDSCAPE, + source: URI + } + const wallpaperInfo3 = { + foldState: wallpaper.FoldState.UNFOLD_TWICE_STATE, + rotateState: wallpaper.RotateState.PORTRAIT, + source: URI + } + const wallpaperInfo4 = { + foldState: wallpaper.FoldState.UNFOLD_TWICE_STATE, + rotateState: wallpaper.RotateState.LANDSCAPE, + source: URI + } + let wallpaperInfos = [wallpaperInfo1, wallpaperInfo2, wallpaperInfo3, wallpaperInfo4]; try { - wallpaper.setVideo(URI_15FPS_7S_MP4, WALLPAPER_LOCKSCREEN, (error) => { - if (error != undefined) { - console.info(`setVideoTest006 error : ${error}`); - expect(true).assertTrue(); - } else { - expect(null).assertFail(); - } + wallpaper.setAllWallpapers(wallpaperInfos, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then(async () => { + expect(true).assertTrue(); done(); - }) + await wallpaper.restore(WALLPAPER_LOCKSCREEN); + }).catch((err) => { + console.info(`setAllWallpapersTest003tmp fail : ${err}`); + done(); + }); } catch (error) { - console.info(`setVideoTest006 error : ${error}`); expect(null).assertFail(); + console.info(`setAllWallpapersTest003tmp fail : ${error}`); done(); } }) diff --git a/test/unittest/js/src/wallpaper_js/config.json b/frameworks/js/napi/test/unittest/src/wallpaper_js/config.json similarity index 100% rename from test/unittest/js/src/wallpaper_js/config.json rename to frameworks/js/napi/test/unittest/src/wallpaper_js/config.json diff --git a/test/unittest/js/src/wallpaper_perf/BUILD.gn b/frameworks/js/napi/test/unittest/src/wallpaper_perf/BUILD.gn similarity index 100% rename from test/unittest/js/src/wallpaper_perf/BUILD.gn rename to frameworks/js/napi/test/unittest/src/wallpaper_perf/BUILD.gn diff --git a/test/unittest/js/src/wallpaper_perf/WallpaperSyncApiPerfJsunit.test.js b/frameworks/js/napi/test/unittest/src/wallpaper_perf/WallpaperSyncApiPerfJsunit.test.js similarity index 99% rename from test/unittest/js/src/wallpaper_perf/WallpaperSyncApiPerfJsunit.test.js rename to frameworks/js/napi/test/unittest/src/wallpaper_perf/WallpaperSyncApiPerfJsunit.test.js index 4b30431b510d69ee34bd38c51a5b1cc8fa26d941..58f69f53e51f54dc5323331821a13310d8311578 100644 --- a/test/unittest/js/src/wallpaper_perf/WallpaperSyncApiPerfJsunit.test.js +++ b/frameworks/js/napi/test/unittest/src/wallpaper_perf/WallpaperSyncApiPerfJsunit.test.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Huawei Device Co., Ltd. + * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/test/unittest/js/src/wallpaper_perf/config.json b/frameworks/js/napi/test/unittest/src/wallpaper_perf/config.json similarity index 100% rename from test/unittest/js/src/wallpaper_perf/config.json rename to frameworks/js/napi/test/unittest/src/wallpaper_perf/config.json