提交 53660364 编写于 作者: L lwx1121892

<liuxueqi3@huawei.com>

Signed-off-by: Nlwx1121892 <liuxueqi3@huawei.com>
上级 0045d8c2
......@@ -22,9 +22,7 @@
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files/*"
],
"teardown-command":[
]
"teardown-command": []
},
{
"type": "PushKit",
......@@ -37,6 +35,14 @@
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
]
}
\ No newline at end of file
......@@ -14,6 +14,9 @@
*/
import imageJsTest from './image.test.js'
import addImage from './addImage.test.js'
export default function testsuite() {
imageJsTest()
addImage()
}
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { testPng } from './testImg'
export default function addImage() {
describe('addImage', function () {
beforeAll(async function () {
console.info('beforeAll case');
})
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(async function () {
console.info('afterEach case');
})
afterAll(async function () {
console.info('afterAll case');
})
function createPixMapPromise(done, testNum, opts) {
const Color = new ArrayBuffer(96);
image.createPixelMap(Color, opts)
.then(pixelmap => {
expect(pixelmap != undefined).assertTrue();
console.info(`${testNum} success`);
done();
})
.catch(error => {
console.log(`${testNum} error: ` + error);
expect(false).assertTrue();
done();
})
}
function createPixMapCb(done, testNum, opts) {
const Color = new ArrayBuffer(96);
image.createPixelMap(Color, opts, (err, pixelmap) => {
expect(pixelmap != undefined).assertTrue();
console.info(`${testNum} success`);
done();
})
}
/**
* @tc.number : addImage_001
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 0)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_001', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 0 }
createPixMapPromise(done, 'add_01_001', opts);
})
/**
* @tc.number : add_01_002
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 1)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_002', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 1 }
createPixMapPromise(done, 'add_01_002', opts);
})
/**
* @tc.number : add_01_003
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 2)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_003', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 2 }
createPixMapPromise(done, 'add_01_003', opts);
})
/**
* @tc.number : add_01_004
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 3)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_004', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 3 }
createPixMapPromise(done, 'add_01_004', opts);
})
/**
* @tc.number : add_02_001
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 0)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_001', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 0 }
createPixMapCb(done, 'add_02_001', opts);
})
/**
* @tc.number : add_02_002
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 1)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_002', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 1 }
createPixMapCb(done, 'add_02_002', opts);
})
/**
* @tc.number : add_02_003
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 2)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_003', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 2 }
createPixMapCb(done, 'add_02_003', opts);
})
/**
* @tc.number : add_02_004
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 3)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_004', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 3 }
createPixMapCb(done, 'add_02_004', opts);
})
/**
* @tc.number : add_053
* @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('add_053', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('add_053 0003 ' + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
console.info('add_053 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('add_053 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('add_053 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('add_053 0011 ' + offset);
}
if (ret) {
console.info('add_053 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('add_053 0014' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('add_053 updateData failed ' + error);
}
})
/**
* @tc.number : add_053-1
* @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('add_053-1', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('add_053-1 0001 ' + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('add_053-1 0002 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await new Promise(res => {
incSouce.updateData(oneStep, isFinished, 0, oneStep.length, (err, ret) => {
res(ret);
})
})
if (!ret) {
console.info('add_053-1 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('add_053-1 0003 ' + offset);
}
if (ret) {
console.info('add_053-1 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('add_053-1 0004' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('add_053-1 updateData failed ' + error);
}
})
})
}
\ No newline at end of file
......@@ -607,4 +607,14 @@ let testJpg = new Uint8Array([255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1
2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160,
2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 15, 255, 217])
export {testPng, testJpg}
\ No newline at end of file
let tc_020Buf = new Uint8Array([0,0,0,4,0,0,0,8,1,0,0,12,1,1,1,16,1,1,1,20,2,2,2,24,3,3,3,28,4,4,4,32,5,5,5,36,6,6,6,40,7,7,7,44,9,9,8,48,10,10,10,52,12,12,12,56,14,14,13,60,16,16,15,64,18,18,17,68,20,20,19,72,22,22,22,76,25,24,24,80,27,27,27,84,30,30,29,88,33,32,32,92,36,35,35,96])
let tc_020_1Buf = new Uint8Array([0,0,0,4,0,0,0,8,1,0,0,12,1,1,1,16,1,1,1,20,2,2,2,24,3,3,3,28,4,4,4,32,5,5,5,36,6,6,6,40,7,7,7,44,9,9,8,48,10,10,10,52,12,12,12,56,14,14,13,60,16,16,15,64,18,18,17,68,20,20,19,72,22,22,22,76,25,24,24,80,27,27,27,84,30,30,29,88,33,32,32,92,36,35,35,96])
let tc_021Buf = new Uint8Array([0,0,0,4,0,0,0,8])
let tc_021_1Buf = new Uint8Array([0,0,0,4,0,0,0,8])
let tc_022Buf = new Uint8Array([0,0,0,4,0,0,0,8])
export { testPng, testJpg ,tc_020Buf, tc_020_1Buf, tc_021Buf, tc_021_1Buf, tc_022Buf}
\ No newline at end of file
......@@ -15,6 +15,14 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
]
}
\ No newline at end of file
......@@ -36,6 +36,14 @@
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files",
"./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
]
}
\ No newline at end of file
......@@ -62,448 +62,7 @@ export default function imageDecodeOptions() {
afterAll(async function () {
console.info('afterAll case');
})
/**
* @tc.number : TC_062
* @tc.name : packing ImageSource - promise
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 99 }
imagePackerApi.packing(imageSourceApi, packOpts)
.then(data => {
console.info('TC_062 success');
expect(data != undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_062 error: ' + error);
expect(false).assertFail();
done();
})
}
}
} catch (error) {
console.info('TC_062 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-1
* @tc.name : packing ImageSource - callback
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-1', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-1 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-1 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 1 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-1 success' + JSON.stringify(data));
expect(data != undefined).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-2
* @tc.name : packing ImageSource - callback - wrong format
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-2', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-2 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-2 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/gif", quality: 98 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-2 success');
expect(data == undefined).assertTrue();
console.info(data);
done();
})
}
}
} catch (error) {
console.info('TC_062-2 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-3
* @tc.name : packing ImageSource - callback - wrong quality
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.call return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-3', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-3 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-3 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 101 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-3 success');
expect(data == undefined).assertTrue();
console.info(data);
done();
})
}
}
} catch (error) {
console.info('TC_062-3 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-4
* @tc.name : createImagePacker
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-4', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-4 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-4 create image packer failed');
expect(false).assertTrue();
done();
} else {
console.info('TC_062-4 create image packer success');
expect(true).assertTrue();
done();
}
}
} catch (error) {
console.info('TC_062-4 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-5
* @tc.name : packing ImageSource - promise - no quality
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.call return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-5', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-5 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-5 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg" }
imagePackerApi.packing(imageSourceApi, packOpts)
.then(data => {
console.info('TC_062-5 failed');
expect(data == undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_062-5 error: ' + error);
console.log('TC_062-5 success');
expect(true).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-5 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-6
* @tc.name : packing ImageSource - promise - no format
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.call return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-6', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-6 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-6 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { quality: 50 }
imagePackerApi.packing(imageSourceApi, packOpts)
.then(data => {
console.info('TC_062-6 failed');
expect(data == undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_062-6 error: ' + error);
console.log('TC_062-6 success');
expect(true).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-6 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-7
* @tc.name : packing ImageSource - callback - quality 100
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-7', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-7 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-7 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 100 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
if (err) {
expect(false).assertTrue();
console.info('TC_062-7 error: ' + err);
done();
return
}
if (data != undefined) {
console.info('TC_062-7 success');
expect(true).assertTrue();
done();
} else {
except(false).assertTrue();
console.info('TC_062-7 failed');
done();
}
})
}
}
} catch (error) {
console.info('TC_062-7 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-8
* @tc.name : packing ImageSource - callback - quality 0
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-8', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-8 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-8 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 0 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-8 success');
expect(data != undefined).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-8 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-9
* @tc.name : packing ImageSource - callback - quality -1
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-9', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-9 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-9 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: -1 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-9 success');
expect(data == undefined).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-9 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_063
* @tc.name : release ImagePacker - promise
......
......@@ -32,6 +32,14 @@
"./resource/image/test_exif.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files",
"./resource/image/test_exif1.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
]
......
......@@ -14,4 +14,3 @@
*/
require('./image.test.js')
require('./addImage.test.js')
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { testPng } from '../../../../../image/src/main/js/test/testImg'
describe('addImage', function () {
beforeAll(async function () {
console.info('beforeAll case');
})
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(async function () {
console.info('afterEach case');
})
afterAll(async function () {
console.info('afterAll case');
})
function createPixMapPromise(done, testNum, opts) {
const Color = new ArrayBuffer(96);
image.createPixelMap(Color, opts)
.then(pixelmap => {
expect(pixelmap != undefined).assertTrue();
console.info(`${testNum} success`);
done();
})
.catch(error => {
console.log(`${testNum} error: ` + error);
expect(false).assertTrue();
done();
})
}
function createPixMapCb(done, testNum, opts) {
const Color = new ArrayBuffer(96);
image.createPixelMap(Color, opts, (err, pixelmap) => {
expect(pixelmap != undefined).assertTrue();
console.info(`${testNum} success`);
done();
})
}
/**
* @tc.number : addImage_001
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 0)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_001', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 0 }
createPixMapPromise(done, 'add_01_001', opts);
})
/**
* @tc.number : add_01_002
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 1)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_002', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 1 }
createPixMapPromise(done, 'add_01_002', opts);
})
/**
* @tc.number : add_01_003
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 2)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_003', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 2 }
createPixMapPromise(done, 'add_01_003', opts);
})
/**
* @tc.number : add_01_004
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 3)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_004', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 3 }
createPixMapPromise(done, 'add_01_004', opts);
})
/**
* @tc.number : add_02_001
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 0)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_001', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 0 }
createPixMapCb(done, 'add_02_001', opts);
})
/**
* @tc.number : add_02_002
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 1)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_002', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 1 }
createPixMapCb(done, 'add_02_002', opts);
})
/**
* @tc.number : add_02_003
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 2)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_003', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 2 }
createPixMapCb(done, 'add_02_003', opts);
})
/**
* @tc.number : add_02_004
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 3)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_004', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 3 }
createPixMapCb(done, 'add_02_004', opts);
})
/**
* @tc.number : add_053
* @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('add_053', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('add_053 0003 ' + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
console.info('add_053 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('add_053 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('add_053 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('add_053 0011 ' + offset);
}
if (ret) {
console.info('add_053 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('add_053 0014' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('add_053 updateData failed ' + error);
}
})
/**
* @tc.number : add_053-1
* @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('add_053-1', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('add_053-1 0001 ' + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('add_053-1 0002 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await new Promise(res => {
incSouce.updateData(oneStep, isFinished, 0, oneStep.length, (err, ret) => {
res(ret);
})
})
if (!ret) {
console.info('add_053-1 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('add_053-1 0003 ' + offset);
}
if (ret) {
console.info('add_053-1 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('add_053-1 0004' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('add_053-1 updateData failed ' + error);
}
})
})
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
let tc_020Buf = new Uint8Array([0,0,0,4,0,0,0,8,1,0,0,12,1,1,1,16,1,1,1,20,2,2,2,24,3,3,3,28,4,4,4,32,5,5,5,36,6,6,6,40,7,7,7,44,9,9,8,48,10,10,10,52,12,12,12,56,14,14,13,60,16,16,15,64,18,18,17,68,20,20,19,72,22,22,22,76,25,24,24,80,27,27,27,84,30,30,29,88,33,32,32,92,36,35,35,96])
let tc_020_1Buf = new Uint8Array([0,0,0,4,0,0,0,8,1,0,0,12,1,1,1,16,1,1,1,20,2,2,2,24,3,3,3,28,4,4,4,32,5,5,5,36,6,6,6,40,7,7,7,44,9,9,8,48,10,10,10,52,12,12,12,56,14,14,13,60,16,16,15,64,18,18,17,68,20,20,19,72,22,22,22,76,25,24,24,80,27,27,27,84,30,30,29,88,33,32,32,92,36,35,35,96])
let tc_021Buf = new Uint8Array([0,0,0,4,0,0,0,8])
let tc_021_1Buf = new Uint8Array([0,0,0,4,0,0,0,8])
let tc_022Buf = new Uint8Array([0,0,0,4,0,0,0,8])
export {tc_020Buf, tc_020_1Buf, tc_021Buf, tc_021_1Buf, tc_022Buf}
\ No newline at end of file
......@@ -10,23 +10,34 @@
},
"kits": [
{
"type": "PushKit",
"pre-push": [],
"push": []
"test-file-name": [
"ActsImagePackingJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.Packing/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.Packing/haps/entry/files/*"
],
"teardown-command": []
},
{
"test-file-name": [
"ActsImagePackingJsTest.hap"
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image.Packing/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"type": "AppInstallKit",
"cleanup-apps": true
"teardown-command": []
}
]
}
\ No newline at end of file
......@@ -15,9 +15,28 @@
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import featureAbility from '@ohos.ability.featureAbility'
import fileio from '@ohos.fileio'
export default function imagePacking() {
describe('imagePacking', function () {
let filePath;
let fdNumber;
async function getFd(fileName) {
let context = await featureAbility.getContext();
await context.getFilesDir().then((data) => {
filePath = data + '/' + fileName;
console.info('image case filePath is ' + filePath);
})
await fileio.open(filePath).then((data) => {
fdNumber = data;
console.info("image case open fd success " + fdNumber);
}, (err) => {
console.info("image cese open fd fail" + err)
}).catch((err) => {
console.info("image case open fd err " + err);
})
}
beforeAll(async function () {
console.info('beforeAll case');
......@@ -499,4 +518,445 @@ describe('imagePacking', function () {
packing_Cb_Fail(done, 'SUB_IMAGE_packing_Cb_010', 5, packOpts)
})
/**
* @tc.number : TC_062
* @tc.name : packing ImageSource - promise
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 99 }
imagePackerApi.packing(imageSourceApi, packOpts)
.then(data => {
console.info('TC_062 success');
expect(data != undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_062 error: ' + error);
expect(false).assertFail();
done();
})
}
}
} catch (error) {
console.info('TC_062 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-1
* @tc.name : packing ImageSource - callback
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-1', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-1 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-1 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 1 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-1 success' + JSON.stringify(data));
expect(data != undefined).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-2
* @tc.name : packing ImageSource - callback - wrong format
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-2', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-2 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-2 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/gif", quality: 98 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-2 success');
expect(data == undefined).assertTrue();
console.info(data);
done();
})
}
}
} catch (error) {
console.info('TC_062-2 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-3
* @tc.name : packing ImageSource - callback - wrong quality
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.call return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-3', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-3 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-3 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 101 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-3 success');
expect(data == undefined).assertTrue();
console.info(data);
done();
})
}
}
} catch (error) {
console.info('TC_062-3 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-4
* @tc.name : createImagePacker
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-4', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-4 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-4 create image packer failed');
expect(false).assertTrue();
done();
} else {
console.info('TC_062-4 create image packer success');
expect(true).assertTrue();
done();
}
}
} catch (error) {
console.info('TC_062-4 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-5
* @tc.name : packing ImageSource - promise - no quality
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.call return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-5', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-5 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-5 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg" }
imagePackerApi.packing(imageSourceApi, packOpts)
.then(data => {
console.info('TC_062-5 failed');
expect(data == undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_062-5 error: ' + error);
console.log('TC_062-5 success');
expect(true).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-5 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-6
* @tc.name : packing ImageSource - promise - no format
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.call return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-6', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-6 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-6 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { quality: 50 }
imagePackerApi.packing(imageSourceApi, packOpts)
.then(data => {
console.info('TC_062-6 failed');
expect(data == undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_062-6 error: ' + error);
console.log('TC_062-6 success');
expect(true).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-6 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-7
* @tc.name : packing ImageSource - callback - quality 100
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-7', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-7 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-7 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 100 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
if (err) {
expect(false).assertTrue();
console.info('TC_062-7 error: ' + err);
done();
return
}
if (data != undefined) {
console.info('TC_062-7 success');
expect(true).assertTrue();
done();
} else {
except(false).assertTrue();
console.info('TC_062-7 failed');
done();
}
})
}
}
} catch (error) {
console.info('TC_062-7 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-8
* @tc.name : packing ImageSource - callback - quality 0
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-8', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-8 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-8 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: 0 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-8 success');
expect(data != undefined).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-8 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_062-9
* @tc.name : packing ImageSource - callback - quality -1
* @tc.desc : 1.create ImageSource
* 2.call packing
* 3.return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_062-9', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_062-9 create image source failed');
expect(false).assertTrue();
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_062-9 create image packer failed');
expect(false).assertTrue();
done();
} else {
let packOpts = { format: "image/jpeg", quality: -1 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-9 success');
expect(data == undefined).assertTrue();
done();
})
}
}
} catch (error) {
console.info('TC_062-9 error: ' + error);
expect(false).assertTrue();
done();
}
})
})}
......@@ -15,6 +15,14 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
]
}
\ No newline at end of file
......@@ -10,14 +10,11 @@
},
"kits": [
{
"type": "ShellKit",
"run-command": [],
"teardown-command": []
},
{
"type": "PushKit",
"pre-push": [],
"push": []
"test-file-name": [
"ActsImageReceiverJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
......@@ -28,13 +25,6 @@
"aa start -a MediaScannerAbility -b com.ohos.medialibrary.MediaScannerAbilityA"
],
"teardown-command": []
},
{
"test-file-name": [
"ActsImageReceiverJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
......@@ -34,7 +34,8 @@
"type": "ShellKit",
"run-command": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/haps/entry/files/test_large.webp",
"hilog -Q pidoff"
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
......
......@@ -10,23 +10,19 @@
},
"kits": [
{
"type": "PushKit",
"pre-push": [],
"push": []
"test-file-name": [
"ActsImageyuvJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff"
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
},
{
"test-file-name": [
"ActsImageyuvJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
......@@ -9,12 +9,19 @@
},
"kits": [
{
"test-file-name": [
"ActsPixelMapNapiEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册