未验证 提交 270df466 编写于 作者: O openharmony_ci 提交者: Gitee

!4754 image XTS整改

Merge pull request !4754 from liuxueqi/master
......@@ -19,31 +19,28 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files"
]
"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": []
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/test.123 ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/files"
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/test.123 ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./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": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.bmp",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.png",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.123",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.gif",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.jpg",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/moving_test.gif"
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
......
......@@ -13,7 +13,10 @@
* limitations under the License.
*/
import Image_test from './image.test.js'
import imageJsTest from './image.test.js'
import addImage from './addImage.test.js'
export default function testsuite() {
Image_test()
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
......@@ -17,70 +17,1203 @@ import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { testPng, testJpg } from './testImg'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
export default function Image_test() {
describe('Image_test', function () {
var pathJpg = '/data/storage/el2/base/files/test.jpg';
var pathBmp = '/data/storage/el2/base/files/test.bmp';
var pathGif = '/data/storage/el2/base/files/test.gif';
var pathPng = '/data/storage/el2/base/files/test.png';
var pathMovingGif = '/data/storage/el2/base/files/moving_test.gif';
import { tcBuf020, tcBuf020_1, tcBuf021, tcBuf021_1, tcBuf022 } from './testImg'
import featureAbility from '@ohos.ability.featureAbility'
export default function imageJsTest() {
describe('imageJsTest', function () {
let filePath;
let fdNumber;
let globalpixelmap;
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 () {
await applyPermission();
console.info('beforeAll case');
})
beforeEach(function () {
console.info('beforeEach case');
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(async function () {
if (globalpixelmap != undefined) {
console.info('globalpixelmap release start');
try {
await globalpixelmap.release();
} catch (error) {
console.info('globalpixelmap release fail');
}
}
console.info('afterEach case');
})
afterAll(async function () {
console.info('afterAll case');
})
/**
* @tc.number : TC_001
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer)
* @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('TC_001', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001 success');
done();
})
.catch(error => {
console.log('TC_001 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_001-1
* @tc.name : create pixelmap-callback (editable: false, pixelFormat: RGBA_8888, size: { height: 4, width: 6 },bytes = buffer)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-1', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: false, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-1 success');
done();
})
})
/**
* @tc.number : TC_001-2
* @tc.name : createpixelmap-promise (editable: true, pixelFormat: RGB_565, size: { height: 6, width: 8 },bytes = buffer)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-2', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-2 success');
done();
})
.catch(error => {
console.log('TC_001-2 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_001-3
* @tc.name : createpixelmap-callback (editable: false, pixelFormat: RGB_565, size: { height: 6, width: 8 },bytes = buffer)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-3', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: false, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-3 success');
done();
})
})
/**
* @tc.number : TC_001-4
* @tc.name : createpixelmap-promise(editable: true, pixelFormat: unkonwn, size: { height: 6, width: 8 })
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-4', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 0, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-4 success');
done();
})
.catch(error => {
console.log('TC_001-4 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_001-5
* @tc.name : create pixelmap-callback(editable: false, pixelFormat: unkonwn, size: { height: 6, width: 8 })
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-5', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: false, pixelFormat: 0, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-5 success');
done();
})
})
/**
* @tc.number : TC_001-6
* @tc.name : create pixelmap-callback(editable: true, pixelFormat: RGBA_8888, size: { height: 6, width: 8 } bytes > buffer )
* @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('TC_001-6', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-6 success');
done();
})
})
/**
* @tc.number : TC_001-7
* @tc.name : create pixelmap-callback(editable: true, pixelFormat: RGB_565, size: { height: 2, width: 3 }, bytes < buffer)
* @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('TC_001-7', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 2, size: { height: 2, width: 3 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-7 success');
done();
})
})
/**
* @tc.number : TC_001-8
* @tc.name : create pixelmap-callback(editable: true, pixelFormat: unkonwn, size: { height: -1, width: -1 })
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-8', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 0, size: { height: -1, width: -1 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap == undefined).assertTrue();
console.info('TC_001-8 success');
done();
})
})
/**
* @tc.number : TC_001-9
* @tc.name : create pixelmap-callback(editable: true, pixelFormat: unsupported format, size: { height: 6, width: 8 })
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size(Unsupported formats are converted to RGBA_8888)
* 3.using color and opts create newPixelMap
* 4.return newpixelmap empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-9', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 21, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-9 success');
done();
})
})
/**
* @tc.number : TC_020
* @tc.name : readPixelsToBuffer-promise
* @tc.desc : read all pixels to an buffer
* 1.create PixelMap,buffer
* 2.call readPixelsToBuffer
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_020', 0, async function (done) {
console.info('TC_020 in');
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_020 createPixelMap failed');
expect(false).assertTrue()
done();
}
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
var bufferArr2 = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr2.length; i++) {
if (bufferArr2[i] != tcBuf020[i]) {
res = false;
console.info('TC_20_buffer' + bufferArr2[i]);
console.info('TC_020 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_020 success');
expect(true).assertTrue()
done();
}
}).catch(error => {
console.log('TC_020 read error: ' + error);
expect().assertFail();
done();
})
}).catch(error => {
console.log('TC_020 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_020-1
* @tc.name : readPixelsToBuffer-callback
* @tc.desc : read all pixels to an buffer
* 1.create PixelMap,buffer
* 2.call readPixelsToBuffer
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_020-1', 0, async function (done) {
console.info('TC_020-1 in');
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_020-1 createPixelMap failed');
expect(false).assertTrue();
done();
} else {
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer, () => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if (bufferArr[i] != tcBuf020_1[i]) {
res = false;
console.info('TC_020-1 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_020-1 success');
expect(true).assertTrue()
done();
}
})
}
})
})
/**
* @tc.number : TC_020-2
* @tc.name : readPixelsToBuffer-callback(buffer:0)
* @tc.desc : read all pixels to an buffer
* 1.create PixelMap,buffer
* 2.call readPixelsToBuffer
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_020-2', 0, async function (done) {
console.info('TC_020-2 in');
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_020-2 createPixelMap failed');
expect(false).assertTrue();
done();
} else {
const readBuffer = new ArrayBuffer(0);
pixelmap.readPixelsToBuffer(readBuffer, () => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if (bufferArr[i] == 0) {
res = false;
console.info('TC_020-2 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_020-2 success');
expect(true).assertTrue()
done();
}
})
}
})
})
/**
* @tc.number : TC_021
* @tc.name : readPixels-promise
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_021 createPixelMap failed');
expect(false).assertTrue()
done();
}
const area = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(area).then(() => {
var bufferArr2 = new Uint8Array(area.pixels);
var res = true;
for (var i = 0; i < bufferArr2.length; i++) {
if (bufferArr2[i] != tcBuf021[i]) {
res = false;
console.info('TC_021 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_021 success');
expect(true).assertTrue()
done();
}
})
})
.catch(error => {
console.log('TC_021 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_021-1
* @tc.name : readPixels-callback
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-1', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_020-1 createPixelMap failed');
expect(false).assertTrue();
done();
} else {
const area = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(area, () => {
var bufferArr = new Uint8Array(area.pixels);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
console.info('TC_021-1 buffer ' + bufferArr[i]);
if (bufferArr[i] != tcBuf021_1[i]) {
res = false;
console.info('TC_021-1 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_021-1 success');
expect(true).assertTrue()
done();
}
})
}
})
})
/**
* @tc.number : TC_021-2
* @tc.name : readPixels-callback( region: { size: { height: 1, width: 2 }, x: -1, y: -1 })
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-2', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue();
console.info('TC_021-2 create pixelmap fail');
done();
} else {
const area = {
pixels: new ArrayBuffer(20),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: -1, y: -1 }
}
pixelmap.readPixels(area).then(() => {
console.info('TC_021-2 failed');
expect(false).assertTrue();
done();
}).catch(() => {
expect(true).assertTrue();
console.info('TC_021-2 success');
done();
})
}
})
})
/**
* @tc.number : TC_021-3
* @tc.name : readPixels-promise(buffer:0)
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-3', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue();
console.info('TC_021-3 create pixelmap failed');
done();
} else {
const area = {
pixels: new ArrayBuffer(0),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(area).then(() => {
console.info('TC_021-3 failed');
expect(false).assertTrue();
done();
}).catch(() => {
expect(true).assertTrue();
console.info('TC_021-3 success');
done();
})
}
})
})
/**
* @tc.number : TC_021-4
* @tc.name : readPixels-promise(offset > buffer)
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-4', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue();
console.info('TC_021-4 createPixelMap success');
done();
}
const area = {
pixels: new ArrayBuffer(20),
offset: 21,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(area).then(() => {
console.info('TC_021-4 failed');
expect(false).assertTrue();
done();
}).catch(() => {
expect(true).assertTrue();
console.info('TC_021-4 success');
done();
})
})
})
/**
* @tc.number : TC_021-5
* @tc.name : readPixels-promise(region: { size: { height: -1, width:-1}, x: 0, y: 0 })
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-5', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue();
console.info('TC_021-5 createPixelMap success');
done();
}
const area = {
pixels: new ArrayBuffer(20),
offset: 0,
stride: 8,
region: { size: { height: -1, width: -1 }, x: 0, y: 0 }
}
pixelmap.readPixels(area).then(() => {
console.info('TC_021-5 failed');
expect(false).assertTrue();
done();
}).catch(() => {
expect(true).assertTrue();
console.info('TC_021-5 success');
done();
})
})
})
/**
* @tc.number : TC_022
* @tc.name : writePixels-promise
* @tc.desc : 1.create PixelMap
* 2.call writePixels
* 3.call return undefined
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_022', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_022 createPixelMap failed');
expect(false).assertTrue()
done();
}
const area = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
var bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
console.info('============ bufferArr ' + JSON.stringify(bufferArr));
pixelmap.writePixels(area).then(() => {
const readArea = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
console.info('============ bufferArr ' + JSON.stringify(readArea));
pixelmap.readPixels(readArea).then(() => {
var readArr = new Uint8Array(readArea.pixels);
var res = true;
for (var i = 0; i < readArr.length; i++) {
if (readArr[i] != tcBuf022[i]) {
res = false;
console.info('TC_022 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_022 success');
expect(true).assertTrue()
done();
}
})
})
})
.catch(error => {
console.log('TC_022 error: ' + error);
expect().assertFail();
done();
})
})
afterEach(async function () {
if (globalpixelmap != undefined) {
console.info('globalpixelmap release start');
/**
* @tc.number : TC_022-1
* @tc.name : writePixels-callback
* @tc.desc : 1.create PixelMap
* 2.call writePixels
* 3.call return undefined
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_022-1', 0, async function (done) {
try {
await globalpixelmap.release();
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_022-1 createPixelMap failed');
expect(false).assertTrue()
done();
}
const area = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
var bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writePixels(area, () => {
const readArea = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(readArea, () => {
var readArr = new Uint8Array(readArea.pixels);
var res = true;
for (var i = 0; i < readArr.length; i++) {
if (readArr[i] != tcBuf022[i]) {
res = false;
console.info('TC_022-1 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_022-1 success');
expect(true).assertTrue()
done();
}
})
})
})
} catch (error) {
console.info('globalpixelmap release fail');
console.info('TC_022-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_023
* @tc.name : writeBufferToPixels-promise
* @tc.desc : 1.create PixelMap,buffer
* 2.call writeBufferToPixels
* 3.call return undefined
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_023', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_023 createPixelMap failed');
expect(false).assertTrue()
done();
}
const writeColor = new ArrayBuffer(96);
var bufferArr = new Uint8Array(writeColor);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writeBufferToPixels(writeColor).then(() => {
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if (bufferArr[i] == 0) {
res = false;
console.info('TC_023 failed');
expect(false).assertTrue()
done();
break;
}
}
console.info('afterEach case');
if (res) {
console.info('TC_023 success');
expect(true).assertTrue();
done();
}
})
})
})
.catch(error => {
console.log('TC_023 error: ' + error);
expect().assertFail();
done();
})
})
afterAll(async function () {
console.info('afterAll case');
/**
* @tc.number : TC_023-1
* @tc.name : writeBufferToPixels-callback
* @tc.desc : 1.create PixelMap,buffer
* 2.call writeBufferToPixels
* 3.call return undefined
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_023-1', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue()
console.info('TC_023-1 failed');
done();
}
const writeColor = new ArrayBuffer(96);
pixelmap.writeBufferToPixels(writeColor, () => {
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer, () => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if (res) {
if (bufferArr[i] == 0) {
res = false;
console.info('TC_023-1 Success');
expect(true).assertTrue()
done();
break;
}
}
}
if (res) {
console.info('TC_023-1 no change after writeBuffer');
expect(false).assertTrue();
done();
}
})
})
})
})
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission]case accessTokenId is' + tokenID);
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA';
let permissionName3 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID, permissionName1).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
/**
* @tc.number : TC_024
* @tc.name : getImageInfo-pixelmap-promise
* @tc.desc : 1.create PixelMap,ImageInfo
* 2.call getImageInfo
* 3.call return imageinfo
* 4.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_024', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_024 createPixelMap failed');
expect(false).assertTrue()
done();
}
pixelmap.getImageInfo().then(imageInfo => {
if (imageInfo == undefined) {
console.info('TC_024 imageInfo is empty');
expect(false).assertTrue()
done();
}
if (imageInfo.size.height == 4 && imageInfo.size.width == 6) {
console.info('TC_024 success ');
expect(true).assertTrue()
done();
}
done();
}).catch(error => {
console.log('TC_024 getimageinfo error: ' + error);
expect().assertFail();
done();
})
done();
})
.catch(error => {
console.log('TC_024 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_024-1
* @tc.name : getImageInfo-pixelmap-callback
* @tc.desc : 1.create PixelMap,ImageInfo
* 2.call getImageInfo
* 3.call return imageinfo
* 4.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_024-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
if (pixelmap == undefined) {
globalpixelmap = pixelmap;
expect(false).assertTrue()
console.info('TC_024-1 create pixelmap fail');
done();
}
pixelmap.getImageInfo((err, imageInfo) => {
if (imageInfo == undefined) {
console.info('TC_024-1 imageInfo is empty');
expect(false).assertTrue()
done();
}
if (imageInfo.size.height == 4 && imageInfo.size.width == 6) {
console.info('TC_024-1 imageInfo success');
expect(true).assertTrue()
done();
}
done();
})
})
})
/**
* @tc.number : TC_025-1
* @tc.name : getBytesNumberPerRow
* @tc.desc : 1.create PixelMap
* 2.set PixelMap
* 3.call getBytesNumberPerRow
* 4. call return number
* 5.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_025-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
const expectNum = 4 * opts.size.width;
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue()
console.info('TC_25-1 create pixelmap fail');
done();
} else {
const num = pixelmap.getBytesNumberPerRow();
console.info('TC_025-1 num is ' + num);
expect(num == expectNum).assertTrue();
if (num == expectNum) {
console.info('TC_25-1 success');
} else {
console.info('TC_25-1 fail');
}
done();
}
})
})
/**
* @tc.number : TC_026-1
* @tc.name : getPixelBytesNumber
* @tc.desc : 1.create PixelMap
* 2.set Pixel
* 3.call getPixelBytesNumber
* 4. call return number
* 5.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_026-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
const expectNum = 4 * opts.size.width * opts.size.height;
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue()
console.info('TC_026-1 create pixelmap fail');
done();
} else {
const num = pixelmap.getPixelBytesNumber();
console.info('TC_026-1 num is ' + num);
expect(num == expectNum).assertTrue();
if (num == expectNum) {
console.info('TC_026-1 success');
} else {
console.info('[permission]case apply permission failed,createAtManager failed');
console.info('TC_026-1 fail');
}
done();
}
})
})
/**
* @tc.number : TC_027
* @tc.name : release-pixelmap-promise
* @tc.desc : 1.create PixelMap
* 2.set Pixel
* 3.call release
* 4.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_027', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_027 createPixelMap failed');
expect(false).assertTrue()
done();
}
pixelmap.release().then(() => {
console.info('TC_027 success');
expect(true).assertTrue();
done();
}).catch(error => {
console.log('TC_027 error: ' + error);
expect().assertFail();
done();
})
}).catch(error => {
console.log('TC_027 createPixelMap failed error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_027-1
* @tc.name : release-pixelmap-callback
* @tc.desc : 1.create PixelMap
* 2.set Pixel
* 3.call release
* 4.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_027-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_027-1 createPixelMap failed');
expect(false).assertTrue()
done();
}
pixelmap.release(() => {
expect(true).assertTrue();
console.log('TC_027-1 success');
done();
})
})
})
......@@ -96,7 +1229,7 @@ describe('Image_test', function () {
*/
it('TC_041', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041 success');
......@@ -121,7 +1254,7 @@ describe('Image_test', function () {
*/
it('TC_041-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041-1 success');
......@@ -145,7 +1278,7 @@ describe('Image_test', function () {
*/
it('TC_041-2', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041-2 success');
......@@ -170,7 +1303,7 @@ describe('Image_test', function () {
*/
it('TC_041-3', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041-3 success');
......@@ -235,7 +1368,7 @@ describe('Image_test', function () {
*/
it('TC_042', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_042 create image source failed');
......@@ -341,7 +1474,7 @@ describe('Image_test', function () {
*/
it('TC_044', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_044 create image source failed');
......@@ -377,7 +1510,7 @@ describe('Image_test', function () {
*/
it('TC_044-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_044-1 create image source failed');
......@@ -410,7 +1543,7 @@ describe('Image_test', function () {
it('TC_045', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_045 create image source failed');
......@@ -457,7 +1590,7 @@ describe('Image_test', function () {
*/
it('TC_045-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_045-1 create image source failed');
......@@ -490,7 +1623,7 @@ describe('Image_test', function () {
*/
it('TC_045-2', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_045-2 create image source failed');
......@@ -523,7 +1656,7 @@ describe('Image_test', function () {
*/
it('TC_045-3', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_045-3 create image source failed');
......@@ -569,7 +1702,7 @@ describe('Image_test', function () {
*/
it('TC_046', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_046 create image source failed');
......@@ -602,7 +1735,7 @@ describe('Image_test', function () {
*/
it('TC_046-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_046-1 create image source failed');
......@@ -635,7 +1768,7 @@ describe('Image_test', function () {
*/
it('TC_046-2', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_046-2 create image source failed');
......@@ -669,7 +1802,7 @@ describe('Image_test', function () {
*/
it('TC_046-3', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_046-3 create image source failed');
......@@ -715,7 +1848,7 @@ describe('Image_test', function () {
*/
it('TC_046-4', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_046-4 create image source failed');
......@@ -751,7 +1884,7 @@ describe('Image_test', function () {
*/
it('TC_046-5', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_046-5 create image source failed');
......@@ -782,7 +1915,7 @@ describe('Image_test', function () {
*/
it('TC_047', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_047 create image source failed');
......@@ -821,7 +1954,7 @@ describe('Image_test', function () {
*/
it('TC_047-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_047-1 create image source failed');
......@@ -860,7 +1993,7 @@ describe('Image_test', function () {
*/
it('TC_047-2', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_047-2 create image source failed');
......@@ -899,7 +2032,7 @@ describe('Image_test', function () {
*/
it('TC_047-3', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_047-3 create image source failed');
......@@ -943,7 +2076,7 @@ describe('Image_test', function () {
*/
it('TC_047-4', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_047-4 create image source failed');
......@@ -980,7 +2113,7 @@ describe('Image_test', function () {
*/
it('TC_047-5', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_047-5 create image source failed');
......@@ -1018,7 +2151,7 @@ describe('Image_test', function () {
*/
it('TC_050-14', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-14 create image source failed');
......@@ -1056,7 +2189,7 @@ describe('Image_test', function () {
*/
it('TC_050-15', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-15 create image source failed');
......@@ -1194,7 +2327,7 @@ describe('Image_test', function () {
*/
it('TC_064', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_064 create image source failed');
......@@ -1230,7 +2363,7 @@ describe('Image_test', function () {
*/
it('TC_064-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_064-1 create image source failed');
......@@ -1269,7 +2402,7 @@ describe('Image_test', function () {
*/
it('TC_065', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_065 create image source failed');
......@@ -1305,7 +2438,7 @@ describe('Image_test', function () {
*/
it('TC_065-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_065-1 create image source failed');
......@@ -1337,7 +2470,7 @@ describe('Image_test', function () {
*/
it('TC_066', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_066 create image source failed');
......@@ -1373,7 +2506,7 @@ describe('Image_test', function () {
*/
it('TC_066-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_066-1 create image source failed');
......@@ -1406,7 +2539,7 @@ describe('Image_test', function () {
*/
it('TC_067-14', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-14 create image source failed');
......@@ -1444,7 +2577,7 @@ describe('Image_test', function () {
*/
it('TC_067-15', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-15 create image source failed');
......@@ -1478,7 +2611,7 @@ describe('Image_test', function () {
*/
it('TC_068-14', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-14 create image source failed');
......@@ -1516,7 +2649,7 @@ describe('Image_test', function () {
*/
it('TC_068-15', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-15 create image source failed');
......@@ -1550,7 +2683,7 @@ describe('Image_test', function () {
*/
it('TC_163-14', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-14 create image source failed');
......@@ -1588,7 +2721,7 @@ describe('Image_test', function () {
*/
it('TC_163-15', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-15 create image source failed');
......@@ -1620,7 +2753,7 @@ describe('Image_test', function () {
*/
it('TC_164', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_164 create image source failed');
......@@ -1687,4 +2820,119 @@ describe('Image_test', function () {
}
})
})
})}
/**
* @tc.number : editable_001
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: ARGB_8888,
* size: { height: 4, width: 6 },bytes = buffer)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('editable_001', 0, async function (done) {
const Color = new ArrayBuffer(96);
let edit = true;
let opts = { editable: true, pixelFormat: 1, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
expect(pixelmap != undefined).assertTrue();
console.info('editable_001 editable: ' + pixelmap.isEditable);
expect(pixelmap.isEditable == opts.editable).assertTrue();
console.info('editable_001 edit: ' + edit);
expect(pixelmap.isEditable == edit).assertTrue();
done();
})
})
/**
* @tc.number : editable_002
* @tc.name : create pixelmap-callback (editable: false, pixelFormat: ARGB_8888,
* size: { height: 4, width: 6 },bytes = buffer)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('editable_002', 0, async function (done) {
const Color = new ArrayBuffer(96);
let edit = false;
let opts = { editable: false, pixelFormat: 1, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
expect(pixelmap != undefined).assertTrue();
console.info('editable_002 editable: ' + pixelmap.isEditable);
expect(pixelmap.isEditable == opts.editable).assertTrue();
console.info('editable_002 edit: ' + edit);
expect(pixelmap.isEditable == edit).assertTrue();
done();
})
})
/**
* @tc.number : editable_003
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGB_565,
* size: { height: 4, width: 6 }, bytes = buffer)
* @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('editable_003', 0, async function (done) {
const Color = new ArrayBuffer(96);
let edit = true;
let opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts)
.then(pixelmap => {
console.info('editable_003 editable: ' + pixelmap.isEditable);
expect(pixelmap != undefined).assertTrue();
expect(pixelmap.isEditable == opts.editable).assertTrue();
expect(pixelmap.isEditable == edit).assertTrue();
done();
})
.catch(error => {
console.log('editable_003 err' + error);
expect(false).assertTrue();
done();
})
})
/**
* @tc.number : editable_004
* @tc.name : create pixelmap-promise (editable: false, pixelFormat: RGB_565,
* size: { height: 4, width: 6 }, bytes = buffer)
* @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('editable_004', 0, async function (done) {
const Color = new ArrayBuffer(96);
let edit = false;
let opts = { editable: false, pixelFormat: 2, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts)
.then(pixelmap => {
console.info('editable_004 editable: ' + pixelmap.isEditable);
expect(pixelmap != undefined).assertTrue();
expect(pixelmap.isEditable == opts.editable).assertTrue();
expect(pixelmap.isEditable == edit).assertTrue();
done();
})
.catch(error => {
console.log('editable_004 err' + error);
expect(false).assertTrue();
done();
})
})
})
}
......@@ -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 tcBuf020 = 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 tcBuf020_1 = 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 tcBuf021 = new Uint8Array([0,0,0,4,0,0,0,8])
let tcBuf021_1 = new Uint8Array([0,0,0,4,0,0,0,8])
let tcBuf022 = new Uint8Array([0,0,0,4,0,0,0,8])
export { testPng, testJpg ,tcBuf020, tcBuf020_1, tcBuf021, tcBuf021_1, tcBuf022}
\ 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
......@@ -14,7 +14,7 @@
*/
import Image_test from './colorspace.test.js'
import imageColorSpace from './colorspace.test.js'
export default function testsuite() {
Image_test()
imageColorSpace()
}
......@@ -17,8 +17,8 @@ import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { iccbuf } from './testImg2'
export default function Image_test() {
describe('Image_test', function () {
export default function imageColorSpace() {
describe('imageColorSpace', function () {
beforeAll(async function () {
console.info('beforeAll case');
})
......
......@@ -19,29 +19,29 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files/*"
],
"teardown-command":[
]
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"./resource/image/test.tiff ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files"
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files",
"./resource/image/test.tiff ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files",
"./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": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.bmp",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.png",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.tiff",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.jpg",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/moving_test.gif"
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import Image_test from './image.test.js'
import imageDecodeOptions from './image.test.js'
export default function testsuite() {
Image_test()
imageDecodeOptions()
}
......@@ -16,20 +16,30 @@
import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
export default function Image_test() {
describe('Image_test', function () {
var pathJpg = '/data/storage/el2/base/files/test.jpg';
var pathBmp = '/data/storage/el2/base/files/test.bmp';
var pathPng = '/data/storage/el2/base/files/test.png';
var pathMovingGif = '/data/storage/el2/base/files/moving_test.gif';
var pathTiff = '/data/storage/el2/base/files/test.tiff';
import featureAbility from '@ohos.ability.featureAbility'
export default function imageDecodeOptions() {
describe('imageDecodeOptions', function () {
let filePath;
let fdNumber;
let globalpixelmap;
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 () {
await applyPermission();
console.info('beforeAll case');
})
......@@ -53,528 +63,6 @@ describe('Image_test', function () {
console.info('afterAll case');
})
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image.DecodeOptions', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission]case accessTokenId is' + tokenID);
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA';
let permissionName3 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID, permissionName1).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
} else {
console.info('[permission]case apply permission failed,createAtManager failed');
}
}
/**
* @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 {
let fdNumber = fileio.openSync(pathPng);
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 {
let fdNumber = fileio.openSync(pathPng);
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');
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 {
let fdNumber = fileio.openSync(pathPng);
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 {
let fdNumber = fileio.openSync(pathPng);
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 {
let fdNumber = fileio.openSync(pathPng);
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 {
let fdNumber = fileio.openSync(pathPng);
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 {
let fdNumber = fileio.openSync(pathPng);
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 {
let fdNumber = fileio.openSync(pathPng);
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 {
let fdNumber = fileio.openSync(pathPng);
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 {
let fdNumber = fileio.openSync(pathPng);
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
* @tc.desc : 1.create ImagePacker
* 2.call release
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_063', 0, async function (done) {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_063 create image packer failed');
expect(false).assertTrue();
done();
} else {
imagePackerApi.release().then(() => {
console.info('TC_063 success');
expect(true).assertTrue();
done();
}).catch(() => {
console.log('TC_063 error: ' + error);
expect(false).assertTrue();
done();
})
}
})
/**
* @tc.number : TC_063-1
* @tc.name : release ImagePacker - callback
* @tc.desc : 1.create ImagePacker
* 2.call release
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_063-1', 0, async function (done) {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_063-1 create image packer failed');
expect(false).assertTrue();
done();
} else {
imagePackerApi.release(() => {
console.info('TC_063-1 success');
expect(true).assertTrue();
done();
})
}
})
/**
......@@ -590,7 +78,7 @@ describe('Image_test', function () {
*/
it('TC_050', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050 create image source failed');
......@@ -607,11 +95,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_050 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_050 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
} catch (error) {
......@@ -620,6 +113,7 @@ describe('Image_test', function () {
done();
}
})
/**
* @tc.number : TC_050-1
* @tc.name : createPixelMap(decodingOptions)-pixelformat:RGB_565-jpg
......@@ -633,7 +127,7 @@ describe('Image_test', function () {
*/
it('TC_050-1', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-1 create image source failed');
......@@ -650,10 +144,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_050-1 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_050-1 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
} catch (error) {
......@@ -662,6 +162,7 @@ describe('Image_test', function () {
done();
}
})
/**
* @tc.number : TC_050-2
* @tc.name : createPixelMap(decodingOptions)-pixelformat:unknown-jpg
......@@ -675,7 +176,7 @@ describe('Image_test', function () {
*/
it('TC_050-2', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-2 create image source failed');
......@@ -692,11 +193,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_050-2 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_050-2 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
} catch (error) {
......@@ -705,6 +211,7 @@ describe('Image_test', function () {
done();
}
})
/**
* @tc.number : TC_050-3
* @tc.name : createPixelMap(decodingOptions: index 1})-jpg
......@@ -718,7 +225,7 @@ describe('Image_test', function () {
*/
it('TC_050-3', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-3 create image source failed');
......@@ -735,13 +242,13 @@ describe('Image_test', function () {
index: 1
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_050-3 success ');
console.info('TC_050-3 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_050-3 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -767,7 +274,7 @@ describe('Image_test', function () {
*/
it('TC_050-4', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-4 create image source failed');
......@@ -784,13 +291,13 @@ describe('Image_test', function () {
index: -1
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.error('TC_050-4 success');
if (err) {
console.info('TC_050-4 success ');
console.info('TC_050-4 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_050-4 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -816,7 +323,7 @@ describe('Image_test', function () {
*/
it('TC_050-5', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-5 create image source failed');
......@@ -833,13 +340,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_050-5 success ');
console.info('TC_050-5 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_050-5 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -865,7 +372,7 @@ describe('Image_test', function () {
*/
it('TC_050-6', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-6 create image source failed');
......@@ -882,13 +389,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_050-6 success ');
console.info('TC_050-6 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_050-6 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -914,7 +421,7 @@ describe('Image_test', function () {
*/
it('TC_050-7', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-7 create image source failed');
......@@ -931,13 +438,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_050-7 success ');
console.info('TC_050-7 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_050-7 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -963,7 +470,7 @@ describe('Image_test', function () {
*/
it('TC_050-8', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-8 create image source failed');
......@@ -980,11 +487,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_050-8 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_050-8 success');
console.info('TC_050-8 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
} catch (error) {
......@@ -1007,7 +519,7 @@ describe('Image_test', function () {
*/
it('TC_050-9', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-9 create image source failed');
......@@ -1024,11 +536,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_050-9 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_050-9 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
} catch (error) {
......@@ -1051,7 +568,7 @@ describe('Image_test', function () {
*/
it('TC_050-10', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-10 create image source failed');
......@@ -1067,16 +584,23 @@ describe('Image_test', function () {
desiredRegion: { size: { height: 10000, width: 10000 }, x: 0, y: 0 },
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_050-10 success ');
expect(true).assertTrue();
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_050-10 createPixelMap err ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
expect(false).assertTrue();
globalpixelmap = pixelmap;
pixelmap.getImageInfo().then((imageInfo) => {
expect(imageInfo.size.height == 2).assertTrue();
expect(imageInfo.size.width == 1).assertTrue();
console.info('TC_050-10 success ');
console.info("imageInfo height :" + imageInfo.size.height );
console.info("imageInfo width : " + imageInfo.size.width);
done();
}).catch((err) => {
console.info('TC_050-10 getimageInfo err ' + JSON.stringify(err));
})
}
})
}
......@@ -1100,7 +624,7 @@ describe('Image_test', function () {
*/
it('TC_050-11', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-11 create image source failed');
......@@ -1117,13 +641,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_050-11 success ');
console.info('TC_050-11 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_050-11 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1149,7 +673,7 @@ describe('Image_test', function () {
*/
it('TC_050-12', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-12 create image source failed');
......@@ -1166,13 +690,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_050-12 success ');
console.info('TC_050-12 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_050-12 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1198,7 +722,7 @@ describe('Image_test', function () {
*/
it('TC_050-13', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-13 create image source failed');
......@@ -1215,13 +739,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_050-13 success ');
console.info('TC_050-13 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_050-13 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1247,7 +771,7 @@ describe('Image_test', function () {
*/
it('TC_050-14', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-14 create image source failed');
......@@ -1256,7 +780,6 @@ describe('Image_test', function () {
} else {
imageSourceApi.createPixelMap().then(pixelmap => {
globalpixelmap = pixelmap;
console.info('TC_050-14 success ');
expect(pixelmap != undefined).assertTrue();
done();
......@@ -1286,7 +809,7 @@ describe('Image_test', function () {
*/
it('TC_050-15', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-15 create image source failed');
......@@ -1319,7 +842,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067 create image source failed');
......@@ -1336,14 +859,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_067 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_067 createPixelMap ');
console.info('TC_067 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_067-1
* @tc.name : createPixelMap(decodingOptions)-pixelformat:RGBA_565-gif
......@@ -1356,7 +885,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-1 create image source failed');
......@@ -1373,14 +902,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_067-1 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_067-1 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_067-2
* @tc.name : createPixelMap(decodingOptions)-pixelformat:unkonwn-gif
......@@ -1393,7 +928,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-2 create image source failed');
......@@ -1410,14 +945,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_067-2 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_067-2 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_067-3
* @tc.name : createPixelMap(decodingOptions:index 1})-gif
......@@ -1430,7 +971,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-3 create image source failed');
......@@ -1447,11 +988,16 @@ describe('Image_test', function () {
index: 1
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_067-3 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_067-3 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -1468,7 +1014,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-4 create image source failed');
......@@ -1485,13 +1031,13 @@ describe('Image_test', function () {
index: -1
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_067-4 success ');
console.info('TC_067-4 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_067-4 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1511,7 +1057,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-5 create image source failed');
......@@ -1528,13 +1074,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_067-5 success ');
console.info('TC_067-5 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_067-5 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1554,7 +1100,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-6 create image source failed');
......@@ -1571,13 +1117,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_067-6 success ');
console.info('TC_067-6 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_067-6 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1597,7 +1143,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-7 create image source failed');
......@@ -1614,19 +1160,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_067-7 success ');
console.info('TC_067-7 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_067-7 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_067-8
* @tc.name : createPixelMap(decodingOptions:editable false})-gif
......@@ -1639,7 +1186,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-8 create image source failed');
......@@ -1656,11 +1203,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_067-8 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_067-8 success');
console.info('TC_067-8 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -1677,7 +1229,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-9', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-9 create image source failed');
......@@ -1694,11 +1246,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_067-9 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_067-9 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -1715,7 +1272,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-10', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info(' TC_067-10 create image source failed');
......@@ -1732,15 +1289,22 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_067-10 success ');
expect(true).assertTrue();
if (err) {
console.info('TC_067-10 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
expect(false).assertTrue();
globalpixelmap = pixelmap;
pixelmap.getImageInfo().then((imageInfo) => {
expect(imageInfo.size.height == 2).assertTrue();
expect(imageInfo.size.width == 1).assertTrue();
console.info('TC_067-10 success ');
console.info("imageInfo height :" + imageInfo.size.height);
console.info("imageInfo width : " + imageInfo.size.width);
done();
}).catch((err) => {
console.info('TC_067-10 getimageInfo err ' + JSON.stringify(err));
})
}
})
}
......@@ -1758,7 +1322,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-11', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-11 create image source failed');
......@@ -1775,13 +1339,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_067-11 success ');
console.info('TC_067-11createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_067-11 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1801,7 +1365,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-12', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-12 create image source failed');
......@@ -1818,13 +1382,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_067-12 success ');
console.info('TC_067-12 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_067-12 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1844,7 +1408,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-13', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-13 create image source failed');
......@@ -1861,13 +1425,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_067-13 success ');
console.info('TC_067-13 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_067-13 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -1887,7 +1451,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-14', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-14 create image source failed');
......@@ -1896,7 +1460,6 @@ describe('Image_test', function () {
} else {
imageSourceApi.createPixelMap().then(pixelmap => {
globalpixelmap = pixelmap;
console.info('TC_067-14 success ');
expect(pixelmap !== undefined).assertTrue();
done();
......@@ -1920,7 +1483,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_067-15', 0, async function (done) {
let fdNumber = fileio.openSync(pathMovingGif);
await getFd('moving_test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_067-15 create image source failed');
......@@ -1936,7 +1499,6 @@ describe('Image_test', function () {
}
})
/**
* @tc.number : TC_068
* @tc.name : createPixelMap(decodingOptions)-pixelformat:RGBA_8888-bmp
......@@ -1949,7 +1511,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068 create image source failed');
......@@ -1966,14 +1528,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_068 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_068 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_068-1
* @tc.name : createPixelMap(decodingOptions)-pixelformat:RGB_565-bmp
......@@ -1986,7 +1554,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-1 create image source failed');
......@@ -2003,11 +1571,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_068-1 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_068-1 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -2024,7 +1597,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-2 create image source failed');
......@@ -2041,11 +1614,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_068-2 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_068-2 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -2062,7 +1640,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-3 create image source failed');
......@@ -2079,13 +1657,13 @@ describe('Image_test', function () {
index: 1
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_068-3 success ');
console.info('TC_068-3 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_068-3 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2105,7 +1683,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-4 create image source failed');
......@@ -2122,13 +1700,13 @@ describe('Image_test', function () {
index: -1
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_068-4 success ');
console.info('TC_068-4 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_068-4 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2148,7 +1726,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-5 create image source failed');
......@@ -2165,13 +1743,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_068-5 success ');
console.info('TC_068-5 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_068-5 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2191,7 +1769,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-6 create image source failed');
......@@ -2208,13 +1786,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_068-6 success ');
console.info('TC_068-6 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_068-6 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2234,7 +1812,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-7 create image source failed');
......@@ -2251,13 +1829,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_068-7 success ');
console.info('TC_068-7 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_068-7 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2277,7 +1855,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-8 create image source failed');
......@@ -2294,11 +1872,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_068-8 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_068-8 success');
console.info('TC_068-8 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -2315,7 +1898,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-9', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-9 create image source failed');
......@@ -2332,11 +1915,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_068-9 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_068-9 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -2353,7 +1941,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-10', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info(' TC_068-10 create image source failed');
......@@ -2369,16 +1957,24 @@ describe('Image_test', function () {
desiredRegion: { size: { height: 10000, width: 10000 }, x: 0, y: 0 },
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_068-10 success ');
expect(true).assertTrue();
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_068-10 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
expect(false).assertTrue();
globalpixelmap = pixelmap;
pixelmap.getImageInfo().then((imageInfo) => {
expect(imageInfo.size.height == 2).assertTrue();
expect(imageInfo.size.width == 1).assertTrue();
console.info('TC_068-10 success ');
console.info("imageInfo height :" + imageInfo.size.height);
console.info("imageInfo width : " + imageInfo.size.width);
done();
}).catch((err) => {
console.info('TC_068-10 getimageInfo err ' + JSON.stringify(err));
})
}
})
}
......@@ -2396,7 +1992,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-11', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-11 create image source failed');
......@@ -2413,13 +2009,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_068-11 success ');
console.info('TC_068-11 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_068-11 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2439,7 +2035,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-12', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-12 create image source failed');
......@@ -2456,19 +2052,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_068-12 success ');
console.info('TC_068-12 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_068-12 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_068-13
* @tc.name : createPixelMap(decodingOptions:rotate>360)-jpg
......@@ -2481,7 +2078,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_068-13', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp);
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-13 create image source failed');
......@@ -2498,13 +2095,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_068-13 success ');
console.info('TC_068-13 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_068-13 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2524,7 +2121,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163 create image source failed');
......@@ -2541,14 +2138,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_163 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_163 success');
console.info('TC_163 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_163-1
* @tc.name : createPixelMap(decodingOptions)-pixelformat:RGB_565-png
......@@ -2561,7 +2164,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-1 create image source failed');
......@@ -2578,14 +2181,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_163-1 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_163-1 success');
console.info('TC_163-1 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_163-2
* @tc.name : createPixelMap(decodingOptions)-pixelformat:unkonwn-png
......@@ -2598,7 +2207,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-2 create image source failed');
......@@ -2615,14 +2224,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_163-2 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_163-2 success');
console.info('TC_163-2 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_163-3
* @tc.name : createPixelMap(decodingOptions: index 1})-png
......@@ -2635,7 +2250,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-3 create image source failed');
......@@ -2652,13 +2267,13 @@ describe('Image_test', function () {
index: 1
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_163-3 success ');
console.info('TC_163-3 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_163-3 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2679,7 +2294,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-4 create image source failed');
......@@ -2696,13 +2311,13 @@ describe('Image_test', function () {
index: -1
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_163-4 success ');
console.info('TC_163-4 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_163-4 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2723,7 +2338,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-5 create image source failed');
......@@ -2740,13 +2355,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_163-5 success ');
console.info('TC_163-5 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_163-5 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2767,7 +2382,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-6 create image source failed');
......@@ -2784,13 +2399,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_163-6 success ');
console.info('TC_163-6 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_163-6 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2811,7 +2426,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-7 create image source failed');
......@@ -2828,13 +2443,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_163-7 success ');
console.info('TC_163-7 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_163-7 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -2855,7 +2470,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-8 create image source failed');
......@@ -2872,11 +2487,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_163-8 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_163-8 success');
console.info('TC_163-8 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -2893,9 +2513,8 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_163-9', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-9 create image source failed');
......@@ -2912,11 +2531,16 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_163-9 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
console.info('TC_163-9 success');
console.info('TC_163-9 success ');
expect(pixelmap != undefined).assertTrue();
done();
}
})
}
})
......@@ -2934,7 +2558,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-10', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info(' TC_163-10 create image source failed');
......@@ -2951,15 +2575,22 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_163-10 success ');
expect(true).assertTrue();
if (err) {
console.info('TC_163-10 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
expect(false).assertTrue();
globalpixelmap = pixelmap;
pixelmap.getImageInfo().then((imageInfo) => {
expect(imageInfo.size.height == 2).assertTrue();
expect(imageInfo.size.width == 1).assertTrue();
console.info('TC_163-10 success ');
console.info("imageInfo height :" + imageInfo.size.height);
console.info("imageInfo width : " + imageInfo.size.width);
done();
}).catch((err) => {
console.info('TC_163-10 getimageInfo err ' + JSON.stringify(err));
})
}
})
}
......@@ -2978,7 +2609,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-11', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-11 create image source failed');
......@@ -2995,13 +2626,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_163-11 success ');
console.info('TC_163-11 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_163-11 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -3022,7 +2653,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-12', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-12 create image source failed');
......@@ -3039,19 +2670,20 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_163-12 success ');
console.info('TC_163-12 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_163-12 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
})
}
})
/**
* @tc.number : TC_163-13
* @tc.name : createPixelMap(decodingOptions:rotate>360)-png
......@@ -3064,7 +2696,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_163-13', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng);
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_163-13 create image source failed');
......@@ -3081,13 +2713,13 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
if (err) {
console.info('TC_163-13 success ');
console.info('TC_163-13 createPixelMap error ' + JSON.stringify(err));
expect(true).assertTrue();
done();
} else {
console.info('TC_163-13 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
......@@ -3107,7 +2739,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_167', 0, async function (done) {
let fdNumber = fileio.openSync(pathTiff);
await getFd('test.tiff');
const imageSourceApi = image.createImageSource(fdNumber);
let decodingOptions = {
sampleSize: 1,
......@@ -3120,10 +2752,17 @@ describe('Image_test', function () {
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (err) {
console.info('TC_167 success ');
console.info('TC_167 createPixelMap error ' + JSON.stringify(err));
expect(pixelmap == undefined).assertTrue();
done();
} else {
console.info('TC_167 fail ' + pixelmap);
expect(false).assertTrue();
done();
}
})
})
......@@ -3139,7 +2778,7 @@ describe('Image_test', function () {
* @tc.level : Level 1
*/
it('TC_169', 0, async function (done) {
let fdNumber = fileio.openSync(pathJpg);
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_169 create image source failed');
......@@ -3156,9 +2795,18 @@ describe('Image_test', function () {
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
if (err) {
console.info('TC_169 createPixelMap error ' + JSON.stringify(err));
expect(false).assertTrue();
done();
} else {
globalpixelmap = pixelmap;
pixelmap.getImageInfo((err, imageInfo) => {
pixelmap.getImageInfo((error, imageInfo) => {
if (error) {
console.info('TC_169 getimageInfo err ' + JSON.stringify(error));
expect(false).assertTrue();
done();
} else {
if (imageInfo != undefined) {
console.info('TC_169 success');
expect(imageInfo.size.height == 2).assertTrue();
......@@ -3169,9 +2817,11 @@ describe('Image_test', function () {
expect(false).assertTrue()
done();
}
}
})
}
})
}
})
})
})
}
......@@ -17,8 +17,11 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files/*"
],
"teardown-command":[
]
},
{
......@@ -26,20 +29,17 @@
"pre-push": [
],
"push": [
"./resource/image/test_exif.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files",
"./resource/image/test_exif1.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files"
"./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": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files/test_exif.jpg",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files/test_exif1.jpg"
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command":[
]
"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
......@@ -16,16 +16,28 @@
import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { tc_020buf, tc_020_1buf, tc_021buf, tc_021_1buf, tc_022buf } from './testImg'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import featureAbility from '@ohos.ability.featureAbility'
describe('Image', function () {
var pathExifJpg = '/data/storage/el2/base/files/test_exif.jpg';
var pathExifJpg1 = '/data/storage/el2/base/files/test_exif1.jpg';
describe('imageExif', function () {
let filePath;
let fdNumber;
let globalpixelmap;
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 () {
await applyPermission();
console.info('beforeAll case');
})
......@@ -37,6 +49,11 @@ describe('Image', function () {
if (globalpixelmap != undefined) {
await globalpixelmap.release();
}
await fileio.close(fdNumber).then(function(){
console.info("close file succeed");
}).catch(function(err){
console.info("close file failed with error:"+ err);
});
console.info('afterEach case');
})
......@@ -44,1181 +61,6 @@ describe('Image', function () {
console.info('afterAll case');
})
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image.Exif', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission]case accessTokenId is' + tokenID);
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA';
let permissionName3 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID, permissionName1).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
} else {
console.info('[permission]case apply permission failed,createAtManager failed');
}
}
/**
* @tc.number : TC_001
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer)
* @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('TC_001', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001 success');
done();
})
.catch(error => {
console.log('TC_001 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_001-1
* @tc.name : create pixelmap-callback (editable: false, pixelFormat: RGBA_8888, size: { height: 4, width: 6 },bytes = buffer)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-1', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: false, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-1 success');
done();
})
})
/**
* @tc.number : TC_001-2
* @tc.name : createpixelmap-promise (editable: true, pixelFormat: RGB_565, size: { height: 6, width: 8 },bytes = buffer)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-2', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-2 success');
done();
})
.catch(error => {
console.log('TC_001-2 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_001-3
* @tc.name : createpixelmap-callback (editable: false, pixelFormat: RGB_565, size: { height: 6, width: 8 },bytes = buffer)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-3', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: false, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-3 success');
done();
})
})
/**
* @tc.number : TC_001-4
* @tc.name : createpixelmap-promise(editable: true, pixelFormat: unkonwn, size: { height: 6, width: 8 })
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-4', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 0, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-4 success');
done();
})
.catch(error => {
console.log('TC_001-4 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_001-5
* @tc.name : create pixelmap-callback(editable: false, pixelFormat: unkonwn, size: { height: 6, width: 8 })
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixelFormat,size
* 3.using colorand opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-5', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: false, pixelFormat: 0, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-5 success');
done();
})
})
/**
* @tc.number : TC_001-6
* @tc.name : create pixelmap-callback(editable: true, pixelFormat: RGBA_8888, size: { height: 6, width: 8 } bytes > buffer )
* @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('TC_001-6', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-6 success');
done();
})
})
/**
* @tc.number : TC_001-7
* @tc.name : create pixelmap-callback(editable: true, pixelFormat: RGB_565, size: { height: 2, width: 3 }, bytes < buffer)
* @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('TC_001-7', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 2, size: { height: 2, width: 3 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-7 success');
done();
})
})
/**
* @tc.number : TC_001-8
* @tc.name : create pixelmap-callback(editable: true, pixelFormat: unkonwn, size: { height: -1, width: -1 })
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-8', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 0, size: { height: -1, width: -1 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap == undefined).assertTrue();
console.info('TC_001-8 success');
done();
})
})
/**
* @tc.number : TC_001-9
* @tc.name : create pixelmap-callback(editable: true, pixelFormat: unsupported format, size: { height: 6, width: 8 })
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size(Unsupported formats are converted to RGBA_8888)
* 3.using color and opts create newPixelMap
* 4.return newpixelmap empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_001-9', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 21, size: { height: 6, width: 8 } }
image.createPixelMap(Color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
expect(pixelmap != undefined).assertTrue();
console.info('TC_001-9 success');
done();
})
})
/**
* @tc.number : TC_020
* @tc.name : readPixelsToBuffer-promise
* @tc.desc : read all pixels to an buffer
* 1.create PixelMap,buffer
* 2.call readPixelsToBuffer
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_020', 0, async function (done) {
console.info('TC_020 in');
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_020 createPixelMap failed');
expect(false).assertTrue()
done();
}
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
var bufferArr2 = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr2.length; i++) {
if (bufferArr2[i] != tc_020buf[i]) {
res = false;
console.info('TC_20_buffer' + bufferArr2[i]);
console.info('TC_020 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_020 success');
expect(true).assertTrue()
done();
}
}).catch(error => {
console.log('TC_020 read error: ' + error);
expect().assertFail();
done();
})
}).catch(error => {
console.log('TC_020 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_020-1
* @tc.name : readPixelsToBuffer-callback
* @tc.desc : read all pixels to an buffer
* 1.create PixelMap,buffer
* 2.call readPixelsToBuffer
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_020-1', 0, async function (done) {
console.info('TC_020-1 in');
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_020-1 createPixelMap failed');
expect(false).assertTrue();
done();
} else {
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer, () => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if (bufferArr[i] != tc_020_1buf[i]) {
res = false;
console.info('TC_020-1 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_020-1 success');
expect(true).assertTrue()
done();
}
})
}
})
})
/**
* @tc.number : TC_020-2
* @tc.name : readPixelsToBuffer-callback(buffer:0)
* @tc.desc : read all pixels to an buffer
* 1.create PixelMap,buffer
* 2.call readPixelsToBuffer
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_020-2', 0, async function (done) {
console.info('TC_020-2 in');
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_020-2 createPixelMap failed');
expect(false).assertTrue();
done();
} else {
const readBuffer = new ArrayBuffer(0);
pixelmap.readPixelsToBuffer(readBuffer, () => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if (bufferArr[i] == 0) {
res = false;
console.info('TC_020-2 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_020-2 success');
expect(true).assertTrue()
done();
}
})
}
})
})
/**
* @tc.number : TC_021
* @tc.name : readPixels-promise
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_021 createPixelMap failed');
expect(false).assertTrue()
done();
}
const area = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(area).then(() => {
var bufferArr2 = new Uint8Array(area.pixels);
var res = true;
for (var i = 0; i < bufferArr2.length; i++) {
if (bufferArr2[i] != tc_021buf[i]) {
res = false;
console.info('TC_021 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_021 success');
expect(true).assertTrue()
done();
}
})
})
.catch(error => {
console.log('TC_021 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_021-1
* @tc.name : readPixels-callback
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-1', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_020-1 createPixelMap failed');
expect(false).assertTrue();
done();
} else {
const area = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(area, () => {
var bufferArr = new Uint8Array(area.pixels);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
console.info('TC_021-1 buffer ' + bufferArr[i]);
if (bufferArr[i] != tc_021_1buf[i]) {
res = false;
console.info('TC_021-1 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_021-1 success');
expect(true).assertTrue()
done();
}
})
}
})
})
/**
* @tc.number : TC_021-2
* @tc.name : readPixels-callback( region: { size: { height: 1, width: 2 }, x: -1, y: -1 })
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-2', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue();
console.info('TC_021-2 create pixelmap fail');
done();
} else {
const area = {
pixels: new ArrayBuffer(20),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: -1, y: -1 }
}
pixelmap.readPixels(area).then(() => {
console.info('TC_021-2 failed');
expect(false).assertTrue();
done();
}).catch(() => {
expect(true).assertTrue();
console.info('TC_021-2 success');
done();
})
}
})
})
/**
* @tc.number : TC_021-3
* @tc.name : readPixels-promise(buffer:0)
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-3', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue();
console.info('TC_021-3 create pixelmap failed');
done();
} else {
const area = {
pixels: new ArrayBuffer(0),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(area).then(() => {
console.info('TC_021-3 failed');
expect(false).assertTrue();
done();
}).catch(() => {
expect(true).assertTrue();
console.info('TC_021-3 success');
done();
})
}
})
})
/**
* @tc.number : TC_021-4
* @tc.name : readPixels-promise(offset > buffer)
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-4', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue();
console.info('TC_021-4 createPixelMap success');
done();
}
const area = {
pixels: new ArrayBuffer(20),
offset: 21,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(area).then(() => {
console.info('TC_021-4 failed');
expect(false).assertTrue();
done();
}).catch(() => {
expect(true).assertTrue();
console.info('TC_021-4 success');
done();
})
})
})
/**
* @tc.number : TC_021-5
* @tc.name : readPixels-promise(region: { size: { height: -1, width:-1}, x: 0, y: 0 })
* @tc.desc : 1.create PixelMap
* 2.call readPixels
* 3.promise return array
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_021-5', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue();
console.info('TC_021-5 createPixelMap success');
done();
}
const area = {
pixels: new ArrayBuffer(20),
offset: 0,
stride: 8,
region: { size: { height: -1, width: -1 }, x: 0, y: 0 }
}
pixelmap.readPixels(area).then(() => {
console.info('TC_021-5 failed');
expect(false).assertTrue();
done();
}).catch(() => {
expect(true).assertTrue();
console.info('TC_021-5 success');
done();
})
})
})
/**
* @tc.number : TC_022
* @tc.name : writePixels-promise
* @tc.desc : 1.create PixelMap
* 2.call writePixels
* 3.call return undefined
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_022', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_022 createPixelMap failed');
expect(false).assertTrue()
done();
}
const area = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
var bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writePixels(area).then(() => {
const readArea = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(readArea).then(() => {
var readArr = new Uint8Array(readArea.pixels);
var res = true;
for (var i = 0; i < readArr.length; i++) {
if (readArr[i] != tc_022buf[i]) {
res = false;
console.info('TC_022 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_022 success');
expect(true).assertTrue()
done();
}
})
})
})
.catch(error => {
console.log('TC_022 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_022-1
* @tc.name : writePixels-callback
* @tc.desc : 1.create PixelMap
* 2.call writePixels
* 3.call return undefined
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_022-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_022-1 createPixelMap failed');
expect(false).assertTrue()
done();
}
const area = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
var bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writePixels(area, () => {
const readArea = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
pixelmap.readPixels(readArea, () => {
var readArr = new Uint8Array(readArea.pixels);
var res = true;
for (var i = 0; i < readArr.length; i++) {
if (readArr[i] != tc_022buf[i]) {
res = false;
console.info('TC_022-1 failed');
expect(false).assertTrue();
done();
break;
}
}
if (res) {
console.info('TC_022-1 success');
expect(true).assertTrue()
done();
}
})
})
})
.catch(error => {
console.log('TC_022-1 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_023
* @tc.name : writeBufferToPixels-promise
* @tc.desc : 1.create PixelMap,buffer
* 2.call writeBufferToPixels
* 3.call return undefined
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_023', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_023 createPixelMap failed');
expect(false).assertTrue()
done();
}
const writeColor = new ArrayBuffer(96);
var bufferArr = new Uint8Array(writeColor);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writeBufferToPixels(writeColor).then(() => {
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if (bufferArr[i] == 0) {
res = false;
console.info('TC_023 failed');
expect(false).assertTrue()
done();
break;
}
}
if (res) {
console.info('TC_023 success');
expect(true).assertTrue();
done();
}
})
})
})
.catch(error => {
console.log('TC_023 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_023-1
* @tc.name : writeBufferToPixels-callback
* @tc.desc : 1.create PixelMap,buffer
* 2.call writeBufferToPixels
* 3.call return undefined
* 4.callbackcall return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_023-1', 0, async function (done) {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue()
console.info('TC_023-1 failed');
done();
}
const writeColor = new ArrayBuffer(96);
pixelmap.writeBufferToPixels(writeColor, () => {
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer, () => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if (res) {
if (bufferArr[i] == 0) {
res = false;
console.info('TC_023-1 Success');
expect(true).assertTrue()
done();
break;
}
}
}
if (res) {
console.info('TC_023-1 no change after writeBuffer');
expect(false).assertTrue();
done();
}
})
})
})
})
/**
* @tc.number : TC_024
* @tc.name : getImageInfo-pixelmap-promise
* @tc.desc : 1.create PixelMap,ImageInfo
* 2.call getImageInfo
* 3.call return imageinfo
* 4.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_024', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(color, opts)
.then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_024 createPixelMap failed');
expect(false).assertTrue()
done();
}
pixelmap.getImageInfo().then(imageInfo => {
if (imageInfo == undefined) {
console.info('TC_024 imageInfo is empty');
expect(false).assertTrue()
done();
}
if (imageInfo.size.height == 4 && imageInfo.size.width == 6) {
console.info('TC_024 success ');
expect(true).assertTrue()
done();
}
done();
}).catch(error => {
console.log('TC_024 getimageinfo error: ' + error);
expect().assertFail();
done();
})
done();
})
.catch(error => {
console.log('TC_024 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_024-1
* @tc.name : getImageInfo-pixelmap-callback
* @tc.desc : 1.create PixelMap,ImageInfo
* 2.call getImageInfo
* 3.call return imageinfo
* 4.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_024-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
if (pixelmap == undefined) {
globalpixelmap = pixelmap;
expect(false).assertTrue()
console.info('TC_024-1 create pixelmap fail');
done();
}
pixelmap.getImageInfo((err, imageInfo) => {
if (imageInfo == undefined) {
console.info('TC_024-1 imageInfo is empty');
expect(false).assertTrue()
done();
}
if (imageInfo.size.height == 4 && imageInfo.size.width == 6) {
console.info('TC_024-1 imageInfo success');
expect(true).assertTrue()
done();
}
done();
})
})
})
/**
* @tc.number : TC_025-1
* @tc.name : getBytesNumberPerRow
* @tc.desc : 1.create PixelMap
* 2.set PixelMap
* 3.call getBytesNumberPerRow
* 4. call return number
* 5.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_025-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
const expectNum = 4 * opts.size.width;
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue()
console.info('TC_25-1 create pixelmap fail');
done();
} else {
const num = pixelmap.getBytesNumberPerRow();
console.info('TC_025-1 num is ' + num);
expect(num == expectNum).assertTrue();
if (num == expectNum) {
console.info('TC_25-1 success');
} else {
console.info('TC_25-1 fail');
}
done();
}
})
})
/**
* @tc.number : TC_026-1
* @tc.name : getPixelBytesNumber
* @tc.desc : 1.create PixelMap
* 2.set Pixel
* 3.call getPixelBytesNumber
* 4. call return number
* 5.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_026-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
const expectNum = 4 * opts.size.width * opts.size.height;
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
expect(false).assertTrue()
console.info('TC_026-1 create pixelmap fail');
done();
} else {
const num = pixelmap.getPixelBytesNumber();
console.info('TC_026-1 num is ' + num);
expect(num == expectNum).assertTrue();
if (num == expectNum) {
console.info('TC_026-1 success');
} else {
console.info('TC_026-1 fail');
}
done();
}
})
})
/**
* @tc.number : TC_027
* @tc.name : release-pixelmap-promise
* @tc.desc : 1.create PixelMap
* 2.set Pixel
* 3.call release
* 4.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_027', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_027 createPixelMap failed');
expect(false).assertTrue()
done();
}
pixelmap.release().then(() => {
console.info('TC_027 success');
expect(true).assertTrue();
done();
}).catch(error => {
console.log('TC_027 error: ' + error);
expect().assertFail();
done();
})
}).catch(error => {
console.log('TC_027 createPixelMap failed error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number : TC_027-1
* @tc.name : release-pixelmap-callback
* @tc.desc : 1.create PixelMap
* 2.set Pixel
* 3.call release
* 4.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_027-1', 0, async function (done) {
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) {
console.info('TC_027-1 createPixelMap failed');
expect(false).assertTrue()
done();
}
pixelmap.release(() => {
expect(true).assertTrue();
console.log('TC_027-1 success');
done();
})
})
})
/**
* @tc.number : TC_171
* @tc.name : getImageProperty(BitsPerSample)-promise
......@@ -1231,7 +73,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg1);
await getFd('test_exif1.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171 create image source failed');
......@@ -1264,7 +106,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171-1 create image source failed');
......@@ -1297,7 +139,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171-2 create image source failed');
......@@ -1330,7 +172,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171-3 create image source failed');
......@@ -1363,7 +205,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171-4 create image source failed');
......@@ -1396,7 +238,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171-5 create image source failed');
......@@ -1429,7 +271,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171-6 create image source failed');
......@@ -1462,7 +304,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171-7 create image source failed');
......@@ -1495,7 +337,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_171-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_171-8 create image source failed');
......@@ -1527,7 +369,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg1);
await getFd('test_exif1.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172 create image source failed');
......@@ -1559,7 +401,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172-1 create image source failed');
......@@ -1591,7 +433,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172-2 create image source failed');
......@@ -1623,7 +465,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172-3 create image source failed');
......@@ -1655,7 +497,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172-4 create image source failed');
......@@ -1687,7 +529,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172-5 create image source failed');
......@@ -1719,7 +561,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172-6 create image source failed');
......@@ -1751,7 +593,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172-7 create image source failed');
......@@ -1783,7 +625,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_172-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_172-8 create image source failed');
......@@ -1816,7 +658,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg1);
await getFd('test_exif1.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173 create image source failed');
......@@ -1850,7 +692,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173-1 create image source failed');
......@@ -1884,7 +726,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173-2 create image source failed');
......@@ -1918,7 +760,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173-3 create image source failed');
......@@ -1952,7 +794,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173-4 create image source failed');
......@@ -1986,7 +828,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173-5 create image source failed');
......@@ -2020,7 +862,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173-6 create image source failed');
......@@ -2054,7 +896,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173-7 create image source failed');
......@@ -2088,7 +930,7 @@ describe('Image', function () {
* @tc.level : Level 1
*/
it('TC_173-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg);
await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_173-8 create image source failed');
......
/*
* 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
......@@ -18,15 +18,18 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files/*"
],
"teardown-command":[
]
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test_exif.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files"
"./resource/image/test_exif.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files"
]
},
{
......@@ -34,7 +37,7 @@
"run-command": [
"hilog -Q pidoff",
"hilog -b D",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files/test_exif.jpg"
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files/test_exif.jpg"
],
"teardown-command": [
"rm -rf /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/*"
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Image from './modify.test.js'
import imageModifyProperty from './modify.test.js'
export default function testsuite() {
Image()
imageModifyProperty()
}
......@@ -17,23 +17,41 @@ import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {modifyBuf} from './modifyBuffer'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
export default function Image() {
describe('Image', function () {
var pathExifJpg = '/data/storage/el2/base/files/test_exif.jpg';
import featureAbility from '@ohos.ability.featureAbility'
export default function imageModifyProperty() {
describe('imageModifyProperty', 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, 0o2 | 0o100, 0o777).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 () {
await applyPermission();
console.info('beforeAll case');
})
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(function () {
afterEach(async function () {
await fileio.close(fdNumber).then(function(){
console.info("close file succeed");
}).catch(function(err){
console.info("close file failed with error:"+ err);
});
console.info('afterEach case');
})
......@@ -41,34 +59,6 @@ describe('Image', function () {
console.info('afterAll case');
})
async function applyPermission(){
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image.ModifyProperty',0,100);
let atManager = abilityAccessCtrl.createAtManager();
if(atManager != null){
let tokenID = appInfo.accessTokenId;
console.info('[permission]case accessTokenId is' + tokenID);
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA';
let permissionName3 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID,permissionName1).then((result)=>{
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err)=>{
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID,permissionName2).then((result)=>{
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err)=>{
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID,permissionName3).then((result)=>{
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err)=>{
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
}else{
console.info('[permission]case apply permission failed,createAtManager failed');
}
}
async function modifyPromise(done, testNum, type, key, value, checkProps){
let imageSourceApi;
......@@ -76,8 +66,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -108,8 +98,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -143,8 +133,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -179,8 +169,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -202,8 +192,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
}else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -226,8 +216,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
} catch (error) {
expect(false).assertTrue();
......
......@@ -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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import Image_test from './packing.test.js'
import imagePacking from './packing.test.js'
export default function testsuite() {
Image_test()
imagePacking()
}
......@@ -14,14 +14,31 @@
*/
import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio'
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 Image_test() {
describe('Image_test', function () {
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 () {
await applyPermission();
console.info('beforeAll case');
})
......@@ -37,37 +54,7 @@ describe('Image_test', function () {
console.info('afterAll case');
})
async function applyPermission() {
console.info('[permission]case applyPermission in');
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image.Packing', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission]case accessTokenId is' + tokenID);
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA';
let permissionName3 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID, permissionName1).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
} else {
console.info('[permission]case apply permission failed,createAtManager failed');
}
}
function packing_promise(done, testNum, pixFormat, arg) {
function packingPromise(done, testNum, pixFormat, arg) {
let opts;
const Color = new ArrayBuffer(96);
if (pixFormat == 2) {
......@@ -113,7 +100,7 @@ describe('Image_test', function () {
})
}
function packing_cb(done, testNum, pixFormat, arg) {
function packingCb(done, testNum, pixFormat, arg) {
let opts;
const Color = new ArrayBuffer(96);
if (pixFormat == 2) {
......@@ -159,7 +146,7 @@ describe('Image_test', function () {
})
}
function packing_cb_fail(done, testNum, pixFormat, arg) {
function packingCbFail(done, testNum, pixFormat, arg) {
const Color = new ArrayBuffer(96);
if (pixFormat == 2) {
var opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } }
......@@ -192,7 +179,7 @@ describe('Image_test', function () {
})
}
function packing_promise_fail(done, testNum, pixFormat, arg) {
function packingPromiseFail(done, testNum, pixFormat, arg) {
const Color = new ArrayBuffer(96);
if (pixFormat == 2) {
var opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } }
......@@ -241,7 +228,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_001', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 99 }
packing_promise(done, 'SUB_IMAGE_packing_P_001', 2, packOpts)
packingPromise(done, 'SUB_IMAGE_packing_P_001', 2, packOpts)
})
/**
......@@ -256,7 +243,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_002', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_002', 2, packOpts)
packingPromiseFail(done, 'SUB_IMAGE_packing_P_002', 2, packOpts)
})
/**
......@@ -271,7 +258,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_003', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_003', 2, packOpts)
packingPromiseFail(done, 'SUB_IMAGE_packing_P_003', 2, packOpts)
})
/**
......@@ -286,7 +273,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_004', 0, async function (done) {
let packOpts = { quality: 99 }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_004', 2, packOpts)
packingPromiseFail(done, 'SUB_IMAGE_packing_P_004', 2, packOpts)
})
/**
......@@ -301,7 +288,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_005', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_005', 2, packOpts)
packingPromiseFail(done, 'SUB_IMAGE_packing_P_005', 2, packOpts)
})
/**
......@@ -316,7 +303,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_006', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 50 }
packing_promise(done, 'SUB_IMAGE_packing_P_006', 5, packOpts)
packingPromise(done, 'SUB_IMAGE_packing_P_006', 5, packOpts)
})
/**
......@@ -331,7 +318,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_007', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_007', 5, packOpts)
packingPromiseFail(done, 'SUB_IMAGE_packing_P_007', 5, packOpts)
})
/**
......@@ -346,7 +333,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_008', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_008', 5, packOpts)
packingPromiseFail(done, 'SUB_IMAGE_packing_P_008', 5, packOpts)
})
/**
......@@ -361,7 +348,7 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_009', 0, async function (done) {
let packOpts = { quality: 99 }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_009', 5, packOpts)
packingPromiseFail(done, 'SUB_IMAGE_packing_P_009', 5, packOpts)
})
/**
......@@ -376,12 +363,12 @@ describe('Image_test', function () {
*/
it('SUB_IMAGE_packing_P_010', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_010', 5, packOpts)
packingPromiseFail(done, 'SUB_IMAGE_packing_P_010', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_001
* @tc.name : SUB_IMAGE_packing_CB_001
* @tc.number : SUB_IMAGE_packingCb_001
* @tc.name : SUB_IMAGE_packingCb_001
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -389,14 +376,14 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_001', 0, async function (done) {
it('SUB_IMAGE_packingCb_001', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 99 }
packing_cb(done, 'SUB_IMAGE_packing_CB_001', 2, packOpts)
packingCb(done, 'SUB_IMAGE_packingCb_001', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_002
* @tc.name : SUB_IMAGE_packing_CB_002 - callback - RGB565 quality 123
* @tc.number : SUB_IMAGE_packingCb_002
* @tc.name : SUB_IMAGE_packingCb_002 - callback - RGB565 quality 123
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -404,15 +391,15 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_002', 0, async function (done) {
it('SUB_IMAGE_packingCb_002', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_002', 2, packOpts)
packingCbFail(done, 'SUB_IMAGE_packingCb_002', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_003
* @tc.name : SUB_IMAGE_packing_CB_003 - callback - RGB565 quality null
* @tc.number : SUB_IMAGE_packingCb_003
* @tc.name : SUB_IMAGE_packingCb_003 - callback - RGB565 quality null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -420,14 +407,14 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_003', 0, async function (done) {
it('SUB_IMAGE_packingCb_003', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_003', 2, packOpts)
packingCbFail(done, 'SUB_IMAGE_packingCb_003', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_004
* @tc.name : SUB_IMAGE_packing_CB_004 - callback - RGB565 format null
* @tc.number : SUB_IMAGE_packingCb_004
* @tc.name : SUB_IMAGE_packingCb_004 - callback - RGB565 format null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -435,14 +422,14 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_004', 0, async function (done) {
it('SUB_IMAGE_packingCb_004', 0, async function (done) {
let packOpts = { quality: 99 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_004', 2, packOpts)
packingCbFail(done, 'SUB_IMAGE_packingCb_004', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_005
* @tc.name : SUB_IMAGE_packing_CB_005 - callback - RGB565 wrong format
* @tc.number : SUB_IMAGE_packingCb_005
* @tc.name : SUB_IMAGE_packingCb_005 - callback - RGB565 wrong format
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -450,14 +437,14 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_005', 0, async function (done) {
it('SUB_IMAGE_packingCb_005', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_005', 2, packOpts)
packingCbFail(done, 'SUB_IMAGE_packingCb_005', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_006
* @tc.name : SUB_IMAGE_packing_CB_006
* @tc.number : SUB_IMAGE_packingCb_006
* @tc.name : SUB_IMAGE_packingCb_006
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -465,14 +452,14 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_006', 0, async function (done) {
it('SUB_IMAGE_packingCb_006', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 50 }
packing_cb(done, 'SUB_IMAGE_packing_CB_006', 5, packOpts)
packingCb(done, 'SUB_IMAGE_packingCb_006', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_007
* @tc.name : SUB_IMAGE_packing_CB_007 - callback - RGB888 quality 123
* @tc.number : SUB_IMAGE_packingCb_007
* @tc.name : SUB_IMAGE_packingCb_007 - callback - RGB888 quality 123
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -480,15 +467,15 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_007', 0, async function (done) {
it('SUB_IMAGE_packingCb_007', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_007', 5, packOpts)
packingCbFail(done, 'SUB_IMAGE_packingCb_007', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_008
* @tc.name : SUB_IMAGE_packing_CB_008 - callback - RGB888 quality null
* @tc.number : SUB_IMAGE_packingCb_008
* @tc.name : SUB_IMAGE_packingCb_008 - callback - RGB888 quality null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -496,14 +483,14 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_008', 0, async function (done) {
it('SUB_IMAGE_packingCb_008', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_008', 5, packOpts)
packingCbFail(done, 'SUB_IMAGE_packingCb_008', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_009
* @tc.name : SUB_IMAGE_packing_CB_009 - callback - RGB888 format null
* @tc.number : SUB_IMAGE_packingCb_009
* @tc.name : SUB_IMAGE_packingCb_009 - callback - RGB888 format null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -511,14 +498,14 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_009', 0, async function (done) {
it('SUB_IMAGE_packingCb_009', 0, async function (done) {
let packOpts = { quality: 99 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_009', 5, packOpts)
packingCbFail(done, 'SUB_IMAGE_packingCb_009', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_010
* @tc.name : SUB_IMAGE_packing_CB_010 - callback - RGB888 wrong format
* @tc.number : SUB_IMAGE_packingCb_010
* @tc.name : SUB_IMAGE_packingCb_010 - callback - RGB888 wrong format
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
......@@ -526,9 +513,505 @@ describe('Image_test', function () {
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_010', 0, async function (done) {
it('SUB_IMAGE_packingCb_010', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_010', 5, packOpts)
packingCbFail(done, 'SUB_IMAGE_packingCb_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();
}
})
/**
* @tc.number : TC_063
* @tc.name : release ImagePacker - promise
* @tc.desc : 1.create ImagePacker
* 2.call release
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_063', 0, async function (done) {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_063 create image packer failed');
expect(false).assertTrue();
done();
} else {
imagePackerApi.release().then(() => {
console.info('TC_063 success');
expect(true).assertTrue();
done();
}).catch(() => {
console.log('TC_063 error: ' + error);
expect(false).assertTrue();
done();
})
}
})
/**
* @tc.number : TC_063-1
* @tc.name : release ImagePacker - callback
* @tc.desc : 1.create ImagePacker
* 2.call release
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_063-1', 0, async function (done) {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_063-1 create image packer failed');
expect(false).assertTrue();
done();
} else {
imagePackerApi.release(() => {
console.info('TC_063-1 success');
expect(true).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
......@@ -14,7 +14,7 @@
*/
import Image_test from './framework.test.js'
import imagePixelMapFramework from './framework.test.js'
export default function testsuite() {
Image_test()
imagePixelMapFramework()
}
......@@ -17,8 +17,8 @@ import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { base64Image, scale2x1, translate3x1, rotate90, flipH, testBmp, testGif, crop3x3, scale1x4, setAlpha8, translate1x3 } from './testImg2'
import { testPng, testJpg} from '../../../../../image/src/main/js/test/testImg'
export default function Image_test() {
describe('Image_test', function () {
export default function imagePixelMapFramework() {
describe('imagePixelMapFramework', function () {
beforeAll(async function () {
console.info('beforeAll case');
})
......
......@@ -10,31 +10,19 @@
},
"kits": [
{
"type": "ShellKit",
"run-command": [],
"teardown-command": []
},
{
"type": "PushKit",
"pre-push": [],
"push": []
"test-file-name": [
"ActsImageReceiverJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D",
"killall com.ohos.medialibrary.MediaScannerAbilityA",
"aa start -a MediaScannerAbility -b com.ohos.medialibrary.MediaScannerAbilityA"
"hilog -b D"
],
"teardown-command": []
},
{
"test-file-name": [
"ActsImageReceiverJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
......@@ -19,31 +19,23 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/haps/entry/files/*"
],
"teardown-command": []
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test_large.webp ->/data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files",
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files",
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files",
"./resource/image/test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files"
"./resource/image/test_large.webp ->/data/app/el2/100/base/ohos.acts.multimedia.image.Webp/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files/test.jpg",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files/test.png",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files/test.bmp",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files/test.gif",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files/test_large.webp",
"hilog -Q pidoff"
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/haps/entry/files/test_large.webp",
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import Image_test from './webp.test.js'
import imageWebp from './webp.test.js'
export default function testsuite() {
Image_test()
imageWebp()
}
......@@ -16,18 +16,28 @@
import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import featureAbility from '@ohos.ability.featureAbility'
export default function Image() {
describe('Image', function () {
var pathJpg = '/data/storage/el2/base/files/test.jpg';
var pathWebp = '/data/storage/el2/base/files/test_large.webp';
var pathPng = '/data/storage/el2/base/files/test.png';
var pathBmp = '/data/storage/el2/base/files/test.bmp';
var pathGif = '/data/storage/el2/base/files/test.gif';
export default function imageWebp() {
describe('imageWebp', 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 () {
await applyPermission();
console.info('beforeAll case');
})
......@@ -36,6 +46,11 @@ describe('Image', function () {
})
afterEach(async function () {
await fileio.close(fdNumber).then(function(){
console.info("close file succeed");
}).catch(function(err){
console.info("close file failed with error:"+ err);
});
console.info('afterEach case');
})
......@@ -43,37 +58,9 @@ describe('Image', function () {
console.info('afterAll case');
})
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image.Webp', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission]case accessTokenId is' + tokenID);
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA';
let permissionName3 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID, permissionName1).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
} else {
console.info('[permission]case apply permission failed,createAtManager failed');
}
}
async function createPixMapCbErr(done, testNum, arg) {
let fdNumber = fileio.openSync(pathWebp);
await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -92,8 +79,37 @@ describe('Image', function () {
})
}
}
async function createPixMapCb(done, testNum, arg) {
await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap(arg, (err, pixelmap) => {
if (err) {
console.info(`${testNum} - fail `);
expect(false).assertTrue();
done();
} else {
pixelmap.getImageInfo().then((imageInfo) => {
expect(imageInfo.size.height == 2).assertTrue();
expect(imageInfo.size.width == 1).assertTrue();
console.info(`${testNum} - success `);
console.info("imageInfo height :" + imageInfo.size.height + "width : " + imageInfo.size.width);
done();
}).catch((err) => {
console.info(`${testNum} getimageInfo err ` + JSON.stringify(err));
})
}
})
}
}
async function createPixMapPromiseErr(done, testNum, arg) {
let fdNumber = fileio.openSync(pathWebp);
await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -111,6 +127,31 @@ describe('Image', function () {
})
}
}
async function createPixMapPromise(done, testNum, arg) {
await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap(arg).then(pixelmap => {
pixelmap.getImageInfo().then((imageInfo) => {
expect(imageInfo.size.height == 2).assertTrue();
expect(imageInfo.size.width == 1).assertTrue();
console.info(`${testNum} - success `);
console.info("imageInfo height :" + imageInfo.size.height + "width : " + imageInfo.size.width);
done();
}).catch((err) => {
console.info(`${testNum} getimageInfo err ` + JSON.stringify(err));
})
}).catch(error => {
console.log(`${testNum} fail `);
expect(flase).assertTrue();
done();
})
}
}
async function packingPromise(done, testNum, arg) {
console.info(`${testNum} enter`);
var height = 4
......@@ -435,7 +476,7 @@ describe('Image', function () {
*/
it('wbp_001', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathWebp);
await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('wbp_001 create image source failed');
......@@ -484,7 +525,7 @@ describe('Image', function () {
*/
it('wbp_002', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathWebp);
await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('wbp_002 create image source failed');
......@@ -533,7 +574,7 @@ describe('Image', function () {
*/
it('wbp_003', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathWebp);
await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('wbp_003 create image source failed');
......@@ -569,7 +610,7 @@ describe('Image', function () {
*/
it('wbp_004', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathWebp);
await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('wbp_004 create image source failed');
......@@ -753,7 +794,7 @@ describe('Image', function () {
desiredRegion: { size: { height: 10000, width: 10000 }, x: 0, y: 0 },
index: 0
};
createPixMapCbErr(done, 'wbp_009', decodingOptions)
createPixMapCb(done, 'wbp_009', decodingOptions)
})
/**
......@@ -874,7 +915,7 @@ describe('Image', function () {
desiredRegion: { size: { height: 10000, width: 10000 }, x: 0, y: 0 },
index: 0
};
createPixMapPromiseErr(done, 'wbp_014', decodingOptions)
createPixMapPromise(done, 'wbp_014', decodingOptions)
})
/**
......
......@@ -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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import Image from './yuv.test.js'
import imageYuv from './yuv.test.js'
export default function testsuite() {
Image()
imageYuv()
}
......@@ -16,11 +16,10 @@
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function Image() {
describe('Image', function () {
export default function imageYuv() {
describe('imageYuv', function () {
beforeAll(async function () {
await applyPermission();
console.info('beforeAll case');
})
......@@ -37,36 +36,6 @@ describe('Image', function () {
console.info('afterAll case');
})
async function applyPermission() {
console.info('[permission]case applyPermission in');
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image.YUV', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission]case accessTokenId is' + tokenID);
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA';
let permissionName3 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID, permissionName1).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3).then((result) => {
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err) => {
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
} else {
console.info('[permission]case apply permission failed,createAtManager failed');
}
}
function createBuffer(height, width) {
var ySize = height * width;
var uvSize = ySize / 2
......@@ -129,7 +98,7 @@ describe('Image', function () {
}
}
async function yuvToJpegByPixelMapPromise_fail(done, testNum, sourceOptions, yuvData) {
async function yuvToJpegByPixelMapPromise_Fail(done, testNum, sourceOptions, yuvData) {
try {
let imageSource = image.createImageSource(yuvData, sourceOptions)
if (imageSource == undefined) {
......@@ -192,7 +161,7 @@ describe('Image', function () {
}
}
async function yuvToJpegByPixelMapCallback_fail(done, testNum, sourceOptions, yuvData) {
async function yuvToJpegByPixelMapCallback_Fail(done, testNum, sourceOptions, yuvData) {
try {
let imageSource = image.createImageSource(yuvData, sourceOptions);
if (imageSource == undefined) {
......@@ -255,7 +224,7 @@ describe('Image', function () {
}
}
async function yuvToJpegByImageSourcePromise_fail(done, testNum, sourceOptions, arg, yuvData) {
async function yuvToJpegByImageSourcePromise_Fail(done, testNum, sourceOptions, arg, yuvData) {
let imageSource = image.createImageSource(yuvData, sourceOptions);
if (imageSource == undefined) {
console.info(`${testNum} create ImageSource failed`);
......@@ -317,7 +286,7 @@ describe('Image', function () {
}
}
async function yuvToJpegByImageSourceCallback_fail(done, testNum, sourceOptions, arg, yuvData) {
async function yuvToJpegByImageSourceCallback_Fail(done, testNum, sourceOptions, arg, yuvData) {
let imageSource = image.createImageSource(yuvData, sourceOptions);
if (imageSource == undefined) {
console.info(`${testNum} create ImageSource failed`);
......@@ -395,7 +364,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_P_004', 0, async function (done) {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } };
yuvToJpegByPixelMapPromise_fail(done, 'SUB_IMAGE_yuv_pixelmap_P_004', sourceOptions, yuvData)
yuvToJpegByPixelMapPromise_Fail(done, 'SUB_IMAGE_yuv_pixelmap_P_004', sourceOptions, yuvData)
})
/**
......@@ -425,7 +394,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_P_006', 0, async function (done) {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } };
yuvToJpegByPixelMapPromise_fail(done, 'SUB_IMAGE_yuv_pixelmap_P_006', sourceOptions, yuvData)
yuvToJpegByPixelMapPromise_Fail(done, 'SUB_IMAGE_yuv_pixelmap_P_006', sourceOptions, yuvData)
})
/**
......@@ -440,7 +409,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_P_007', 0, async function (done) {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 6 } };
yuvToJpegByPixelMapPromise_fail(done, 'SUB_IMAGE_yuv_pixelmap_P_007', sourceOptions, yuvData)
yuvToJpegByPixelMapPromise_Fail(done, 'SUB_IMAGE_yuv_pixelmap_P_007', sourceOptions, yuvData)
})
/**
......@@ -455,7 +424,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_P_008', 0, async function (done) {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 6 } };
yuvToJpegByPixelMapPromise_fail(done, 'SUB_IMAGE_yuv_pixelmap_P_008', sourceOptions, yuvData)
yuvToJpegByPixelMapPromise_Fail(done, 'SUB_IMAGE_yuv_pixelmap_P_008', sourceOptions, yuvData)
})
/**
......@@ -527,7 +496,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } };
let packOpts = { format: "image/jpeg", quality: 99 }
yuvToJpegByImageSourcePromise_fail(done, 'SUB_IMAGE_yuv_imagesource_P_004', sourceOptions, packOpts, yuvData)
yuvToJpegByImageSourcePromise_Fail(done, 'SUB_IMAGE_yuv_imagesource_P_004', sourceOptions, packOpts, yuvData)
})
/**
......@@ -563,7 +532,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } };
let packOpts = { format: "image/jpeg", quality: 99 }
yuvToJpegByImageSourcePromise_fail(done, 'SUB_IMAGE_yuv_imagesource_P_006', sourceOptions, packOpts, yuvData)
yuvToJpegByImageSourcePromise_Fail(done, 'SUB_IMAGE_yuv_imagesource_P_006', sourceOptions, packOpts, yuvData)
})
/**
......@@ -581,7 +550,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 6 } };
let packOpts = { format: "image/jpeg", quality: 99 }
yuvToJpegByImageSourcePromise_fail(done, 'SUB_IMAGE_yuv_imagesource_P_007', sourceOptions, packOpts, yuvData)
yuvToJpegByImageSourcePromise_Fail(done, 'SUB_IMAGE_yuv_imagesource_P_007', sourceOptions, packOpts, yuvData)
})
/**
......@@ -599,7 +568,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 6 } };
let packOpts = { format: "image/jpeg", quality: 99 }
yuvToJpegByImageSourcePromise_fail(done, 'SUB_IMAGE_yuv_imagesource_P_008', sourceOptions, packOpts, yuvData)
yuvToJpegByImageSourcePromise_Fail(done, 'SUB_IMAGE_yuv_imagesource_P_008', sourceOptions, packOpts, yuvData)
})
/**
......@@ -659,7 +628,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_CB_004', 0, async function (done) {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } };
yuvToJpegByPixelMapCallback_fail(done, 'SUB_IMAGE_yuv_pixelmap_CB_004', sourceOptions, yuvData)
yuvToJpegByPixelMapCallback_Fail(done, 'SUB_IMAGE_yuv_pixelmap_CB_004', sourceOptions, yuvData)
})
/**
......@@ -689,7 +658,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_CB_006', 0, async function (done) {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } };
yuvToJpegByPixelMapCallback_fail(done, 'SUB_IMAGE_yuv_pixelmap_CB_006', sourceOptions, yuvData)
yuvToJpegByPixelMapCallback_Fail(done, 'SUB_IMAGE_yuv_pixelmap_CB_006', sourceOptions, yuvData)
})
/**
......@@ -704,7 +673,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_CB_007', 0, async function (done) {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 6 } };
yuvToJpegByPixelMapCallback_fail(done, 'SUB_IMAGE_yuv_pixelmap_CB_007', sourceOptions, yuvData)
yuvToJpegByPixelMapCallback_Fail(done, 'SUB_IMAGE_yuv_pixelmap_CB_007', sourceOptions, yuvData)
})
/**
......@@ -719,7 +688,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_CB_008', 0, async function (done) {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 6 } };
yuvToJpegByPixelMapCallback_fail(done, 'SUB_IMAGE_yuv_pixelmap_CB_008', sourceOptions, yuvData)
yuvToJpegByPixelMapCallback_Fail(done, 'SUB_IMAGE_yuv_pixelmap_CB_008', sourceOptions, yuvData)
})
/**
......@@ -791,7 +760,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } };
let packOpts = { format: "image/jpeg", quality: 99 }
yuvToJpegByImageSourceCallback_fail(done, 'SUB_IMAGE_yuv_imagesource_CB_004', sourceOptions, packOpts, yuvData)
yuvToJpegByImageSourceCallback_Fail(done, 'SUB_IMAGE_yuv_imagesource_CB_004', sourceOptions, packOpts, yuvData)
})
/**
......@@ -827,7 +796,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } };
let packOpts = { format: "image/jpeg", quality: 99 }
yuvToJpegByImageSourceCallback_fail(done, 'SUB_IMAGE_yuv_imagesource_CB_006', sourceOptions, packOpts, yuvData)
yuvToJpegByImageSourceCallback_Fail(done, 'SUB_IMAGE_yuv_imagesource_CB_006', sourceOptions, packOpts, yuvData)
})
/**
......@@ -845,7 +814,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 6 } };
let packOpts = { format: "image/jpeg", quality: 99 }
yuvToJpegByImageSourceCallback_fail(done, 'SUB_IMAGE_yuv_imagesource_CB_007', sourceOptions, packOpts, yuvData)
yuvToJpegByImageSourceCallback_Fail(done, 'SUB_IMAGE_yuv_imagesource_CB_007', sourceOptions, packOpts, yuvData)
})
/**
......@@ -863,6 +832,6 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 6 } };
let packOpts = { format: "image/jpeg", quality: 99 }
yuvToJpegByImageSourceCallback_fail(done, 'SUB_IMAGE_yuv_imagesource_CB_008', sourceOptions, packOpts, yuvData)
yuvToJpegByImageSourceCallback_Fail(done, 'SUB_IMAGE_yuv_imagesource_CB_008', sourceOptions, packOpts, yuvData)
})
})}
......@@ -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": []
}
]
}
......@@ -15,7 +15,7 @@
// @ts-nocheck
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
import mypixelmap from "libimagePixelmap.so"
export default function nativeApiImageJsunit() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册