提交 6acd45cb 编写于 作者: L lwx1121892

<xts整改>

Signed-off-by: Nlwx1121892 <liuxueqi3@huawei.com>
上级 0d93d9a9
...@@ -60,6 +60,101 @@ export default function addImage() { ...@@ -60,6 +60,101 @@ export default function addImage() {
}) })
} }
async function createIncrementalSourceCb(done, testNum, type, opts) {
let testimagebuffer = testPng;
let incSouce;
console.info(`${testNum} 0001 ` + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
if (type == 'sourceOpts') {
incSouce = image.createIncrementalSource(new ArrayBuffer(1), opts);
} else {
incSouce = image.createIncrementalSource(new ArrayBuffer(1));
}
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info(`${testNum} 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(`${testNum} updateData failed`);
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info(`${testNum} 0003 ` + offset);
}
if (ret) {
console.info(`${testNum} updateData success `);
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info(`${testNum} 0004` + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
}
async function createIncrementalSourcePromise(done, testNum, type, opts) {
let testimagebuffer = testPng;
let incSouce;
console.info(`${testNum} 0001 ` + testimagebuffer.length);
let bufferSize = 5000;
let offset = 0;
if (type == 'sourceOpts') {
console.info(`${testNum} have sourceopts`)
incSouce = image.createIncrementalSource(new ArrayBuffer(1), opts);
} else {
console.info(`${testNum} no sourceopts`)
incSouce = image.createIncrementalSource(new ArrayBuffer(1));
}
let ret;
let isFinished = false;
while (offset < testimagebuffer.length) {
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info(`${testNum} 0002 ` + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info(`${testNum} updateData failed`);
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info(`${testNum} 0003 ` + offset);
}
if (ret) {
console.info(`${testNum} updateData success `);
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info(`${testNum} 0004` + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
}
/** /**
* @tc.number : SUB_GRAPHIC_IMAGE_CREATEPIXELMAP_PROMISE_0100 * @tc.number : SUB_GRAPHIC_IMAGE_CREATEPIXELMAP_PROMISE_0100
* @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 0) * @tc.name : create pixelmap-promise (editable: true, pixelFormat: RGBA_8888, size: { height: 4, width: 6 }, bytes = buffer,scaleMode: 1, alphaType: 0)
...@@ -199,52 +294,11 @@ export default function addImage() { ...@@ -199,52 +294,11 @@ export default function addImage() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100', 0, async function (done) { it('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100', 0, async function (done) {
try { createIncrementalSourcePromise(done, 'SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100', 'noSourceOpts')
let testimagebuffer = testPng;
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100 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('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100 0006 ' + testimagebuffer.length);
var oneStep = testimagebuffer.slice(offset, offset + bufferSize);
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100 0007 ' + oneStep.length);
if (oneStep.length < bufferSize) {
isFinished = true;
}
ret = await incSouce.updateData(oneStep, isFinished, 0, oneStep.length);
if (!ret) {
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100 updateData failed');
expect(ret).assertTrue();
break;
}
offset = offset + oneStep.length;
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100 0011 ' + offset);
}
if (ret) {
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100 updateData success ');
let decodingOptions = {
sampleSize: 1
};
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => {
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100 0014' + pixelmap);
expect(pixelmap != undefined).assertTrue();
done();
})
} else {
expect(false).assertTrue();
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0100 updateData failed ' + error);
}
}) })
/** /**
* @tc.number : SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200 * @tc.number : SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_CALLBACK_0100
* @tc.name : createIncrementalSource-updateData-png-promise * @tc.name : createIncrementalSource-updateData-png-promise
* @tc.desc : 1.create imagesource * @tc.desc : 1.create imagesource
* 2.update data * 2.update data
...@@ -253,52 +307,46 @@ export default function addImage() { ...@@ -253,52 +307,46 @@ export default function addImage() {
* @tc.type : Functional * @tc.type : Functional
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200', 0, async function (done) { it('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_CALLBACK_0100', 0, async function (done) {
try { createIncrementalSourceCb(done, 'SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_CALLBACK_0100', 'noSourceOpts')
let testimagebuffer = testPng; })
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200 0001 ' + testimagebuffer.length);
let bufferSize = 5000; /**
let offset = 0; * @tc.number : SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0300
const incSouce = image.createIncrementalSource(new ArrayBuffer(1)); * @tc.name : createIncrementalSource-updateData-png-promise
let ret; * @tc.desc : 1.create imagesource
let isFinished = false; * 2.update data
while (offset < testimagebuffer.length) { * 3.create pixelmap
var oneStep = testimagebuffer.slice(offset, offset + bufferSize); * @tc.size : MEDIUM
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200 0002 ' + oneStep.length); * @tc.type : Functional
if (oneStep.length < bufferSize) { * @tc.level : Level 1
isFinished = true; */
} it('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0300', 0, async function (done) {
ret = await new Promise(res => { let opts = {
incSouce.updateData(oneStep, isFinished, 0, oneStep.length, (err, ret) => { sourceDensity: 240,
res(ret); pixelFormat: 3,
}) size: { height: 4, width: 6 }
}) };
if (!ret) { createIncrementalSourcePromise(done, 'SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0300', 'sourceOpts', opts)
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200 updateData failed'); })
expect(ret).assertTrue();
break; /**
} * @tc.number : SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_CALLBACK_0200
offset = offset + oneStep.length; * @tc.name : createIncrementalSource-updateData-png-callback
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200 0003 ' + offset); * @tc.desc : 1.create imagesource
} * 2.update data
if (ret) { * 3.create pixelmap
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200 updateData success '); * @tc.size : MEDIUM
let decodingOptions = { * @tc.type : Functional
sampleSize: 1 * @tc.level : Level 1
}; */
incSouce.createPixelMap(decodingOptions, (err, pixelmap) => { it('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_CALLBACK_0200', 0, async function (done) {
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200 0004' + pixelmap); let opts = {
expect(pixelmap != undefined).assertTrue(); sourceDensity: 240,
done(); pixelFormat: 3,
}) size: { height: 4, width: 6 }
} else { };
expect(false).assertTrue(); createIncrementalSourceCb(done, 'SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_CALLBACK_0200', 'sourceOpts', opts)
done();
}
} catch (error) {
expect(false).assertTrue();
console.info('SUB_GRAPHIC_IMAGE_CREATEINCREMENTALSOURCE_UPDATEDATA_PNG_PROMISE_0200 updateData failed ' + error);
}
}) })
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册