未验证 提交 9c02abf3 编写于 作者: O openharmony_ci 提交者: Gitee

!8843 test receiver

Merge pull request !8843 from 黄开兴/master
...@@ -17,6 +17,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from ...@@ -17,6 +17,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export default function ImageReceiver() { export default function ImageReceiver() {
describe("ImageReceiver", function () { describe("ImageReceiver", function () {
let globalreceiver;
let globalImg;
const WIDTH = 8192; const WIDTH = 8192;
const HEIGHT = 8; const HEIGHT = 8;
const CAPACITY = 8; const CAPACITY = 8;
...@@ -34,6 +36,22 @@ export default function ImageReceiver() { ...@@ -34,6 +36,22 @@ export default function ImageReceiver() {
}); });
afterEach(async function () { 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 {
await globalreceiver.release();
} catch (error) {
console.info("globalreceiver release fail");
}
}
console.info("afterEach case"); console.info("afterEach case");
}); });
...@@ -71,6 +89,7 @@ export default function ImageReceiver() { ...@@ -71,6 +89,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalreceiver = receiver;
var error = receiver.checkDeviceTest; var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) { if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue(); expect(error == DEVICE_CODE).assertTrue();
...@@ -88,6 +107,7 @@ export default function ImageReceiver() { ...@@ -88,6 +107,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalImg = img;
expect(img.size.width == WIDTH).assertTrue(); expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue(); expect(img.size.height == HEIGHT).assertTrue();
console.log(`${testNum} img.format: ${img.format}`) console.log(`${testNum} img.format: ${img.format}`)
...@@ -122,6 +142,7 @@ export default function ImageReceiver() { ...@@ -122,6 +142,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalreceiver = receiver;
var error = receiver.checkDeviceTest; var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) { if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue(); expect(error == DEVICE_CODE).assertTrue();
...@@ -139,6 +160,7 @@ export default function ImageReceiver() { ...@@ -139,6 +160,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalImg = img;
expect(img.size.width == WIDTH).assertTrue(); expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue(); expect(img.size.height == HEIGHT).assertTrue();
console.log(`${testNum} img.format: ${img.format}`) console.log(`${testNum} img.format: ${img.format}`)
...@@ -173,6 +195,7 @@ export default function ImageReceiver() { ...@@ -173,6 +195,7 @@ export default function ImageReceiver() {
expect(false).assertTrue(); expect(false).assertTrue();
return; return;
} }
globalreceiver = receiver;
var error = receiver.checkDeviceTest; var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) { if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue(); expect(error == DEVICE_CODE).assertTrue();
...@@ -190,6 +213,7 @@ export default function ImageReceiver() { ...@@ -190,6 +213,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalImg = img;
expect(img.size.width == WIDTH).assertTrue(); expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue(); expect(img.size.height == HEIGHT).assertTrue();
checkFormat(img.format); checkFormat(img.format);
...@@ -248,6 +272,7 @@ export default function ImageReceiver() { ...@@ -248,6 +272,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalImg = img;
expect(img.size.width == WIDTH).assertTrue(); expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue(); expect(img.size.height == HEIGHT).assertTrue();
checkFormat(img.format); checkFormat(img.format);
...@@ -285,6 +310,7 @@ export default function ImageReceiver() { ...@@ -285,6 +310,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalreceiver = receiver;
try { try {
var error = receiver.checkDeviceTest; var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) { if (DEVICE_CODE == error) {
...@@ -327,6 +353,7 @@ export default function ImageReceiver() { ...@@ -327,6 +353,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalreceiver = receiver;
expect(receiver.size.width == WIDTH).assertTrue(); expect(receiver.size.width == WIDTH).assertTrue();
expect(receiver.size.height == HEIGHT).assertTrue(); expect(receiver.size.height == HEIGHT).assertTrue();
expect(receiver.capacity == CAPACITY).assertTrue(); expect(receiver.capacity == CAPACITY).assertTrue();
...@@ -543,6 +570,7 @@ export default function ImageReceiver() { ...@@ -543,6 +570,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalreceiver = receiver;
expect(receiver.size.width == WIDTH).assertTrue(); expect(receiver.size.width == WIDTH).assertTrue();
expect(receiver.size.height == HEIGHT).assertTrue(); expect(receiver.size.height == HEIGHT).assertTrue();
expect(receiver.capacity == CAPACITY).assertTrue(); expect(receiver.capacity == CAPACITY).assertTrue();
...@@ -565,6 +593,7 @@ export default function ImageReceiver() { ...@@ -565,6 +593,7 @@ export default function ImageReceiver() {
it("SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_PROMISE_0100", 0, async function (done) { it("SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_PROMISE_0100", 0, async function (done) {
var receiver = image.createImageReceiver(WIDTH, HEIGHT, FORMATJPEG, CAPACITY); var receiver = image.createImageReceiver(WIDTH, HEIGHT, FORMATJPEG, CAPACITY);
if (receiver != undefined) { if (receiver != undefined) {
globalreceiver = receiver;
receiver receiver
.getReceivingSurfaceId() .getReceivingSurfaceId()
.then((id) => { .then((id) => {
...@@ -603,6 +632,7 @@ export default function ImageReceiver() { ...@@ -603,6 +632,7 @@ export default function ImageReceiver() {
it("SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_CALLBACK_0100", 0, async function (done) { it("SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_CALLBACK_0100", 0, async function (done) {
var receiver = image.createImageReceiver(WIDTH, HEIGHT, FORMATJPEG, CAPACITY); var receiver = image.createImageReceiver(WIDTH, HEIGHT, FORMATJPEG, CAPACITY);
if (receiver != undefined) { if (receiver != undefined) {
globalreceiver = receiver;
receiver.getReceivingSurfaceId((err, id) => { receiver.getReceivingSurfaceId((err, id) => {
console.info( console.info(
"SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_CALLBACK_0100 getReceivingSurfaceId call back [" + "SUB_GRAPHIC_IMAGE_RECEIVER_GETRECEIVINGSURFACEID_CALLBACK_0100 getReceivingSurfaceId call back [" +
...@@ -633,6 +663,7 @@ export default function ImageReceiver() { ...@@ -633,6 +663,7 @@ export default function ImageReceiver() {
it("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_PROMISE_0100", 0, async function (done) { it("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_PROMISE_0100", 0, async function (done) {
var receiver = image.createImageReceiver(WIDTH, HEIGHT, FORMATJPEG, CAPACITY); var receiver = image.createImageReceiver(WIDTH, HEIGHT, FORMATJPEG, CAPACITY);
if (receiver != undefined) { if (receiver != undefined) {
globalreceiver = receiver;
receiver receiver
.release() .release()
.then(() => { .then(() => {
...@@ -666,6 +697,7 @@ export default function ImageReceiver() { ...@@ -666,6 +697,7 @@ export default function ImageReceiver() {
it("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_CALLBACK_0100", 0, async function (done) { it("SUB_GRAPHIC_IMAGE_RECEIVER_RELEASE_CALLBACK_0100", 0, async function (done) {
var receiver = image.createImageReceiver(WIDTH, HEIGHT, FORMATJPEG, CAPACITY); var receiver = image.createImageReceiver(WIDTH, HEIGHT, FORMATJPEG, CAPACITY);
if (receiver != undefined) { if (receiver != undefined) {
globalreceiver = receiver;
receiver.release((err) => { receiver.release((err) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -707,9 +739,11 @@ export default function ImageReceiver() { ...@@ -707,9 +739,11 @@ export default function ImageReceiver() {
} }
var dummy = receiver.test; var dummy = receiver.test;
if (receiver != undefined) { if (receiver != undefined) {
globalreceiver = receiver;
receiver receiver
.readLatestImage() .readLatestImage()
.then((img) => { .then((img) => {
globalImg = img;
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_PROMISE_0100 readLatestImage Success"); console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_PROMISE_0100 readLatestImage Success");
expect(img != undefined).assertTrue(); expect(img != undefined).assertTrue();
done(); done();
...@@ -749,7 +783,9 @@ export default function ImageReceiver() { ...@@ -749,7 +783,9 @@ export default function ImageReceiver() {
} }
var dummy = receiver.test; var dummy = receiver.test;
if (receiver != undefined) { if (receiver != undefined) {
globalreceiver = receiver;
receiver.readLatestImage((err, img) => { receiver.readLatestImage((err, img) => {
globalImg = img;
console.info( console.info(
"SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_CALLBACK_0100 readLatestImage call back Success" "SUB_GRAPHIC_IMAGE_RECEIVER_READLATESTIMAGE_CALLBACK_0100 readLatestImage call back Success"
); );
...@@ -786,9 +822,11 @@ export default function ImageReceiver() { ...@@ -786,9 +822,11 @@ export default function ImageReceiver() {
var dummy = receiver.test; var dummy = receiver.test;
expect(receiver != undefined).assertTrue(); expect(receiver != undefined).assertTrue();
if (receiver != undefined) { if (receiver != undefined) {
globalreceiver = receiver;
receiver receiver
.readNextImage() .readNextImage()
.then((img) => { .then((img) => {
globalImg = img;
console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_PROMISE_0100 readNextImage Success"); console.info("SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_PROMISE_0100 readNextImage Success");
expect(img != undefined).assertTrue(); expect(img != undefined).assertTrue();
done(); done();
...@@ -828,12 +866,14 @@ export default function ImageReceiver() { ...@@ -828,12 +866,14 @@ export default function ImageReceiver() {
} }
var dummy = receiver.test; var dummy = receiver.test;
if (receiver != undefined) { if (receiver != undefined) {
globalreceiver = receiver;
receiver.readNextImage((err, img) => { receiver.readNextImage((err, img) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
return; return;
} else { } else {
globalImg = img;
console.info( console.info(
"SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_CALLBACK_0100 readNextImage call back Success" "SUB_GRAPHIC_IMAGE_RECEIVER_READNEXTIMAGE_CALLBACK_0100 readNextImage call back Success"
); );
...@@ -924,6 +964,7 @@ export default function ImageReceiver() { ...@@ -924,6 +964,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalreceiver = receiver;
var error = receiver.checkDeviceTest; var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) { if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue(); expect(error == DEVICE_CODE).assertTrue();
...@@ -970,6 +1011,7 @@ export default function ImageReceiver() { ...@@ -970,6 +1011,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} }
globalreceiver = receiver;
var error = receiver.checkDeviceTest; var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) { if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue(); expect(error == DEVICE_CODE).assertTrue();
...@@ -990,6 +1032,7 @@ export default function ImageReceiver() { ...@@ -990,6 +1032,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} else { } else {
globalImg = img;
expect(img.size.width == WIDTH).assertTrue(); expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue(); expect(img.size.height == HEIGHT).assertTrue();
expect(img.format == RGBA).assertTrue(); expect(img.format == RGBA).assertTrue();
...@@ -1039,6 +1082,7 @@ export default function ImageReceiver() { ...@@ -1039,6 +1082,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} }
globalreceiver = receiver;
var error = receiver.checkDeviceTest; var error = receiver.checkDeviceTest;
if (DEVICE_CODE == error) { if (DEVICE_CODE == error) {
expect(error == DEVICE_CODE).assertTrue(); expect(error == DEVICE_CODE).assertTrue();
...@@ -1055,6 +1099,7 @@ export default function ImageReceiver() { ...@@ -1055,6 +1099,7 @@ export default function ImageReceiver() {
done(); done();
return; return;
} }
globalImg = img;
expect(img.size.width == WIDTH).assertTrue(); expect(img.size.width == WIDTH).assertTrue();
expect(img.size.height == HEIGHT).assertTrue(); expect(img.size.height == HEIGHT).assertTrue();
expect(img.format == RGBA).assertTrue(); expect(img.format == RGBA).assertTrue();
...@@ -1249,4 +1294,4 @@ export default function ImageReceiver() { ...@@ -1249,4 +1294,4 @@ export default function ImageReceiver() {
onErr(done, "SUB_GRAPHIC_IMAGE_RECEIVER_IMAGERECEIVER_ON_ERROR_0400", "a"); onErr(done, "SUB_GRAPHIC_IMAGE_RECEIVER_IMAGERECEIVER_ON_ERROR_0400", "a");
}); });
}); });
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册