diff --git a/multimedia/image/image_js_standard/imagePacking/src/main/js/test/packing.test.js b/multimedia/image/image_js_standard/imagePacking/src/main/js/test/packing.test.js index 386f4d22ffbdc3fcb5bf747587a6807f5c2e9f35..31b9ef6edb32cc422140e1940d129dc293b67804 100644 --- a/multimedia/image/image_js_standard/imagePacking/src/main/js/test/packing.test.js +++ b/multimedia/image/image_js_standard/imagePacking/src/main/js/test/packing.test.js @@ -21,6 +21,8 @@ import fileio from "@ohos.fileio"; export default function imagePacking() { describe("imagePacking", function () { let globalpixelmap; + let globalPacker; + let globalImagesource; let filePath; let fdNumber; async function getFd(fileName) { @@ -62,6 +64,22 @@ export default function imagePacking() { console.info("globalpixelmap release fail"); } } + if (globalImagesource != undefined) { + console.info("globalpixelmap 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"); }); @@ -92,6 +110,7 @@ export default function imagePacking() { console.info(`${testNum} create imagepacker fail`); done(); } else { + globalPacker = imagePackerApi; imagePackerApi .packing(pixelmap, arg) .then((data) => { @@ -142,6 +161,7 @@ export default function imagePacking() { console.info(`${testNum} create imagepacker fail`); done(); } else { + globalPacker = imagePackerApi; imagePackerApi.packing(pixelmap, arg, (err, data) => { if (err != undefined) { console.info(`${testNum} packing failerr: ${err}`); @@ -188,6 +208,7 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi.packing(pixelmap, arg, (err, data) => { expect(err != undefined).assertTrue(); done(); @@ -222,6 +243,7 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi .packing(pixelmap, arg) .then((data) => { @@ -563,12 +585,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_PROMISE_0100 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { format: "image/jpeg", quality: 99 }; imagePackerApi .packing(imageSourceApi, packOpts) @@ -611,12 +635,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0100 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { format: "image/jpeg", quality: 1 }; imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => { console.info( @@ -654,12 +680,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0200 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { format: "image/gif", quality: 98 }; imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0200 success"); @@ -696,12 +724,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0300 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { format: "image/jpeg", quality: 101 }; imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0300 success"); @@ -738,12 +768,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_CREATEIMAGEPACKER_0100 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; console.info("SUB_GRAPHIC_IMAGE_PACKING_CREATEIMAGEPACKER_0100 create image packer success"); expect(true).assertTrue(); done(); @@ -777,12 +809,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_PROMISE_0200 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { format: "image/jpeg" }; imagePackerApi .packing(imageSourceApi, packOpts) @@ -826,12 +860,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_PROMISE_0300 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { quality: 50 }; imagePackerApi .packing(imageSourceApi, packOpts) @@ -876,12 +912,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0400 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { format: "image/jpeg", quality: 100 }; imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => { if (err) { @@ -929,12 +967,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0500 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { format: "image/jpeg", quality: 0 }; imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0500 success"); @@ -970,12 +1010,14 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0600 create image packer failed"); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOpts = { format: "image/jpeg", quality: -1 }; imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => { console.info("SUB_GRAPHIC_IMAGE_PACKING_IMAGESOURCE_CALLBACK_0600 success"); @@ -1008,6 +1050,7 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi .release() .then(() => { @@ -1040,6 +1083,7 @@ export default function imagePacking() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi.release(() => { console.info("SUB_GRAPHIC_IMAGE_PACKING_RELEASE_IMAGEPACKER_CALLBACK_0100 success"); expect(true).assertTrue(); diff --git a/multimedia/image/image_js_standard/imagePixelMapFramework/src/main/js/test/framework.test.js b/multimedia/image/image_js_standard/imagePixelMapFramework/src/main/js/test/framework.test.js index 68d91b6be7f48fe51bccb3e5a29f724b3cf74769..a967a84e789d2b036c9a5d8302fb8a30631c3c4d 100644 --- a/multimedia/image/image_js_standard/imagePixelMapFramework/src/main/js/test/framework.test.js +++ b/multimedia/image/image_js_standard/imagePixelMapFramework/src/main/js/test/framework.test.js @@ -20,6 +20,7 @@ import { testPng, testJpg } from '../../../../../image/src/main/js/test/testImg' export default function imagePixelMapFramework() { describe('imagePixelMapFramework', function () { let globalpixelmap; + let globalImagesource; beforeAll(async function () { console.info('beforeAll case'); }) @@ -37,6 +38,14 @@ export default function imagePixelMapFramework() { console.info("globalpixelmap release fail"); } } + if (globalImagesource != undefined) { + console.info("globalpixelmap release start"); + try { + await globalImagesource.release(); + } catch (error) { + console.info("globalImagesource release fail"); + } + } console.info('afterEach case'); }) @@ -141,6 +150,7 @@ export default function imagePixelMapFramework() { async function checkAlphaPixelmap(done, logger, alphaPixelMap) { logger.log("AlphaPixelMap " + alphaPixelMap); if (alphaPixelMap != undefined) { + globalpixelmap = alphaPixelMap; var imageInfo = await alphaPixelMap.getImageInfo(); logger.log("AlphaPixelMap pixelformat " + imageInfo.pixelFormat); expect(imageInfo.pixelFormat == 6).assertTrue(); @@ -157,6 +167,7 @@ export default function imagePixelMapFramework() { let imageSource = image.createImageSource(imageData); logger.log("ImageSource " + (imageSource != undefined)); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(); logger.log("PixelMap " + pixelMap); if (pixelMap != undefined) { @@ -193,6 +204,7 @@ export default function imagePixelMapFramework() { let imageSource = image.createImageSource(imageData, sourceOptions); logger.log("ImageSource " + (imageSource != undefined)); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(decodingOptions); logger.log("PixelMap " + pixelMap); if (pixelMap != undefined) { @@ -225,6 +237,7 @@ export default function imagePixelMapFramework() { let imageSource = image.createImageSource(imageData, sourceOptions); logger.log("ImageSource " + (imageSource != undefined)); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(); logger.log("PixelMap " + pixelMap); if (pixelMap != undefined) { @@ -290,7 +303,7 @@ export default function imagePixelMapFramework() { async function opacityErr(done, testNum, param, type) { let logger = loger(testNum) try { - var pixelMap = await genPixelMap() + var pixelMap = await genPixelMap(); logger.log("pixelMap " + (pixelMap != undefined)); if (pixelMap != undefined) { globalpixelmap = pixelMap; @@ -327,6 +340,7 @@ export default function imagePixelMapFramework() { let imageSource = genPicSource(); logger.log("ImageSource " + (imageSource != undefined)); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(); logger.log("PixelMap " + pixelMap); if (pixelMap != undefined) { @@ -363,6 +377,7 @@ export default function imagePixelMapFramework() { let imageSource = image.createImageSource(imageData, sourceOptions); logger.log("ImageSource " + (imageSource != undefined)); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(); logger.log("PixelMap " + pixelMap); if (pixelMap != undefined) { @@ -417,20 +432,22 @@ export default function imagePixelMapFramework() { const imageSource = image.createImageSource(base64Image) logger.log("ImageSource " + (imageSource != undefined)); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(); globalpixelmap = pixelMap; logger.log("PixelMap " + (pixelMap != undefined)); expect(pixelMap != undefined).assertTrue(); + done(); } else { logger.log("ImageSource undefined"); expect(false).assertTrue(); + done(); } } catch (error) { logger.log('failed ' + error); expect(false).assertTrue(); done(); } - done(); }) /** @@ -670,6 +687,7 @@ export default function imagePixelMapFramework() { let imageSource = genPicSource(); logger.log("ImageSource " + (imageSource != undefined)); if (imageSource != undefined) { + globalImagesource = imageSource; let pixelMap = await imageSource.createPixelMap(); logger.log("PixelMap " + pixelMap); if (pixelMap != undefined) { diff --git a/multimedia/image/image_js_standard/imageRaw/src/main/js/test/raw.test.js b/multimedia/image/image_js_standard/imageRaw/src/main/js/test/raw.test.js index ffb6b23643ee7ab692f105636ae65af28f85e679..390da13fe8b02b79f458e269331376385bdfd7b1 100644 --- a/multimedia/image/image_js_standard/imageRaw/src/main/js/test/raw.test.js +++ b/multimedia/image/image_js_standard/imageRaw/src/main/js/test/raw.test.js @@ -20,6 +20,8 @@ import featureAbility from "@ohos.ability.featureAbility"; export default function imageRaw() { describe("imageRaw", function () { let globalpixelmap; + let globalImagesource; + let globalPacker; const RGBA_8888 = image.PixelMapFormat.RGBA_8888; let filePath; let fdNumber; @@ -62,6 +64,22 @@ export default function imageRaw() { console.info("globalpixelmap release fail"); } } + if (globalImagesource != undefined) { + console.info("globalpixelmap 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"); }); @@ -78,6 +96,7 @@ export default function imageRaw() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; let packOptsFormat = `format:` + packOpts.format; let packOptsQuality = `quality:` + packOpts.quality; console.info( @@ -134,6 +153,7 @@ export default function imageRaw() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; console.info(`${testNum} createPixelMapPromise create imagesource success`); imageSourceApi .createPixelMap(decodeOpts) @@ -172,6 +192,7 @@ export default function imageRaw() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; console.info(`${testNum} createPixelMapPromise create imagesource success`); imageSourceApi.createPixelMap(decodeOpts, (err, pixelmap) => { if (pixelmap != undefined) { @@ -203,6 +224,7 @@ export default function imageRaw() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; console.info(`${testNum} createPixelMapPromise create imagesource success`); imageSourceApi.createPixelMap(decodeOpts, (err, pixelmap) => { if (pixelmap == undefined) { @@ -232,6 +254,7 @@ export default function imageRaw() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; console.info(`${testNum} createPixelMapPromise create imagesource success`); imageSourceApi .createPixelMap(decodeOpts) diff --git a/multimedia/image/image_js_standard/imageReceiver/src/main/js/test/receiver.test.js b/multimedia/image/image_js_standard/imageReceiver/src/main/js/test/receiver.test.js index f784151be1a6c20db6e268226b3caa49f158c32e..58b2acb14df8b674fc19061f824bcb58e2fa92ad 100644 --- a/multimedia/image/image_js_standard/imageReceiver/src/main/js/test/receiver.test.js +++ b/multimedia/image/image_js_standard/imageReceiver/src/main/js/test/receiver.test.js @@ -18,6 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from export default function ImageReceiver() { describe("ImageReceiver", function () { let globalreceiver; + let globalImg; const WIDTH = 8192; const HEIGHT = 8; const CAPACITY = 8; @@ -35,6 +36,14 @@ export default function ImageReceiver() { }); afterEach(async function () { + if (globalImg != undefined) { + console.info("globalImg release start"); + try { + await globalImg.release(); + } catch (error) { + console.info("globalImg release fail"); + } + } if (globalreceiver != undefined) { console.info("globalreceiver release start"); try { @@ -98,6 +107,7 @@ export default function ImageReceiver() { done(); return; } else { + globalImg = img; expect(img.size.width == WIDTH).assertTrue(); expect(img.size.height == HEIGHT).assertTrue(); console.log(`${testNum} img.format: ${img.format}`) @@ -150,6 +160,7 @@ export default function ImageReceiver() { done(); return; } else { + globalImg = img; expect(img.size.width == WIDTH).assertTrue(); expect(img.size.height == HEIGHT).assertTrue(); console.log(`${testNum} img.format: ${img.format}`) @@ -202,6 +213,7 @@ export default function ImageReceiver() { done(); return; } else { + globalImg = img; expect(img.size.width == WIDTH).assertTrue(); expect(img.size.height == HEIGHT).assertTrue(); checkFormat(img.format); @@ -261,6 +273,7 @@ export default function ImageReceiver() { done(); return; } else { + globalImg = img; expect(img.size.width == WIDTH).assertTrue(); expect(img.size.height == HEIGHT).assertTrue(); checkFormat(img.format); @@ -731,6 +744,7 @@ export default function ImageReceiver() { receiver .readLatestImage() .then((img) => { + globalImg = img; console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_PROMISE_0100 readLatestImage Success"); expect(img != undefined).assertTrue(); done(); @@ -772,6 +786,7 @@ export default function ImageReceiver() { if (receiver != undefined) { globalreceiver = receiver; receiver.readLatestImage((err, img) => { + globalImg = img; console.info( "SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_CALLBACK_0100 readLatestImage call back Success" ); @@ -812,6 +827,7 @@ export default function ImageReceiver() { receiver .readNextImage() .then((img) => { + globalImg = img; console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_PROMISE_0100 readNextImage Success"); expect(img != undefined).assertTrue(); done(); @@ -858,6 +874,7 @@ export default function ImageReceiver() { done(); return; } else { + globalImg = img; console.info( "SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_CALLBACK_0100 readNextImage call back Success" ); @@ -1016,6 +1033,7 @@ export default function ImageReceiver() { done(); return; } else { + globalImg = img; expect(img.size.width == WIDTH).assertTrue(); expect(img.size.height == HEIGHT).assertTrue(); expect(img.format == RGBA).assertTrue(); @@ -1082,7 +1100,7 @@ export default function ImageReceiver() { done(); return; } - + globalImg = img; expect(img.size.width == WIDTH).assertTrue(); expect(img.size.height == HEIGHT).assertTrue(); expect(img.format == RGBA).assertTrue(); diff --git a/multimedia/image/image_js_standard/imageWebp/src/main/js/test/webp.test.js b/multimedia/image/image_js_standard/imageWebp/src/main/js/test/webp.test.js index 5c5415068700e787c88d1f332dc797691feaf738..ad0ed39de1da78d65dddde5a70d7b7bf1ad0a1e5 100644 --- a/multimedia/image/image_js_standard/imageWebp/src/main/js/test/webp.test.js +++ b/multimedia/image/image_js_standard/imageWebp/src/main/js/test/webp.test.js @@ -21,6 +21,8 @@ import featureAbility from "@ohos.ability.featureAbility"; export default function imageWebp() { describe("imageWebp", function () { let globalpixelmap; + let globalImagesource; + let globalPacker; let filePath; async function getFd(fileName) { let context = await featureAbility.getContext(); @@ -47,6 +49,22 @@ export default function imageWebp() { console.info("globalpixelmap release fail"); } } + if (globalImagesource != undefined) { + console.info("globalpixelmap 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"); }); @@ -62,6 +80,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi.createPixelMap(arg, (err, pixelmap) => { if (pixelmap == undefined) { expect(true).assertTrue(); @@ -83,6 +102,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi.createPixelMap(arg, (err, pixelmap) => { if (err) { console.info(`${testNum} - fail ${err}`); @@ -116,6 +136,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi .createPixelMap(arg) .then((pixelmap) => { @@ -138,6 +159,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi .createPixelMap(arg) .then((pixelmap) => { @@ -224,6 +246,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi .packing(pixelmap, arg) .then((data) => { @@ -309,6 +332,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi.packing(pixelmap, arg, (err, data) => { console.info(`${testNum} success`); expect(data != undefined).assertTrue(); @@ -390,6 +414,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi .packing(pixelmap, arg) .then((data) => { @@ -469,6 +494,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi.packing(pixelmap, arg, (err, data) => { console.info(`${testNum} success`); expect(data == undefined).assertTrue(); @@ -505,6 +531,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; let decodingOptions = { sampleSize: 1, editable: true, @@ -554,6 +581,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; let decodingOptions = { sampleSize: 1, editable: true, @@ -603,6 +631,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi .createPixelMap() .then((pixelmap) => { @@ -642,6 +671,7 @@ export default function imageWebp() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSourceApi; imageSourceApi.createPixelMap((err, pixelmap) => { globalpixelmap = pixelmap; expect(pixelmap != undefined).assertTrue(); diff --git a/multimedia/image/image_js_standard/imageYUV/src/main/js/test/yuv.test.js b/multimedia/image/image_js_standard/imageYUV/src/main/js/test/yuv.test.js index 5b95ddb37266273d55101972a216f60f8a1e3f2a..feb21c1798dd9fbf47a1be241f7b49947fc04ec2 100644 --- a/multimedia/image/image_js_standard/imageYUV/src/main/js/test/yuv.test.js +++ b/multimedia/image/image_js_standard/imageYUV/src/main/js/test/yuv.test.js @@ -19,6 +19,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from export default function imageYuv() { describe("imageYuv", function () { let globalpixelmap; + let globalImagesource; + let globalPacker; const { NV21, NV12 } = image.PixelMapFormat; const WRONG_FORMAT = 10; @@ -40,6 +42,22 @@ export default function imageYuv() { console.info("globalpixelmap release fail"); } } + if (globalImagesource != undefined) { + console.info("globalpixelmap 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"); }); @@ -77,6 +95,7 @@ export default function imageYuv() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSource; imageSource .createPixelMap() .then((pixelmap) => { @@ -121,6 +140,7 @@ export default function imageYuv() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSource; imageSource .createPixelMap() .then((pixelmap) => { @@ -149,6 +169,7 @@ export default function imageYuv() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSource; imageSource.createPixelMap((err, pixelmap) => { if (err != undefined || pixelmap == undefined) { console.info(`${testNum} err2: ` + err); @@ -187,6 +208,7 @@ export default function imageYuv() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSource; imageSource.createPixelMap((err, pixelmap) => { if (err != undefined || pixelmap == undefined) { console.info(`${testNum} err: ` + err); @@ -212,12 +234,14 @@ export default function imageYuv() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSource; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info(`${testNum} create ImagePacker failed`); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi .packing(imageSource, arg) .then((data) => { @@ -251,12 +275,14 @@ export default function imageYuv() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSource; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info(`${testNum} create ImagePacker failed`); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi .packing(imageSource, arg) .then((data) => { @@ -279,12 +305,14 @@ export default function imageYuv() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSource; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info(`${testNum} create ImagePacker failed`); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi.packing(imageSource, arg, (err, data) => { if (err != undefined) { expect(false).assertTrue(); @@ -315,12 +343,14 @@ export default function imageYuv() { expect(false).assertTrue(); done(); } else { + globalImagesource = imageSource; const imagePackerApi = image.createImagePacker(); if (imagePackerApi == undefined) { console.info(`${testNum} create ImagePacker failed`); expect(false).assertTrue(); done(); } else { + globalPacker = imagePackerApi; imagePackerApi.packing(imageSource, arg, (err, data) => { expect(err != undefined || data == undefined).assertTrue(); done();