未验证 提交 47bdcf8d 编写于 作者: R renhw001 提交者: Gitee

update multimedia/image/image_js_standard/imageReceiver/src/main/js/test/receiver.test.js.

Signed-off-by: Nrenhw001 <renhongwei9@huawei.com>
上级 f0a08c3a
......@@ -54,10 +54,12 @@ export default function ImageReceiver() {
image.createImageReceiver(wid, hei, fmt, cap);
expect(false).assertTrue();
done();
return;
} catch (error) {
expect(error.code == 1).assertTrue();
console.info(`${testNum} err message` + error);
done();
return;
}
}
......@@ -67,11 +69,13 @@ export default function ImageReceiver() {
if (receiver == undefined) {
expect(false).assertTrue();
done();
return;
} else {
var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
receiver.on("imageArrival", () => {
if (once) {
......@@ -82,6 +86,7 @@ export default function ImageReceiver() {
if (img == undefined) {
expect(false).assertTrue();
done();
return;
} else {
expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue();
......@@ -94,10 +99,12 @@ export default function ImageReceiver() {
await img.getComponent(param);
expect(false).assertTrue();
done();
return;
} catch (error) {
expect(error.code == 1).assertTrue();
console.log(`${testNum} error msg: ` + error);
done();
return;
}
}
});
......@@ -113,11 +120,13 @@ export default function ImageReceiver() {
if (receiver == undefined) {
expect(false).assertTrue();
done();
return;
} else {
var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
receiver.on("imageArrival", () => {
if (once) {
......@@ -128,6 +137,7 @@ export default function ImageReceiver() {
if (img == undefined) {
expect(false).assertTrue();
done();
return;
} else {
expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue();
......@@ -140,11 +150,13 @@ export default function ImageReceiver() {
img.getComponent(param, (err, component) => {
expect(false).assertTrue();
done();
return;
});
} catch (error) {
expect(error.code == 1).assertTrue();
console.log(`${testNum} error msg: ` + error);
done();
return;
}
}
});
......@@ -165,6 +177,7 @@ export default function ImageReceiver() {
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
receiver.on("imageArrival", () => {
if (once) {
......@@ -175,6 +188,7 @@ export default function ImageReceiver() {
if (err) {
expect(false).assertTrue();
done();
return;
} else {
expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue();
......@@ -194,11 +208,13 @@ export default function ImageReceiver() {
expect(component.byteBuffer != undefined).assertTrue();
checkStride(component.rowStride, component.pixelStride);
done();
return;
})
.catch((error) => {
console.log(`${testNum} error:` + error);
expect(false).assertTrue();
done();
return;
});
}
});
......@@ -219,6 +235,7 @@ export default function ImageReceiver() {
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
receiver.on("imageArrival", () => {
if (once) {
......@@ -229,6 +246,7 @@ export default function ImageReceiver() {
if (err) {
expect(false).assertTrue();
done();
return;
} else {
expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue();
......@@ -242,12 +260,14 @@ export default function ImageReceiver() {
expect(false).assertTrue();
console.log(`${testNum} geterror: ` + err);
done();
return;
} else {
expect(component != undefined).assertTrue();
expect(component.componentType == param).assertTrue();
expect(component.byteBuffer != undefined).assertTrue();
checkStride(component.rowStride, component.pixelStride);
done();
return;
}
});
}
......@@ -263,12 +283,14 @@ export default function ImageReceiver() {
if (receiver == undefined) {
expect(false).assertTrue();
done();
return;
} else {
try {
var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
receiver.on(param, () => {
expect(false).assertTrue();
......@@ -277,6 +299,7 @@ export default function ImageReceiver() {
expect(error.code == 1).assertTrue();
console.log(`${testNum} error msg: ` + error);
done();
return;
}
var dummy = receiver.test;
}
......@@ -302,12 +325,14 @@ export default function ImageReceiver() {
expect(false).assertTrue();
console.info("receiver_001 undefined");
done();
return;
} else {
expect(receiver.size.width == WIDTH).assertTrue();
expect(receiver.size.height == HEIGHT).assertTrue();
expect(receiver.capacity == CAPACITY).assertTrue();
expect(receiver.format == FORMATJPEG).assertTrue();
done();
return;
}
});
......@@ -516,12 +541,14 @@ export default function ImageReceiver() {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_CREATEIMAGERECEIVER_0400 undefined");
done();
return;
} else {
expect(receiver.size.width == WIDTH).assertTrue();
expect(receiver.size.height == HEIGHT).assertTrue();
expect(receiver.capacity == CAPACITY).assertTrue();
expect(receiver.format == FORMATJPEG).assertTrue();
done();
return;
}
});
......@@ -548,15 +575,18 @@ export default function ImageReceiver() {
);
expect(isString(id)).assertTrue();
done();
return;
})
.catch((error) => {
console.log("SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_PROMISE_0100 error: " + error);
expect(false).assertTrue();
done();
return;
});
} else {
expect(false).assertTrue();
done();
return;
}
});
......@@ -581,11 +611,13 @@ export default function ImageReceiver() {
);
expect(isString(id)).assertTrue();
done();
return;
});
} else {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_CALLBACK_0100 finished");
done();
return;
}
});
......@@ -607,15 +639,18 @@ export default function ImageReceiver() {
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_PROMISE_0100 release ");
expect(true).assertTrue();
done();
return;
})
.catch((error) => {
expect(false).assertTrue();
done();
return;
});
} else {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_PROMISE_0100 finished");
done();
return;
}
});
......@@ -636,16 +671,19 @@ export default function ImageReceiver() {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_CALLBACK_0100 release fail");
done();
return;
} else {
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_CALLBACK_0100 release call back");
expect(true).assertTrue();
done();
return;
}
});
} else {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_CALLBACK_0100 finished");
done();
return;
}
});
......@@ -665,6 +703,7 @@ export default function ImageReceiver() {
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
var dummy = receiver.test;
if (receiver != undefined) {
......@@ -674,16 +713,19 @@ export default function ImageReceiver() {
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_PROMISE_0100 readLatestImage Success");
expect(img != undefined).assertTrue();
done();
return;
})
.catch((error) => {
console.log("SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_PROMISE_0100 error: " + error);
expect(false).assertTrue();
done();
return;
});
} else {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_PROMISE_0100 finished");
done();
return;
}
});
......@@ -703,6 +745,7 @@ export default function ImageReceiver() {
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
var dummy = receiver.test;
if (receiver != undefined) {
......@@ -712,11 +755,13 @@ export default function ImageReceiver() {
);
expect(img != undefined).assertTrue();
done();
return;
});
} else {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_CALLBACK_0100 finished");
done();
return;
}
});
......@@ -736,6 +781,7 @@ export default function ImageReceiver() {
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
var dummy = receiver.test;
expect(receiver != undefined).assertTrue();
......@@ -746,16 +792,19 @@ export default function ImageReceiver() {
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_PROMISE_0100 readNextImage Success");
expect(img != undefined).assertTrue();
done();
return;
})
.catch((error) => {
console.log("SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_PROMISE_0100 error: " + error);
expect(false).assertTrue();
done();
return;
});
} else {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_PROMISE_0100 finished");
done();
return;
}
});
......@@ -775,6 +824,7 @@ export default function ImageReceiver() {
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
var dummy = receiver.test;
if (receiver != undefined) {
......@@ -782,18 +832,21 @@ export default function ImageReceiver() {
if (err) {
expect(false).assertTrue();
done();
return;
} else {
console.info(
"SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_CALLBACK_0100 readNextImage call back Success"
);
expect(img != undefined).assertTrue();
done();
return;
}
});
} else {
expect(false).assertTrue();
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_CALLBACK_0100 finished");
done();
return;
}
});
......@@ -869,11 +922,13 @@ export default function ImageReceiver() {
if (receiver == undefined) {
expect(false).assertTrue();
done();
return;
} else {
var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
let pass = false;
receiver.on("imageArrival", (err) => {
......@@ -881,6 +936,7 @@ export default function ImageReceiver() {
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_RECEIVERON_0100 on err" + err);
expect(false).assertTrue();
done();
return;
} else {
pass = true;
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_RECEIVERON_0100 on call back IN");
......@@ -891,6 +947,7 @@ export default function ImageReceiver() {
await sleep(2000);
expect(pass).assertTrue();
done();
return;
}
});
......@@ -917,6 +974,7 @@ export default function ImageReceiver() {
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
receiver.on("imageArrival", () => {
expect(true).assertTrue();
......@@ -930,6 +988,7 @@ export default function ImageReceiver() {
if (img == undefined) {
expect(false).assertTrue();
done();
return;
} else {
expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue();
......@@ -943,11 +1002,13 @@ export default function ImageReceiver() {
.then(() => {
expect(true).assertTrue();
done();
return;
})
.catch((error) => {
console.log("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_PROMISE_0200 err" + error);
expect(false).assertTrue();
done();
return;
});
}
})
......@@ -955,6 +1016,7 @@ export default function ImageReceiver() {
console.log("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_PROMISE_0200 readLatestImage err" + error);
expect(false).assertTrue();
done();
return;
});
});
......@@ -981,13 +1043,12 @@ export default function ImageReceiver() {
if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue();
done();
return;
}
receiver.on("imageArrival", () => {
expect(true).assertTrue();
});
var dummy = receiver.test;
receiver.readLatestImage((err, img) => {
if (img == undefined) {
expect(false).assertTrue();
......@@ -1007,9 +1068,11 @@ export default function ImageReceiver() {
if (err) {
expect(false).assertTrue();
done();
return;
} else {
expect(true).assertTrue();
done();
return;
}
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册