提交 426629b5 编写于 作者: Z zwx1016320

optimization theme of wallpaper

Signed-off-by: Nzwx1016320 <zhangyushuai1@huawei-partners.com>
上级 8b57c300
......@@ -22,7 +22,6 @@
"tablet",
"default",
"phone",
"tablet",
"tv",
"wearable"
],
......
......@@ -23,22 +23,6 @@ let imageSourceLockscreen = '/data/storage/el2/base/haps/wp.png';
export default function wallpaperJSUnit() {
describe('WallpaperJsunitTest', function () {
beforeAll(async function () {
console.info('beforeAll: Prerequisites at the test suite level, ' +
'which are executed before the test suite is executed.');
})
beforeEach(function () {
console.info('beforeEach: Prerequisites at the test case level, ' +
'which are executed before each test case is executed.');
})
afterEach(function () {
console.info('afterEach: Test case-level clearance conditions,' +
' which are executed after each test case is executed.');
})
afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition, ' +
'which is executed after the test suite is executed');
})
/*
* @tc.number testWALLPAPER_SYSTEM
......@@ -47,11 +31,13 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testWALLPAPER_SYSTEM', 0, async function (done) {
console.info('--------------testWALLPAPER_SYSTEM start-----------------');
console.info('wallpaperXTS ===> testWALLPAPER_SYSTEM : ' +
JSON.stringify(wallpaper.WallpaperType.WALLPAPER_SYSTEM));
expect(wallpaper.WallpaperType.WALLPAPER_SYSTEM == 0).assertTrue();
done();
})
console.info('--------------testWALLPAPER_SYSTEM end-----------------');
});
/*
* @tc.number testWALLPAPER_LOCKSCREEN
......@@ -60,11 +46,13 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testWALLPAPER_LOCKSCREEN', 0, async function (done) {
console.info('--------------testWALLPAPER_LOCKSCREEN start-----------------');
console.info('wallpaperXTS ===> testWALLPAPER_LOCKSCREEN : ' +
JSON.stringify(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN));
expect(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN == 1).assertTrue();
done();
})
console.info('--------------testWALLPAPER_LOCKSCREEN end-----------------');
});
/*
* @tc.number testGetColorsCallbackSystem101
......@@ -73,29 +61,33 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetColorsCallbackSystem101', 0, async function (done) {
await wallpaper.getColors(WALLPAPER_SYSTEM, function (err, data) {
console.info('--------------testGetColorsCallbackSystem101 start-----------------');
wallpaper.getColors(WALLPAPER_SYSTEM, (err, RgbaColors) => {
let RgbaColor = {
red: data[0][0],
green: data[0][1],
blue: data[0][2],
alpha: data[0][3]
red: 152,
green: 182,
blue: 211,
alpha: 255
}
console.info('wallpaperXTS ===> testGetColorsCallbackSystem err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + JSON.stringify(data));
console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + data[0][0]);
console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + data[0][1]);
console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + data[0][2]);
console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + data[0][3]);
try {
if (err) {
console.info('====>testGetColorsCallbackSystem101 fail: ' + JSON.stringify(err));
expect(null).assertFail();
done();
}
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
})
console.info('====>testGetColorsCallbackSystem101 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
})
} catch (err) {
console.info('====>testGetColorsCallbackSystem101 catch err: ' + JSON.stringify(err));
done();
};
});
console.info('--------------testGetColorsCallbackSystem101 end-----------------');
});
/*
* @tc.number testGetColorsPromiseSystem101
......@@ -104,19 +96,21 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetColorsPromiseSystem101', 0, async function (done) {
await wallpaper.getColors(WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testGetColorsPromiseSystem data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
console.info('--------------testGetColorsPromiseSystem101 start-----------------');
await wallpaper.getColors(WALLPAPER_SYSTEM).then((RgbaColors) => {
console.info('====>testGetColorsPromiseSystem101 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testGetColorsPromiseSystem err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
console.info('====>testGetColorsPromiseSystem101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
})
});
console.info('--------------testGetColorsPromiseSystem101 end-----------------');
});
/*
* @tc.number testGetColorsCallbackLock102
......@@ -125,18 +119,27 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetColorsCallbackLock102', 0, async function (done) {
await wallpaper.getColors(WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testGetColorsCallbackLock err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetColorsCallbackLock data : ' + JSON.stringify(data));
console.info('--------------testGetColorsCallbackLock102 start-----------------');
wallpaper.getColors(WALLPAPER_LOCKSCREEN, (err, RgbaColors) => {
try {
if (err) {
console.info('====>testGetColorsCallbackLock102 fail: ' + JSON.stringify(err));
expect(null).assertFail();
done();
}
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
})
console.info('====>testGetColorsCallbackLock102 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
})
} catch (err) {
console.info('====>testGetColorsCallbackLock102 catch err: ' + JSON.stringify(err));
done();
};
});
console.info('--------------testGetColorsCallbackLock102 end-----------------');
});
/*
* @tc.number testGetColorsPromiseLock102
......@@ -145,39 +148,47 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetColorsPromiseLock102', 0, async function (done) {
await wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('wallpaperXTS ===> testGetColorsCallbackLock data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
console.info('--------------testGetColorsPromiseLock102 start-----------------');
await wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((RgbaColors) => {
console.info('====>testGetColorsPromiseLock102 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testGetColorsCallbackLock err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
console.info('====>testGetColorsPromiseLock102 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetColorsPromiseLock102 end-----------------');
})
/*
* @tc.number testGetColorsPromiseLock102
* @tc.number testGetIdCallbackSystem101
* @tc.name Test getId() to the ID of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetIdCallbackSystem101', 0, async function (done) {
await wallpaper.getId(WALLPAPER_SYSTEM, function (err, data) {
console.info('wallpaperXTS ===> testGetIdCallbackSystem err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetIdCallbackSystem data : ' + JSON.stringify(data));
console.info('--------------testGetIdCallbackSystem101 start-----------------');
wallpaper.getId(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
console.info('====>testGetIdCallbackSystem101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
})
console.info('====>testGetIdCallbackSystem101 successful data: ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
})
} catch (err) {
console.info('====>testGetIdCallbackSystem101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetIdCallbackSystem101 end-----------------');
});
/*
* @tc.number testGetIdPromiseSystem101
......@@ -186,18 +197,17 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetIdPromiseSystem101', 0, async function (done) {
console.info('--------------testGetIdCallbackSystem101 start-----------------');
await wallpaper.getId(WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testGetIdCallbackSystem data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
console.info('====>testGetIdCallbackSystem101 data : ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testGetIdCallbackSystem err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
console.info('====>testGetIdCallbackSystem101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetIdCallbackSystem101 end-----------------');
})
/*
......@@ -207,18 +217,24 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetIdCallbackLock102', 0, async function (done) {
await wallpaper.getId(WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testGetIdCallbackLock err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetIdCallbackLock data : ' + JSON.stringify(data));
console.info('--------------testGetIdCallbackLock102 start-----------------');
wallpaper.getId(WALLPAPER_LOCKSCREEN, (err, data) => {
try {
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
console.info('====>testGetIdCallbackLock102 err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
})
console.info('====>testGetIdCallbackLock102 successful data: ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
})
} catch (err) {
console.info('====>testGetIdCallbackLock102 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetIdCallbackLock102 end-----------------');
});
/*
* @tc.number testGetIdPromiseLock102
......@@ -227,19 +243,20 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetIdPromiseLock102', 0, async function (done) {
console.info('--------------testGetIdPromiseLock102 start-----------------');
await wallpaper.getId(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('wallpaperXTS ===> testGetIdCallbackLock data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
console.info('====>testGetIdPromiseLock102 data : ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testGetIdCallbackLock err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
console.info('====>testGetIdPromiseLock102 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
})
});
console.info('--------------testGetIdPromiseLock102 end-----------------');
});
/*
* @tc.number testGetMinHeightCallback101
......@@ -248,18 +265,24 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetMinHeightCallback101', 0, async function (done) {
await wallpaper.getMinHeight(function (err, data) {
console.info('wallpaperXTS ===> testGetMinHeightCallback err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetMinHeightCallback data : ' + JSON.stringify(data));
console.info('--------------testGetMinHeightCallback101 start-----------------');
wallpaper.getMinHeight((err, data) => {
try {
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
console.info('====>testGetMinHeightCallback101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
})
console.info('====>testGetMinHeightCallback101 successful data: ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
})
} catch (err) {
console.info('====>testGetMinHeightCallback101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetMinHeightCallback101 end-----------------');
});
/*
* @tc.number testGetMinHeightPromise101
......@@ -268,19 +291,18 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetMinHeightPromise101', 0, async function (done) {
console.info('--------------testGetMinHeightPromise101 start-----------------');
await wallpaper.getMinHeight().then((data) => {
console.info('wallpaperXTS ===> testGetMinHeightPromise data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
console.info('====>testGetMinHeightPromise101 successful data : ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testGetMinHeightPromise err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
console.info('====>testGetMinHeightPromise101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
});
console.info('--------------testGetMinHeightPromise101 end-----------------');
});
/*
* @tc.number testGetMinWidthCallback101
......@@ -289,18 +311,24 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetMinWidthCallback101', 0, async function (done) {
await wallpaper.getMinWidth(function (err, data) {
console.info('wallpaperXTS ===> testGetMinWidthCallback err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetMinWidthCallback data : ' + JSON.stringify(data));
console.info('--------------testGetMinWidthCallback101 start-----------------');
wallpaper.getMinWidth((err, data) => {
try {
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
console.info('====>testGetMinWidthCallback101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
})
console.info('====>testGetMinWidthCallback101 successful data: ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
})
} catch (err) {
console.info('====>testGetMinWidthCallback101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetMinWidthCallback101 end-----------------');
});
/*
* @tc.number testGetMinWidthPromise101
......@@ -309,19 +337,18 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetMinWidthPromise101', 0, async function (done) {
console.info('--------------testGetMinWidthPromise101 start-----------------');
await wallpaper.getMinWidth().then((data) => {
console.info('wallpaperXTS ===> testGetMinWidthPromise data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
console.info('====>testGetMinWidthPromise101 successful data : ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testGetMinWidthPromise err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
console.info('====>testGetMinWidthPromise101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
});
console.info('--------------testGetMinWidthPromise101 end-----------------');
});
/*
* @tc.number testIsChangePermittedCallback101
......@@ -331,18 +358,24 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testIsChangePermittedCallback101', 0, async function (done) {
await wallpaper.isChangePermitted(function (err, data) {
console.info('wallpaperXTS ===> testIsChangePermittedCallback err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testIsChangePermittedCallback data : ' + JSON.stringify(data));
console.info('--------------testIsChangePermittedCallback101 start-----------------');
wallpaper.isChangePermitted((err, data) => {
try {
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
console.info('====>testIsChangePermittedCallback101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
})
console.info('====>testIsChangePermittedCallback101 successful data: ' + JSON.stringify(data));
expect(typeof data == "boolean").assertTrue();
done();
} catch (err) {
console.info('====>testIsChangePermittedCallback101 catch err : ' + JSON.stringify(err));
done();
}
})
console.info('--------------testIsChangePermittedCallback101 end-----------------');
});
/*
* @tc.number testIsChangePermittedPromise101
......@@ -352,19 +385,18 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testIsChangePermittedPromise101', 0, async function (done) {
console.info('--------------testIsChangePermittedPromise101 start-----------------');
await wallpaper.isChangePermitted().then((data) => {
console.info('wallpaperXTS ===> testIsChangePermittedPromise data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
console.info('====>testIsChangePermittedPromise101 successful data : ' + JSON.stringify(data));
expect(typeof data == "boolean").assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testIsChangePermittedPromise err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
console.info('====>testIsChangePermittedPromise101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
});
console.info('--------------testIsChangePermittedPromise101 end-----------------');
});
/*
* @tc.number testIsOperationAllowedCallback101
......@@ -373,18 +405,24 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testIsOperationAllowedCallback101', 0, async function (done) {
await wallpaper.isOperationAllowed(function (err, data) {
console.info('wallpaperXTS ===> testIsOperationAllowedCallback err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testIsOperationAllowedCallback data : ' + JSON.stringify(data));
console.info('--------------testIsOperationAllowedCallback101 start-----------------');
wallpaper.isOperationAllowed((err, data) => {
try {
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
console.info('====>testIsOperationAllowedCallback101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
})
console.info('====>testIsOperationAllowedCallback101 successful data: ' + JSON.stringify(data));
expect(typeof data == "boolean").assertTrue();
done();
} catch (err) {
console.info('====>testIsOperationAllowedCallback101 catch err : ' + JSON.stringify(err));
done();
}
})
console.info('--------------testIsOperationAllowedCallback101 end-----------------');
});
/*
* @tc.number testIsOperationAllowedPromise101
......@@ -393,19 +431,18 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testIsOperationAllowedPromise101', 0, async function (done) {
console.info('--------------testIsOperationAllowedPromise101 start-----------------');
await wallpaper.isOperationAllowed().then((data) => {
console.info('wallpaperXTS ===> testIsOperationAllowedPromise data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
expect(true).assertTrue();
}
console.info('====>testIsOperationAllowedPromise101 successful data : ' + JSON.stringify(data));
expect(typeof data == "boolean").assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testIsOperationAllowedPromise err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
console.info('====>testIsOperationAllowedPromise101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
})
});
console.info('--------------testIsOperationAllowedPromise101 end-----------------');
});
/*
* @tc.number testResetCallbackSystem101
......@@ -414,18 +451,24 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testResetCallbackSystem101', 0, async function (done) {
await wallpaper.reset(WALLPAPER_SYSTEM, function (err, data) {
console.info('wallpaperXTS ===> testResetCallbackSystem err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testResetCallbackSystem data : ' + JSON.stringify(data));
console.info('--------------testResetCallbackSystem101 start-----------------');
wallpaper.reset(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
expect(null).assertFail();
console.info('====>testResetCallbackSystem101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
if ((data != undefined) && (data != null)) {
console.info('====>testResetCallbackSystem101 successful data: ' + JSON.stringify(data));
expect(true).assertTrue();
}
})
done();
} catch (err) {
console.info('====>testResetCallbackSystem101 catch err : ' + JSON.stringify(err));
done();
}
})
console.info('--------------testResetCallbackSystem101 end-----------------');
});
/*
* @tc.number testResetPromiseSystem101
......@@ -434,16 +477,18 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testResetPromiseSystem101', 0, async function (done) {
console.info('--------------testResetPromiseSystem101 start-----------------');
await wallpaper.reset(WALLPAPER_SYSTEM).then((data) => {
if ((data != undefined) && (data != null)) {
console.info('====>testResetPromiseSystem101 successful data : ' + JSON.stringify(data));
expect(true).assertTrue();
}
done();
}).catch((err) => {
expect(true).assertTrue();
console.info('====>testResetPromiseSystem101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
})
console.info('--------------testResetPromiseSystem101 end-----------------');
});
/*
* @tc.number testResetCallbackLock102
......@@ -452,18 +497,24 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testResetCallbackLock102', 0, async function (done) {
await wallpaper.reset(WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testResetCallbackLock err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testResetCallbackLock data : ' + JSON.stringify(data));
console.info('--------------testResetCallbackLock102 start-----------------');
wallpaper.reset(WALLPAPER_LOCKSCREEN, (err, data) => {
try {
if (err) {
expect(null).assertFail();
console.info('====>testResetCallbackLock102 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
if ((data != undefined) && (data != null)) {
console.info('====>testResetCallbackLock102 successful data: ' + JSON.stringify(data));
expect(true).assertTrue();
}
})
done();
} catch (err) {
console.info('====>testResetCallbackLock102 catch err : ' + JSON.stringify(err));
done();
}
})
console.info('--------------testResetCallbackLock102 end-----------------');
});
/*
* @tc.number testResetPromiseLock102
......@@ -472,18 +523,18 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testResetPromiseLock102', 0, async function (done) {
console.info('--------------testResetPromiseLock102 start-----------------');
await wallpaper.reset(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('wallpaperXTS ===> testResetPromiseLock data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null)) {
console.info('====>testResetPromiseLock102 successful data : ' + JSON.stringify(data));
expect(true).assertTrue();
}
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testResetPromiseLock--- err : ' + JSON.stringify(err));
expect(true).assertTrue();
console.info('====>testResetPromiseLock102 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
})
console.info('--------------testResetPromiseLock102 end-----------------');
});
/*
* @tc.number testSetWallpaperURLPromiseLock104
......@@ -494,24 +545,17 @@ export default function wallpaperJSUnit() {
*/
it('testSetWallpaperURLPromiseLock104', 0, async function (done) {
console.info('--------------------testSetWallpaperURLPromiseLock104 start------------------' );
try{
wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => {
console.info('wallpaperXTS ===> testSetWallpaperURLPromiseLock104 data : ' + data);
await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testSetWallpaperURLPromiseLock104 successful data : ' + data);
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testSetWallpaperURLPromiseLock104 err : ' + err);
console.info('====>testSetWallpaperURLPromiseLock104 fail: ' + err);
expect().assertFail();
done();
});
}catch(error){
console.info('testSetWallpaperURLPromiseLock104 catch error : ' + error);
expect().assertFail();
done();
}
console.info('--------------------testSetWallpaperURLPromiseLock104 end------------------' );
})
});
/*
* @tc.number testSetWallpaperURLCallbackSystem103
......@@ -522,24 +566,23 @@ export default function wallpaperJSUnit() {
*/
it('testSetWallpaperURLCallbackSystem103', 0, async function (done) {
console.info('--------------------testSetWallpaperURLCallbackSystem103 start------------------' );
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_SYSTEM, (err, data) => {
try{
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_SYSTEM, function (err, data) {
console.info('wallpaperXTS ===> testSetWallpaperURLCallbackSystem103 data : ' + data);
if (err) {
console.info('wallpaperXTS ===> testSetWallpaperURLCallbackSystem103 err : ' + err);
console.info('====->testSetWallpaperURLCallbackSystem103 err : ' + err);
expect().assertFail();
done();
}
console.info('====>testSetWallpaperURLCallbackSystem103 successful data: ' + data);
expect(true).assertTrue();
done();
});
}catch(error){
console.info('testSetWallpaperURLCallbackSystem103 catch error: ' + error);
expect().assertFail();
done();
}
});
console.info('--------------------testSetWallpaperURLCallbackSystem103 end------------------' );
})
});
/*
* @tc.number testSetWallpaperURLPromiseSystem103
......@@ -548,25 +591,19 @@ export default function wallpaperJSUnit() {
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLPromiseSystem103', 0, function (done) {
it('testSetWallpaperURLPromiseSystem103', 0, async function (done) {
console.info('--------------------testSetWallpaperURLPromiseSystem103 start------------------' );
try{
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testSetWallpaperURLPromiseSystem103 data : ' + data);
await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testSetWallpaperURLPromiseSystem103 successful data : ' + data);
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testSetWallpaperURLPromiseSystem103 err : ' + err);
console.info('====>testSetWallpaperURLPromiseSystem103 fail: ' + err);
expect().assertFail();
done();
});
}catch(error){
console.info('testSetWallpaperURLPromiseSystem103 err: ' + error);
expect().assertFail();
}
console.info('--------------------testSetWallpaperURLPromiseSystem103 end------------------' );
})
});
/*
* @tc.number testSetWallpaperURLCallbackLock104
......@@ -577,24 +614,23 @@ export default function wallpaperJSUnit() {
*/
it('testSetWallpaperURLCallbackLock104', 0, async function (done) {
console.info('--------------------testSetWallpaperURLCallbackLock104 start------------------' );
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_LOCKSCREEN, (err, data) => {
try{
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testSetWallpaperURLCallbackLock104 data : ' + data);
if (err) {
console.info('wallpaperXTS ===> testSetWallpaperURLCallbackLock104 err : ' + JSON.stringify(err));
console.info('====->testSetWallpaperURLCallbackLock104 err : ' + err);
expect().assertFail();
done();
}
console.info('====>testSetWallpaperURLCallbackLock104 successful data: ' + data);
expect(true).assertTrue();
done();
});
}catch(error){
console.info('testSetWallpaperURLCallbackLock104 catch error : ' + error);
expect().assertFail();
console.info('testSetWallpaperURLCallbackLock104 catch error: ' + error);
done();
}
});
console.info('--------------------testSetWallpaperURLCallbackLock104 end------------------' );
})
});
/*
* @tc.number testOnCallback101
......@@ -604,18 +640,32 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testOnCallback101', 0, async function (done) {
wallpaper.on('colorChange', function (colors, wallpaperType) {
console.info('wallpaperXTS ===> testOnCallback colors : ' + JSON.stringify(colors));
console.info('wallpaperXTS ===> testOnCallback wallpaperType : ' + JSON.stringify(wallpaperType));
if ((colors != undefined) && (colors != null)) {
expect(true).assertTrue();
}
if ((wallpaperType != undefined) && (wallpaperType != null)) {
expect(true).assertTrue();
console.info('--------------testOnCallback101 start-----------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
await wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
try {
wallpaper.on('colorChange', async (colors, wallpaperType) => {
try {
console.info('====>testOnCallback101 colors: ' + JSON.stringify(colors));
console.info('====>testOnCallback101 wallpaperType: ' + JSON.stringify(wallpaperType));
expect(colors != null).assertTrue();
expect(wallpaperType != null).assertTrue();
wallpaper.off('colorChange')
console.info('====>testOnCallback101 off');
done();
} catch (err) {
console.info('====>testOnCallback101 setImage or other err : ' + JSON.stringify(err));
done();
}
})
});
} catch (err) {
console.info('====>testOnCallback101 catch err : ' + JSON.stringify(err));
done();
})
}
await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
console.info('====>testOnCallback10 setImage successful');
console.info('--------------testOnCallback101 end-----------------');
});
/*
* @tc.number testOffCallback101
......@@ -625,18 +675,37 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testOffCallback101', 0, async function (done) {
wallpaper.off('colorChange', function (colors, wallpaperType) {
console.info('wallpaperXTS ===> testOffCallback colors : ' + JSON.stringify(colors));
console.info('wallpaperXTS ===> testOffCallback wallpaperType : ' + JSON.stringify(wallpaperType));
if ((colors != undefined) && (colors != null)) {
expect(true).assertTrue();
}
if ((wallpaperType != undefined) && (wallpaperType != null)) {
expect(true).assertTrue();
console.info('--------------testOffCallback101 start-----------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
let callbackTimes = 0;
await wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM)
try {
wallpaper.on('colorChange', async (colors, wallpaperType) => {
try {
console.info('====>testOffCallback101 colors: ' + JSON.stringify(colors));
console.info('====>testOffCallback101 wallpaperType: ' + JSON.stringify(wallpaperType));
callbackTimes = callbackTimes + 1;
console.info('====>testOffCallback101 on callbackTime: ' + callbackTimes);
expect(callbackTimes == 1).assertTrue();
wallpaper.off('colorChange');
setTimeout(() => {
done();
}, 3000)
} catch (err) {
console.info('====>testOffCallback101 setImage or other err : ' + JSON.stringify(err));
done();
}
})
});
} catch (err) {
console.info('====>testOffCallback101 catch err : ' + JSON.stringify(err));
done();
})
}
await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM)
await wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM)
await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM)
console.info('====>testOffCallback101 setImage successful');
console.info('--------------testOffCallback101 end-----------------');
});
/*
* @tc.number testGetFileCallback101
......@@ -645,19 +714,24 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetFileCallback101', 0, async function (done) {
wallpaper.getFile(WALLPAPER_SYSTEM, (error, data) => {
if (error) {
console.error("callback failed to getFile because: " + JSON.stringify(error));
expect().assertFail()
} else {
expect(typeof data == "number").assertTrue();
expect(!isNaN(data)).assertTrue();
console.info("callback success to getFile: " + JSON.stringify(data));
done()
console.info('--------------testGetFileCallback101 start-----------------');
wallpaper.getFile(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
console.info('====>testGetFileCallback101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
});
console.info('====>testGetFileCallback101 successful data: ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
})
} catch (err) {
console.info('====>testGetFileCallback101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetFileCallback101 end-----------------');
});
/*
* @tc.number testGetFilePromise101
......@@ -666,17 +740,18 @@ export default function wallpaperJSUnit() {
* @tc.level 0
*/
it('testGetFilePromise101', 0, async function (done) {
wallpaper.getFile(WALLPAPER_SYSTEM).then((data) => {
expect(typeof data == "number").assertTrue();
expect(!isNaN(data)).assertTrue();
console.info("promise success to getFile: " + JSON.stringify(data));
done()
}).catch((error) => {
console.error("promise failed to getFile because: " + JSON.stringify(error));
expect().assertFail()
});
console.info('--------------testGetFilePromise101 start-----------------');
await wallpaper.getFile(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testGetFilePromise101 successful data : ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
})
}).catch((err) => {
console.info('====>testGetFilePromise101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetFilePromise101 end-----------------');
});
/*
* @tc.number testGetColorsSync101
......@@ -717,7 +792,7 @@ export default function wallpaperJSUnit() {
let colors = null;
try{
colors = wallpaper.getColorsSync(WALLPAPER_LOCKSCREEN)
console.info('wallpaperXTS ===> testGetColorsSync102 data : ' + JSON.stringify(colors));
console.info('====>testGetColorsSync102 data : ' + JSON.stringify(colors));
if (colors.length >= 1) {
expect(true).assertTrue();
done()
......@@ -726,12 +801,11 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testGetColorsSync102 err : ' + JSON.stringify(err));
console.info('====>testGetColorsSync102 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
console.info('------------------testGetColorsSync102 end----------------------');
done()
})
/*
......@@ -745,7 +819,7 @@ export default function wallpaperJSUnit() {
let number = null;
try{
number = wallpaper.getIdSync(WALLPAPER_SYSTEM)
console.info('wallpaperXTS ===> testGetIdSync101 data : ' + JSON.stringify(number));
console.info('====>testGetIdSync101 data : ' + JSON.stringify(number));
if (typeof number == "number") {
expect(true).assertTrue();
done()
......@@ -754,12 +828,11 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testGetIdSync101 err : ' + JSON.stringify(err));
console.info('====>testGetIdSync101 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
console.info('------------------testGetIdSync101 end----------------------');
done()
})
/*
......@@ -773,7 +846,7 @@ export default function wallpaperJSUnit() {
let number = null;
try{
number = wallpaper.getIdSync(WALLPAPER_LOCKSCREEN)
console.info('wallpaperXTS ===> testGetIdSync102 data : ' + JSON.stringify(number));
console.info('====>testGetIdSync102 data : ' + JSON.stringify(number));
if (typeof number == "number") {
expect(true).assertTrue();
done()
......@@ -782,12 +855,11 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testGetIdSync102 err : ' + JSON.stringify(err));
console.info('====>testGetIdSync102 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
console.info('------------------testGetIdSync102 end----------------------');
done()
})
/*
......@@ -801,7 +873,7 @@ export default function wallpaperJSUnit() {
let number = null;
try{
number = wallpaper.getFileSync(WALLPAPER_SYSTEM)
console.info('wallpaperXTS ===> testGetFileSync101 data : ' + JSON.stringify(number));
console.info('====>testGetFileSync101 data : ' + JSON.stringify(number));
if (typeof number == "number") {
expect(true).assertTrue();
done()
......@@ -810,12 +882,11 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testGetFileSync101 err : ' + JSON.stringify(err));
console.info('====>testGetFileSync101 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
console.info('------------------testGetFileSync101 end----------------------');
done()
})
/*
......@@ -829,7 +900,7 @@ export default function wallpaperJSUnit() {
let number = null;
try{
number = wallpaper.getFileSync(WALLPAPER_LOCKSCREEN)
console.info('wallpaperXTS ===> testGetFileSync102 data : ' + JSON.stringify(number));
console.info('====>testGetFileSync102 data : ' + JSON.stringify(number));
if (typeof number == "number") {
expect(true).assertTrue();
done()
......@@ -838,12 +909,11 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testGetFileSync102 err : ' + JSON.stringify(err));
console.info('====>testGetFileSync102 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
console.info('------------------testGetFileSync102 end----------------------');
done()
})
/*
......@@ -857,7 +927,7 @@ export default function wallpaperJSUnit() {
let number = null;
try{
number = wallpaper.getFileSync(3)
console.info('wallpaperXTS ===> testGetFileSync103 data : ' + JSON.stringify(number));
console.info('====>testGetFileSync103 data : ' + JSON.stringify(number));
if (typeof number == "number") {
expect(true).assertTrue();
done()
......@@ -866,13 +936,12 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testGetFileSync103 err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetFileSync103 (err.code : ' + err.code);
console.info('====>testGetFileSync103 err : ' + JSON.stringify(err));
console.info('====>testGetFileSync103 (err.code : ' + err.code);
expect(err.code == "401").assertTrue();
done()
}
console.info('------------------testGetFileSync103 end----------------------');
done()
})
/*
......@@ -886,7 +955,7 @@ export default function wallpaperJSUnit() {
let number = null;
try{
number = wallpaper.getMinHeightSync()
console.info('wallpaperXTS ===> testGetMinHeightSync101 data : ' + JSON.stringify(number));
console.info('====>testGetMinHeightSync101 data : ' + JSON.stringify(number));
if (typeof number == "number") {
expect(true).assertTrue();
done()
......@@ -895,7 +964,7 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testGetMinHeightSync101 err : ' + JSON.stringify(err));
console.info('====>testGetMinHeightSync101 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
......@@ -914,7 +983,7 @@ export default function wallpaperJSUnit() {
let number = null;
try{
number = wallpaper.getMinWidthSync()
console.info('wallpaperXTS ===> testGetMinWidthSync101 data : ' + JSON.stringify(number));
console.info('====>testGetMinWidthSync101 data : ' + JSON.stringify(number));
if (typeof number == "number") {
expect(true).assertTrue();
done()
......@@ -923,12 +992,11 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testGetMinWidthSync101 err : ' + JSON.stringify(err));
console.info('====>testGetMinWidthSync101 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
console.info('------------------testGetMinWidthSync101 end----------------------');
done()
})
/*
......@@ -942,7 +1010,7 @@ export default function wallpaperJSUnit() {
let allow = null;
try{
allow = wallpaper.isChangeAllowed()
console.info('wallpaperXTS ===> testIsChangeAllowed101 data : ' + JSON.stringify(allow));
console.info('====>testIsChangeAllowed101 data : ' + JSON.stringify(allow));
if (typeof allow == "boolean") {
expect(true).assertTrue();
done()
......@@ -951,12 +1019,11 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testIsChangeAllowed101 err : ' + JSON.stringify(err));
console.info('====>testIsChangeAllowed101 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
console.info('------------------testIsChangeAllowed101 end----------------------');
done()
})
/*
......@@ -970,7 +1037,7 @@ export default function wallpaperJSUnit() {
let allow = null;
try{
allow = wallpaper.isUserChangeAllowed()
console.info('wallpaperXTS ===> testIsUserChangeAllowed101 data : ' + JSON.stringify(allow));
console.info('====>testIsUserChangeAllowed101 data : ' + JSON.stringify(allow));
if (typeof allow == "boolean") {
expect(true).assertTrue();
done()
......@@ -979,7 +1046,7 @@ export default function wallpaperJSUnit() {
done()
}
}catch(err){
console.info('wallpaperXTS ===> testIsUserChangeAllowed101 err : ' + JSON.stringify(err));
console.info('====>testIsUserChangeAllowed101 err : ' + JSON.stringify(err));
expect().assertFail();
done()
}
......@@ -995,23 +1062,22 @@ export default function wallpaperJSUnit() {
*/
it('testRestoreCallback101', 0, async function (done) {
console.info('------------------testRestoreCallback101 start----------------------');
try{
wallpaper.restore(WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testRestoreCallback101 data : ' + data);
try{
console.info('====>testRestoreCallback101 data : ' + data);
if (err) {
console.info('wallpaperXTS ===> testRestoreCallback101 err : ' + JSON.stringify(err));
console.info('====>testRestoreCallback101 fail: ' + JSON.stringify(err));
expect().assertFail();
done()
done();
}
console.info('testRestoreCallback101 restore success');
console.info('====>testRestoreCallback101 restore success');
expect(true).assertTrue();
done()
})
done();
}catch(err){
console.info('testRestoreCallback101 catch err : ' + JSON.stringify(err));
expect().assertFail();
done()
console.info('====>testRestoreCallback101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('------------------testRestoreCallback101 end----------------------');
})
......@@ -1023,22 +1089,16 @@ export default function wallpaperJSUnit() {
*/
it('testRestorePromise101', 0, async function (done) {
console.info('------------------testRestorePromise101 start----------------------');
try{
wallpaper.restore(WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testRestorePromise101 data : ' + JSON.stringify(data));
console.info('testRestorePromise101 restore success');
await wallpaper.restore(WALLPAPER_SYSTEM).then((data) => {
console.info('====>testRestorePromise101 data : ' + JSON.stringify(data));
console.info('====>testRestorePromise101 restore success');
expect(true).assertTrue();
done()
}).catch((err) => {
console.info('wallpaperXTS ===> testRestorePromise101 err : ' + JSON.stringify(err));
console.info('====>testRestorePromise101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
}catch(err){
console.info('testRestorePromise101 catch err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('------------------testRestorePromise101 end----------------------');
})
......@@ -1051,22 +1111,21 @@ export default function wallpaperJSUnit() {
it('testSetImageCallBack101', 0, async function (done) {
console.info('------------------testSetImageCallBack101 start----------------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
try{
wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
try{
if (error) {
console.error(`testSetImageCallBack101 failed to setImage because: ` + JSON.stringify(error));
console.error(`====>testSetImageCallBack101 failed to setImage because: ` + JSON.stringify(error));
expect().assertFail();
done();
}
console.log(`testSetImageCallBack101 success to setImage.`);
console.log(`====>testSetImageCallBack101 success to setImage.`);
expect(true).assertTrue();
done();
});
}catch(err){
console.info('testSetImageCallBack101 catch err : ' + JSON.stringify(err));
expect().assertFail();
console.info('====>testSetImageCallBack101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('------------------testSetImageCallBack101 end----------------------');
})
......@@ -1079,22 +1138,21 @@ export default function wallpaperJSUnit() {
it('testSetImageCallBack102', 0, async function (done) {
console.info('------------------testSetImageCallBack102 start----------------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
try{
wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN, (error, data) => {
try{
if (error) {
console.error(`testSetImageCallBack102 failed to setImage because: ` + JSON.stringify(error));
console.error(`====>testSetImageCallBack102 failed to setImage because: ` + JSON.stringify(error));
expect().assertFail();
done();
}
console.log(`testSetImageCallBack102 success to setImage.`);
console.log(`====>testSetImageCallBack102 success to setImage.`);
expect(true).assertTrue();
done();
});
}catch(err){
console.info('testSetImageCallBack102 catch err : ' + JSON.stringify(err));
expect().assertFail();
console.info('====>testSetImageCallBack102 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('------------------testSetImageCallBack102 end----------------------');
})
......@@ -1106,36 +1164,28 @@ export default function wallpaperJSUnit() {
*/
it('testSetImageCallBack103', 0, async function (done) {
console.info('------------------testSetImageCallBack103 start----------------------');
const color = new ArrayBuffer(96);
let bufferArr = new Uint8Array(color);
let opts = {
editable: true,
pixelFormat: 3,
size: { height: 4, width: 6 }
}
console.log(`testSetImageCallBack103 opts success`)
try{
image.createPixelMap(color, opts).then((pixelMap) => {
wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((pixelMap) => {
wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
try{
if (error) {
console.error(`testSetImageCallBack103 failed to setImage because: ` + JSON.stringify(error));
expect().assertFail();
done()
done();
}
console.log(`testSetImageCallBack103 success to setImage.`);
expect(true).assertTrue();
done()
done();
}catch(err){
console.info('testSetImageCallBack103 catch err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
});
}).catch((error) => {
console.error(`testSetImageCallBack103 failed to createPixelMap because: ` + JSON.stringify(error));
expect().assertFail();
done()
});
}catch(err){
console.info('testSetImageCallBack103 catch err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('------------------testSetImageCallBack103 end----------------------');
})
......@@ -1148,22 +1198,15 @@ export default function wallpaperJSUnit() {
it('testSetImagePromise101', 0, async function (done) {
console.info('------------------testSetImagePromise101 start----------------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
try{
wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`testSetImagePromise101 success to setImage.`);
await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`====>testSetImagePromise101 success to setImage.`);
expect(true).assertTrue();
done();
}).catch(err => {
expect().assertFail();
console.log(`testSetImagePromise101 promise catch: ` + JSON.stringify(err));
console.log(`====>testSetImagePromise101 promise fail: ` + JSON.stringify(err));
});
}catch(err){
console.info('testSetImagePromise101 catch err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('------------------testSetImagePromise101 end----------------------');
})
/*
......@@ -1175,21 +1218,15 @@ export default function wallpaperJSUnit() {
it('testSetImagePromise102', 0, async function (done) {
console.info('------------------testSetImagePromise102 start----------------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
try{
wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then((data) => {
console.log(`testSetImagePromise102 success to setImage.`);
await wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then((data) => {
console.log(`====>testSetImagePromise102 success to setImage.`);
expect(true).assertTrue();
done();
}).catch(err => {
console.log(`testSetImagePromise102 promise catch: ` + JSON.stringify(err));
console.log(`====>testSetImagePromise102 promise catch: ` + JSON.stringify(err));
expect().assertFail();
done()
});
}catch(err){
console.info('testSetImagePromise102 catch err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('------------------testSetImagePromise102 end----------------------');
})
......@@ -1201,16 +1238,8 @@ export default function wallpaperJSUnit() {
*/
it('testSetImagePromise103', 0, async function (done) {
console.info('------------------testSetImagePromise103 start----------------------');
const color = new ArrayBuffer(96);
let bufferArr = new Uint8Array(color);
let opts = {
editable: true,
pixelFormat: 3,
size: { height: 4, width: 6 }
}
console.log(`testSetImagePromise103 opts success`)
try{
image.createPixelMap(color, opts).then((pixelMap) => {
wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((pixelMap) => {
wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`testSetImagePromise103 success to setImage.`);
expect(true).assertTrue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册