未验证 提交 a4e61b8b 编写于 作者: 范晓兵 提交者: Gitee

【mediaLibrary】【master】mediaLibrary_getThumbnail 补充异常场景用例

Signed-off-by: N范晓兵 <fanxiaobing2@huawei.com>
上级 12d9fbe2
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022-2023 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
......@@ -15,6 +15,7 @@
import mediaLibrary from "@ohos.multimedia.mediaLibrary";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import fileio from "@ohos.fileio";
import image from "@ohos.multimedia.image";
import {
......@@ -29,8 +30,12 @@ import {
} from "../../../../../../common";
export default function getThumbnailCallback(abilityContext) {
describe("getThumbnailCallback", function () {
console.info('MediaLibraryTest:getMediaLibrary IN');
image.createPixelMap(new ArrayBuffer(4096), { size: { height: 1, width: 2 } }).then((pixelmap) => {});
const media = mediaLibrary.getMediaLibrary(abilityContext);
console.info('MediaLibraryTest:getMediaLibrary OUT');
let fileKeyObj = mediaLibrary.FileKey;
beforeAll(async function () {
console.info("beforeAll case");
await getPermission(null, abilityContext);
......@@ -47,6 +52,32 @@ export default function getThumbnailCallback(abilityContext) {
console.info("afterAll case");
});
function fetchThumbnailOps(id){
return{
selections:fileKeyObj.ID + '= ? AND '+'lcd is not null'+' AND '+'thumbnail is not null',
selectionArgs:[id+''],
};
}
function fetchOpsNew(path,type){
return{
selections:fileKeyObj.RELATIVE_PATH + '= ? AND '+fileKeyObj.MEDIA_TYPE + '=?',
selectionArgs:[path,type.toString()],
order:fileKeyObj.DATE_ADDED,
};
}
function checkCount(done,testNum,count){
console.info('${testNum}::count:${count}');
if(count <= 0){
console.info('${testNum}::resources is empty');
expect(false).assertTrue();
done();
return false;
}
return true;
}
async function testGetThumbnail(done, testNum, dOp, size) {
try {
let fetchFileResult = await media.getFileAssets(dOp);
......@@ -114,6 +145,30 @@ export default function getThumbnailCallback(abilityContext) {
}
}
async function testGetThumbnailTypeError(done, testNum, dOp, size) {
try {
let fetchFileResult = await media.getFileAssets(dOp);
let count = fetchFileResult.getCount();
if (!checkCount(done,testNum,count)) return;
let asset = await fetchFileResult.getFirstObject();
asset.getThumbnail(size, async (err, pixelmap) => {
expect(false).assertTrue();
done();
});
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(true).assertTrue();
done();
}
}
async function copyFile(fd1, fd2){
let stat = await fileio.fstat(fd1);
let buf = new ArrayBuffer(stat.size);
await fileio.read(fd1,buf);
await fileio.write(fd2,buf);
}
// ------------------------------ image type start -----------------------
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01
......@@ -181,9 +236,9 @@ export default function getThumbnailCallback(abilityContext) {
* @tc.desc : getThumbnail(image) by { width: 0, height: 0 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05";
let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE);
let size = { width: 0, height: 0 };
......@@ -196,9 +251,9 @@ export default function getThumbnailCallback(abilityContext) {
* @tc.desc : getThumbnail(image) by { width: -128, height: -128 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06";
let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE);
let size = { width: -128, height: -128 };
......@@ -219,6 +274,96 @@ export default function getThumbnailCallback(abilityContext) {
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_03
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by 1
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_03", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_03";
let dOp = fetchOpsNew('Pictures/Thumbnail/', IMAGE_TYPE);
let size = 1;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_04
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by 'str'
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_04", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_04";
let dOp = fetchOpsNew('Pictures/Thumbnail/', IMAGE_TYPE);
let size = "str";
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_05
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_05";
let dOp = fetchOpsNew('Pictures/Thumbnail/', IMAGE_TYPE);
let size = true;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_06
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_06";
let dOp = fetchOpsNew('Pictures/Thumbnail/', IMAGE_TYPE);
let size = false;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_07
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by null
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_07", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_07";
let dOp = fetchOpsNew('Pictures/Thumbnail/', IMAGE_TYPE);
let size = null;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_08
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by {width: 99999, height: 99999}
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_08", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_001_08";
let dOp = fetchOpsNew('Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 99999, height: 99999 };
await testGetThumbnailError(done, testNum, dOp, size);
});
// ------------------------------image type end--------------------------
// ------------------------------video type start -----------------------
......@@ -288,9 +433,9 @@ export default function getThumbnailCallback(abilityContext) {
* @tc.desc : getThumbnail(video) by { width: 0, height: 0 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05";
let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE);
let size = { width: 0, height: 0 };
......@@ -303,9 +448,9 @@ export default function getThumbnailCallback(abilityContext) {
* @tc.desc : getThumbnail(video) by { width: -128, height: -128 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06";
let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE);
let size = { width: -128, height: -128 };
......@@ -326,6 +471,96 @@ export default function getThumbnailCallback(abilityContext) {
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_03
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by 1
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_03", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_03";
let dOp = fetchOpsNew('Videos/Thumbnail/', VIDEO_TYPE);
let size = 1;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_04
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by 'str'
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_04", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_04";
let dOp = fetchOpsNew('Videos/Thumbnail/', VIDEO_TYPE);
let size = 'str';
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_05
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_05";
let dOp = fetchOpsNew('Videos/Thumbnail/', VIDEO_TYPE);
let size = true;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_06
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_06";
let dOp = fetchOpsNew('Videos/Thumbnail/', VIDEO_TYPE);
let size = false;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_07
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by null
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_07", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_07";
let dOp = fetchOpsNew('Videos/Thumbnail/', VIDEO_TYPE);
let size = null;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_08
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by {width: 99999, height: 99999}
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_08", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_002_08";
let dOp = fetchOpsNew('Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 99999, height: 99999 };
await testGetThumbnailError(done, testNum, dOp, size);
});
// ------------------------------video type end--------------------------
// ------------------------------audio type start -----------------------
......@@ -395,9 +630,9 @@ export default function getThumbnailCallback(abilityContext) {
* @tc.desc : getThumbnail(audio) by { width: 0, height: 0 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05";
let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE);
let size = { width: 0, height: 0 };
......@@ -410,9 +645,9 @@ export default function getThumbnailCallback(abilityContext) {
* @tc.desc : getThumbnail(audio) by { width: -128, height: -128 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06";
let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE);
let size = { width: -128, height: -128 };
......@@ -433,6 +668,96 @@ export default function getThumbnailCallback(abilityContext) {
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_03
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by 1
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_03", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_03";
let dOp = fetchOpsNew('Audios/Thumbnail/', AUDIO_TYPE);
let size = 1;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_04
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by 'str'
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_04", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_04";
let dOp = fetchOpsNew('Audios/Thumbnail/', AUDIO_TYPE);
let size = 'str';
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_05
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_05";
let dOp = fetchOpsNew('Audios/Thumbnail/', AUDIO_TYPE);
let size = true;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_06
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_06";
let dOp = fetchOpsNew('Audios/Thumbnail/', AUDIO_TYPE);
let size = false;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_07
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by null
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_07", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_07";
let dOp = fetchOpsNew('Audios/Thumbnail/', AUDIO_TYPE);
let size = null;
await testGetThumbnailTypeError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_08
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by {width: 99999, height: 99999}
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_08", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_ERROR_CALLBACK_003_08";
let dOp = fetchOpsNew('Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 99999, height: 99999 };
await testGetThumbnailError(done, testNum, dOp, size);
});
// ------------------------------audio type end--------------------------
});
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022-2023 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
......@@ -15,6 +15,7 @@
import mediaLibrary from "@ohos.multimedia.mediaLibrary";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import fileio from '@ohos.fileio';
import image from "@ohos.multimedia.image";
import {
sleep,
......@@ -29,7 +30,11 @@ import {
export default function getThumbnailPromise(abilityContext) {
describe("getThumbnailPromise", function () {
image.createPixelMap(new ArrayBuffer(4096), { size: { height: 1, width: 2 } }).then((pixelmap) => {});
console.info('MediaLibraryTest : getMediaLibrary IN');
const media = mediaLibrary.getMediaLibrary(abilityContext);
console.info('MediaLibraryTest : getMediaLibrary OUT');
let fileKeyObj = mediaLibrary.FileKey;
beforeAll(async function () {
console.info("beforeAll case");
});
......@@ -44,6 +49,32 @@ export default function getThumbnailPromise(abilityContext) {
console.info("afterAll case");
});
function fetchThumbnailOps(id){
return{
selections:fileKeyObj.ID + '= ? AND '+'lcd is not null'+' AND '+'thumbnail is not null',
selectionArgs:[id+''],
};
}
function fetchOpsNew(path,type){
return{
selections:fileKeyObj.RELATIVE_PATH + '= ? AND '+fileKeyObj.MEDIA_TYPE + '=?',
selectionArgs:[path,type.toString()],
order:fileKeyObj.DATE_ADDED,
};
}
function checkCount(done,testNum,count){
console.info('${testNum}::count:${count}');
if(count <= 0){
console.info('${testNum}::resources is empty');
expect(false).assertTrue();
done();
return false;
}
return true;
}
async function testGetThumbnail(done, testNum, dOp, size) {
try {
let fetchFileResult = await media.getFileAssets(dOp);
......@@ -99,6 +130,13 @@ export default function getThumbnailPromise(abilityContext) {
}
}
async function copyFile(fd1, fd2){
let stat = await fileio.fstat(fd1);
let buf = new ArrayBuffer(stat.size);
await fileio.read(fd1,buf);
await fileio.write(fd2,buf);
}
// ------------------------------ image type start -----------------------
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01
......@@ -166,9 +204,9 @@ export default function getThumbnailPromise(abilityContext) {
* @tc.desc : getThumbnail(image) by { width: 1024, height: 1024 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05";
let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE);
let size = { width: 0, height: 0 };
......@@ -181,9 +219,9 @@ export default function getThumbnailPromise(abilityContext) {
* @tc.desc : getThumbnail(image) by { width: -128, height: -128 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06";
let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE);
let size = { width: -128, height: -128 };
......@@ -203,6 +241,95 @@ export default function getThumbnailPromise(abilityContext) {
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_03
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by 1
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_03", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_03";
let dOp = fetchOpsNew("Pictures/Thumbnail/", IMAGE_TYPE);
let size = 1;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_04
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by 'str'
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_04", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_04";
let dOp = fetchOpsNew("Pictures/Thumbnail/", IMAGE_TYPE);
let size = "str";
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_05
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_05";
let dOp = fetchOpsNew("Pictures/Thumbnail/", IMAGE_TYPE);
let size = true;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_06
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_06";
let dOp = fetchOpsNew("Pictures/Thumbnail/", IMAGE_TYPE);
let size = false;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_07
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by null
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_07", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_07";
let dOp = fetchOpsNew("Pictures/Thumbnail/", IMAGE_TYPE);
let size = null;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_08
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by { width: 99999, height: 99999 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_08", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_08";
let dOp = fetchOpsNew("Pictures/Thumbnail/", IMAGE_TYPE);
let size = { width: 99999, height: 99999 };
await testGetThumbnailError(done, testNum, dOp, size);
});
// ------------------------------image type end--------------------------
// ------------------------------video type start -----------------------
......@@ -272,9 +399,9 @@ export default function getThumbnailPromise(abilityContext) {
* @tc.desc : getThumbnail(video) by { width: 0, height: 0 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05";
let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE);
let size = { width: 0, height: 0 };
......@@ -287,9 +414,9 @@ export default function getThumbnailPromise(abilityContext) {
* @tc.desc : getThumbnail(video) by { width: -128, height: -128 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06";
let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE);
let size = { width: -128, height: -128 };
......@@ -310,6 +437,95 @@ export default function getThumbnailPromise(abilityContext) {
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_03
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by 1
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_03", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_03";
let dOp = fetchOpsNew("Videos/Thumbnail/", VIDEO_TYPE);
let size = 1;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_04
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by 'str'
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_04", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_04";
let dOp = fetchOpsNew("Videos/Thumbnail/", VIDEO_TYPE);
let size = "str";
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_05
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_05";
let dOp = fetchOpsNew("Videos/Thumbnail/", VIDEO_TYPE);
let size = true;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_06
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_06";
let dOp = fetchOpsNew("Videos/Thumbnail/", VIDEO_TYPE);
let size = false;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_07
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by null
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_07", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_07";
let dOp = fetchOpsNew("Videos/Thumbnail/", VIDEO_TYPE);
let size = null;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_08
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(video) by { width: 99999, height: 99999 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_08", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_08";
let dOp = fetchOpsNew("Videos/Thumbnail/", VIDEO_TYPE);
let size = { width: 99999, height: 99999 };
await testGetThumbnailError(done, testNum, dOp, size);
});
// ------------------------------video type end--------------------------
// ------------------------------audio type start -----------------------
......@@ -379,9 +595,9 @@ export default function getThumbnailPromise(abilityContext) {
* @tc.desc : getThumbnail(audio) by { width: 0, height: 0 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05";
let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE);
let size = { width: 0, height: 0 };
......@@ -394,9 +610,9 @@ export default function getThumbnailPromise(abilityContext) {
* @tc.desc : getThumbnail(audio) by { width: -128, height: -128 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06", 0, async function (done) {
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06";
let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE);
let size = { width: -128, height: -128 };
......@@ -417,6 +633,95 @@ export default function getThumbnailPromise(abilityContext) {
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_03
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by 1
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_03", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_03";
let dOp = fetchOpsNew("Audios/Thumbnail/", AUDIO_TYPE);
let size = 1;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_04
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by 'str'
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_04", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_04";
let dOp = fetchOpsNew("Audios/Thumbnail/", AUDIO_TYPE);
let size = "str";
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_05
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_05", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_05";
let dOp = fetchOpsNew("Audios/Thumbnail/", AUDIO_TYPE);
let size = true;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_06
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_06", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_06";
let dOp = fetchOpsNew("Audios/Thumbnail/", AUDIO_TYPE);
let size = false;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_07
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by null
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_07", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_07";
let dOp = fetchOpsNew("Audios/Thumbnail/", AUDIO_TYPE);
let size = null;
await testGetThumbnailError(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_08
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(audio) by { width: 99999, height: 99999 }
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_08", 3, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_08";
let dOp = fetchOpsNew("Audios/Thumbnail/", AUDIO_TYPE);
let size = { width: 99999, height: 99999 };
await testGetThumbnailError(done, testNum, dOp, size);
});
// ------------------------------audio type end--------------------------
});
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册