提交 e299dee4 编写于 作者: C caochuan

add receiver release test

Signed-off-by: Ncaochuan <caochuan@huawei.com>
Change-Id: I18d8a1f3ba0b5d6eb2ffc0ab705cb2c13967f6ff
上级 0e805406
......@@ -51,6 +51,8 @@ napi_value ImageReceiverNDKTest::Init(napi_env env, napi_value exports)
STATIC_FUNCTION("imageSize", JsImageSize),
STATIC_FUNCTION("imageFormat", JsImageFormat),
STATIC_FUNCTION("imageGetComponent", JsImageGetComponent),
STATIC_FUNCTION("receiverRelease", JsReceiverRelease),
STATIC_FUNCTION("imageRelease", JsImageRelease),
};
napi_define_properties(env, exports, sizeof(props) / sizeof(props[0]), props);
return exports;
......@@ -183,6 +185,22 @@ napi_value ImageReceiverNDKTest::JsOn(napi_env env, napi_callback_info info)
return result;
}
napi_value ImageReceiverNDKTest::JsReceiverRelease(napi_env env, napi_callback_info info)
{
napi_value result = nullptr;
napi_get_undefined(env, &result);
ImageReceiverNative *native = getNativeReceiver(env, info);
if (native == nullptr)
{
return result;
}
int32_t res = OH_Image_Receiver_Release(native);
napi_create_int32(env, res, &result);
return result;
}
static void setInt32NamedProperty(napi_env env, napi_value object, const char* utf8name, int32_t value)
{
napi_value tmp;
......@@ -276,6 +294,22 @@ static ImageNative* getNativeImage(napi_env env, napi_callback_info info)
return OH_Image_InitImageNative(env, argValue[NUM_0]);
}
napi_value ImageReceiverNDKTest::JsImageRelease(napi_env env, napi_callback_info info)
{
napi_value result = nullptr;
napi_get_undefined(env, &result);
ImageNative *native = getNativeImage(env, info);
if (native == nullptr)
{
return result;
}
int32_t res = OH_Image_Release(native);
napi_create_int32(env, res, &result);
return result;
}
napi_value ImageReceiverNDKTest::JsImageClipRect(napi_env env, napi_callback_info info)
{
napi_value result = nullptr;
......
......@@ -41,6 +41,8 @@ public:
static napi_value JsImageSize(napi_env env, napi_callback_info info);
static napi_value JsImageFormat(napi_env env, napi_callback_info info);
static napi_value JsImageGetComponent(napi_env env, napi_callback_info info);
static napi_value JsReceiverRelease(napi_env env, napi_callback_info info);
static napi_value JsImageRelease(napi_env env, napi_callback_info info);
private:
static uint32_t sOnEvnentCount;
......
......@@ -365,5 +365,70 @@ export default function ImageReceiverNDKTest() {
done();
}
})
/**
* @tc.number : SUB_GRAPHIC_IMAGE_RECEIVERNDK_0900
* @tc.name : img.release
* @tc.desc : 1.createImageReceiver
* : 2.readLatestImage
* : 3.release
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('SUB_GRAPHIC_IMAGE_RECEIVERNDK_0900', 0, async function (done) {
let mlg = logger("SUB_GRAPHIC_IMAGE_RECEIVERNDK_0900");
try {
mlg.log("SUB_GRAPHIC_IMAGE_RECEIVERNDK_0900");
let myReceiver = ndkTest.createImageReceiver(WIDTH, HEIGHT, RECEIVER_FORMAT, CAPACITY);
let onRet = ndkTest.on(myReceiver);
mlg.log("onRet " + JSON.stringify(onRet));
expect(onRet != undefined).assertTrue();
var dummy = myReceiver.test;
mlg.log("dummy test !!! ")
let myLatestImage = ndkTest.readLatestImage(myReceiver);
let myImageComponent = ndkTest.imageGetComponent(myLatestImage, JPEG);
var bufferArr = new Uint8Array(myImageComponent.byteBuffer);
mlg.log("myImageComponent.byteBuffer size " + JSON.stringify(bufferArr.length));
for (var i = 0; i < 30; i++) {
mlg.log("myImageComponent.byteBuffer data " + JSON.stringify(bufferArr[i]));
}
expect(myImageComponent.byteBuffer != undefined).assertTrue();
let releaseRes = ndkTest.imageRelease(myLatestImage);
mlg.log('release result ' + JSON.stringify(releaseRes));
expect(releaseRes != undefined).assertTrue();
done();
} catch (error) {
mlg.log("Test exception " + error);
expect().assertFail();
done();
}
})
/**
* @tc.number : SUB_GRAPHIC_IMAGE_RECEIVERNDK_1000
* @tc.name : receiver.release
* @tc.desc : 1.createImageReceiver
* : 2.release
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('SUB_GRAPHIC_IMAGE_RECEIVERNDK_1000', 0, async function (done) {
let mlg = logger("SUB_GRAPHIC_IMAGE_RECEIVERNDK_1000");
try {
mlg.log("SUB_GRAPHIC_IMAGE_RECEIVERNDK_1000");
let myReceiver = ndkTest.createImageReceiver(WIDTH, HEIGHT, RECEIVER_FORMAT, CAPACITY);
let releaseRes = ndkTest.receiverRelease(myReceiver);
mlg.log('release result ' + JSON.stringify(releaseRes));
expect(releaseRes != undefined).assertTrue();
done();
} catch (error) {
mlg.log("Test exception " + error);
expect().assertFail();
done();
}
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册