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

!4754 image XTS整改

Merge pull request !4754 from liuxueqi/master
...@@ -19,31 +19,28 @@ ...@@ -19,31 +19,28 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir /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 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files" "chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files/*"
] ],
"teardown-command": []
}, },
{ {
"type": "PushKit", "type": "PushKit",
"pre-push": [], "pre-push": [],
"push": [ "push": [
"./resource/image/test.bmp ->/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/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/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/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/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/files" "./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.bmp", "hilog -Q pidoff",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.png", "hilog -b D"
"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"
], ],
"teardown-command": [] "teardown-command": []
} }
......
...@@ -13,7 +13,10 @@ ...@@ -13,7 +13,10 @@
* limitations under the License. * 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() { 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,1674 +17,2922 @@ import image from '@ohos.multimedia.image' ...@@ -17,1674 +17,2922 @@ import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio' import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { testPng, testJpg } from './testImg' import { testPng, testJpg } from './testImg'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import { tcBuf020, tcBuf020_1, tcBuf021, tcBuf021_1, tcBuf022 } from './testImg'
import bundle from '@ohos.bundle' import featureAbility from '@ohos.ability.featureAbility'
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';
let globalpixelmap;
beforeAll(async function () {
await applyPermission();
console.info('beforeAll case');
})
beforeEach(function () { export default function imageJsTest() {
console.info('beforeEach case'); 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 () {
console.info('beforeAll 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();
}
afterEach(async function () { const area = {
if (globalpixelmap != undefined) { pixels: new ArrayBuffer(8),
console.info('globalpixelmap release start'); 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();
})
})
/**
* @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 { 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) { } catch (error) {
console.info('globalpixelmap release fail'); console.info('TC_022-1 error: ' + error);
expect(false).assertTrue();
done();
} }
} })
console.info('afterEach case');
})
afterAll(async function () { /**
console.info('afterAll case'); * @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();
}
async function applyPermission() { const writeColor = new ArrayBuffer(96);
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image', 0, 100); var bufferArr = new Uint8Array(writeColor);
let atManager = abilityAccessCtrl.createAtManager(); for (var i = 0; i < bufferArr.length; i++) {
if (atManager != null) { bufferArr[i] = i + 1;
let tokenID = appInfo.accessTokenId; }
console.info('[permission]case accessTokenId is' + tokenID); pixelmap.writeBufferToPixels(writeColor).then(() => {
let permissionName1 = 'ohos.permission.MEDIA_LOCATION'; const readBuffer = new ArrayBuffer(96);
let permissionName2 = 'ohos.permission.READ_MEDIA'; pixelmap.readPixelsToBuffer(readBuffer).then(() => {
let permissionName3 = 'ohos.permission.WRITE_MEDIA'; var bufferArr = new Uint8Array(readBuffer);
await atManager.grantUserGrantedPermission(tokenID, permissionName1).then((result) => { var res = true;
console.info('[permission]case grantUserGrantedPermission success:' + result); for (var i = 0; i < bufferArr.length; i++) {
}).catch((err) => { if (bufferArr[i] == 0) {
console.info('[permission]case grantUserGrantedPermission failed:' + err); res = false;
}); console.info('TC_023 failed');
await atManager.grantUserGrantedPermission(tokenID, permissionName2).then((result) => { expect(false).assertTrue()
console.info('[permission]case grantUserGrantedPermission success:' + result); done();
}).catch((err) => { break;
console.info('[permission]case grantUserGrantedPermission failed:' + err); }
}); }
await atManager.grantUserGrantedPermission(tokenID, permissionName3).then((result) => { if (res) {
console.info('[permission]case grantUserGrantedPermission success:' + result); console.info('TC_023 success');
}).catch((err) => { expect(true).assertTrue();
console.info('[permission]case grantUserGrantedPermission failed:' + err); done();
}); }
} else { })
console.info('[permission]case apply permission failed,createAtManager failed'); })
} })
} .catch(error => {
console.log('TC_023 error: ' + error);
expect().assertFail();
done();
/** })
* @tc.number : TC_041 })
* @tc.name : createImageSource(uri)-jpg
* @tc.desc : 1.set uri
* 2.call createImageSource(uri)
* 3.return imagesource
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_041', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041 success');
fileio.closeSync(fdNumber);
done();
} catch (error) {
console.info('TC_041 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_041-1 * @tc.number : TC_023-1
* @tc.name : createImageSource(uri)-bmp * @tc.name : writeBufferToPixels-callback
* @tc.desc : 1.seturi * @tc.desc : 1.create PixelMap,buffer
* 2.call createImageSource(uri) * 2.call writeBufferToPixels
* 3.return imagesource * 3.call return undefined
* @tc.size : MEDIUM * 4.callbackcall return undefined
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 0 * @tc.type : Functional
*/ * @tc.level : Level 1
it('TC_041-1', 0, async function (done) { */
try { it('TC_023-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp); const color = new ArrayBuffer(96);
const imageSourceApi = image.createImageSource(fdNumber); var bufferArr = new Uint8Array(color);
expect(imageSourceApi != undefined).assertTrue(); for (var i = 0; i < bufferArr.length; i++) {
console.info('TC_041-1 success'); bufferArr[i] = i + 1;
done(); }
} catch (error) { let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
console.info('TC_041-1 error: ' + error); image.createPixelMap(color, opts).then(pixelmap => {
expect(false).assertTrue(); globalpixelmap = pixelmap;
done(); 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_041-2 * @tc.number : TC_024
* @tc.name : createImageSource(uri)-gif * @tc.name : getImageInfo-pixelmap-promise
* @tc.desc : 1.seturi * @tc.desc : 1.create PixelMap,ImageInfo
* 2.call createImageSource(uri) * 2.call getImageInfo
* 3.return imagesource * 3.call return imageinfo
* @tc.size : MEDIUM * 4.callback return undefined
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 0 * @tc.type : Functional
*/ * @tc.level : Level 1
it('TC_041-2', 0, async function (done) { */
try { it('TC_024', 0, async function (done) {
let fdNumber = fileio.openSync(pathGif); const color = new ArrayBuffer(96);
const imageSourceApi = image.createImageSource(fdNumber); let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
expect(imageSourceApi != undefined).assertTrue(); image.createPixelMap(color, opts)
console.info('TC_041-2 success'); .then(pixelmap => {
done(); globalpixelmap = pixelmap;
} catch (error) { if (pixelmap == undefined) {
console.info('TC_041-2 error: ' + error); console.info('TC_024 createPixelMap failed');
expect(false).assertTrue(); expect(false).assertTrue()
done(); 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_041-3 * @tc.number : TC_025-1
* @tc.name : createImageSource(uri)-png * @tc.name : getBytesNumberPerRow
* @tc.desc : 1.seturi * @tc.desc : 1.create PixelMap
* 2.call createImageSource(uri) * 2.set PixelMap
* 3.return imagesource * 3.call getBytesNumberPerRow
* @tc.size : MEDIUM * 4. call return number
* @tc.type : Functional * 5.callback return undefined
* @tc.level : Level 0 * @tc.size : MEDIUM
*/ * @tc.type : Functional
it('TC_041-3', 0, async function (done) { * @tc.level : Level 1
try { */
let fdNumber = fileio.openSync(pathPng); it('TC_025-1', 0, async function (done) {
const imageSourceApi = image.createImageSource(fdNumber); const color = new ArrayBuffer(96);
expect(imageSourceApi != undefined).assertTrue(); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
console.info('TC_041-3 success'); const expectNum = 4 * opts.size.width;
done(); image.createPixelMap(color, opts, (err, pixelmap) => {
} catch (error) { globalpixelmap = pixelmap;
console.info('TC_041-3 error: ' + error); if (pixelmap == undefined) {
expect(false).assertTrue(); 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_041
* @tc.name : createImageSource(uri)-jpg
* @tc.desc : 1.set uri
* 2.call createImageSource(uri)
* 3.return imagesource
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_041', 0, async function (done) {
try {
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041 success');
fileio.closeSync(fdNumber);
done();
} catch (error) {
console.info('TC_041 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_041-1
* @tc.name : createImageSource(uri)-bmp
* @tc.desc : 1.seturi
* 2.call createImageSource(uri)
* 3.return imagesource
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_041-1', 0, async function (done) {
try {
await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041-1 success');
done();
} catch (error) {
console.info('TC_041-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_041-2
* @tc.name : createImageSource(uri)-gif
* @tc.desc : 1.seturi
* 2.call createImageSource(uri)
* 3.return imagesource
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_041-2', 0, async function (done) {
try {
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041-2 success');
done();
} catch (error) {
console.info('TC_041-2 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_041-3
* @tc.name : createImageSource(uri)-png
* @tc.desc : 1.seturi
* 2.call createImageSource(uri)
* 3.return imagesource
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_041-3', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
expect(imageSourceApi != undefined).assertTrue();
console.info('TC_041-3 success');
done();
} catch (error) {
console.info('TC_041-3 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_041-4
* @tc.name : createImageSource(uri)-wrong suffix file
* @tc.desc : 1.call createImageSource(uri)
* 2.Incoming wrong suffix file
* 3.imagesource null
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_041-4', 0, async function (done) {
const imageSourceApi = image.createImageSource('file:///data/local/tmp/test.123');
expect(imageSourceApi == undefined).assertTrue();
console.info('TC_041-4 success');
done(); done();
} })
}) /**
* @tc.number : TC_041-5
* @tc.name : createImageSource(uri)-wrong uri
* @tc.desc : 1.call createImageSource(uri)
* 2.set wrong uri
* 3.return null
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_041-5', 0, async function (done) {
try {
const imageSourceApi = image.createImageSource('file:///multimedia/test.jpg');
expect(imageSourceApi == undefined).assertTrue();
console.info('TC_041-5 success');
done();
} catch (error) {
console.info('TC_041-5 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_041-4 * @tc.number : TC_042
* @tc.name : createImageSource(uri)-wrong suffix file * @tc.name : createImageSource(fd)
* @tc.desc : 1.call createImageSource(uri) * @tc.desc : 1.call createImageSource
* 2.Incoming wrong suffix file * 2.set fd
* 3.imagesource null * 3.return imagesource
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TC_041-4', 0, async function (done) { it('TC_042', 0, async function (done) {
const imageSourceApi = image.createImageSource('file:///data/local/tmp/test.123'); try {
expect(imageSourceApi == undefined).assertTrue(); await getFd('test.jpg');
console.info('TC_041-4 success'); const imageSourceApi = image.createImageSource(fdNumber);
done(); if (imageSourceApi == undefined) {
}) console.info('TC_042 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo((err, imageInfo) => {
if (err) {
expect(false).assertTrue();
console.info('TC_042 err: ' + err);
done();
return
}
if (imageInfo != undefined) {
expect(true).assertTrue();
fileio.closeSync(fdNumber);
done();
} else {
console.info('TC_042 failed');
expect(false).assertTrue();
done();
}
})
}
} catch (error) {
console.info('TC_042 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_041-5 * @tc.number : TC_042-1
* @tc.name : createImageSource(uri)-wrong uri * @tc.name : createImageSource(fd) fd<0
* @tc.desc : 1.call createImageSource(uri) * @tc.desc : 1.call createImageSource
* 2.set wrong uri * 2.set wrong fd
* 3.return null * 3.return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TC_041-5', 0, async function (done) { it('TC_042-1', 0, async function (done) {
try { const imageSourceApi = image.createImageSource(-2);
const imageSourceApi = image.createImageSource('file:///multimedia/test.jpg');
expect(imageSourceApi == undefined).assertTrue(); expect(imageSourceApi == undefined).assertTrue();
console.info('TC_041-5 success'); console.info('TC_042-1 success');
done(); done();
} catch (error) { })
console.info('TC_041-5 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_042 * @tc.number : TC_043
* @tc.name : createImageSource(fd) * @tc.name : createImageSource(data)
* @tc.desc : 1.call createImageSource * @tc.desc : 1.setdata
* 2.set fd * 2.createImageSource
* 3.return imagesource * 3.return imagesource
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('TC_042', 0, async function (done) { it('TC_043', 0, async function (done) {
try { const data = testJpg.buffer;
let fdNumber = fileio.openSync(pathJpg); const imageSourceApi = image.createImageSource(data);
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_042 create image source failed'); console.info('TC_043 create image source failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
imageSourceApi.getImageInfo((err, imageInfo) => { imageSourceApi.getImageInfo((err, imageInfo) => {
if (err) { console.info('TC_043 imageInfo');
expect(false).assertTrue(); expect(imageInfo != undefined).assertTrue();
console.info('TC_042 err: ' + err); done();
done(); })
return }
} })
if (imageInfo != undefined) {
/**
* @tc.number : TC_043-1
* @tc.name : createImageSource(data) buffer:0
* @tc.desc : 1.setdata
* 2.createImageSource
* 3.return imagesource
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_043-1', 0, async function (done) {
const data = new ArrayBuffer(0);
const imageSourceApi = image.createImageSource(data);
expect(imageSourceApi == undefined).assertTrue();
console.info('TC_043-1 success');
done();
})
/**
* @tc.number : TC_044
* @tc.name : release-imagesource-promise-jpg
* @tc.desc : 1.create ImageSource
* 2.call release()
* 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_044', 0, async function (done) {
try {
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_044 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.release().then(() => {
console.info('TC_044 success');
expect(true).assertTrue(); expect(true).assertTrue();
fileio.closeSync(fdNumber);
done(); done();
} else { }).catch(error => {
console.info('TC_042 failed'); console.info('TC_044 error');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} })
}
} catch (error) {
console.info('TC_044 err:' + error);
expect(false).assertTrue();
done();
}
})
}) /**
* @tc.number : TC_044-1
* @tc.name : release-imagesource-callback-jpg
* @tc.desc : 1.create ImageSource
* 2.call release()
* 3.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_044-1', 0, async function (done) {
try {
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_044-1 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.release(() => {
console.info('TC_044-1 Success');
expect(true).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_044-1 err:' + error);
expect(false).assertTrue();
done();
} }
} catch (error) { })
console.info('TC_042 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_042-1 * @tc.number : TC_045
* @tc.name : createImageSource(fd) fd<0 * @tc.name : getImageInfo(callback: AsyncCallback<ImageInfo>)-jpg
* @tc.desc : 1.call createImageSource * @tc.desc : 1.create imageSource
* 2.set wrong fd * 2.imageSourcecall getImageInfo(ImageInfo)
* 3.return undefined * 3.callback return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 0 * @tc.level : Level 1
*/ */
it('TC_042-1', 0, async function (done) {
const imageSourceApi = image.createImageSource(-2);
expect(imageSourceApi == undefined).assertTrue();
console.info('TC_042-1 success');
done();
})
/** it('TC_045', 0, async function (done) {
* @tc.number : TC_043 try {
* @tc.name : createImageSource(data) await getFd('test.jpg');
* @tc.desc : 1.setdata const imageSourceApi = image.createImageSource(fdNumber);
* 2.createImageSource if (imageSourceApi == undefined) {
* 3.return imagesource console.info('TC_045 create image source failed');
* @tc.size : MEDIUM expect(false).assertTrue();
* @tc.type : Functional done();
* @tc.level : Level 0 } else {
*/ imageSourceApi.getImageInfo((err, imageInfo) => {
it('TC_043', 0, async function (done) { if (err) {
const data = testJpg.buffer; expect(false).assertTrue();
const imageSourceApi = image.createImageSource(data); console.info('TC_045 err:' + err);
if (imageSourceApi == undefined) { done();
console.info('TC_043 create image source failed'); return
expect(false).assertTrue(); }
done(); if (imageInfo != undefined) {
} else { console.info('TC_045 imageInfo.size.height:' + imageInfo.size.height);
imageSourceApi.getImageInfo((err, imageInfo) => { console.info('TC_045 imageInfo.size.width:' + imageInfo.size.width);
console.info('TC_043 imageInfo'); expect(true).assertTrue();
expect(imageInfo != undefined).assertTrue(); fileio.closeSync(fdNumber);
done();
} else {
console.info('TC_045 failed');
expect(false).assertTrue();
done();
}
})
}
} catch (error) {
console.info('TC_045 error: ' + error);
expect(false).assertTrue();
done(); done();
}) }
} })
})
/**
* @tc.number : TC_043-1
* @tc.name : createImageSource(data) buffer:0
* @tc.desc : 1.setdata
* 2.createImageSource
* 3.return imagesource
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_043-1', 0, async function (done) {
const data = new ArrayBuffer(0);
const imageSourceApi = image.createImageSource(data);
expect(imageSourceApi == undefined).assertTrue();
console.info('TC_043-1 success');
done();
})
/** /**
* @tc.number : TC_044 * @tc.number : TC_045-1
* @tc.name : release-imagesource-promise-jpg * @tc.name : getImageInfo(callback: AsyncCallback<ImageInfo>)-bmp
* @tc.desc : 1.create ImageSource * @tc.desc : 1.create imageSource
* 2.call release() * 2.imageSourcecall getImageInfo(ImageInfo)
* 3.return undefined * 3.callback return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_044', 0, async function (done) { it('TC_045-1', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathJpg); await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_044 create image source failed'); console.info('TC_045-1 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo((err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_045-1 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_045-1 imageInfo.size.width:' + imageInfo.size.width);
done();
})
}
} catch (error) {
console.info('TC_045-1 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { }
imageSourceApi.release().then(() => { })
console.info('TC_044 success');
expect(true).assertTrue(); /**
done(); * @tc.number : TC_045-2
}).catch(error => { * @tc.name : getImageInfo(callback: AsyncCallback<ImageInfo>)-png
console.info('TC_044 error'); * @tc.desc : 1.create imageSource
* 2.imageSourcecall getImageInfo(ImageInfo)
* 3.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_045-2', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_045-2 create image source failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
}) } else {
imageSourceApi.getImageInfo((err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_045-2 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_045-2 imageInfo.size.width:' + imageInfo.size.width);
done();
})
}
} catch (error) {
console.info('TC_045-2 error: ' + error);
expect(false).assertTrue();
done();
} }
} catch (error) { })
console.info('TC_044 err:' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_044-1 * @tc.number : TC_045-3
* @tc.name : release-imagesource-callback-jpg * @tc.name : getImageInfo(callback: AsyncCallback<ImageInfo>)-gif
* @tc.desc : 1.create ImageSource * @tc.desc : 1.create ImageInfo
* 2.call release() * 2.call getImageInfo(index, ImageInfo)
* 3.callback return undefined * 3.callback return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_044-1', 0, async function (done) { it('TC_045-3', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathJpg); await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_044-1 create image source failed'); console.info('TC_045-3 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo((err, imageInfo) => {
if (err) {
expect(false).assertTrue();
console.info('TC_045-3 error' + err);
done();
return
}
if (imageInfo != undefined && imageInfo != null) {
expect(true).assertTrue();
console.info('TC_045-3 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_045-3 imageInfo.size.width:' + imageInfo.size.width);
console.info('TC_045-3 success')
done();
} else {
expect(false).assertTrue();
console.info('TC_045-3 failed')
done();
}
})
}
} catch (error) {
console.info('TC_045-3 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.release(() => {
console.info('TC_044-1 Success');
expect(true).assertTrue();
done();
})
} }
} catch (error) { })
console.info('TC_044-1 err:' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_045 * @tc.number : TC_046
* @tc.name : getImageInfo(callback: AsyncCallback<ImageInfo>)-jpg * @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-jpg
* @tc.desc : 1.create imageSource * @tc.desc : 1.create ImageInfo
* 2.imageSourcecall getImageInfo(ImageInfo) * 2.call getImageInfo(index, ImageInfo)
* 3.callback return undefined * 3.callback return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_046', 0, async function (done) {
it('TC_045', 0, async function (done) { try {
try { await getFd('test.jpg');
let fdNumber = fileio.openSync(pathJpg); const imageSourceApi = image.createImageSource(fdNumber);
const imageSourceApi = image.createImageSource(fdNumber); if (imageSourceApi == undefined) {
if (imageSourceApi == undefined) { console.info('TC_046 create image source failed');
console.info('TC_045 create image source failed'); expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0, (err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_046 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_046 imageInfo.size.width:' + imageInfo.size.width);
done();
})
}
} catch (error) {
console.info('TC_046 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo((err, imageInfo) => {
if (err) {
expect(false).assertTrue();
console.info('TC_045 err:' + err);
done();
return
}
if (imageInfo != undefined) {
console.info('TC_045 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_045 imageInfo.size.width:' + imageInfo.size.width);
expect(true).assertTrue();
fileio.closeSync(fdNumber);
done();
} else {
console.info('TC_045 failed');
expect(false).assertTrue();
done();
}
})
} }
} catch (error) { })
console.info('TC_045 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_045-1 * @tc.number : TC_046-1
* @tc.name : getImageInfo(callback: AsyncCallback<ImageInfo>)-bmp * @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-bmp
* @tc.desc : 1.create imageSource * @tc.desc : 1.create ImageInfo
* 2.imageSourcecall getImageInfo(ImageInfo) * 2.call getImageInfo(index, ImageInfo)
* 3.callback return undefined * 3.callback return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_045-1', 0, async function (done) { it('TC_046-1', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathBmp); await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_045-1 create image source failed'); console.info('TC_046-1 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0, (err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_046-1 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_046-1 imageInfo.size.width:' + imageInfo.size.width);
done();
})
}
} catch (error) {
console.info('TC_046-1 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo((err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_045-1 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_045-1 imageInfo.size.width:' + imageInfo.size.width);
done();
})
} }
} catch (error) { })
console.info('TC_045-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_045-2 * @tc.number: TC_046-2
* @tc.name : getImageInfo(callback: AsyncCallback<ImageInfo>)-png * @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-png
* @tc.desc : 1.create imageSource * @tc.desc : 1.create ImageInfo
* 2.imageSourcecall getImageInfo(ImageInfo) * 2.call getImageInfo(index, ImageInfo)
* 3.callback return undefined * 3.callback return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_045-2', 0, async function (done) { it('TC_046-2', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathPng); await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_045-2 create image source failed'); console.info('TC_046-2 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0, (err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_046-2 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_046-2 imageInfo.size.width:' + imageInfo.size.width);
done();
})
}
} catch {
console.info('TC_046-2 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo((err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_045-2 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_045-2 imageInfo.size.width:' + imageInfo.size.width);
done();
})
} }
} catch (error) {
console.info('TC_045-2 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** })
* @tc.number : TC_045-3
* @tc.name : getImageInfo(callback: AsyncCallback<ImageInfo>)-gif /**
* @tc.desc : 1.create ImageInfo * @tc.number: TC_046-3
* 2.call getImageInfo(index, ImageInfo) * @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-gif
* 3.callback return undefined * @tc.desc : 1.create ImageInfo
* @tc.size : MEDIUM * 2.call getImageInfo(index, ImageInfo)
* @tc.type : Functional * 3.callback return undefined
* @tc.level : Level 1 * @tc.size : MEDIUM MEDIUM
*/ * @tc.type : Functional
it('TC_045-3', 0, async function (done) { * @tc.level : Level 1
try { */
let fdNumber = fileio.openSync(pathGif); it('TC_046-3', 0, async function (done) {
const imageSourceApi = image.createImageSource(fdNumber); try {
if (imageSourceApi == undefined) { await getFd('test.gif');
console.info('TC_045-3 create image source failed'); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_046-3 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0, (err, imageInfo) => {
if (err) {
expect(false).assertTrue();
console.info('TC_046-3 error' + err);
done();
return
}
if (imageInfo != undefined && imageInfo != null) {
expect(true).assertTrue();
console.info('TC_046-3 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_046-3 imageInfo.size.width:' + imageInfo.size.width);
console.info('TC_046-3 success')
done();
} else {
expect(false).assertTrue();
console.info('TC_046-3 failed')
done();
}
})
}
} catch (error) {
console.info('TC_046-3 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo((err, imageInfo) => {
if (err) {
expect(false).assertTrue();
console.info('TC_045-3 error' + err);
done();
return
}
if (imageInfo != undefined && imageInfo != null) {
expect(true).assertTrue();
console.info('TC_045-3 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_045-3 imageInfo.size.width:' + imageInfo.size.width);
console.info('TC_045-3 success')
done();
} else {
expect(false).assertTrue();
console.info('TC_045-3 failed')
done();
}
})
} }
} catch (error) { })
console.info('TC_045-3 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_046 * @tc.number: TC_046-4
* @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-jpg * @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-gif(frame:1)-index:1
* @tc.desc : 1.create ImageInfo * @tc.desc : 1.create ImageInfo
* 2.call getImageInfo(index, ImageInfo) * 2.call getImageInfo(index, ImageInfo)
* 3.callback return undefined * 3.callback return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_046', 0, async function (done) { it('TC_046-4', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathJpg); await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_046 create image source failed'); console.info('TC_046-4 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(1, (err, imageInfo) => {
if (imageInfo == undefined) {
expect(true).assertTrue();
done();
} else {
expect(false).assertTrue();
done();
}
})
}
} catch (error) {
console.info('TC_046-4 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { }
imageSourceApi.getImageInfo(0, (err, imageInfo) => { })
expect(imageInfo != undefined).assertTrue();
console.info('TC_046 imageInfo.size.height:' + imageInfo.size.height); /**
console.info('TC_046 imageInfo.size.width:' + imageInfo.size.width); * @tc.number: TC_046-5
* @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-gif-index:-1
* @tc.desc : 1.create ImageInfo
* 2.call getImageInfo(index, ImageInfo)
* 3.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_046-5', 0, async function (done) {
try {
await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_046-5 create image source failed');
expect(false).assertTrue();
done(); done();
}) } else {
imageSourceApi.getImageInfo(-1, (err, imageInfo) => {
expect(imageInfo == undefined).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_046-5 error: ' + error);
expect(false).assertTrue();
done();
} }
} catch (error) { })
console.info('TC_046 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_046-1 * @tc.number : TC_047
* @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-bmp * @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-jpg
* @tc.desc : 1.create ImageInfo * @tc.desc : 1.create imagesource
* 2.call getImageInfo(index, ImageInfo) * 2.call getImageInfo(index)
* 3.callback return undefined * 3.callbackcall ,return imageinfo
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_046-1', 0, async function (done) { it('TC_047', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathBmp); await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_046-1 create image source failed'); console.info('TC_047 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0)
.then(imageInfo => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_047 imageInfo');
console.info('imageInfo.size.height:' + imageInfo.size.height);
console.info('imageInfo.size.width:' + imageInfo.size.width);
done();
}).catch(error => {
console.log('TC_047 error: ' + error);
expect().assertFail();
done();
})
}
} catch (error) {
console.info('TC_047 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo(0, (err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_046-1 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_046-1 imageInfo.size.width:' + imageInfo.size.width);
done();
})
} }
} catch (error) { })
console.info('TC_046-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number: TC_046-2 * @tc.number : TC_047-1
* @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-png * @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-bmp
* @tc.desc : 1.create ImageInfo * @tc.desc : 1.create imagesource
* 2.call getImageInfo(index, ImageInfo) * 2.call getImageInfo(index)
* 3.callback return undefined * 3.callbackcall ,return imageinfo
* @tc.size : MEDIUM MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_046-2', 0, async function (done) { it('TC_047-1', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathPng); await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_046-2 create image source failed'); console.info('TC_047-1 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0)
.then(imageInfo => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_047-1 imageInfo');
console.info('imageInfo.size.height:' + imageInfo.size.height);
console.info('imageInfo.size.width:' + imageInfo.size.width);
done();
}).catch(error => {
console.log('TC_047-1 error: ' + error);
expect().assertFail();
done();
})
}
} catch (error) {
console.info('TC_047-1 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo(0, (err, imageInfo) => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_046-2 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_046-2 imageInfo.size.width:' + imageInfo.size.width);
done();
})
} }
} catch { })
console.info('TC_046-2 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number: TC_046-3 * @tc.number : TC_047-2
* @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-gif * @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-png
* @tc.desc : 1.create ImageInfo * @tc.desc : 1.create imagesource
* 2.call getImageInfo(index, ImageInfo) * 2.call getImageInfo(index)
* 3.callback return undefined * 3.callbackcall ,return imageinfo
* @tc.size : MEDIUM MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_046-3', 0, async function (done) { it('TC_047-2', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathGif); await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_046-3 create image source failed'); console.info('TC_047-2 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0)
.then(imageInfo => {
expect(imageInfo != undefined).assertTrue();
console.info('TC_047-2 imageInfo');
console.info('imageInfo.size.height:' + imageInfo.size.height);
console.info('imageInfo.size.width:' + imageInfo.size.width);
done();
}).catch(error => {
console.log('TC_047-2 error: ' + error);
expect().assertFail();
done();
})
}
} catch (error) {
console.info('TC_047-2 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo(0, (err, imageInfo) => {
if (err) {
expect(false).assertTrue();
console.info('TC_046-3 error' + err);
done();
return
}
if (imageInfo != undefined && imageInfo != null) {
expect(true).assertTrue();
console.info('TC_046-3 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_046-3 imageInfo.size.width:' + imageInfo.size.width);
console.info('TC_046-3 success')
done();
} else {
expect(false).assertTrue();
console.info('TC_046-3 failed')
done();
}
})
} }
} catch (error) { })
console.info('TC_046-3 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number: TC_046-4 * @tc.number : TC_047-3
* @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-gif(frame:1)-index:1 * @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-gif
* @tc.desc : 1.create ImageInfo * @tc.desc : 1.create imagesource
* 2.call getImageInfo(index, ImageInfo) * 2.call getImageInfo(index)
* 3.callback return undefined * 3.callbackcall ,return imageinfo
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_046-4', 0, async function (done) { it('TC_047-3', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathGif); await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_046-4 create image source failed'); console.info('TC_047-3 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0)
.then(imageInfo => {
if (imageInfo != undefined && imageInfo != null) {
expect(true).assertTrue();
console.info('TC_047-3 imageInfo.size.height:' + imageInfo.size.height);
console.info('TC_047-3 imageInfo.size.width:' + imageInfo.size.width);
done();
} else {
expect(false).assertTrue();
console.info('TC_047-3 failed');
done();
}
}).catch(error => {
console.log('TC_047-3 error: ' + error);
expect().assertFail();
done();
})
}
} catch (error) {
console.info('TC_047-3 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo(1, (err, imageInfo) => {
if (imageInfo == undefined) {
expect(true).assertTrue();
done();
} else {
expect(false).assertTrue();
done();
}
})
} }
} catch (error) { })
console.info('TC_046-4 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number: TC_046-5 * @tc.number: TC_047-4
* @tc.name : getImageInfo(index: number, callback: AsyncCallback<ImageInfo>)-gif-index:-1 * @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-gif(frame:1)-index:1
* @tc.desc : 1.create ImageInfo * @tc.desc : 1.create imagesource
* 2.call getImageInfo(index, ImageInfo) * 2.call getImageInfo(index=1)
* 3.callback return undefined * 3.callback return imageinfo undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_046-5', 0, async function (done) { it('TC_047-4', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathGif); await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_046-5 create image source failed'); console.info('TC_047-4 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(1)
.then(() => {
console.log('TC_047-4 failed');
expect().assertFail();
done();
}).catch(error => {
console.log('TC_047-4 success');
expect(true).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_047-4 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo(-1, (err, imageInfo) => {
expect(imageInfo == undefined).assertTrue();
done();
})
} }
} catch (error) { })
console.info('TC_046-5 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_047 * @tc.number : TC_047-5
* @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-jpg * @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-gif-index:-1
* @tc.desc : 1.create imagesource * @tc.desc : 1.create imagesource
* 2.call getImageInfo(index) * 2.call getImageInfo(index=-1)
* 3.callbackcall ,return imageinfo * 3.callback return imageinfo undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_047', 0, async function (done) { it('TC_047-5', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathJpg); await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_047 create image source failed'); console.info('TC_047-5 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(-1)
.then(() => {
console.log('TC_047-5 failed');
expect().assertFail();
done();
}).catch(error => {
console.log('TC_047-5 success');
expect(true).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_047-5 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { }
imageSourceApi.getImageInfo(0) })
.then(imageInfo => {
expect(imageInfo != undefined).assertTrue(); /**
console.info('TC_047 imageInfo'); * @tc.number : TC_050-14
console.info('imageInfo.size.height:' + imageInfo.size.height); * @tc.name : createPixelMap-promise-jpg
console.info('imageInfo.size.width:' + imageInfo.size.width); * @tc.desc : 1.create imagesource
* 2.set index and DecodeOptions
* 3.create PixelMap
* 4.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_050-14', 0, async function (done) {
try {
await getFd('test.jpg');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-14 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap().then(pixelmap => {
globalpixelmap = pixelmap;
console.info('TC_050-14 success ');
expect(pixelmap != undefined).assertTrue();
done(); done();
}).catch(error => { }).catch(error => {
console.log('TC_047 error: ' + error); console.log('TC_050-14 error: ' + error);
expect().assertFail(); expect().assertFail();
done(); done();
}) })
}
} catch (error) {
console.info('TC_050-14 error: ' + error);
expect(false).assertTrue();
done();
} }
} catch (error) { })
console.info('TC_047 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_047-1 * @tc.number : TC_050-15
* @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-bmp * @tc.name : createPixelMap-callback-jpg
* @tc.desc : 1.create imagesource * @tc.desc : 1.create imagesource
* 2.call getImageInfo(index) * 2.set index and DecodeOptions
* 3.callbackcall ,return imageinfo * 3.create PixelMap
* @tc.size : MEDIUM * 4.callback return null
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 1
it('TC_047-1', 0, async function (done) { */
try { it('TC_050-15', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp); try {
const imageSourceApi = image.createImageSource(fdNumber); await getFd('test.jpg');
if (imageSourceApi == undefined) { const imageSourceApi = image.createImageSource(fdNumber);
console.info('TC_047-1 create image source failed'); if (imageSourceApi == undefined) {
console.info('TC_050-15 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap((err, pixelmap) => {
globalpixelmap = pixelmap;
console.info('TC_050-15 success ');
expect(pixelmap != undefined).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_050-15 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { }
imageSourceApi.getImageInfo(0) })
.then(imageInfo => {
expect(imageInfo != undefined).assertTrue(); /**
console.info('TC_047-1 imageInfo'); * @tc.number : TC_053
console.info('imageInfo.size.height:' + imageInfo.size.height); * @tc.name : createIncrementalSource-updateData-png
console.info('imageInfo.size.width:' + imageInfo.size.width); * @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_053', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('TC_053 0003 ' + testimagebuffer.length);
let bufferSize = testimagebuffer.length;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
console.info('TC_053 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('TC_053 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('TC_053 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('TC_053 0011 ' + offset);
}
if (ret) {
console.info('TC_053 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('TC_053 0014' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done(); done();
}).catch(error => { })
console.log('TC_047-1 error: ' + error); } else {
expect().assertFail(); done();
}
} catch (error) {
console.info('TC_053 updateData failed ' + error);
}
})
/**
* @tc.number : TC_053-1
* @tc.name : createIncrementalSource-updateData-jpg
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_053-1', 0, async function (done) {
try {
let testimagebuffer = testJpg;
console.info('TC_053-1 0003 ' + testimagebuffer.length);
let bufferSize = testimagebuffer.length;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let isFinished = false;
let ret;
while (offset < testimagebuffer.length) {
console.info('TC_053-1 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('TC_053-1 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('TC_053-1 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('TC_053-1 0011 ' + offset);
}
if (ret) {
console.info('TC_053-1 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
expect(pixelmap != undefined).assertTrue();
done(); done();
}) })
} else {
done();
}
} catch (error) {
console.info('TC_053-1 updateData failed ' + error);
} }
} catch (error) { })
console.info('TC_047-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_047-2 * @tc.number : TC_064
* @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-png * @tc.name : release ImageSource - promise - png
* @tc.desc : 1.create imagesource * @tc.desc : 1.create ImageSource
* 2.call getImageInfo(index) * 2.call release()
* 3.callbackcall ,return imageinfo * 3.return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_047-2', 0, async function (done) { it('TC_064', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathPng); await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_047-2 create image source failed'); console.info('TC_064 create image source failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
imageSourceApi.getImageInfo(0) imageSourceApi.release().then(() => {
.then(imageInfo => { console.info('TC_064 success');
expect(imageInfo != undefined).assertTrue(); expect(true).assertTrue();
console.info('TC_047-2 imageInfo');
console.info('imageInfo.size.height:' + imageInfo.size.height);
console.info('imageInfo.size.width:' + imageInfo.size.width);
done(); done();
}).catch(error => { }).catch(error => {
console.log('TC_047-2 error: ' + error); console.log('TC_064 error: ' + error);
expect().assertFail(); expect().assertFail();
done(); done();
}) })
} }
} catch (error) { } catch (error) {
console.info('TC_047-2 error: ' + error); console.info('TC_064 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_047-3
* @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-gif
* @tc.desc : 1.create imagesource
* 2.call getImageInfo(index)
* 3.callbackcall ,return imageinfo
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_047-3', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_047-3 create image source failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { }
imageSourceApi.getImageInfo(0) })
.then(imageInfo => {
if (imageInfo != undefined && imageInfo != null) { /**
expect(true).assertTrue(); * @tc.number : TC_064-1
console.info('TC_047-3 imageInfo.size.height:' + imageInfo.size.height); * @tc.name : release ImageSource - callback - png
console.info('TC_047-3 imageInfo.size.width:' + imageInfo.size.width); * @tc.desc : 1.create ImageSource
done(); * 2.call release()
} else { * 3.return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_064-1', 0, async function (done) {
try {
await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_064-1 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.release(async (err) => {
if (err) {
console.info('TC_064-1 err:' + err);
expect(false).assertTrue(); expect(false).assertTrue();
console.info('TC_047-3 failed');
done(); done();
return
} }
}).catch(error => { console.info('TC_064-1 Success');
console.log('TC_047-3 error: ' + error); expect(true).assertTrue();
expect().assertFail(); expect(true).assertTrue();
done(); done();
}) })
} }
} catch (error) { } catch (error) {
console.info('TC_047-3 error: ' + error); console.info('TC_064-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number: TC_047-4
* @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-gif(frame:1)-index:1
* @tc.desc : 1.create imagesource
* 2.call getImageInfo(index=1)
* 3.callback return imageinfo undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_047-4', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathGif);
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_047-4 create image source failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.getImageInfo(1)
.then(() => {
console.log('TC_047-4 failed');
expect().assertFail();
done();
}).catch(error => {
console.log('TC_047-4 success');
expect(true).assertTrue();
done();
})
} }
} catch (error) { })
console.info('TC_047-4 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_047-5 * @tc.number : TC_065
* @tc.name : getImageInfo(index?: number): Promise<ImageInfo>-gif-index:-1 * @tc.name : release ImageSource - promise - bmp
* @tc.desc : 1.create imagesource * @tc.desc : 1.create ImageSource
* 2.call getImageInfo(index=-1) * 2.call release()
* 3.callback return imageinfo undefined * 3.return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_047-5', 0, async function (done) { it('TC_065', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathGif); await getFd('test.bmp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_047-5 create image source failed'); console.info('TC_065 create image source failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
imageSourceApi.getImageInfo(-1) imageSourceApi.release().then(() => {
.then(() => { console.info('TC_065 success');
console.log('TC_047-5 failed'); expect(true).assertTrue();
expect().assertFail();
done(); done();
}).catch(error => { }).catch(error => {
console.log('TC_047-5 success'); console.log('TC_065 error: ' + error);
expect(true).assertTrue(); expect().assertFail();
done(); done();
}) })
} }
} catch (error) { } catch (error) {
console.info('TC_047-5 error: ' + error); console.info('TC_065 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_050-14
* @tc.name : createPixelMap-promise-jpg
* @tc.desc : 1.create imagesource
* 2.set index and DecodeOptions
* 3.create PixelMap
* 4.callback return undefined
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_050-14', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_050-14 create image source failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.createPixelMap().then(pixelmap => {
globalpixelmap = pixelmap;
console.info('TC_050-14 success ');
expect(pixelmap != undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_050-14 error: ' + error);
expect().assertFail();
done();
})
} }
} catch (error) { })
console.info('TC_050-14 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_050-15 * @tc.number : TC_065-1
* @tc.name : createPixelMap-callback-jpg * @tc.name : release ImageSource - callback - bmp
* @tc.desc : 1.create imagesource * @tc.desc : 1.create ImageSource
* 2.set index and DecodeOptions * 2.create SourceStream
* 3.create PixelMap * 3.return undefined
* 4.callback return null * @tc.size : MEDIUM
* @tc.size : MEDIUM * @tc.type : Functional
* @tc.type : Functional * @tc.level : Level 1
* @tc.level : Level 1 */
*/ it('TC_065-1', 0, async function (done) {
it('TC_050-15', 0, async function (done) { try {
try { await getFd('test.bmp');
let fdNumber = fileio.openSync(pathJpg); const imageSourceApi = image.createImageSource(fdNumber);
const imageSourceApi = image.createImageSource(fdNumber); if (imageSourceApi == undefined) {
if (imageSourceApi == undefined) { console.info('TC_065-1 create image source failed');
console.info('TC_050-15 create image source failed'); expect(false).assertTrue();
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap((err, pixelmap) => {
globalpixelmap = pixelmap;
console.info('TC_050-15 success ');
expect(pixelmap != undefined).assertTrue();
done(); done();
}) } else {
} imageSourceApi.release(async () => {
} catch (error) { console.info('TC_065-1 Success');
console.info('TC_050-15 error: ' + error); expect(true).assertTrue();
expect(false).assertTrue(); done();
done(); })
}
})
/**
* @tc.number : TC_053
* @tc.name : createIncrementalSource-updateData-png
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_053', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('TC_053 0003 ' + testimagebuffer.length);
let bufferSize = testimagebuffer.length;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
console.info('TC_053 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('TC_053 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('TC_053 updateData failed');
expect(ret).assertTrue();
break;
} }
offset = offset + oneStep.length; } catch (error) {
console.info('TC_053 0011 ' + offset); console.info('TC_065-1 error: ' + error);
} expect(false).assertTrue();
if (ret) {
console.info('TC_053 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('TC_053 0014' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
done(); done();
} }
} catch (error) { })
console.info('TC_053 updateData failed ' + error);
}
})
/** /**
* @tc.number : TC_053-1 * @tc.number : TC_066
* @tc.name : createIncrementalSource-updateData-jpg * @tc.name : release ImageSource - promise - gif
* @tc.desc : 1.create imagesource * @tc.desc : 1.create ImageSource
* 2.update data * 2.call release()
* 3.create pixelmap * 3.return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_053-1', 0, async function (done) { it('TC_066', 0, async function (done) {
try { try {
let testimagebuffer = testJpg; await getFd('test.gif');
console.info('TC_053-1 0003 ' + testimagebuffer.length); const imageSourceApi = image.createImageSource(fdNumber);
let bufferSize = testimagebuffer.length; if (imageSourceApi == undefined) {
let offset = 0; console.info('TC_066 create image source failed');
const incSouce = image.createIncrementalSource(new ArrayBuffer(1)); expect(false).assertTrue();
let isFinished = false;
let ret;
while (offset < testimagebuffer.length) {
console.info('TC_053-1 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('TC_053-1 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('TC_053-1 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('TC_053-1 0011 ' + offset);
}
if (ret) {
console.info('TC_053-1 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
expect(pixelmap != undefined).assertTrue();
done(); done();
}) } else {
} else { imageSourceApi.release().then(() => {
console.info('TC_066 success');
expect(true).assertTrue();
done();
}).catch(error => {
console.log('TC_066 error: ' + error);
expect().assertFail();
done();
})
}
} catch (error) {
console.info('TC_066 error: ' + error);
expect(false).assertTrue();
done(); done();
} }
} catch (error) { })
console.info('TC_053-1 updateData failed ' + error);
}
})
/** /**
* @tc.number : TC_064 * @tc.number : TC_066-1
* @tc.name : release ImageSource - promise - png * @tc.name : release ImageSource - callback - gif
* @tc.desc : 1.create ImageSource * @tc.desc : 1.create ImageSource
* 2.call release() * 2.call release()
* 3.return undefined * 3.return undefined
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_064', 0, async function (done) { it('TC_066-1', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathPng); await getFd('test.gif');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_064 create image source failed'); console.info('TC_066-1 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.release(() => {
console.info('TC_066-1 Success');
expect(true).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_066-1 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.release().then(() => {
console.info('TC_064 success');
expect(true).assertTrue();
done();
}).catch(error => {
console.log('TC_064 error: ' + error);
expect().assertFail();
done();
})
} }
} catch (error) { })
console.info('TC_064 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_064-1 * @tc.number : TC_067-14
* @tc.name : release ImageSource - callback - png * @tc.name : createPixelMap-promise-gif
* @tc.desc : 1.create ImageSource * @tc.desc : 1.create imagesource
* 2.call release() * 2.set index and DecodeOptions
* 3.return undefined * 3.create PixelMap
* @tc.size : MEDIUM * 4.callback return undefined
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 1
it('TC_064-1', 0, async function (done) { */
try { it('TC_067-14', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng); try {
const imageSourceApi = image.createImageSource(fdNumber); await getFd('moving_test.gif');
if (imageSourceApi == undefined) { const imageSourceApi = image.createImageSource(fdNumber);
console.info('TC_064-1 create image source failed'); if (imageSourceApi == undefined) {
console.info('TC_067-14 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap().then(pixelmap => {
globalpixelmap = pixelmap;
console.info('TC_067-14 success ');
expect(pixelmap !== undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_067-14 error: ' + error);
expect().assertFail();
done();
})
}
} catch (error) {
console.info('TC_067-14 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.release(async (err) => {
if (err) {
console.info('TC_064-1 err:' + err);
expect(false).assertTrue();
done();
return
}
console.info('TC_064-1 Success');
expect(true).assertTrue();
expect(true).assertTrue();
done();
})
} }
} catch (error) { })
console.info('TC_064-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_065 * @tc.number : TC_067-15
* @tc.name : release ImageSource - promise - bmp * @tc.name : createPixelMap-pcallback-gif
* @tc.desc : 1.create ImageSource * @tc.desc : 1.create imagesource
* 2.call release() * 2.set index and DecodeOptions
* 3.return undefined * 3.create PixelMap
* @tc.size : MEDIUM * 4.callback return null
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 1
it('TC_065', 0, async function (done) { */
try { it('TC_067-15', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp); try {
const imageSourceApi = image.createImageSource(fdNumber); await getFd('moving_test.gif');
if (imageSourceApi == undefined) { const imageSourceApi = image.createImageSource(fdNumber);
console.info('TC_065 create image source failed'); if (imageSourceApi == undefined) {
console.info('TC_067-15 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap((err, pixelmap) => {
globalpixelmap = pixelmap;
console.info('TC_067-15 success ');
expect(pixelmap !== undefined).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_067-15 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.release().then(() => {
console.info('TC_065 success');
expect(true).assertTrue();
done();
}).catch(error => {
console.log('TC_065 error: ' + error);
expect().assertFail();
done();
})
} }
} catch (error) { })
console.info('TC_065 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_065-1 * @tc.number : TC_068-14
* @tc.name : release ImageSource - callback - bmp * @tc.name : createPixelMap-promise-bmp
* @tc.desc : 1.create ImageSource * @tc.desc : 1.create imagesource
* 2.create SourceStream * 2.set index and DecodeOptions
* 3.return undefined * 3.create PixelMap
* @tc.size : MEDIUM * 4.callback return undefined
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 1
it('TC_065-1', 0, async function (done) { */
try { it('TC_068-14', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp); try {
const imageSourceApi = image.createImageSource(fdNumber); await getFd('test.bmp');
if (imageSourceApi == undefined) { const imageSourceApi = image.createImageSource(fdNumber);
console.info('TC_065-1 create image source failed'); if (imageSourceApi == undefined) {
console.info('TC_068-14 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap().then(pixelmap => {
globalpixelmap = pixelmap;
console.info('TC_068-14 success ');
expect(pixelmap != undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_068-14 error: ' + error);
expect().assertFail();
done();
})
}
} catch (error) {
console.info('TC_068-14 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.release(async () => {
console.info('TC_065-1 Success');
expect(true).assertTrue();
done();
})
} }
} catch (error) { })
console.info('TC_065-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_066 * @tc.number : TC_068-15
* @tc.name : release ImageSource - promise - gif * @tc.name : createPixelMap-callback-bmp
* @tc.desc : 1.create ImageSource * @tc.desc : 1.create imagesource
* 2.call release() * 2.set index and DecodeOptions
* 3.return undefined * 3.create PixelMap
* @tc.size : MEDIUM * 4.callback return undefined
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 1
it('TC_066', 0, async function (done) { */
try { it('TC_068-15', 0, async function (done) {
let fdNumber = fileio.openSync(pathGif); try {
const imageSourceApi = image.createImageSource(fdNumber); await getFd('test.bmp');
if (imageSourceApi == undefined) { const imageSourceApi = image.createImageSource(fdNumber);
console.info('TC_066 create image source failed'); if (imageSourceApi == undefined) {
console.info('TC_068-15 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap((err, pixelmap) => {
globalpixelmap = pixelmap;
console.info('TC_068-15 success ');
expect(pixelmap != undefined).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_068-15 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.release().then(() => {
console.info('TC_066 success');
expect(true).assertTrue();
done();
}).catch(error => {
console.log('TC_066 error: ' + error);
expect().assertFail();
done();
})
} }
} catch (error) { })
console.info('TC_066 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_066-1 * @tc.number : TC_163-14
* @tc.name : release ImageSource - callback - gif * @tc.name : createPixelMap-promise-png
* @tc.desc : 1.create ImageSource * @tc.desc : 1.create imagesource
* 2.call release() * 2.set index and DecodeOptions
* 3.return undefined * 3.create PixelMap
* @tc.size : MEDIUM * 4.callback return undefined
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 1
it('TC_066-1', 0, async function (done) { */
try { it('TC_163-14', 0, async function (done) {
let fdNumber = fileio.openSync(pathGif); try {
const imageSourceApi = image.createImageSource(fdNumber); await getFd('test.png');
if (imageSourceApi == undefined) { const imageSourceApi = image.createImageSource(fdNumber);
console.info('TC_066-1 create image source failed'); if (imageSourceApi == undefined) {
console.info('TC_163-14 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap().then(pixelmap => {
globalpixelmap = pixelmap;
console.info('TC_163-14 success');
expect(pixelmap != undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_163-14 error: ' + error);
expect().assertFail();
done();
})
}
} catch (error) {
console.info('TC_163-14 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.release(() => {
console.info('TC_066-1 Success');
expect(true).assertTrue();
done();
})
} }
} catch (error) { })
console.info('TC_066-1 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_067-14 * @tc.number : TC_163-15
* @tc.name : createPixelMap-promise-gif * @tc.name : createPixelMap-callback-png
* @tc.desc : 1.create imagesource * @tc.desc : 1.create imagesource
* 2.set index and DecodeOptions * 2.set index and DecodeOptions
* 3.create PixelMap * 3.create PixelMap
* 4.callback return undefined * 4.callback return null
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_067-14', 0, async function (done) { it('TC_163-15', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathMovingGif); await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_067-14 create image source failed'); console.info('TC_163-15 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.createPixelMap((err, pixelmap) => {
globalpixelmap = pixelmap;
console.info('TC_163-15 success');
expect(pixelmap != undefined).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_163-15 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.createPixelMap().then(pixelmap => {
globalpixelmap = pixelmap;
console.info('TC_067-14 success ');
expect(pixelmap !== undefined).assertTrue();
done();
}).catch(error => {
console.log('TC_067-14 error: ' + error);
expect().assertFail();
done();
})
} }
} catch (error) { })
console.info('TC_067-14 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_067-15 * @tc.number : TC_164
* @tc.name : createPixelMap-pcallback-gif * @tc.name : imagesource supportedFormats
* @tc.desc : 1.create imagesource * @tc.desc : 1.create imagesource
* 2.set index and DecodeOptions * 2.call supportedFormats
* 3.create PixelMap * @tc.size : MEDIUM
* 4.callback return null * @tc.type : Functional
* @tc.size : MEDIUM * @tc.level : Level 0
* @tc.type : Functional */
* @tc.level : Level 1 it('TC_164', 0, async function (done) {
*/ try {
it('TC_067-15', 0, async function (done) { await getFd('test.jpg');
try { const imageSourceApi = image.createImageSource(fdNumber);
let fdNumber = fileio.openSync(pathMovingGif); if (imageSourceApi == undefined) {
const imageSourceApi = image.createImageSource(fdNumber); console.info('TC_164 create image source failed');
if (imageSourceApi == undefined) { expect(false).assertTrue();
console.info('TC_067-15 create image source failed'); done();
} else {
expect(imageSourceApi.supportedFormats != undefined).assertTrue();
console.info(imageSourceApi.supportedFormats);
console.info('TC_164 success ');
done();
}
} catch (error) {
console.info('TC_164 error: ' + error);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else {
imageSourceApi.createPixelMap((err, pixelmap) => {
globalpixelmap = pixelmap;
console.info('TC_067-15 success ');
expect(pixelmap !== undefined).assertTrue();
done();
})
} }
} catch (error) { })
console.info('TC_067-15 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_068-14 * @tc.number : TC_166
* @tc.name : createPixelMap-promise-bmp * @tc.name : imagepacker supportedFormats
* @tc.desc : 1.create imagesource * @tc.desc : 1.create imagepacker
* 2.set index and DecodeOptions * 2.call supportedFormats
* 3.create PixelMap * @tc.size : MEDIUM
* 4.callback return undefined * @tc.type : Functional
* @tc.size : MEDIUM * @tc.level : Level 0
* @tc.type : Functional */
* @tc.level : Level 1 it('TC_166', 0, async function (done) {
*/ const imagePackerApi = image.createImagePacker();
it('TC_068-14', 0, async function (done) { if (imagePackerApi == undefined) {
try { console.info('TC_166 create image packer failed');
let fdNumber = fileio.openSync(pathBmp);
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_068-14 create image source failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
imageSourceApi.createPixelMap().then(pixelmap => { expect(imagePackerApi.supportedFormats != undefined).assertTrue();
globalpixelmap = pixelmap; console.info(imagePackerApi.supportedFormats);
console.info('TC_068-14 success '); console.info('TC_166 success ');
expect(pixelmap != undefined).assertTrue(); done();
}
})
/**
* @tc.number : TC_168
* @tc.name : isEditable
* @tc.desc : 1.create pixelmap
* 2.call isEditable
* 3.return true
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_168', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts, (error, pixelmap) => {
if (pixelmap == undefined) {
console.info('TC_168 create pixelmap failed');
expect(false).assertTrue();
done(); done();
}).catch(error => { } else {
console.log('TC_068-14 error: ' + error); expect(pixelmap.isEditable == true).assertTrue();
expect().assertFail(); console.info('TC_168 success ');
done(); done();
}) }
} })
} catch (error) { })
console.info('TC_068-14 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_068-15 * @tc.number : editable_001
* @tc.name : createPixelMap-callback-bmp * @tc.name : create pixelmap-callback (editable: true, pixelFormat: ARGB_8888,
* @tc.desc : 1.create imagesource * size: { height: 4, width: 6 },bytes = buffer)
* 2.set index and DecodeOptions * @tc.desc : 1.create InitializationOptions object
* 3.create PixelMap * 2.set editable,pixelFormat,size
* 4.callback return undefined * 3.using color and opts create newPixelMap
* @tc.size : MEDIUM * 4.return newpixelmap not empty
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 0
it('TC_068-15', 0, async function (done) { */
try { it('editable_001', 0, async function (done) {
let fdNumber = fileio.openSync(pathBmp); const Color = new ArrayBuffer(96);
const imageSourceApi = image.createImageSource(fdNumber); let edit = true;
if (imageSourceApi == undefined) { let opts = { editable: true, pixelFormat: 1, size: { height: 4, width: 6 } }
console.info('TC_068-15 create image source failed'); image.createPixelMap(Color, opts, (err, pixelmap) => {
expect(false).assertTrue(); 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(); done();
} else { })
imageSourceApi.createPixelMap((err, pixelmap) => { })
globalpixelmap = pixelmap;
console.info('TC_068-15 success ');
expect(pixelmap != undefined).assertTrue();
done();
})
}
} catch (error) {
console.info('TC_068-15 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_163-14 * @tc.number : editable_002
* @tc.name : createPixelMap-promise-png * @tc.name : create pixelmap-callback (editable: false, pixelFormat: ARGB_8888,
* @tc.desc : 1.create imagesource * size: { height: 4, width: 6 },bytes = buffer)
* 2.set index and DecodeOptions * @tc.desc : 1.create InitializationOptions object
* 3.create PixelMap * 2.set editable,pixelFormat,size
* 4.callback return undefined * 3.using color and opts create newPixelMap
* @tc.size : MEDIUM * 4.return newpixelmap not empty
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 0
it('TC_163-14', 0, async function (done) { */
try { it('editable_002', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng); const Color = new ArrayBuffer(96);
const imageSourceApi = image.createImageSource(fdNumber); let edit = false;
if (imageSourceApi == undefined) { let opts = { editable: false, pixelFormat: 1, size: { height: 4, width: 6 } }
console.info('TC_163-14 create image source failed'); image.createPixelMap(Color, opts, (err, pixelmap) => {
expect(false).assertTrue(); 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(); done();
} else { })
imageSourceApi.createPixelMap().then(pixelmap => { })
globalpixelmap = pixelmap;
console.info('TC_163-14 success'); /**
* @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 != undefined).assertTrue();
expect(pixelmap.isEditable == opts.editable).assertTrue();
expect(pixelmap.isEditable == edit).assertTrue();
done(); done();
}).catch(error => { })
console.log('TC_163-14 error: ' + error); .catch(error => {
expect().assertFail(); console.log('editable_003 err' + error);
expect(false).assertTrue();
done(); done();
}) })
} })
} catch (error) {
console.info('TC_163-14 error: ' + error);
expect(false).assertTrue();
done();
}
})
/** /**
* @tc.number : TC_163-15 * @tc.number : editable_004
* @tc.name : createPixelMap-callback-png * @tc.name : create pixelmap-promise (editable: false, pixelFormat: RGB_565,
* @tc.desc : 1.create imagesource * size: { height: 4, width: 6 }, bytes = buffer)
* 2.set index and DecodeOptions * @tc.desc : 1.create InitializationOptions object
* 3.create PixelMap * 2.set editable,pixeFormat,size
* 4.callback return null * 3.using color and opts create newPixelMap
* @tc.size : MEDIUM * 4.return newpixelmap not empty
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : Level 1 * @tc.type : Functional
*/ * @tc.level : Level 0
it('TC_163-15', 0, async function (done) { */
try { it('editable_004', 0, async function (done) {
let fdNumber = fileio.openSync(pathPng); const Color = new ArrayBuffer(96);
const imageSourceApi = image.createImageSource(fdNumber); let edit = false;
if (imageSourceApi == undefined) { let opts = { editable: false, pixelFormat: 2, size: { height: 4, width: 6 } }
console.info('TC_163-15 create image source failed'); image.createPixelMap(Color, opts)
expect(false).assertTrue(); .then(pixelmap => {
done(); console.info('editable_004 editable: ' + pixelmap.isEditable);
} else {
imageSourceApi.createPixelMap((err, pixelmap) => {
globalpixelmap = pixelmap;
console.info('TC_163-15 success');
expect(pixelmap != undefined).assertTrue(); 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(); done();
}) })
}
} catch (error) {
console.info('TC_163-15 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_164
* @tc.name : imagesource supportedFormats
* @tc.desc : 1.create imagesource
* 2.call supportedFormats
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_164', 0, async function (done) {
try {
let fdNumber = fileio.openSync(pathJpg);
const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) {
console.info('TC_164 create image source failed');
expect(false).assertTrue();
done();
} else {
expect(imageSourceApi.supportedFormats != undefined).assertTrue();
console.info(imageSourceApi.supportedFormats);
console.info('TC_164 success ');
done();
}
} catch (error) {
console.info('TC_164 error: ' + error);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : TC_166
* @tc.name : imagepacker supportedFormats
* @tc.desc : 1.create imagepacker
* 2.call supportedFormats
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('TC_166', 0, async function (done) {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
console.info('TC_166 create image packer failed');
expect(false).assertTrue();
done();
} else {
expect(imagePackerApi.supportedFormats != undefined).assertTrue();
console.info(imagePackerApi.supportedFormats);
console.info('TC_166 success ');
done();
}
})
/**
* @tc.number : TC_168
* @tc.name : isEditable
* @tc.desc : 1.create pixelmap
* 2.call isEditable
* 3.return true
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('TC_168', 0, async function (done) {
const Color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(Color, opts, (error, pixelmap) => {
if (pixelmap == undefined) {
console.info('TC_168 create pixelmap failed');
expect(false).assertTrue();
done();
} else {
expect(pixelmap.isEditable == true).assertTrue();
console.info('TC_168 success ');
done();
}
}) })
}) })
})} }
...@@ -607,4 +607,14 @@ let testJpg = new Uint8Array([255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1 ...@@ -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, 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]) 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} 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])
\ No newline at end of file
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 @@ ...@@ -15,6 +15,14 @@
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "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 @@ ...@@ -14,7 +14,7 @@
*/ */
import Image_test from './colorspace.test.js' import imageColorSpace from './colorspace.test.js'
export default function testsuite() { export default function testsuite() {
Image_test() imageColorSpace()
} }
...@@ -17,8 +17,8 @@ import image from '@ohos.multimedia.image' ...@@ -17,8 +17,8 @@ import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { iccbuf } from './testImg2' import { iccbuf } from './testImg2'
export default function Image_test() { export default function imageColorSpace() {
describe('Image_test', function () { describe('imageColorSpace', function () {
beforeAll(async function () { beforeAll(async function () {
console.info('beforeAll case'); console.info('beforeAll case');
}) })
......
...@@ -19,29 +19,29 @@ ...@@ -19,29 +19,29 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir /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 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files" "chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files/*"
],
"teardown-command":[
] ]
}, },
{ {
"type": "PushKit", "type": "PushKit",
"pre-push": [], "pre-push": [],
"push": [ "push": [
"./resource/image/test.bmp ->/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/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/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/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/files" "./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.bmp", "hilog -Q pidoff",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.png", "hilog -b D"
"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"
], ],
"teardown-command": [] "teardown-command": []
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import Image_test from './image.test.js' import imageDecodeOptions from './image.test.js'
export default function testsuite() { export default function testsuite() {
Image_test() imageDecodeOptions()
} }
...@@ -17,8 +17,11 @@ ...@@ -17,8 +17,11 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir /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 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files" "chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files/*"
],
"teardown-command":[
] ]
}, },
{ {
...@@ -26,20 +29,17 @@ ...@@ -26,20 +29,17 @@
"pre-push": [ "pre-push": [
], ],
"push": [ "push": [
"./resource/image/test_exif.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/files" "./resource/image/test_exif1.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files"
] ]
}, },
{
{
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files/test_exif.jpg", "hilog -Q pidoff",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files/test_exif1.jpg" "hilog -b D"
], ],
"teardown-command":[ "teardown-command": []
]
} }
] ]
......
...@@ -14,4 +14,3 @@ ...@@ -14,4 +14,3 @@
*/ */
require('./image.test.js') 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 @@ ...@@ -16,16 +16,28 @@
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio' import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' 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 featureAbility from '@ohos.ability.featureAbility'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
describe('Image', function () { describe('imageExif', function () {
var pathExifJpg = '/data/storage/el2/base/files/test_exif.jpg'; let filePath;
var pathExifJpg1 = '/data/storage/el2/base/files/test_exif1.jpg'; let fdNumber;
let globalpixelmap; 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 () { beforeAll(async function () {
await applyPermission();
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -37,1188 +49,18 @@ describe('Image', function () { ...@@ -37,1188 +49,18 @@ describe('Image', function () {
if (globalpixelmap != undefined) { if (globalpixelmap != undefined) {
await globalpixelmap.release(); 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'); console.info('afterEach case');
}) })
afterAll(async function () { afterAll(async function () {
console.info('afterAll case'); 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.number : TC_171
* @tc.name : getImageProperty(BitsPerSample)-promise * @tc.name : getImageProperty(BitsPerSample)-promise
...@@ -1231,7 +73,7 @@ describe('Image', function () { ...@@ -1231,7 +73,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171', 0, async function (done) { it('TC_171', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg1); await getFd('test_exif1.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171 create image source failed'); console.info('TC_171 create image source failed');
...@@ -1264,7 +106,7 @@ describe('Image', function () { ...@@ -1264,7 +106,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171-1', 0, async function (done) { it('TC_171-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171-1 create image source failed'); console.info('TC_171-1 create image source failed');
...@@ -1297,7 +139,7 @@ describe('Image', function () { ...@@ -1297,7 +139,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171-2', 0, async function (done) { it('TC_171-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171-2 create image source failed'); console.info('TC_171-2 create image source failed');
...@@ -1330,7 +172,7 @@ describe('Image', function () { ...@@ -1330,7 +172,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171-3', 0, async function (done) { it('TC_171-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171-3 create image source failed'); console.info('TC_171-3 create image source failed');
...@@ -1363,7 +205,7 @@ describe('Image', function () { ...@@ -1363,7 +205,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171-4', 0, async function (done) { it('TC_171-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171-4 create image source failed'); console.info('TC_171-4 create image source failed');
...@@ -1396,7 +238,7 @@ describe('Image', function () { ...@@ -1396,7 +238,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171-5', 0, async function (done) { it('TC_171-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171-5 create image source failed'); console.info('TC_171-5 create image source failed');
...@@ -1429,7 +271,7 @@ describe('Image', function () { ...@@ -1429,7 +271,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171-6', 0, async function (done) { it('TC_171-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171-6 create image source failed'); console.info('TC_171-6 create image source failed');
...@@ -1462,7 +304,7 @@ describe('Image', function () { ...@@ -1462,7 +304,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171-7', 0, async function (done) { it('TC_171-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171-7 create image source failed'); console.info('TC_171-7 create image source failed');
...@@ -1495,7 +337,7 @@ describe('Image', function () { ...@@ -1495,7 +337,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_171-8', 0, async function (done) { it('TC_171-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_171-8 create image source failed'); console.info('TC_171-8 create image source failed');
...@@ -1527,7 +369,7 @@ describe('Image', function () { ...@@ -1527,7 +369,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172', 0, async function (done) { it('TC_172', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg1); await getFd('test_exif1.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172 create image source failed'); console.info('TC_172 create image source failed');
...@@ -1559,7 +401,7 @@ describe('Image', function () { ...@@ -1559,7 +401,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172-1', 0, async function (done) { it('TC_172-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172-1 create image source failed'); console.info('TC_172-1 create image source failed');
...@@ -1591,7 +433,7 @@ describe('Image', function () { ...@@ -1591,7 +433,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172-2', 0, async function (done) { it('TC_172-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172-2 create image source failed'); console.info('TC_172-2 create image source failed');
...@@ -1623,7 +465,7 @@ describe('Image', function () { ...@@ -1623,7 +465,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172-3', 0, async function (done) { it('TC_172-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172-3 create image source failed'); console.info('TC_172-3 create image source failed');
...@@ -1655,7 +497,7 @@ describe('Image', function () { ...@@ -1655,7 +497,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172-4', 0, async function (done) { it('TC_172-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172-4 create image source failed'); console.info('TC_172-4 create image source failed');
...@@ -1687,7 +529,7 @@ describe('Image', function () { ...@@ -1687,7 +529,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172-5', 0, async function (done) { it('TC_172-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172-5 create image source failed'); console.info('TC_172-5 create image source failed');
...@@ -1719,7 +561,7 @@ describe('Image', function () { ...@@ -1719,7 +561,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172-6', 0, async function (done) { it('TC_172-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172-6 create image source failed'); console.info('TC_172-6 create image source failed');
...@@ -1751,7 +593,7 @@ describe('Image', function () { ...@@ -1751,7 +593,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172-7', 0, async function (done) { it('TC_172-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172-7 create image source failed'); console.info('TC_172-7 create image source failed');
...@@ -1783,7 +625,7 @@ describe('Image', function () { ...@@ -1783,7 +625,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_172-8', 0, async function (done) { it('TC_172-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_172-8 create image source failed'); console.info('TC_172-8 create image source failed');
...@@ -1816,7 +658,7 @@ describe('Image', function () { ...@@ -1816,7 +658,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173', 0, async function (done) { it('TC_173', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg1); await getFd('test_exif1.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173 create image source failed'); console.info('TC_173 create image source failed');
...@@ -1850,7 +692,7 @@ describe('Image', function () { ...@@ -1850,7 +692,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173-1', 0, async function (done) { it('TC_173-1', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173-1 create image source failed'); console.info('TC_173-1 create image source failed');
...@@ -1884,7 +726,7 @@ describe('Image', function () { ...@@ -1884,7 +726,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173-2', 0, async function (done) { it('TC_173-2', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173-2 create image source failed'); console.info('TC_173-2 create image source failed');
...@@ -1918,7 +760,7 @@ describe('Image', function () { ...@@ -1918,7 +760,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173-3', 0, async function (done) { it('TC_173-3', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173-3 create image source failed'); console.info('TC_173-3 create image source failed');
...@@ -1952,7 +794,7 @@ describe('Image', function () { ...@@ -1952,7 +794,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173-4', 0, async function (done) { it('TC_173-4', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173-4 create image source failed'); console.info('TC_173-4 create image source failed');
...@@ -1986,7 +828,7 @@ describe('Image', function () { ...@@ -1986,7 +828,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173-5', 0, async function (done) { it('TC_173-5', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173-5 create image source failed'); console.info('TC_173-5 create image source failed');
...@@ -2020,7 +862,7 @@ describe('Image', function () { ...@@ -2020,7 +862,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173-6', 0, async function (done) { it('TC_173-6', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173-6 create image source failed'); console.info('TC_173-6 create image source failed');
...@@ -2054,7 +896,7 @@ describe('Image', function () { ...@@ -2054,7 +896,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173-7', 0, async function (done) { it('TC_173-7', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173-7 create image source failed'); console.info('TC_173-7 create image source failed');
...@@ -2088,7 +930,7 @@ describe('Image', function () { ...@@ -2088,7 +930,7 @@ describe('Image', function () {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('TC_173-8', 0, async function (done) { it('TC_173-8', 0, async function (done) {
let fdNumber = fileio.openSync(pathExifJpg); await getFd('test_exif.jpg');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('TC_173-8 create image source failed'); 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 @@ ...@@ -18,15 +18,18 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir /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 777 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files" "chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files/*"
],
"teardown-command":[
] ]
}, },
{ {
"type": "PushKit", "type": "PushKit",
"pre-push": [], "pre-push": [],
"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 @@ ...@@ -34,7 +37,7 @@
"run-command": [ "run-command": [
"hilog -Q pidoff", "hilog -Q pidoff",
"hilog -b D", "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": [ "teardown-command": [
"rm -rf /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/*" "rm -rf /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/*"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import Image from './modify.test.js' import imageModifyProperty from './modify.test.js'
export default function testsuite() { export default function testsuite() {
Image() imageModifyProperty()
} }
...@@ -17,23 +17,41 @@ import image from '@ohos.multimedia.image' ...@@ -17,23 +17,41 @@ import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio' import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {modifyBuf} from './modifyBuffer' import {modifyBuf} from './modifyBuffer'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
export default function imageModifyProperty() {
export default function Image() { describe('imageModifyProperty', function () {
describe('Image', function () { let filePath;
var pathExifJpg = '/data/storage/el2/base/files/test_exif.jpg'; 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 () { beforeAll(async function () {
await applyPermission();
console.info('beforeAll case'); console.info('beforeAll case');
}) })
beforeEach(function () { beforeEach(function () {
console.info('beforeEach case'); 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'); console.info('afterEach case');
}) })
...@@ -41,34 +59,6 @@ describe('Image', function () { ...@@ -41,34 +59,6 @@ describe('Image', function () {
console.info('afterAll case'); 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){ async function modifyPromise(done, testNum, type, key, value, checkProps){
let imageSourceApi; let imageSourceApi;
...@@ -76,8 +66,8 @@ describe('Image', function () { ...@@ -76,8 +66,8 @@ describe('Image', function () {
const data = modifyBuf.buffer; const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data); imageSourceApi = image.createImageSource(data);
} else { } else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777); await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdExifJpg); imageSourceApi = image.createImageSource(fdNumber);
} }
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`); console.info(`${testNum} create image source failed`);
...@@ -108,8 +98,8 @@ describe('Image', function () { ...@@ -108,8 +98,8 @@ describe('Image', function () {
const data = modifyBuf.buffer; const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data); imageSourceApi = image.createImageSource(data);
} else { } else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777); await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdExifJpg); imageSourceApi = image.createImageSource(fdNumber);
} }
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`); console.info(`${testNum} create image source failed`);
...@@ -143,8 +133,8 @@ describe('Image', function () { ...@@ -143,8 +133,8 @@ describe('Image', function () {
const data = modifyBuf.buffer; const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data); imageSourceApi = image.createImageSource(data);
} else { } else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777); await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdExifJpg); imageSourceApi = image.createImageSource(fdNumber);
} }
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`); console.info(`${testNum} create image source failed`);
...@@ -179,8 +169,8 @@ describe('Image', function () { ...@@ -179,8 +169,8 @@ describe('Image', function () {
const data = modifyBuf.buffer; const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data); imageSourceApi = image.createImageSource(data);
} else { } else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777); await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdExifJpg); imageSourceApi = image.createImageSource(fdNumber);
} }
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`); console.info(`${testNum} create image source failed`);
...@@ -202,8 +192,8 @@ describe('Image', function () { ...@@ -202,8 +192,8 @@ describe('Image', function () {
const data = modifyBuf.buffer; const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data); imageSourceApi = image.createImageSource(data);
}else { }else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777); await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdExifJpg); imageSourceApi = image.createImageSource(fdNumber);
} }
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`); console.info(`${testNum} create image source failed`);
...@@ -226,8 +216,8 @@ describe('Image', function () { ...@@ -226,8 +216,8 @@ describe('Image', function () {
const data = modifyBuf.buffer; const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data); imageSourceApi = image.createImageSource(data);
} else { } else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777); await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdExifJpg); imageSourceApi = image.createImageSource(fdNumber);
} }
} catch (error) { } catch (error) {
expect(false).assertTrue(); expect(false).assertTrue();
......
...@@ -10,23 +10,34 @@ ...@@ -10,23 +10,34 @@
}, },
"kits": [ "kits": [
{ {
"type": "PushKit", "test-file-name": [
"pre-push": [], "ActsImagePackingJsTest.hap"
"push": [] ],
"type": "AppInstallKit",
"cleanup-apps": true
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "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": [] "teardown-command": []
}, },
{ {
"test-file-name": [ "type": "PushKit",
"ActsImagePackingJsTest.hap" "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", "teardown-command": []
"cleanup-apps": true
} }
] ]
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import Image_test from './packing.test.js' import imagePacking from './packing.test.js'
export default function testsuite() { export default function testsuite() {
Image_test() imagePacking()
} }
...@@ -14,521 +14,1004 @@ ...@@ -14,521 +14,1004 @@
*/ */
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' 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() { export default function imagePacking() {
describe('Image_test', function () { describe('imagePacking', function () {
let filePath;
beforeAll(async function () { let fdNumber;
await applyPermission(); async function getFd(fileName) {
console.info('beforeAll case'); let context = await featureAbility.getContext();
}) await context.getFilesDir().then((data) => {
filePath = data + '/' + fileName;
beforeEach(function () { console.info('image case filePath is ' + filePath);
console.info('beforeEach case'); })
}) 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);
})
}
afterEach(function () { beforeAll(async function () {
console.info('afterEach case'); console.info('beforeAll case');
}) })
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(function () {
console.info('afterEach case');
})
afterAll(function () {
console.info('afterAll case');
})
function packingPromise(done, testNum, pixFormat, arg) {
let opts;
const Color = new ArrayBuffer(96);
if (pixFormat == 2) {
opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } }
} else {
opts = { editable: true, pixelFormat: 5, size: { height: 4, width: 6 } }
}
image.createPixelMap(Color, opts)
.then(pixelmap => {
if (pixelmap == undefined) {
expect(false).assertTrue()
console.info(`${testNum} create pixelmap fail`)
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
expect(false).assertTrue();
console.info(`${testNum} create imagepacker fail`)
done();
} else {
imagePackerApi.packing(pixelmap, arg)
.then((data) => {
var dataArr = new Uint8Array(data);
console.info(`${testNum} dataArr.length=` + dataArr.length);
for (var i = 0; i < dataArr.length; i++) {
console.info(`dataArr[` + i + `]=` + dataArr[i]);
}
expect(data != undefined).assertTrue();
console.info(`${testNum} success`)
done();
}).catch(error => {
console.log(`${testNum} error:` + error);
expect().assertFail();
done();
})
}
}
})
.catch(error => {
console.log('createpixelmap error: ' + error);
expect().assertFail();
done();
})
}
afterAll(function () { function packingCb(done, testNum, pixFormat, arg) {
console.info('afterAll case'); let opts;
}) const Color = new ArrayBuffer(96);
if (pixFormat == 2) {
opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } }
} else {
opts = { editable: true, pixelFormat: 5, size: { height: 4, width: 6 } }
}
image.createPixelMap(Color, opts)
.then(pixelmap => {
if (pixelmap == undefined) {
expect(false).assertTrue()
console.info(`${testNum} create pixelmap fail`)
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
expect(false).assertTrue();
console.info(`${testNum} create imagepacker fail`)
done();
} else {
imagePackerApi.packing(pixelmap, arg, (err, data) => {
if (err != undefined) {
console.info(`${testNum} packing failerr: ${err}`)
expect(false).assertTrue();
done();
return;
}
var dataArr = new Uint8Array(data);
console.info(`${testNum} dataArr.length=` + dataArr.length);
for (var i = 0; i < dataArr.length; i++) {
console.info(`dataArr[` + i + `]=` + dataArr[i]);
}
expect(data != undefined).assertTrue();
done();
})
}
}
})
.catch(error => {
console.log(`${testNum} createpixelmap error: ` + error);
expect().assertFail();
done();
})
}
async function applyPermission() { function packingCbFail(done, testNum, pixFormat, arg) {
console.info('[permission]case applyPermission in'); const Color = new ArrayBuffer(96);
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image.Packing', 0, 100); if (pixFormat == 2) {
let atManager = abilityAccessCtrl.createAtManager(); var opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } }
if (atManager != null) { } else {
let tokenID = appInfo.accessTokenId; var opts = { editable: true, pixelFormat: 5, size: { height: 4, width: 6 } }
console.info('[permission]case accessTokenId is' + tokenID); }
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA'; image.createPixelMap(Color, opts)
let permissionName3 = 'ohos.permission.WRITE_MEDIA'; .then(pixelmap => {
await atManager.grantUserGrantedPermission(tokenID, permissionName1).then((result) => { if (pixelmap == undefined) {
console.info('[permission]case grantUserGrantedPermission success:' + result); expect(false).assertTrue()
}).catch((err) => { done();
console.info('[permission]case grantUserGrantedPermission failed:' + err); } else {
}); const imagePackerApi = image.createImagePacker();
await atManager.grantUserGrantedPermission(tokenID, permissionName2).then((result) => { if (imagePackerApi == undefined) {
console.info('[permission]case grantUserGrantedPermission success:' + result); expect(false).assertTrue();
}).catch((err) => { done();
console.info('[permission]case grantUserGrantedPermission failed:' + err); } else {
}); imagePackerApi.packing(pixelmap, arg, (err, data) => {
await atManager.grantUserGrantedPermission(tokenID, permissionName3).then((result) => { expect(err != undefined).assertTrue();
console.info('[permission]case grantUserGrantedPermission success:' + result); done();
}).catch((err) => { })
console.info('[permission]case grantUserGrantedPermission failed:' + err); }
}); }
} else { })
console.info('[permission]case apply permission failed,createAtManager failed'); .catch(error => {
console.log(`${testNum} createpixelmap error:` + error);
expect().assertFail();
done();
})
} }
}
function packingPromiseFail(done, testNum, pixFormat, arg) {
function packing_promise(done, testNum, pixFormat, arg) { const Color = new ArrayBuffer(96);
let opts; if (pixFormat == 2) {
const Color = new ArrayBuffer(96); var opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } }
if (pixFormat == 2) { } else {
opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } } var opts = { editable: true, pixelFormat: 5, size: { height: 4, width: 6 } }
} else { }
opts = { editable: true, pixelFormat: 5, size: { height: 4, width: 6 } } image.createPixelMap(Color, opts)
.then(pixelmap => {
if (pixelmap == undefined) {
expect(false).assertTrue()
done();
} else {
const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
expect(false).assertTrue();
done();
} else {
imagePackerApi.packing(pixelmap, arg)
.then((data) => {
expect(false).assertTrue();
done();
}).catch(error => {
console.log(`${testNum} error:` + error);
expect(true).assertTrue();
done();
})
}
}
})
.catch(error => {
console.log('createpixelmap error: ' + error);
expect().assertFail();
done();
})
} }
image.createPixelMap(Color, opts)
.then(pixelmap => { /**
if (pixelmap == undefined) { * @tc.number : SUB_IMAGE_packing_P_001
expect(false).assertTrue() * @tc.name : SUB_IMAGE_packing_P_001
console.info(`${testNum} create pixelmap fail`) * @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_001', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 99 }
packingPromise(done, 'SUB_IMAGE_packing_P_001', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_002
* @tc.name : SUB_IMAGE_packing_P_002 - Promise - RGB565 quality 123
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_002', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packingPromiseFail(done, 'SUB_IMAGE_packing_P_002', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_003
* @tc.name : SUB_IMAGE_packing_P_003 - Promise - RGB565 quality null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_003', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packingPromiseFail(done, 'SUB_IMAGE_packing_P_003', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_004
* @tc.name : SUB_IMAGE_packing_P_004 - Promise - RGB565 format null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_004', 0, async function (done) {
let packOpts = { quality: 99 }
packingPromiseFail(done, 'SUB_IMAGE_packing_P_004', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_005
* @tc.name : SUB_IMAGE_packing_P_005 - Promise - RGB565 wrong format
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_005', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
packingPromiseFail(done, 'SUB_IMAGE_packing_P_005', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_006
* @tc.name : SUB_IMAGE_packing_P_006
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_006', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 50 }
packingPromise(done, 'SUB_IMAGE_packing_P_006', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_007
* @tc.name : SUB_IMAGE_packing_P_007 - Promise - RGB888 quality 123
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_007', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packingPromiseFail(done, 'SUB_IMAGE_packing_P_007', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_008
* @tc.name : SUB_IMAGE_packing_P_008 - Promise - RGB888 quality null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_008', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packingPromiseFail(done, 'SUB_IMAGE_packing_P_008', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_009
* @tc.name : SUB_IMAGE_packing_P_009 - Promise - RGB888 format null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_009', 0, async function (done) {
let packOpts = { quality: 99 }
packingPromiseFail(done, 'SUB_IMAGE_packing_P_009', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_P_010
* @tc.name : SUB_IMAGE_packing_P_010 - Promise - RGB888 wrong format
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_P_010', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
packingPromiseFail(done, 'SUB_IMAGE_packing_P_010', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packingCb_001
* @tc.name : SUB_IMAGE_packingCb_001
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_001', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 99 }
packingCb(done, 'SUB_IMAGE_packingCb_001', 2, packOpts)
})
/**
* @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
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_002', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packingCbFail(done, 'SUB_IMAGE_packingCb_002', 2, packOpts)
})
/**
* @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
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_003', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packingCbFail(done, 'SUB_IMAGE_packingCb_003', 2, packOpts)
})
/**
* @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
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_004', 0, async function (done) {
let packOpts = { quality: 99 }
packingCbFail(done, 'SUB_IMAGE_packingCb_004', 2, packOpts)
})
/**
* @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
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_005', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
packingCbFail(done, 'SUB_IMAGE_packingCb_005', 2, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packingCb_006
* @tc.name : SUB_IMAGE_packingCb_006
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_006', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 50 }
packingCb(done, 'SUB_IMAGE_packingCb_006', 5, packOpts)
})
/**
* @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
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_007', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packingCbFail(done, 'SUB_IMAGE_packingCb_007', 5, packOpts)
})
/**
* @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
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_008', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packingCbFail(done, 'SUB_IMAGE_packingCb_008', 5, packOpts)
})
/**
* @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
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_009', 0, async function (done) {
let packOpts = { quality: 99 }
packingCbFail(done, 'SUB_IMAGE_packingCb_009', 5, packOpts)
})
/**
* @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
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packingCb_010', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
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(); done();
} else { } else {
const imagePackerApi = image.createImagePacker(); const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) { if (imagePackerApi == undefined) {
console.info('TC_062 create image packer failed');
expect(false).assertTrue(); expect(false).assertTrue();
console.info(`${testNum} create imagepacker fail`)
done(); done();
} else { } else {
imagePackerApi.packing(pixelmap, arg) let packOpts = { format: "image/jpeg", quality: 99 }
.then((data) => { imagePackerApi.packing(imageSourceApi, packOpts)
var dataArr = new Uint8Array(data); .then(data => {
console.info(`${testNum} dataArr.length=` + dataArr.length); console.info('TC_062 success');
for (var i = 0; i < dataArr.length; i++) {
console.info(`dataArr[` + i + `]=` + dataArr[i]);
}
expect(data != undefined).assertTrue(); expect(data != undefined).assertTrue();
console.info(`${testNum} success`)
done(); done();
}).catch(error => { }).catch(error => {
console.log(`${testNum} error:` + error); console.log('TC_062 error: ' + error);
expect().assertFail(); expect(false).assertFail();
done(); done();
}) })
} }
} }
}) } catch (error) {
.catch(error => { console.info('TC_062 error: ' + error);
console.log('createpixelmap error: ' + error); expect(false).assertTrue();
expect().assertFail();
done(); done();
}) }
}
})
function packing_cb(done, testNum, pixFormat, arg) {
let opts; /**
const Color = new ArrayBuffer(96); * @tc.number : TC_062-1
if (pixFormat == 2) { * @tc.name : packing ImageSource - callback
opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } } * @tc.desc : 1.create ImageSource
} else { * 2.call packing
opts = { editable: true, pixelFormat: 5, size: { height: 4, width: 6 } } * 3.return array
} * 4.callbackcall return undefined
image.createPixelMap(Color, opts) * @tc.size : MEDIUM
.then(pixelmap => { * @tc.type : Functional
if (pixelmap == undefined) { * @tc.level : Level 1
expect(false).assertTrue() */
console.info(`${testNum} create pixelmap fail`) 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(); done();
} else { } else {
const imagePackerApi = image.createImagePacker(); const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) { if (imagePackerApi == undefined) {
console.info('TC_062-1 create image packer failed');
expect(false).assertTrue(); expect(false).assertTrue();
console.info(`${testNum} create imagepacker fail`)
done(); done();
} else { } else {
imagePackerApi.packing(pixelmap, arg, (err, data) => { let packOpts = { format: "image/jpeg", quality: 1 }
if (err != undefined) { imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info(`${testNum} packing failerr: ${err}`) console.info('TC_062-1 success' + JSON.stringify(data));
expect(false).assertTrue();
done();
return;
}
var dataArr = new Uint8Array(data);
console.info(`${testNum} dataArr.length=` + dataArr.length);
for (var i = 0; i < dataArr.length; i++) {
console.info(`dataArr[` + i + `]=` + dataArr[i]);
}
expect(data != undefined).assertTrue(); expect(data != undefined).assertTrue();
done(); done();
}) })
} }
} }
}) } catch (error) {
.catch(error => { console.info('TC_062-1 error: ' + error);
console.log(`${testNum} createpixelmap error: ` + error); expect(false).assertTrue();
expect().assertFail();
done(); done();
}) }
} })
function packing_cb_fail(done, testNum, pixFormat, arg) { /**
const Color = new ArrayBuffer(96); * @tc.number : TC_062-2
if (pixFormat == 2) { * @tc.name : packing ImageSource - callback - wrong format
var opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } } * @tc.desc : 1.create ImageSource
} else { * 2.call packing
var opts = { editable: true, pixelFormat: 5, size: { height: 4, width: 6 } } * 3.return array
} * 4.callbackcall return undefined
* @tc.size : MEDIUM
image.createPixelMap(Color, opts) * @tc.type : Functional
.then(pixelmap => { * @tc.level : Level 1
if (pixelmap == undefined) { */
expect(false).assertTrue() 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(); done();
} else { } else {
const imagePackerApi = image.createImagePacker(); const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) { if (imagePackerApi == undefined) {
console.info('TC_062-2 create image packer failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
imagePackerApi.packing(pixelmap, arg, (err, data) => { let packOpts = { format: "image/gif", quality: 98 }
expect(err != undefined).assertTrue(); imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-2 success');
expect(data == undefined).assertTrue();
console.info(data);
done(); done();
}) })
} }
} }
}) } catch (error) {
.catch(error => { console.info('TC_062-2 error: ' + error);
console.log(`${testNum} createpixelmap error:` + error); expect(false).assertTrue();
expect().assertFail();
done(); done();
}) }
} })
function packing_promise_fail(done, testNum, pixFormat, arg) { /**
const Color = new ArrayBuffer(96); * @tc.number : TC_062-3
if (pixFormat == 2) { * @tc.name : packing ImageSource - callback - wrong quality
var opts = { editable: true, pixelFormat: 2, size: { height: 4, width: 6 } } * @tc.desc : 1.create ImageSource
} else { * 2.call packing
var opts = { editable: true, pixelFormat: 5, size: { height: 4, width: 6 } } * 3.call return array
} * 4.callbackcall return undefined
image.createPixelMap(Color, opts) * @tc.size : MEDIUM
.then(pixelmap => { * @tc.type : Functional
if (pixelmap == undefined) { * @tc.level : Level 1
expect(false).assertTrue() */
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(); done();
} else { } else {
const imagePackerApi = image.createImagePacker(); const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) { if (imagePackerApi == undefined) {
console.info('TC_062-3 create image packer failed');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} else { } else {
imagePackerApi.packing(pixelmap, arg) let packOpts = { format: "image/jpeg", quality: 101 }
.then((data) => { imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
expect(false).assertTrue(); 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(); done();
}).catch(error => { }).catch(error => {
console.log(`${testNum} error:` + error); console.log('TC_062-5 error: ' + error);
console.log('TC_062-5 success');
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}) })
} }
} }
}) } catch (error) {
.catch(error => { console.info('TC_062-5 error: ' + error);
console.log('createpixelmap error: ' + error); expect(false).assertTrue();
expect().assertFail();
done(); done();
}) }
} })
/** /**
* @tc.number : SUB_IMAGE_packing_P_001 * @tc.number : TC_062-6
* @tc.name : SUB_IMAGE_packing_P_001 * @tc.name : packing ImageSource - promise - no format
* @tc.desc : 1.create PixelMap * @tc.desc : 1.create ImageSource
* 2.create ImagePacker * 2.call packing
* 3.call packing * 3.call return array
* @tc.size : MEDIUM * 4.callbackcall return undefined
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : level 0 * @tc.type : Functional
*/ * @tc.level : Level 1
it('SUB_IMAGE_packing_P_001', 0, async function (done) { */
let packOpts = { format: "image/jpeg", quality: 99 } it('TC_062-6', 0, async function (done) {
packing_promise(done, 'SUB_IMAGE_packing_P_001', 2, packOpts) try {
}) await getFd('test.png');
const imageSourceApi = image.createImageSource(fdNumber);
/** if (imageSourceApi == undefined) {
* @tc.number : SUB_IMAGE_packing_P_002 console.info('TC_062-6 create image source failed');
* @tc.name : SUB_IMAGE_packing_P_002 - Promise - RGB565 quality 123 expect(false).assertTrue();
* @tc.desc : 1.create PixelMap done();
* 2.create ImagePacker } else {
* 3.call packing const imagePackerApi = image.createImagePacker();
* @tc.size : MEDIUM if (imagePackerApi == undefined) {
* @tc.type : Functional console.info('TC_062-6 create image packer failed');
* @tc.level : level 0 expect(false).assertTrue();
*/ done();
it('SUB_IMAGE_packing_P_002', 0, async function (done) { } else {
let packOpts = { format: "image/jpeg", quality: 123 } let packOpts = { quality: 50 }
packing_promise_fail(done, 'SUB_IMAGE_packing_P_002', 2, packOpts) imagePackerApi.packing(imageSourceApi, packOpts)
}) .then(data => {
console.info('TC_062-6 failed');
/** expect(data == undefined).assertTrue();
* @tc.number : SUB_IMAGE_packing_P_003 done();
* @tc.name : SUB_IMAGE_packing_P_003 - Promise - RGB565 quality null }).catch(error => {
* @tc.desc : 1.create PixelMap console.log('TC_062-6 error: ' + error);
* 2.create ImagePacker console.log('TC_062-6 success');
* 3.call packing expect(true).assertTrue();
* @tc.size : MEDIUM done();
* @tc.type : Functional })
* @tc.level : level 0 }
*/ }
it('SUB_IMAGE_packing_P_003', 0, async function (done) { } catch (error) {
let packOpts = { format: "image/jpeg" } console.info('TC_062-6 error: ' + error);
packing_promise_fail(done, 'SUB_IMAGE_packing_P_003', 2, packOpts) expect(false).assertTrue();
}) done();
}
/** })
* @tc.number : SUB_IMAGE_packing_P_004
* @tc.name : SUB_IMAGE_packing_P_004 - Promise - RGB565 format null /**
* @tc.desc : 1.create PixelMap * @tc.number : TC_062-7
* 2.create ImagePacker * @tc.name : packing ImageSource - callback - quality 100
* 3.call packing * @tc.desc : 1.create ImageSource
* @tc.size : MEDIUM * 2.call packing
* @tc.type : Functional * 3.return array
* @tc.level : level 0 * 4.callbackcall return undefined
*/ * @tc.size : MEDIUM
it('SUB_IMAGE_packing_P_004', 0, async function (done) { * @tc.type : Functional
let packOpts = { quality: 99 } * @tc.level : Level 1
packing_promise_fail(done, 'SUB_IMAGE_packing_P_004', 2, packOpts) */
})
it('TC_062-7', 0, async function (done) {
/** try {
* @tc.number : SUB_IMAGE_packing_P_005 await getFd('test.png');
* @tc.name : SUB_IMAGE_packing_P_005 - Promise - RGB565 wrong format const imageSourceApi = image.createImageSource(fdNumber);
* @tc.desc : 1.create PixelMap if (imageSourceApi == undefined) {
* 2.create ImagePacker console.info('TC_062-7 create image source failed');
* 3.call packing expect(false).assertTrue();
* @tc.size : MEDIUM done();
* @tc.type : Functional } else {
* @tc.level : level 0 const imagePackerApi = image.createImagePacker();
*/ if (imagePackerApi == undefined) {
it('SUB_IMAGE_packing_P_005', 0, async function (done) { console.info('TC_062-7 create image packer failed');
let packOpts = { format: "image/png", quality: 99 } expect(false).assertTrue();
packing_promise_fail(done, 'SUB_IMAGE_packing_P_005', 2, packOpts) done();
}) } else {
let packOpts = { format: "image/jpeg", quality: 100 }
/** imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
* @tc.number : SUB_IMAGE_packing_P_006 if (err) {
* @tc.name : SUB_IMAGE_packing_P_006 expect(false).assertTrue();
* @tc.desc : 1.create PixelMap console.info('TC_062-7 error: ' + err);
* 2.create ImagePacker done();
* 3.call packing return
* @tc.size : MEDIUM }
* @tc.type : Functional if (data != undefined) {
* @tc.level : level 0 console.info('TC_062-7 success');
*/ expect(true).assertTrue();
it('SUB_IMAGE_packing_P_006', 0, async function (done) { done();
let packOpts = { format: "image/jpeg", quality: 50 } } else {
packing_promise(done, 'SUB_IMAGE_packing_P_006', 5, packOpts) except(false).assertTrue();
}) console.info('TC_062-7 failed');
done();
/** }
* @tc.number : SUB_IMAGE_packing_P_007 })
* @tc.name : SUB_IMAGE_packing_P_007 - Promise - RGB888 quality 123 }
* @tc.desc : 1.create PixelMap }
* 2.create ImagePacker } catch (error) {
* 3.call packing console.info('TC_062-7 error: ' + error);
* @tc.size : MEDIUM expect(false).assertTrue();
* @tc.type : Functional done();
* @tc.level : level 0 }
*/ })
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) * @tc.number : TC_062-8
}) * @tc.name : packing ImageSource - callback - quality 0
* @tc.desc : 1.create ImageSource
/** * 2.call packing
* @tc.number : SUB_IMAGE_packing_P_008 * 3.return array
* @tc.name : SUB_IMAGE_packing_P_008 - Promise - RGB888 quality null * 4.callbackcall return undefined
* @tc.desc : 1.create PixelMap * @tc.size : MEDIUM
* 2.create ImagePacker * @tc.type : Functional
* 3.call packing * @tc.level : Level 1
* @tc.size : MEDIUM */
* @tc.type : Functional it('TC_062-8', 0, async function (done) {
* @tc.level : level 0 try {
*/ await getFd('test.png');
it('SUB_IMAGE_packing_P_008', 0, async function (done) { const imageSourceApi = image.createImageSource(fdNumber);
let packOpts = { format: "image/jpeg" } if (imageSourceApi == undefined) {
packing_promise_fail(done, 'SUB_IMAGE_packing_P_008', 5, packOpts) console.info('TC_062-8 create image source failed');
}) expect(false).assertTrue();
done();
/** } else {
* @tc.number : SUB_IMAGE_packing_P_009 const imagePackerApi = image.createImagePacker();
* @tc.name : SUB_IMAGE_packing_P_009 - Promise - RGB888 format null if (imagePackerApi == undefined) {
* @tc.desc : 1.create PixelMap console.info('TC_062-8 create image packer failed');
* 2.create ImagePacker expect(false).assertTrue();
* 3.call packing done();
* @tc.size : MEDIUM } else {
* @tc.type : Functional let packOpts = { format: "image/jpeg", quality: 0 }
* @tc.level : level 0 imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
*/ console.info('TC_062-8 success');
it('SUB_IMAGE_packing_P_009', 0, async function (done) { expect(data != undefined).assertTrue();
let packOpts = { quality: 99 } done();
packing_promise_fail(done, 'SUB_IMAGE_packing_P_009', 5, packOpts) })
}) }
}
/** } catch (error) {
* @tc.number : SUB_IMAGE_packing_P_010 console.info('TC_062-8 error: ' + error);
* @tc.name : SUB_IMAGE_packing_P_010 - Promise - RGB888 wrong format expect(false).assertTrue();
* @tc.desc : 1.create PixelMap done();
* 2.create ImagePacker }
* 3.call packing })
* @tc.size : MEDIUM
* @tc.type : Functional /**
* @tc.level : level 0 * @tc.number : TC_062-9
*/ * @tc.name : packing ImageSource - callback - quality -1
it('SUB_IMAGE_packing_P_010', 0, async function (done) { * @tc.desc : 1.create ImageSource
let packOpts = { format: "image/png", quality: 99 } * 2.call packing
packing_promise_fail(done, 'SUB_IMAGE_packing_P_010', 5, packOpts) * 3.return array
}) * 4.callbackcall return undefined
* @tc.size : MEDIUM
/** * @tc.type : Functional
* @tc.number : SUB_IMAGE_packing_CB_001 * @tc.level : Level 1
* @tc.name : SUB_IMAGE_packing_CB_001 */
* @tc.desc : 1.create PixelMap it('TC_062-9', 0, async function (done) {
* 2.create ImagePacker try {
* 3.call packing await getFd('test.png');
* @tc.size : MEDIUM const imageSourceApi = image.createImageSource(fdNumber);
* @tc.type : Functional if (imageSourceApi == undefined) {
* @tc.level : level 0 console.info('TC_062-9 create image source failed');
*/ expect(false).assertTrue();
it('SUB_IMAGE_packing_CB_001', 0, async function (done) { done();
let packOpts = { format: "image/jpeg", quality: 99 } } else {
packing_cb(done, 'SUB_IMAGE_packing_CB_001', 2, packOpts) const imagePackerApi = image.createImagePacker();
}) if (imagePackerApi == undefined) {
console.info('TC_062-9 create image packer failed');
/** expect(false).assertTrue();
* @tc.number : SUB_IMAGE_packing_CB_002 done();
* @tc.name : SUB_IMAGE_packing_CB_002 - callback - RGB565 quality 123 } else {
* @tc.desc : 1.create PixelMap let packOpts = { format: "image/jpeg", quality: -1 }
* 2.create ImagePacker imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
* 3.call packing console.info('TC_062-9 success');
* @tc.size : MEDIUM expect(data == undefined).assertTrue();
* @tc.type : Functional done();
* @tc.level : level 0 })
*/ }
it('SUB_IMAGE_packing_CB_002', 0, async function (done) { }
let packOpts = { format: "image/jpeg", quality: 123 } } catch (error) {
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_002', 2, packOpts) console.info('TC_062-9 error: ' + error);
expect(false).assertTrue();
}) done();
}
/** })
* @tc.number : SUB_IMAGE_packing_CB_003
* @tc.name : SUB_IMAGE_packing_CB_003 - callback - RGB565 quality null /**
* @tc.desc : 1.create PixelMap * @tc.number : TC_063
* 2.create ImagePacker * @tc.name : release ImagePacker - promise
* 3.call packing * @tc.desc : 1.create ImagePacker
* @tc.size : MEDIUM * 2.call release
* @tc.type : Functional * 3.return undefined
* @tc.level : level 0 * @tc.size : MEDIUM
*/ * @tc.type : Functional
it('SUB_IMAGE_packing_CB_003', 0, async function (done) { * @tc.level : Level 1
let packOpts = { format: "image/jpeg" } */
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_003', 2, packOpts) it('TC_063', 0, async function (done) {
}) const imagePackerApi = image.createImagePacker();
if (imagePackerApi == undefined) {
/** console.info('TC_063 create image packer failed');
* @tc.number : SUB_IMAGE_packing_CB_004 expect(false).assertTrue();
* @tc.name : SUB_IMAGE_packing_CB_004 - callback - RGB565 format null done();
* @tc.desc : 1.create PixelMap } else {
* 2.create ImagePacker imagePackerApi.release().then(() => {
* 3.call packing console.info('TC_063 success');
* @tc.size : MEDIUM expect(true).assertTrue();
* @tc.type : Functional done();
* @tc.level : level 0 }).catch(() => {
*/ console.log('TC_063 error: ' + error);
it('SUB_IMAGE_packing_CB_004', 0, async function (done) { expect(false).assertTrue();
let packOpts = { quality: 99 } done();
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_004', 2, packOpts) })
}) }
})
/**
* @tc.number : SUB_IMAGE_packing_CB_005 /**
* @tc.name : SUB_IMAGE_packing_CB_005 - callback - RGB565 wrong format * @tc.number : TC_063-1
* @tc.desc : 1.create PixelMap * @tc.name : release ImagePacker - callback
* 2.create ImagePacker * @tc.desc : 1.create ImagePacker
* 3.call packing * 2.call release
* @tc.size : MEDIUM * 3.return undefined
* @tc.type : Functional * @tc.size : MEDIUM
* @tc.level : level 0 * @tc.type : Functional
*/ * @tc.level : Level 1
it('SUB_IMAGE_packing_CB_005', 0, async function (done) { */
let packOpts = { format: "image/png", quality: 99 } it('TC_063-1', 0, async function (done) {
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_005', 2, packOpts) const imagePackerApi = image.createImagePacker();
}) if (imagePackerApi == undefined) {
console.info('TC_063-1 create image packer failed');
/** expect(false).assertTrue();
* @tc.number : SUB_IMAGE_packing_CB_006 done();
* @tc.name : SUB_IMAGE_packing_CB_006 } else {
* @tc.desc : 1.create PixelMap imagePackerApi.release(() => {
* 2.create ImagePacker console.info('TC_063-1 success');
* 3.call packing expect(true).assertTrue();
* @tc.size : MEDIUM done();
* @tc.type : Functional })
* @tc.level : level 0 }
*/ })
it('SUB_IMAGE_packing_CB_006', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 50 }
packing_cb(done, 'SUB_IMAGE_packing_CB_006', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_007
* @tc.name : SUB_IMAGE_packing_CB_007 - callback - RGB888 quality 123
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_007', 0, async function (done) {
let packOpts = { format: "image/jpeg", quality: 123 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_007', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_008
* @tc.name : SUB_IMAGE_packing_CB_008 - callback - RGB888 quality null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_008', 0, async function (done) {
let packOpts = { format: "image/jpeg" }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_008', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_009
* @tc.name : SUB_IMAGE_packing_CB_009 - callback - RGB888 format null
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_009', 0, async function (done) {
let packOpts = { quality: 99 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_009', 5, packOpts)
})
/**
* @tc.number : SUB_IMAGE_packing_CB_010
* @tc.name : SUB_IMAGE_packing_CB_010 - callback - RGB888 wrong format
* @tc.desc : 1.create PixelMap
* 2.create ImagePacker
* 3.call packing
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : level 0
*/
it('SUB_IMAGE_packing_CB_010', 0, async function (done) {
let packOpts = { format: "image/png", quality: 99 }
packing_cb_fail(done, 'SUB_IMAGE_packing_CB_010', 5, packOpts)
}) })
}
})}
...@@ -15,6 +15,14 @@ ...@@ -15,6 +15,14 @@
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "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 @@ ...@@ -14,7 +14,7 @@
*/ */
import Image_test from './framework.test.js' import imagePixelMapFramework from './framework.test.js'
export default function testsuite() { export default function testsuite() {
Image_test() imagePixelMapFramework()
} }
...@@ -17,8 +17,8 @@ import image from '@ohos.multimedia.image' ...@@ -17,8 +17,8 @@ import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' 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 { base64Image, scale2x1, translate3x1, rotate90, flipH, testBmp, testGif, crop3x3, scale1x4, setAlpha8, translate1x3 } from './testImg2'
import { testPng, testJpg} from '../../../../../image/src/main/js/test/testImg' import { testPng, testJpg} from '../../../../../image/src/main/js/test/testImg'
export default function Image_test() { export default function imagePixelMapFramework() {
describe('Image_test', function () { describe('imagePixelMapFramework', function () {
beforeAll(async function () { beforeAll(async function () {
console.info('beforeAll case'); console.info('beforeAll case');
}) })
......
...@@ -10,31 +10,19 @@ ...@@ -10,31 +10,19 @@
}, },
"kits": [ "kits": [
{ {
"type": "ShellKit", "test-file-name": [
"run-command": [], "ActsImageReceiverJsTest.hap"
"teardown-command": [] ],
}, "type": "AppInstallKit",
{ "cleanup-apps": true
"type": "PushKit",
"pre-push": [],
"push": []
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"hilog -Q pidoff", "hilog -Q pidoff",
"hilog -b D", "hilog -b D"
"killall com.ohos.medialibrary.MediaScannerAbilityA",
"aa start -a MediaScannerAbility -b com.ohos.medialibrary.MediaScannerAbilityA"
], ],
"teardown-command": [] "teardown-command": []
},
{
"test-file-name": [
"ActsImageReceiverJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
} }
] ]
} }
\ No newline at end of file
...@@ -19,31 +19,23 @@ ...@@ -19,31 +19,23 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir /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 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files" "chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/haps/entry/files/*"
], ],
"teardown-command": [] "teardown-command": []
}, },
{ {
"type": "PushKit", "type": "PushKit",
"pre-push": [],
"push": [ "push": [
"./resource/image/test_large.webp ->/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"
"./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"
] ]
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "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/haps/entry/files/test_large.webp",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files/test.png", "hilog -Q pidoff",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Webp/files/test.bmp", "hilog -b D"
"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"
], ],
"teardown-command": [] "teardown-command": []
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import Image_test from './webp.test.js' import imageWebp from './webp.test.js'
export default function testsuite() { export default function testsuite() {
Image_test() imageWebp()
} }
...@@ -16,18 +16,28 @@ ...@@ -16,18 +16,28 @@
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio' import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
export default function Image() { export default function imageWebp() {
describe('Image', function () { describe('imageWebp', function () {
var pathJpg = '/data/storage/el2/base/files/test.jpg'; let filePath;
var pathWebp = '/data/storage/el2/base/files/test_large.webp'; let fdNumber;
var pathPng = '/data/storage/el2/base/files/test.png'; async function getFd(fileName) {
var pathBmp = '/data/storage/el2/base/files/test.bmp'; let context = await featureAbility.getContext();
var pathGif = '/data/storage/el2/base/files/test.gif'; 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 () { beforeAll(async function () {
await applyPermission();
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -36,6 +46,11 @@ describe('Image', function () { ...@@ -36,6 +46,11 @@ describe('Image', function () {
}) })
afterEach(async 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'); console.info('afterEach case');
}) })
...@@ -43,37 +58,9 @@ describe('Image', function () { ...@@ -43,37 +58,9 @@ describe('Image', function () {
console.info('afterAll case'); 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) { async function createPixMapCbErr(done, testNum, arg) {
let fdNumber = fileio.openSync(pathWebp); await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`); console.info(`${testNum} create image source failed`);
...@@ -92,8 +79,37 @@ describe('Image', function () { ...@@ -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) { async function createPixMapPromiseErr(done, testNum, arg) {
let fdNumber = fileio.openSync(pathWebp); await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`); console.info(`${testNum} create image source failed`);
...@@ -111,6 +127,31 @@ describe('Image', function () { ...@@ -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) { async function packingPromise(done, testNum, arg) {
console.info(`${testNum} enter`); console.info(`${testNum} enter`);
var height = 4 var height = 4
...@@ -435,7 +476,7 @@ describe('Image', function () { ...@@ -435,7 +476,7 @@ describe('Image', function () {
*/ */
it('wbp_001', 0, async function (done) { it('wbp_001', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathWebp); await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('wbp_001 create image source failed'); console.info('wbp_001 create image source failed');
...@@ -484,7 +525,7 @@ describe('Image', function () { ...@@ -484,7 +525,7 @@ describe('Image', function () {
*/ */
it('wbp_002', 0, async function (done) { it('wbp_002', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathWebp); await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('wbp_002 create image source failed'); console.info('wbp_002 create image source failed');
...@@ -533,7 +574,7 @@ describe('Image', function () { ...@@ -533,7 +574,7 @@ describe('Image', function () {
*/ */
it('wbp_003', 0, async function (done) { it('wbp_003', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathWebp); await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('wbp_003 create image source failed'); console.info('wbp_003 create image source failed');
...@@ -569,7 +610,7 @@ describe('Image', function () { ...@@ -569,7 +610,7 @@ describe('Image', function () {
*/ */
it('wbp_004', 0, async function (done) { it('wbp_004', 0, async function (done) {
try { try {
let fdNumber = fileio.openSync(pathWebp); await getFd('test_large.webp');
const imageSourceApi = image.createImageSource(fdNumber); const imageSourceApi = image.createImageSource(fdNumber);
if (imageSourceApi == undefined) { if (imageSourceApi == undefined) {
console.info('wbp_004 create image source failed'); console.info('wbp_004 create image source failed');
...@@ -753,7 +794,7 @@ describe('Image', function () { ...@@ -753,7 +794,7 @@ describe('Image', function () {
desiredRegion: { size: { height: 10000, width: 10000 }, x: 0, y: 0 }, desiredRegion: { size: { height: 10000, width: 10000 }, x: 0, y: 0 },
index: 0 index: 0
}; };
createPixMapCbErr(done, 'wbp_009', decodingOptions) createPixMapCb(done, 'wbp_009', decodingOptions)
}) })
/** /**
...@@ -874,7 +915,7 @@ describe('Image', function () { ...@@ -874,7 +915,7 @@ describe('Image', function () {
desiredRegion: { size: { height: 10000, width: 10000 }, x: 0, y: 0 }, desiredRegion: { size: { height: 10000, width: 10000 }, x: 0, y: 0 },
index: 0 index: 0
}; };
createPixMapPromiseErr(done, 'wbp_014', decodingOptions) createPixMapPromise(done, 'wbp_014', decodingOptions)
}) })
/** /**
......
...@@ -10,23 +10,19 @@ ...@@ -10,23 +10,19 @@
}, },
"kits": [ "kits": [
{ {
"type": "PushKit", "test-file-name": [
"pre-push": [], "ActsImageyuvJsTest.hap"
"push": [] ],
"type": "AppInstallKit",
"cleanup-apps": true
}, },
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"hilog -Q pidoff" "hilog -Q pidoff",
"hilog -b D"
], ],
"teardown-command": [] "teardown-command": []
},
{
"test-file-name": [
"ActsImageyuvJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
} }
] ]
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import Image from './yuv.test.js' import imageYuv from './yuv.test.js'
export default function testsuite() { export default function testsuite() {
Image() imageYuv()
} }
...@@ -16,11 +16,10 @@ ...@@ -16,11 +16,10 @@
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function Image() { export default function imageYuv() {
describe('Image', function () { describe('imageYuv', function () {
beforeAll(async function () { beforeAll(async function () {
await applyPermission();
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -37,36 +36,6 @@ describe('Image', function () { ...@@ -37,36 +36,6 @@ describe('Image', function () {
console.info('afterAll case'); 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) { function createBuffer(height, width) {
var ySize = height * width; var ySize = height * width;
var uvSize = ySize / 2 var uvSize = ySize / 2
...@@ -129,7 +98,7 @@ describe('Image', function () { ...@@ -129,7 +98,7 @@ describe('Image', function () {
} }
} }
async function yuvToJpegByPixelMapPromise_fail(done, testNum, sourceOptions, yuvData) { async function yuvToJpegByPixelMapPromise_Fail(done, testNum, sourceOptions, yuvData) {
try { try {
let imageSource = image.createImageSource(yuvData, sourceOptions) let imageSource = image.createImageSource(yuvData, sourceOptions)
if (imageSource == undefined) { if (imageSource == undefined) {
...@@ -192,7 +161,7 @@ describe('Image', function () { ...@@ -192,7 +161,7 @@ describe('Image', function () {
} }
} }
async function yuvToJpegByPixelMapCallback_fail(done, testNum, sourceOptions, yuvData) { async function yuvToJpegByPixelMapCallback_Fail(done, testNum, sourceOptions, yuvData) {
try { try {
let imageSource = image.createImageSource(yuvData, sourceOptions); let imageSource = image.createImageSource(yuvData, sourceOptions);
if (imageSource == undefined) { if (imageSource == undefined) {
...@@ -255,7 +224,7 @@ describe('Image', function () { ...@@ -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); let imageSource = image.createImageSource(yuvData, sourceOptions);
if (imageSource == undefined) { if (imageSource == undefined) {
console.info(`${testNum} create ImageSource failed`); console.info(`${testNum} create ImageSource failed`);
...@@ -317,7 +286,7 @@ describe('Image', function () { ...@@ -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); let imageSource = image.createImageSource(yuvData, sourceOptions);
if (imageSource == undefined) { if (imageSource == undefined) {
console.info(`${testNum} create ImageSource failed`); console.info(`${testNum} create ImageSource failed`);
...@@ -395,7 +364,7 @@ describe('Image', function () { ...@@ -395,7 +364,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_P_004', 0, async function (done) { it('SUB_IMAGE_yuv_pixelmap_P_004', 0, async function (done) {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } }; 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 () { ...@@ -425,7 +394,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_P_006', 0, async function (done) { it('SUB_IMAGE_yuv_pixelmap_P_006', 0, async function (done) {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } }; 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 () { ...@@ -440,7 +409,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_P_007', 0, async function (done) { it('SUB_IMAGE_yuv_pixelmap_P_007', 0, async function (done) {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 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 () { ...@@ -455,7 +424,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_P_008', 0, async function (done) { it('SUB_IMAGE_yuv_pixelmap_P_008', 0, async function (done) {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 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 () { ...@@ -527,7 +496,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } }; let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } };
let packOpts = { format: "image/jpeg", quality: 99 } 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 () { ...@@ -563,7 +532,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } }; let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } };
let packOpts = { format: "image/jpeg", quality: 99 } 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 () { ...@@ -581,7 +550,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 6 } }; let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 6 } };
let packOpts = { format: "image/jpeg", quality: 99 } 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 () { ...@@ -599,7 +568,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 6 } }; let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 6 } };
let packOpts = { format: "image/jpeg", quality: 99 } 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 () { ...@@ -659,7 +628,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_CB_004', 0, async function (done) { it('SUB_IMAGE_yuv_pixelmap_CB_004', 0, async function (done) {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } }; 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 () { ...@@ -689,7 +658,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_CB_006', 0, async function (done) { it('SUB_IMAGE_yuv_pixelmap_CB_006', 0, async function (done) {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } }; 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 () { ...@@ -704,7 +673,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_CB_007', 0, async function (done) { it('SUB_IMAGE_yuv_pixelmap_CB_007', 0, async function (done) {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 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 () { ...@@ -719,7 +688,7 @@ describe('Image', function () {
it('SUB_IMAGE_yuv_pixelmap_CB_008', 0, async function (done) { it('SUB_IMAGE_yuv_pixelmap_CB_008', 0, async function (done) {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 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 () { ...@@ -791,7 +760,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } }; let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 8, sourceSize: { height: 4, width: 5 } };
let packOpts = { format: "image/jpeg", quality: 99 } 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 () { ...@@ -827,7 +796,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } }; let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 9, sourceSize: { height: 4, width: 5 } };
let packOpts = { format: "image/jpeg", quality: 99 } 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 () { ...@@ -845,7 +814,7 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 6 } }; let sourceOptions = { sourceDensity: 120, sourcePixelFormat: 10, sourceSize: { height: 4, width: 6 } };
let packOpts = { format: "image/jpeg", quality: 99 } 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 () { ...@@ -863,6 +832,6 @@ describe('Image', function () {
let yuvData = createBuffer(4, 6); let yuvData = createBuffer(4, 6);
let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 6 } }; let sourceOptions = { sourceDensity: 120, sourceSize: { height: 4, width: 6 } };
let packOpts = { format: "image/jpeg", quality: 99 } 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 @@ ...@@ -9,12 +9,19 @@
}, },
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": [
"ActsPixelMapNapiEtsTest.hap" "ActsPixelMapNapiEtsTest.hap"
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
} }
] ]
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
// @ts-nocheck // @ts-nocheck
import image from '@ohos.multimedia.image' 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" import mypixelmap from "libimagePixelmap.so"
export default function nativeApiImageJsunit() { export default function nativeApiImageJsunit() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册