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

!4754 image XTS整改

Merge pull request !4754 from liuxueqi/master
......@@ -19,31 +19,28 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files"
]
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files/*"
],
"teardown-command": []
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/test.123 ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image/files",
"./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/files"
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/test.123 ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files",
"./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.bmp",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.png",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.123",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.gif",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/test.jpg",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image/files/moving_test.gif"
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
......
......@@ -13,7 +13,10 @@
* limitations under the License.
*/
import Image_test from './image.test.js'
import imageJsTest from './image.test.js'
import addImage from './addImage.test.js'
export default function testsuite() {
Image_test()
imageJsTest()
addImage()
}
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { testPng } from './testImg'
export default function addImage() {
describe('addImage', function () {
beforeAll(async function () {
console.info('beforeAll case');
})
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(async function () {
console.info('afterEach case');
})
afterAll(async function () {
console.info('afterAll case');
})
function createPixMapPromise(done, testNum, opts) {
const Color = new ArrayBuffer(96);
image.createPixelMap(Color, opts)
.then(pixelmap => {
expect(pixelmap != undefined).assertTrue();
console.info(`${testNum} success`);
done();
})
.catch(error => {
console.log(`${testNum} error: ` + error);
expect(false).assertTrue();
done();
})
}
function createPixMapCb(done, testNum, opts) {
const Color = new ArrayBuffer(96);
image.createPixelMap(Color, opts, (err, pixelmap) => {
expect(pixelmap != undefined).assertTrue();
console.info(`${testNum} success`);
done();
})
}
/**
* @tc.number : addImage_001
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 0)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_001', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 0 }
createPixMapPromise(done, 'add_01_001', opts);
})
/**
* @tc.number : add_01_002
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 1)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_002', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 1 }
createPixMapPromise(done, 'add_01_002', opts);
})
/**
* @tc.number : add_01_003
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 2)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_003', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 2 }
createPixMapPromise(done, 'add_01_003', opts);
})
/**
* @tc.number : add_01_004
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 3)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_004', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 3 }
createPixMapPromise(done, 'add_01_004', opts);
})
/**
* @tc.number : add_02_001
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 0)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_001', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 0 }
createPixMapCb(done, 'add_02_001', opts);
})
/**
* @tc.number : add_02_002
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 1)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_002', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 1 }
createPixMapCb(done, 'add_02_002', opts);
})
/**
* @tc.number : add_02_003
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 2)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_003', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 2 }
createPixMapCb(done, 'add_02_003', opts);
})
/**
* @tc.number : add_02_004
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 3)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_004', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 3 }
createPixMapCb(done, 'add_02_004', opts);
})
/**
* @tc.number : add_053
* @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('add_053', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('add_053 0003 ' + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
console.info('add_053 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('add_053 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('add_053 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('add_053 0011 ' + offset);
}
if (ret) {
console.info('add_053 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('add_053 0014' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('add_053 updateData failed ' + error);
}
})
/**
* @tc.number : add_053-1
* @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('add_053-1', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('add_053-1 0001 ' + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('add_053-1 0002 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await new Promise(res => {
incSouce.updateData(oneStep, isFinished, 0, oneStep.length, (err, ret) => {
res(ret);
})
})
if (!ret) {
console.info('add_053-1 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('add_053-1 0003 ' + offset);
}
if (ret) {
console.info('add_053-1 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('add_053-1 0004' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('add_053-1 updateData failed ' + error);
}
})
})
}
\ No newline at end of file
......@@ -607,4 +607,14 @@ let testJpg = new Uint8Array([255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1
2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160,
2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 15, 255, 217])
export {testPng, testJpg}
\ No newline at end of file
let tcBuf020 = new Uint8Array([0,0,0,4,0,0,0,8,1,0,0,12,1,1,1,16,1,1,1,20,2,2,2,24,3,3,3,28,4,4,4,32,5,5,5,36,6,6,6,40,7,7,7,44,9,9,8,48,10,10,10,52,12,12,12,56,14,14,13,60,16,16,15,64,18,18,17,68,20,20,19,72,22,22,22,76,25,24,24,80,27,27,27,84,30,30,29,88,33,32,32,92,36,35,35,96])
let tcBuf020_1 = new Uint8Array([0,0,0,4,0,0,0,8,1,0,0,12,1,1,1,16,1,1,1,20,2,2,2,24,3,3,3,28,4,4,4,32,5,5,5,36,6,6,6,40,7,7,7,44,9,9,8,48,10,10,10,52,12,12,12,56,14,14,13,60,16,16,15,64,18,18,17,68,20,20,19,72,22,22,22,76,25,24,24,80,27,27,27,84,30,30,29,88,33,32,32,92,36,35,35,96])
let tcBuf021 = new Uint8Array([0,0,0,4,0,0,0,8])
let tcBuf021_1 = new Uint8Array([0,0,0,4,0,0,0,8])
let tcBuf022 = new Uint8Array([0,0,0,4,0,0,0,8])
export { testPng, testJpg ,tcBuf020, tcBuf020_1, tcBuf021, tcBuf021_1, tcBuf022}
\ No newline at end of file
......@@ -15,6 +15,14 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
]
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
*/
import Image_test from './colorspace.test.js'
import imageColorSpace from './colorspace.test.js'
export default function testsuite() {
Image_test()
imageColorSpace()
}
......@@ -17,8 +17,8 @@ import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { iccbuf } from './testImg2'
export default function Image_test() {
describe('Image_test', function () {
export default function imageColorSpace() {
describe('imageColorSpace', function () {
beforeAll(async function () {
console.info('beforeAll case');
})
......
......@@ -19,29 +19,29 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files/*"
],
"teardown-command":[
]
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"./resource/image/test.tiff ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files",
"./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files"
"./resource/image/test.bmp ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files",
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files",
"./resource/image/test.tiff ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files",
"./resource/image/test.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files",
"./resource/image/moving_test.gif ->/data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.bmp",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.png",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.tiff",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/test.jpg",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.DecodeOptions/files/moving_test.gif"
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import Image_test from './image.test.js'
import imageDecodeOptions from './image.test.js'
export default function testsuite() {
Image_test()
imageDecodeOptions()
}
......@@ -17,8 +17,11 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files/*"
],
"teardown-command":[
]
},
{
......@@ -26,20 +29,17 @@
"pre-push": [
],
"push": [
"./resource/image/test_exif.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files",
"./resource/image/test_exif1.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files"
"./resource/image/test_exif.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files",
"./resource/image/test_exif1.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.Exif/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files/test_exif.jpg",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.Exif/files/test_exif1.jpg"
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command":[
]
"teardown-command": []
}
]
......
......@@ -14,4 +14,3 @@
*/
require('./image.test.js')
require('./addImage.test.js')
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { testPng } from '../../../../../image/src/main/js/test/testImg'
describe('AddImage', function () {
beforeAll(async function () {
console.info('beforeAll case');
})
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(async function () {
console.info('afterEach case');
})
afterAll(async function () {
console.info('afterAll case');
})
function createPixMapPromise(done, testNum, opts) {
const Color = new ArrayBuffer(96);
image.createPixelMap(Color, opts)
.then(pixelmap => {
expect(pixelmap != undefined).assertTrue();
console.info(`${testNum} success`);
done();
})
.catch(error => {
console.log(`${testNum} error: ` + error);
expect(false).assertTrue();
done();
})
}
function createPixMapCb(done, testNum, opts) {
const Color = new ArrayBuffer(96);
image.createPixelMap(Color, opts, (err, pixelmap) => {
expect(pixelmap != undefined).assertTrue();
console.info(`${testNum} success`);
done();
})
}
/**
* @tc.number : addImage_001
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 0)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_001', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 0 }
createPixMapPromise(done, 'add_01_001', opts);
})
/**
* @tc.number : add_01_002
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 1)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_002', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 1 }
createPixMapPromise(done, 'add_01_002', opts);
})
/**
* @tc.number : add_01_003
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 2)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_003', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 2 }
createPixMapPromise(done, 'add_01_003', opts);
})
/**
* @tc.number : add_01_004
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 3)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_01_004', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 3 }
createPixMapPromise(done, 'add_01_004', opts);
})
/**
* @tc.number : add_02_001
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 0)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_001', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 0 }
createPixMapCb(done, 'add_02_001', opts);
})
/**
* @tc.number : add_02_002
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 0, alphaType: 1)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_002', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 0, alphaType: 1 }
createPixMapCb(done, 'add_02_002', opts);
})
/**
* @tc.number : add_02_003
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 2)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_003', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 2 }
createPixMapCb(done, 'add_02_003', opts);
})
/**
* @tc.number : add_02_004
* @tc.name : create pixelmap-callback (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 3)
* @tc.desc : 1.create InitializationOptions object
* 2.set editable,pixeFormat,size
* 3.using color and opts create newPixelMap
* 4.return newpixelmap not empty
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 0
*/
it('add_02_004', 0, async function (done) {
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 }, scaleMode: 1, alphaType: 3 }
createPixMapCb(done, 'add_02_004', opts);
})
/**
* @tc.number : add_053
* @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('add_053', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('add_053 0003 ' + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
console.info('add_053 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('add_053 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('add_053 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('add_053 0011 ' + offset);
}
if (ret) {
console.info('add_053 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('add_053 0014' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('add_053 updateData failed ' + error);
}
})
/**
* @tc.number : add_053-1
* @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource
* 2.update data
* 3.create pixelmap
* @tc.size : MEDIUM
* @tc.type : Functional
* @tc.level : Level 1
*/
it('add_053-1', 0, async function (done) {
try {
let testimagebuffer = testPng;
console.info('add_053-1 0001 ' + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
const incSouce = image.createIncrementalSource(new ArrayBuffer(1));
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('add_053-1 0002 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await new Promise(res => {
incSouce.updateData(oneStep, isFinished, 0, oneStep.length, (err, ret) => {
res(ret);
})
})
if (!ret) {
console.info('add_053-1 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('add_053-1 0003 ' + offset);
}
if (ret) {
console.info('add_053-1 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('add_053-1 0004' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('add_053-1 updateData failed ' + error);
}
})
})
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
let tc_020buf = new Uint8Array([0,0,0,4,0,0,0,8,1,0,0,12,1,1,1,16,1,1,1,20,2,2,2,24,3,3,3,28,4,4,4,32,5,5,5,36,6,6,6,40,7,7,7,44,9,9,8,48,10,10,10,52,12,12,12,56,14,14,13,60,16,16,15,64,18,18,17,68,20,20,19,72,22,22,22,76,25,24,24,80,27,27,27,84,30,30,29,88,33,32,32,92,36,35,35,96])
let tc_020_1buf = new Uint8Array([0,0,0,4,0,0,0,8,1,0,0,12,1,1,1,16,1,1,1,20,2,2,2,24,3,3,3,28,4,4,4,32,5,5,5,36,6,6,6,40,7,7,7,44,9,9,8,48,10,10,10,52,12,12,12,56,14,14,13,60,16,16,15,64,18,18,17,68,20,20,19,72,22,22,22,76,25,24,24,80,27,27,27,84,30,30,29,88,33,32,32,92,36,35,35,96])
let tc_021buf = new Uint8Array([0,0,0,4,0,0,0,8])
let tc_021_1buf = new Uint8Array([0,0,0,4,0,0,0,8])
let tc_022buf = new Uint8Array([0,0,0,4,0,0,0,8])
export {tc_020buf, tc_020_1buf, tc_021buf, tc_021_1buf, tc_022buf}
\ No newline at end of file
......@@ -18,15 +18,18 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files/*"
],
"teardown-command":[
]
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test_exif.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files"
"./resource/image/test_exif.jpg ->/data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files"
]
},
{
......@@ -34,7 +37,7 @@
"run-command": [
"hilog -Q pidoff",
"hilog -b D",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/files/test_exif.jpg"
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/haps/entry/files/test_exif.jpg"
],
"teardown-command": [
"rm -rf /data/app/el2/100/base/ohos.acts.multimedia.image.ModifyProperty/*"
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Image from './modify.test.js'
import imageModifyProperty from './modify.test.js'
export default function testsuite() {
Image()
imageModifyProperty()
}
......@@ -17,23 +17,41 @@ import image from '@ohos.multimedia.image'
import fileio from '@ohos.fileio'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import {modifyBuf} from './modifyBuffer'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
export default function Image() {
describe('Image', function () {
var pathExifJpg = '/data/storage/el2/base/files/test_exif.jpg';
import featureAbility from '@ohos.ability.featureAbility'
export default function imageModifyProperty() {
describe('imageModifyProperty', function () {
let filePath;
let fdNumber;
async function getFd(fileName) {
let context = await featureAbility.getContext();
await context.getFilesDir().then((data) => {
filePath = data + '/' + fileName;
console.info('image case filePath is ' + filePath);
})
await fileio.open(filePath, 0o2 | 0o100, 0o777).then((data) => {
fdNumber = data;
console.info("image case open fd success " + fdNumber);
}, (err) => {
console.info("image cese open fd fail" + err)
}).catch((err) => {
console.info("image case open fd err " + err);
})
}
beforeAll(async function () {
await applyPermission();
console.info('beforeAll case');
})
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(function () {
afterEach(async function () {
await fileio.close(fdNumber).then(function(){
console.info("close file succeed");
}).catch(function(err){
console.info("close file failed with error:"+ err);
});
console.info('afterEach case');
})
......@@ -41,34 +59,6 @@ describe('Image', function () {
console.info('afterAll case');
})
async function applyPermission(){
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.image.ModifyProperty',0,100);
let atManager = abilityAccessCtrl.createAtManager();
if(atManager != null){
let tokenID = appInfo.accessTokenId;
console.info('[permission]case accessTokenId is' + tokenID);
let permissionName1 = 'ohos.permission.MEDIA_LOCATION';
let permissionName2 = 'ohos.permission.READ_MEDIA';
let permissionName3 = 'ohos.permission.WRITE_MEDIA';
await atManager.grantUserGrantedPermission(tokenID,permissionName1).then((result)=>{
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err)=>{
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID,permissionName2).then((result)=>{
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err)=>{
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
await atManager.grantUserGrantedPermission(tokenID,permissionName3).then((result)=>{
console.info('[permission]case grantUserGrantedPermission success:' + result);
}).catch((err)=>{
console.info('[permission]case grantUserGrantedPermission failed:' + err);
});
}else{
console.info('[permission]case apply permission failed,createAtManager failed');
}
}
async function modifyPromise(done, testNum, type, key, value, checkProps){
let imageSourceApi;
......@@ -76,8 +66,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -108,8 +98,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -143,8 +133,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -179,8 +169,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -202,8 +192,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
}else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
if (imageSourceApi == undefined) {
console.info(`${testNum} create image source failed`);
......@@ -226,8 +216,8 @@ describe('Image', function () {
const data = modifyBuf.buffer;
imageSourceApi = image.createImageSource(data);
} else {
let fdExifJpg = fileio.openSync(pathExifJpg, 0o2 | 0o100, 0o777);
imageSourceApi = image.createImageSource(fdExifJpg);
await getFd('test_exif.jpg');
imageSourceApi = image.createImageSource(fdNumber);
}
} catch (error) {
expect(false).assertTrue();
......
......@@ -10,23 +10,34 @@
},
"kits": [
{
"type": "PushKit",
"pre-push": [],
"push": []
"test-file-name": [
"ActsImagePackingJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff"
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image.Packing/haps/entry/files/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image.Packing/haps/entry/files/*"
],
"teardown-command": []
},
{
"test-file-name": [
"ActsImagePackingJsTest.hap"
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/image/test.png ->/data/app/el2/100/base/ohos.acts.multimedia.image.Packing/haps/entry/files"
]
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"type": "AppInstallKit",
"cleanup-apps": true
"teardown-command": []
}
]
}
\ No newline at end of file
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import Image_test from './packing.test.js'
import imagePacking from './packing.test.js'
export default function testsuite() {
Image_test()
imagePacking()
}
......@@ -15,6 +15,14 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D"
],
"teardown-command": []
}
]
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
*/
import Image_test from './framework.test.js'
import imagePixelMapFramework from './framework.test.js'
export default function testsuite() {
Image_test()
imagePixelMapFramework()
}
......@@ -17,8 +17,8 @@ import image from '@ohos.multimedia.image'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { base64Image, scale2x1, translate3x1, rotate90, flipH, testBmp, testGif, crop3x3, scale1x4, setAlpha8, translate1x3 } from './testImg2'
import { testPng, testJpg} from '../../../../../image/src/main/js/test/testImg'
export default function Image_test() {
describe('Image_test', function () {
export default function imagePixelMapFramework() {
describe('imagePixelMapFramework', function () {
beforeAll(async function () {
console.info('beforeAll case');
})
......
......@@ -10,31 +10,19 @@
},
"kits": [
{
"type": "ShellKit",
"run-command": [],
"teardown-command": []
},
{
"type": "PushKit",
"pre-push": [],
"push": []
"test-file-name": [
"ActsImageReceiverJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"hilog -b D",
"killall com.ohos.medialibrary.MediaScannerAbilityA",
"aa start -a MediaScannerAbility -b com.ohos.medialibrary.MediaScannerAbilityA"
"hilog -b D"
],
"teardown-command": []
},
{
"test-file-name": [
"ActsImageReceiverJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册