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 595d14efb128f068e86bf58dfa2f6ef7cc6f2d94..43c1bd1aa7616eb6ab56c0e8903262cd7d4b037c 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 @@ -21,6 +21,9 @@ export default function ImageReceiver() { const HEIGHT = 8; const CAPACITY = 8; const RGBA = 12; + const YCBCR = 22; + const Jpg_YStride = 1; + const UVStride = 2; const { JPEG: FORMATJPEG, YCBCR_422_SP } = image.ImageFormat; const { YUV_Y, YUV_U, YUV_V, JPEG } = image.ComponentType; beforeAll(async function () { @@ -142,8 +145,8 @@ export default function ImageReceiver() { } } - async function getComponentPromise(done, testNum, param) { - var receiver = image.createImageReceiver(WIDTH, HEIGHT, YCBCR_422_SP, CAPACITY); + async function getComponentPromise(done, testNum, format, param, checkFormat, checkStride) { + var receiver = image.createImageReceiver(WIDTH, HEIGHT, format, CAPACITY); let once = false; if (receiver == undefined) { expect(false).assertTrue(); @@ -161,7 +164,7 @@ export default function ImageReceiver() { } else { expect(img.size.width == WIDTH).assertTrue(); expect(img.size.height == HEIGHT).assertTrue(); - expect(img.format == RGBA).assertTrue(); + checkFormat(img.format); expect(img.clipRect.size.width == WIDTH).assertTrue(); expect(img.clipRect.size.height == HEIGHT).assertTrue(); expect(img.clipRect.x == 0).assertTrue(); @@ -175,8 +178,7 @@ export default function ImageReceiver() { } expect(component.componentType == param).assertTrue(); expect(component.byteBuffer != undefined).assertTrue(); - expect(component.rowStride == 8192).assertTrue(); - expect(component.pixelStride == 1).assertTrue(); + checkStride(component.rowStride, component.pixelStride); done(); }) .catch((error) => { @@ -188,11 +190,15 @@ export default function ImageReceiver() { }); expect(true).assertTrue(); }); - var dummy = receiver.test; + if (format == FORMATJPEG) { + var dummy = receiver.test; + } else { + var dummy = receiver.testYUV; + } } - async function getComponentCb(done, testNum, param) { - var receiver = image.createImageReceiver(WIDTH, HEIGHT, YCBCR_422_SP, CAPACITY); + async function getComponentCb(done, testNum, format, param, checkFormat, checkStride) { + var receiver = image.createImageReceiver(WIDTH, HEIGHT, format, CAPACITY); let once = false; if (receiver == undefined) { expect(false).assertTrue(); @@ -211,7 +217,7 @@ export default function ImageReceiver() { } else { expect(img.size.width == WIDTH).assertTrue(); expect(img.size.height == HEIGHT).assertTrue(); - expect(img.format == RGBA).assertTrue(); + checkFormat(img.format); expect(img.clipRect.size.width == WIDTH).assertTrue(); expect(img.clipRect.size.height == HEIGHT).assertTrue(); expect(img.clipRect.x == 0).assertTrue(); @@ -225,8 +231,7 @@ export default function ImageReceiver() { expect(component != undefined).assertTrue(); expect(component.componentType == param).assertTrue(); expect(component.byteBuffer != undefined).assertTrue(); - expect(component.rowStride == 8192).assertTrue(); - expect(component.pixelStride == 1).assertTrue(); + checkStride(component.rowStride, component.pixelStride); done(); } }); @@ -234,7 +239,11 @@ export default function ImageReceiver() { }); expect(true).assertTrue(); }); - var dummy = receiver.test; + if (format == FORMATJPEG) { + var dummy = receiver.test; + } else { + var dummy = receiver.testYUV; + } } async function onErr(done, testNum, param) { @@ -543,8 +552,8 @@ export default function ImageReceiver() { .then((id) => { console.info( "SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_PROMISE_0100 getReceivingSurfaceId [" + - id + - "]" + id + + "]" ); expect(isString(id)).assertTrue(); done(); @@ -576,8 +585,8 @@ export default function ImageReceiver() { receiver.getReceivingSurfaceId((err, id) => { console.info( "SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_CALLBACK_0100 getReceivingSurfaceId call back [" + - id + - "]" + id + + "]" ); expect(isString(id)).assertTrue(); done(); @@ -789,7 +798,21 @@ export default function ImageReceiver() { * @tc.level : Level 0 */ it("SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_JPEG_0100", 0, async function (done) { - getComponentPromise(done, "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_JPEG_0100", JPEG); + function checkFormat(imgformat) { + expect(imgformat == RGBA); + } + function checkStride(rowStride, pixelStride) { + expect(rowStride == WIDTH / Jpg_YStride); + expect(pixelStride == Jpg_YStride); + } + getComponentPromise( + done, + "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_JPEG_0100", + FORMATJPEG, + JPEG, + checkFormat, + checkStride + ); }); /** @@ -804,7 +827,21 @@ export default function ImageReceiver() { * @tc.level : Level 0 */ it("SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_U_0100", 0, async function (done) { - getComponentPromise(done, "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_U_0100", YUV_U); + function checkFormat(imgformat) { + expect(imgformat == YCBCR); + } + function checkStride(rowStride, pixelStride) { + expect(rowStride == WIDTH / UVStride); + expect(pixelStride == UVStride); + } + getComponentPromise( + done, + "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_U_0100", + YCBCR_422_SP, + YUV_U, + checkFormat, + checkStride + ); }); /** @@ -819,7 +856,21 @@ export default function ImageReceiver() { * @tc.level : Level 0 */ it("SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_V_0100", 0, async function (done) { - getComponentPromise(done, "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_V_0100", YUV_V); + function checkFormat(imgformat) { + expect(imgformat == YCBCR); + } + function checkStride(rowStride, pixelStride) { + expect(rowStride == WIDTH / UVStride); + expect(pixelStride == UVStride); + } + getComponentPromise( + done, + "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_V_0100", + YCBCR_422_SP, + YUV_V, + checkFormat, + checkStride + ); }); /** @@ -834,7 +885,21 @@ export default function ImageReceiver() { * @tc.level : Level 0 */ it("SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_Y_0100", 0, async function (done) { - getComponentPromise(done, "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_Y_0100", YUV_Y); + function checkFormat(imgformat) { + expect(imgformat == YCBCR); + } + function checkStride(rowStride, pixelStride) { + expect(rowStride == WIDTH / Jpg_YStride); + expect(pixelStride == Jpg_YStride); + } + getComponentPromise( + done, + "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_PROMISE_YUV_Y_0100", + YCBCR_422_SP, + YUV_Y, + checkFormat, + checkStride + ); }); /** @@ -849,7 +914,21 @@ export default function ImageReceiver() { * @tc.level : Level 0 */ it("SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_JPEG_0100", 0, async function (done) { - getComponentCb(done, "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_JPEG_0100", JPEG); + function checkFormat(imgformat) { + expect(imgformat == RGBA); + } + function checkStride(rowStride, pixelStride) { + expect(rowStride == WIDTH / Jpg_YStride); + expect(pixelStride == Jpg_YStride); + } + getComponentCb( + done, + "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_JPEG_0100", + FORMATJPEG, + JPEG, + checkFormat, + checkStride + ); }); /** @@ -864,7 +943,21 @@ export default function ImageReceiver() { * @tc.level : Level 0 */ it("SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_Y_0100", 0, async function (done) { - getComponentCb(done, "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_Y_0100", YUV_Y); + function checkFormat(imgformat) { + expect(imgformat == YCBCR); + } + function checkStride(rowStride, pixelStride) { + expect(rowStride == WIDTH / Jpg_YStride); + expect(pixelStride == Jpg_YStride); + } + getComponentCb( + done, + "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_Y_0100", + YCBCR_422_SP, + YUV_Y, + checkFormat, + checkStride + ); }); /** @@ -879,7 +972,21 @@ export default function ImageReceiver() { * @tc.level : Level 0 */ it("SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_V_0100", 0, async function (done) { - getComponentCb(done, "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_V_0100", YUV_V); + function checkFormat(imgformat) { + expect(imgformat == YCBCR); + } + function checkStride(rowStride, pixelStride) { + expect(rowStride == WIDTH / UVStride); + expect(pixelStride == UVStride); + } + getComponentCb( + done, + "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_V_0100", + YCBCR_422_SP, + YUV_V, + checkFormat, + checkStride + ); }); /** @@ -894,7 +1001,21 @@ export default function ImageReceiver() { * @tc.level : Level 0 */ it("SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_U_0100", 0, async function (done) { - getComponentCb(done, "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_U_0100", YUV_U); + function checkFormat(imgformat) { + expect(imgformat == YCBCR); + } + function checkStride(rowStride, pixelStride) { + expect(rowStride == WIDTH / UVStride); + expect(pixelStride == UVStride); + } + getComponentCb( + done, + "SUB_GRAPHIC_IMAGE_RECEIVER_GETCOMPONENT_CALLBACK_YUV_U_0100", + YCBCR_422_SP, + YUV_U, + checkFormat, + checkStride + ); }); /**