diff --git a/multimedia/image/image_js_standard/imageColorspace/src/main/js/test/P3.test.js b/multimedia/image/image_js_standard/imageColorspace/src/main/js/test/P3.test.js index 175ed43865a82679724be055f8ffa3d85bcc1c09..a2baf2860cd9b869295bd8ff3f9c977aca5e4722 100644 --- a/multimedia/image/image_js_standard/imageColorspace/src/main/js/test/P3.test.js +++ b/multimedia/image/image_js_standard/imageColorspace/src/main/js/test/P3.test.js @@ -25,6 +25,8 @@ export default function ImageP3() { const COLORSPACENAME = 5; let filePath; let fdNumber; + let globalpixelmap; + let globalImagesource; async function getFd(fileName) { let context = await featureAbility.getContext(); await context.getFilesDir().then((data) => { @@ -51,6 +53,22 @@ export default function ImageP3() { }); afterEach(async function () { + if (globalpixelmap != undefined) { + console.info("globalpixelmap release start"); + try { + await globalpixelmap.release(); + } catch (error) { + console.info("globalpixelmap release fail"); + } + } + if (globalImagesource != undefined) { + console.info("globalImagesource release start"); + try { + await globalImagesource.release(); + } catch (error) { + console.info("globalImagesource release fail"); + } + } console.info("afterEach case"); }); @@ -77,7 +95,9 @@ export default function ImageP3() { try { logger.log("ImageSource " + (imageSource != undefined)); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(); + globalpixelmap = pixelMap; logger.log("PixelMap " + pixelMap); var csm = colorSpaceManager.create(colorSpaceName); logger.log("colorSpaceManager.ColorSpace: " + colorSpaceName); @@ -115,7 +135,9 @@ export default function ImageP3() { try { let imageSource = GenPicSource(testImg); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(); + globalpixelmap = pixelMap; var csm = pixelMap.getColorSpace(); logger.log("getColorSpace csm " + csm); var csmn = csm.getColorSpaceName(); diff --git a/multimedia/image/image_js_standard/imageColorspace/src/main/js/test/colorspace.test.js b/multimedia/image/image_js_standard/imageColorspace/src/main/js/test/colorspace.test.js index d9b6f06122e731fcdbce1cb4f28e016189cb0e3a..c64b1157f47a061055fe3a6f2eba6f0c398cd30b 100644 --- a/multimedia/image/image_js_standard/imageColorspace/src/main/js/test/colorspace.test.js +++ b/multimedia/image/image_js_standard/imageColorspace/src/main/js/test/colorspace.test.js @@ -18,374 +18,413 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from import { iccbuf } from './testImg2' export default function imageColorSpace() { -describe('imageColorSpace', function () { - beforeAll(async function () { - console.info('beforeAll case'); - }) + describe('imageColorSpace', function () { + let globalpixelmap; + let globalImagesource; + let globalPacker; + beforeAll(async function () { + console.info('beforeAll case'); + }) - beforeEach(function () { - console.info('beforeEach case'); - }) + beforeEach(function () { + console.info('beforeEach case'); + }) - afterEach(async function () { - console.info('afterEach case'); - }) + afterEach(async function () { + if (globalpixelmap != undefined) { + console.info("globalpixelmap release start"); + try { + await globalpixelmap.release(); + } catch (error) { + console.info("globalpixelmap release fail"); + } + } + if (globalImagesource != undefined) { + console.info("globalImagesource release start"); + try { + await globalImagesource.release(); + } catch (error) { + console.info("globalImagesource release fail"); + } + } + if (globalPacker != undefined) { + console.info("globalPacker release start"); + try { + await globalPacker.release(); + } catch (error) { + console.info("globalPacker release fail"); + } + } + console.info('afterEach case'); + }) - afterAll(async function () { - console.info('afterAll case'); - }) + afterAll(async function () { + console.info('afterAll case'); + }) - function genPicSource() { - var data = iccbuf.buffer; - return image.createImageSource(data); - } + function genPicSource() { + var data = iccbuf.buffer; + return image.createImageSource(data); + } - function loger(caseName) { - return { - myName: caseName, - log:function(msg) { - console.info(this.myName+ ' ' + msg); + function loger(caseName) { + return { + myName: caseName, + log: function (msg) { + console.info(this.myName + ' ' + msg); + } } } - } - async function packingCbFail(done, testNum, args){ - let logger = loger(`${testNum}`) - try { - let imageSource = genPicSource(); - logger.log("ImageSource " + (imageSource != undefined)); - if (imageSource == undefined) { - console.info(`${testNum} create image source failed`); - expect(false).assertTrue(); - done(); - }else{ - const imagePackerApi = image.createImagePacker(); - if (imagePackerApi == undefined) { - console.info(`${testNum} create image packer failed`); - expect(false).assertTrue(); - done(); - }else{ - imagePackerApi.packing(imageSource, args, (err, data) => { - expect(data == undefined).assertTrue(); + async function packingCbFail(done, testNum, args) { + let logger = loger(`${testNum}`) + try { + let imageSource = genPicSource(); + logger.log("ImageSource " + (imageSource != undefined)); + if (imageSource == undefined) { + console.info(`${testNum} create image source failed`); + expect(false).assertTrue(); done(); - }) - } - } - } catch (error) { - logger.log('failed ' + error); - expect(false).assertTrue(); - done(); - } - } - - async function packingPromiseFail(done, testNum, args) { - let logger = loger(`testNum`) - try { - let imageSource = genPicSource(); - logger.log("ImageSource " + (imageSource != undefined)); - if (imageSource == undefined) { - console.info(`${testNum} create image source failed`); - expect(false).assertTrue(); - done(); - }else{ - const imagePackerApi = image.createImagePacker(); - if (imagePackerApi == undefined) { - console.info(`${testNum} create image packer failed`); + } else { + globalImagesource = imageSource; + const imagePackerApi = image.createImagePacker(); + if (imagePackerApi == undefined) { + console.info(`${testNum} create image packer failed`); + expect(false).assertTrue(); + done(); + } else { + globalPacker = imagePackerApi; + imagePackerApi.packing(imageSource, args, (err, data) => { + expect(data == undefined).assertTrue(); + done(); + }) + } + } + } catch (error) { + logger.log('failed ' + error); expect(false).assertTrue(); done(); - }else{ - imagePackerApi.packing(imageSource, args).then(data => { - expect(data == undefined).assertTrue(); - done(); - }).catch(error => { - console.log(` ${testNum} error: ` + error); - expect(true).assertTrue(); - done(); - }) } } - } catch (error) { - logger.log('failed ' + error); - expect(false).assertTrue(); - done(); - } - } - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_0100 - * @tc.name : Decode - * @tc.desc : 1.create imagesource - * 2.create pixelmap - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_0100', 0, async function (done) { - let logger = loger('SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_0100') - try { - let imageSource = genPicSource(); - logger.log("ImageSource " + (imageSource != undefined)); - if (imageSource != undefined) { - let pixelMap = await imageSource.createPixelMap(); - logger.log("PixelMap " + pixelMap); - logger.log("PixelMap " + (pixelMap != undefined)); - expect(pixelMap != undefined ).assertTrue(); + async function packingPromiseFail(done, testNum, args) { + let logger = loger(`testNum`) + try { + let imageSource = genPicSource(); + logger.log("ImageSource " + (imageSource != undefined)); + if (imageSource == undefined) { + console.info(`${testNum} create image source failed`); + expect(false).assertTrue(); + done(); + } else { + globalImagesource = imageSource; + const imagePackerApi = image.createImagePacker(); + if (imagePackerApi == undefined) { + console.info(`${testNum} create image packer failed`); + expect(false).assertTrue(); + done(); + } else { + globalPacker = imagePackerApi; + imagePackerApi.packing(imageSource, args).then(data => { + expect(data == undefined).assertTrue(); + done(); + }).catch(error => { + console.log(` ${testNum} error: ` + error); + expect(true).assertTrue(); + done(); + }) + } + } + } catch (error) { + logger.log('failed ' + error); + expect(false).assertTrue(); done(); } - } catch (error) { - logger.log('failed ' + error); - expect(false).assertTrue(); - done(); } - - }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_CALLBACK_0100 - * @tc.name : Decode -callback - * @tc.desc : 1.create imagesource - * 2.create pixelmap - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_CALLBACK_0100', 0, async function (done) { - let logger = loger('SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_CALLBACK_0100') - try { - let imageSource = genPicSource(); - logger.log("ImageSource " + (imageSource != undefined)); - if (imageSource != undefined) { - imageSource.createPixelMap((err,pixelMap)=>{ + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_0100 + * @tc.name : Decode + * @tc.desc : 1.create imagesource + * 2.create pixelmap + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_0100', 0, async function (done) { + let logger = loger('SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_0100') + try { + let imageSource = genPicSource(); + logger.log("ImageSource " + (imageSource != undefined)); + if (imageSource != undefined) { + globalImagesource = imageSource; + let pixelMap = await imageSource.createPixelMap(); + globalpixelmap = pixelMap; logger.log("PixelMap " + pixelMap); logger.log("PixelMap " + (pixelMap != undefined)); - expect(pixelMap != undefined ).assertTrue(); + expect(pixelMap != undefined).assertTrue(); done(); - }) - } - } catch (error) { - logger.log('failed ' + error); - expect(false).assertTrue(); - done(); - } - }) - - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0100 - * @tc.name : Encode -callback - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0100', 0, async function (done) { - let logger = loger('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0100') - let testNum = 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0100' - try { - let imageSource = genPicSource(); - logger.log("ImageSource " + (imageSource != undefined)); - if (imageSource == undefined) { - console.info(`${testNum} create image source failed`); - expect(false).assertTrue(); - done(); - }else{ - const imagePackerApi = image.createImagePacker(); - if (imagePackerApi == undefined) { - console.info(`${testNum} create image packer failed`); + } + } catch (error) { + logger.log('failed ' + error); expect(false).assertTrue(); done(); - }else{ - let packOpts = { format:["image/jpeg"], quality:90 } - imagePackerApi.packing(imageSource, packOpts, (err, data) => { - expect(data != undefined).assertTrue(); - var dataArr = new Uint8Array(data); - console.info(`${testNum} dataArr.length=` + dataArr.length); - for (var i = 0; i < dataArr.length; i++) { - console.info(`dataArr[` + i + `]=` + dataArr[i]); - } - done(); - }) } - } - } catch (error) { - logger.log('failed ' + error); - expect(false).assertTrue(); - done(); - } - - }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100 - * @tc.name : Encode -promise - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100', 0, async function (done) { - let logger = loger('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100') - let testNum = 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100' - try { - let imageSource = genPicSource(); - logger.log("ImageSource " + (imageSource != undefined)); - if (imageSource == undefined) { - console.info(`${testNum} create image source failed`); + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_CALLBACK_0100 + * @tc.name : Decode -callback + * @tc.desc : 1.create imagesource + * 2.create pixelmap + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_CALLBACK_0100', 0, async function (done) { + let logger = loger('SUB_GRAPHIC_IMAGE_COLORSPACE_DECODE_CALLBACK_0100') + try { + let imageSource = genPicSource(); + logger.log("ImageSource " + (imageSource != undefined)); + if (imageSource != undefined) { + globalImagesource = imageSource; + imageSource.createPixelMap((err, pixelMap) => { + globalpixelmap = pixelMap; + logger.log("PixelMap " + pixelMap); + logger.log("PixelMap " + (pixelMap != undefined)); + expect(pixelMap != undefined).assertTrue(); + done(); + }) + } + } catch (error) { + logger.log('failed ' + error); expect(false).assertTrue(); done(); - }else{ - const imagePackerApi = image.createImagePacker(); - if (imagePackerApi == undefined) { - console.info(`${testNum} create image packer failed`); + } + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0100 + * @tc.name : Encode -callback + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0100', 0, async function (done) { + let logger = loger('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0100') + let testNum = 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0100' + try { + let imageSource = genPicSource(); + logger.log("ImageSource " + (imageSource != undefined)); + if (imageSource == undefined) { + console.info(`${testNum} create image source failed`); + expect(false).assertTrue(); + done(); + } else { + globalImagesource = imageSource; + const imagePackerApi = image.createImagePacker(); + if (imagePackerApi == undefined) { + console.info(`${testNum} create image packer failed`); + expect(false).assertTrue(); + done(); + } else { + globalPacker = imagePackerApi; + let packOpts = { format: ["image/jpeg"], quality: 90 } + imagePackerApi.packing(imageSource, packOpts, (err, data) => { + expect(data != undefined).assertTrue(); + var dataArr = new Uint8Array(data); + console.info(`${testNum} dataArr.length=` + dataArr.length); + for (var i = 0; i < dataArr.length; i++) { + console.info(`dataArr[` + i + `]=` + dataArr[i]); + } + done(); + }) + } + } + } catch (error) { + logger.log('failed ' + error); expect(false).assertTrue(); done(); - }else{ - let packOpts = { format:["image/jpeg"], quality:90 } - imagePackerApi.packing(imageSource, packOpts).then(data => { - expect(data != undefined).assertTrue(); - var dataArr = new Uint8Array(data); - console.info(`${testNum} dataArr.length=` + dataArr.length); - for (var i = 0; i < dataArr.length; i++) { - console.info(`dataArr[` + i + `]=` + dataArr[i]); - } - - done(); - }).catch(error => { - console.log('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100 error: ' + error); + } + + }) + + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100 + * @tc.name : Encode -promise + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100', 0, async function (done) { + let logger = loger('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100') + let testNum = 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100' + try { + let imageSource = genPicSource(); + logger.log("ImageSource " + (imageSource != undefined)); + if (imageSource == undefined) { + console.info(`${testNum} create image source failed`); expect(false).assertTrue(); done(); - }) + } else { + globalImagesource = imageSource; + const imagePackerApi = image.createImagePacker(); + if (imagePackerApi == undefined) { + console.info(`${testNum} create image packer failed`); + expect(false).assertTrue(); + done(); + } else { + globalPacker = imagePackerApi; + let packOpts = { format: ["image/jpeg"], quality: 90 } + imagePackerApi.packing(imageSource, packOpts).then(data => { + expect(data != undefined).assertTrue(); + var dataArr = new Uint8Array(data); + console.info(`${testNum} dataArr.length=` + dataArr.length); + for (var i = 0; i < dataArr.length; i++) { + console.info(`dataArr[` + i + `]=` + dataArr[i]); + } + + done(); + }).catch(error => { + console.log('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0100 error: ' + error); + expect(false).assertTrue(); + done(); + }) + } + } + } catch (error) { + logger.log('failed ' + error); + expect(false).assertTrue(); + done(); } - } - } catch (error) { - logger.log('failed ' + error); - expect(false).assertTrue(); - done(); - } - }) + }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0200 - * @tc.name : Encode -callback- - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0200', 0, async function (done) { - let packOpts = { format:["image/gif"], quality:90 } - packingCbFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0200', packOpts) - }) + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0200 + * @tc.name : Encode -callback- + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0200', 0, async function (done) { + let packOpts = { format: ["image/gif"], quality: 90 } + packingCbFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_0200', packOpts) + }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_ERROR_FORMAT_0100 - * @tc.name : Encode -callback-wrong format - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_ERROR_FORMAT_0100', 0, async function (done) { - let packOpts = { format:["image/jpeg"], quality:200 } - packingCbFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_ERROR_FORMAT_0100', packOpts) - }) + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_ERROR_FORMAT_0100 + * @tc.name : Encode -callback-wrong format + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_ERROR_FORMAT_0100', 0, async function (done) { + let packOpts = { format: ["image/jpeg"], quality: 200 } + packingCbFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_ERROR_FORMAT_0100', packOpts) + }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_QUALITY_0100 - * @tc.name : Encode -callback-no quality - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_QUALITY_0100', 0, async function (done) { - let packOpts = { format:["image/jpeg"] } - packingCbFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_QUALITY_0100', packOpts) - }) + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_QUALITY_0100 + * @tc.name : Encode -callback-no quality + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_QUALITY_0100', 0, async function (done) { + let packOpts = { format: ["image/jpeg"] } + packingCbFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_QUALITY_0100', packOpts) + }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_FORMAT_0100 - * @tc.name : Encode -callback-no format - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_FORMAT_0100', 0, async function (done) { - let packOpts = { quality:50 } - packingCbFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_FORMAT_0100', packOpts) - }) - - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0200 - * @tc.name : Encode -promise - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0200', 0, async function (done) { - let packOpts = { format:["image/gif"], quality:90 } - packingPromiseFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0200', packOpts) - }) + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_FORMAT_0100 + * @tc.name : Encode -callback-no format + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_FORMAT_0100', 0, async function (done) { + let packOpts = { quality: 50 } + packingCbFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_CALLBACK_NO_FORMAT_0100', packOpts) + }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0300 - * @tc.name : Encode -promise - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0300', 0, async function (done) { - let packOpts = { format:["image/jpeg"], quality:101 } - packingPromiseFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0300', packOpts) - }) + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0200 + * @tc.name : Encode -promise + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0200', 0, async function (done) { + let packOpts = { format: ["image/gif"], quality: 90 } + packingPromiseFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0200', packOpts) + }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_QUALITY_0100 - * @tc.name : Encode -promise -no quality - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_QUALITY_0100', 0, async function (done) { - let packOpts = { format:["image/jpeg"] } - packingPromiseFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_QUALITY_0100', packOpts) - }) + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0300 + * @tc.name : Encode -promise + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0300', 0, async function (done) { + let packOpts = { format: ["image/jpeg"], quality: 101 } + packingPromiseFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_0300', packOpts) + }) - /** - * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_FORMAT_0100 - * @tc.name : Encode -promise -no format - * @tc.desc : 1.create imagesource - * 2.createImagePacker - * 3.packing - * @tc.size : MEDIUM - * @tc.type : Functional - * @tc.level : Level 1 - */ - it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_FORMAT_0100', 0, async function (done) { - let packOpts = { quality:100 } - packingPromiseFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_FORMAT_0100', packOpts) - }) + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_QUALITY_0100 + * @tc.name : Encode -promise -no quality + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_QUALITY_0100', 0, async function (done) { + let packOpts = { format: ["image/jpeg"] } + packingPromiseFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_QUALITY_0100', packOpts) + }) -}) + /** + * @tc.number : SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_FORMAT_0100 + * @tc.name : Encode -promise -no format + * @tc.desc : 1.create imagesource + * 2.createImagePacker + * 3.packing + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_FORMAT_0100', 0, async function (done) { + let packOpts = { quality: 100 } + packingPromiseFail(done, 'SUB_GRAPHIC_IMAGE_COLORSPACE_ENCODE_PROMISE_NO_FORMAT_0100', packOpts) + }) + + }) } diff --git a/multimedia/image/image_js_standard/imageCreator/src/main/js/test/creator.test.js b/multimedia/image/image_js_standard/imageCreator/src/main/js/test/creator.test.js index 35ea2c9b32ee2e3a4b951a03d6c4f237279b734d..0af5d4106190871e381eea2ca446495f66f0ab32 100644 --- a/multimedia/image/image_js_standard/imageCreator/src/main/js/test/creator.test.js +++ b/multimedia/image/image_js_standard/imageCreator/src/main/js/test/creator.test.js @@ -17,7 +17,8 @@ import image from '@ohos.multimedia.image' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' describe('ImageCreator', function () { - + let globalCreator; + let globalImg; const JPEG = 4; const WIDTH = 8192; const HEIGHT = 8; @@ -32,7 +33,23 @@ describe('ImageCreator', function () { console.info('beforeEach case'); }) - afterEach(function () { + afterEach(async function () { + if (globalCreator != undefined) { + console.info("globalCreator release start"); + try { + await globalCreator.release(); + } catch (error) { + console.info("globalCreator release fail"); + } + } + if (globalImg != undefined) { + console.info("globalImg release start"); + try { + await globalImg.release(); + } catch (error) { + console.info("globalImg release fail"); + } + } console.info('afterEach case'); }) @@ -58,6 +75,7 @@ describe('ImageCreator', function () { expect(false).assertTrue(); done(); } else { + globalCreator = creator; try { creator.on(param, (err) => { expect(false).assertTrue(); @@ -74,12 +92,14 @@ describe('ImageCreator', function () { async function queueImageError(done, testNum, param) { var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY); if (creator != undefined) { + globalCreator = creator; creator.dequeueImage().then(img => { if (img == undefined) { expect(false).assertTrue(); done(); return } + globalImg = img; img.getComponent(JPEG, async (err, component) => { if (err) { expect(false).assertTrue(); @@ -123,11 +143,13 @@ describe('ImageCreator', function () { async function queueImageCbError(done, testNum, param) { var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY); if (creator != undefined) { + globalCreator = creator; creator.dequeueImage().then(img => { if (img == undefined) { expect(false).assertTrue(); done() } else { + globalImg = img; img.getComponent(JPEG, (err, component) => { if (err) { expect(false).assertTrue(); @@ -187,6 +209,7 @@ describe('ImageCreator', function () { console.info('SUB_GRAPHIC_IMAGE_CREATOR_CREATEIMAGECREATOR_0100 undefined') done(); } else { + globalCreator = creator; expect(creator.size.width == WIDTH).assertTrue(); expect(creator.size.height == HEIGHT).assertTrue(); expect(creator.capacity == CAPACITY).assertTrue(); @@ -335,6 +358,7 @@ describe('ImageCreator', function () { it('SUB_GRAPHIC_IMAGE_CREATOR_RELEASE_PROMISE_0100', 0, async function (done) { var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY); if (creator != undefined) { + globalCreator = creator; creator.release().then(() => { console.info('SUB_GRAPHIC_IMAGE_CREATOR_RELEASE_PROMISE_0100 release '); expect(true).assertTrue(); @@ -363,6 +387,7 @@ describe('ImageCreator', function () { it('SUB_GRAPHIC_IMAGE_CREATOR_RELEASE_CALLBACK_0100', 0, async function (done) { var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY); if (creator != undefined) { + globalCreator = creator; creator.release((err) => { if (err) { console.info('SUB_GRAPHIC_IMAGE_CREATOR_RELEASE_CALLBACK_0100 release call back' + err); @@ -394,9 +419,11 @@ describe('ImageCreator', function () { it('SUB_GRAPHIC_IMAGE_CREATOR_DEQUEUEIMAGE_PROMISE_0100', 0, async function (done) { var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY); if (creator != undefined) { + globalCreator = creator; creator.dequeueImage().then(img => { console.info('SUB_GRAPHIC_IMAGE_CREATOR_DEQUEUEIMAGE_PROMISE_0100 dequeueImage Success'); expect(img != undefined).assertTrue(); + globalImg = img; done(); }).catch(error => { console.log('SUB_GRAPHIC_IMAGE_CREATOR_DEQUEUEIMAGE_PROMISE_0100 error: ' + error); @@ -423,6 +450,7 @@ describe('ImageCreator', function () { it('SUB_GRAPHIC_IMAGE_CREATOR_DEQUEUEIMAGE_CALLBACK_0100', 0, async function (done) { var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY); if (creator != undefined) { + globalCreator = creator; creator.dequeueImage((err, img) => { if (err) { console.info('SUB_GRAPHIC_IMAGE_CREATOR_DEQUEUEIMAGE_CALLBACK_0100 err:' + err); @@ -430,6 +458,7 @@ describe('ImageCreator', function () { done(); return; } + globalImg = img; console.info('SUB_GRAPHIC_IMAGE_CREATOR_DEQUEUEIMAGE_CALLBACK_0100 dequeueImage call back Success'); expect(img != undefined).assertTrue(); done(); @@ -455,12 +484,14 @@ describe('ImageCreator', function () { it('SUB_GRAPHIC_IMAGE_CREATOR_QUEUEIMAGE_PROMISE_0200', 0, async function (done) { var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY); if (creator != undefined) { + globalCreator = creator; creator.dequeueImage().then(img => { if (img == undefined) { expect(false).assertTrue(); done(); return; } + globalImg = img; img.getComponent(JPEG, (err, component) => { if (err) { expect(false).assertTrue(); @@ -564,6 +595,7 @@ describe('ImageCreator', function () { it('SUB_GRAPHIC_IMAGE_CREATOR_QUEUEIMAGE_CALLBACK_0200', 0, async function (done) { var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY); if (creator != undefined) { + globalCreator = creator; creator.dequeueImage((err, img) => { if (err || img == undefined) { console.log('SUB_GRAPHIC_IMAGE_CREATOR_QUEUEIMAGE_CALLBACK_0200 dequeueImage error:' + err); @@ -571,7 +603,7 @@ describe('ImageCreator', function () { done(); return; } - + globalImg = img; img.getComponent(JPEG, (err, component) => { if (err) { expect(false).assertTrue(); @@ -687,6 +719,7 @@ describe('ImageCreator', function () { done() return; } + globalCreator = creator; creator.on('imageRelease', (err) => { if (err) { console.info('SUB_GRAPHIC_IMAGE_CREATOR_ON_0100 on release faild' + err); @@ -705,6 +738,7 @@ describe('ImageCreator', function () { done(); return; } + globalImg = img; img.getComponent(JPEG, (err, component) => { if (err || component == undefined) { console.info('SUB_GRAPHIC_IMAGE_CREATOR_ON_0100 getComponent err:' + err); diff --git a/multimedia/image/image_js_standard/imageModifyProperty/src/main/js/test/modify.test.js b/multimedia/image/image_js_standard/imageModifyProperty/src/main/js/test/modify.test.js index 4eaafc4de6d8fc0d1509867dcd035eeeaef32e77..f8045c57f39e5e2098563a881d2f40df2a7e52fb 100644 --- a/multimedia/image/image_js_standard/imageModifyProperty/src/main/js/test/modify.test.js +++ b/multimedia/image/image_js_standard/imageModifyProperty/src/main/js/test/modify.test.js @@ -21,6 +21,7 @@ import featureAbility from "@ohos.ability.featureAbility"; export default function imageModifyProperty() { describe("imageModifyProperty", function () { + let globalImagesource; let filePath; async function getFd(fileName) { let context = await featureAbility.getContext(); @@ -38,6 +39,14 @@ export default function imageModifyProperty() { }); afterEach(async function () { + if (globalImagesource != undefined) { + console.info("globalImagesource release start"); + try { + await globalImagesource.release(); + } catch (error) { + console.info("globalImagesource release fail"); + } + } console.info("afterEach case"); }); @@ -59,6 +68,7 @@ export default function imageModifyProperty() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi .modifyImageProperty(key, value) .then(() => { @@ -97,6 +107,7 @@ export default function imageModifyProperty() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi.modifyImageProperty(key, value, (error) => { if (error) { expect(false).assertTrue(); @@ -131,6 +142,7 @@ export default function imageModifyProperty() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; let property = { index: 0, defaultValue: "1" }; imageSourceApi.modifyImageProperty(key, value, property, (error) => { if (error) { @@ -166,6 +178,7 @@ export default function imageModifyProperty() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi.modifyImageProperty(key, value, (error) => { expect(error.code != 0).assertTrue(); console.info(`${testNum} errormsg: ` + error); @@ -188,6 +201,7 @@ export default function imageModifyProperty() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; let property = { index: 0, defaultValue: "1" }; imageSourceApi.modifyImageProperty(key, value, property, (error) => { expect(error.code != 0).assertTrue(); @@ -217,6 +231,7 @@ export default function imageModifyProperty() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi .modifyImageProperty(key, value) .then(() => {