未验证 提交 35d3c412 编写于 作者: O openharmony_ci 提交者: Gitee

!8694 非必传参数传入undefined场景用例覆盖

Merge pull request !8694 from yangbo/xts
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -476,5 +476,83 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { ...@@ -476,5 +476,83 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
let currentFetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE); let currentFetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE);
await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount); await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount);
}); });
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_04
* @tc.name : getFileAssets
* @tc.desc : getFileAssets by undefined option
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_04", 0, async function (done) {
const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_04";
let fetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE);
try {
const albumList = await media.getAlbums(fetchOp);
// check album length
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, 1);
if (!albumCountPass) return;
const album = albumList[0];
let fetchFileResult;
let fetchAllResult;
try {
fetchFileResult = await album.getFileAssets(undefined);
fetchAllResult = await album.getFileAssets(allFetchOp());
expect(fetchFileResult.getCount()).assertEqual(fetchAllResult.getCount());
} catch (error) {
console.info(`${testNum} getFileAssets fail, error: ${error}`);
expect(false).assertTrue();
}
fetchFileResult.close();
fetchAllResult.close();
done();
} catch (error) {
console.info(`${testNum}, error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_05
* @tc.name : getFileAssets
* @tc.desc : getFileAssets by null option
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_05", 0, async function (done) {
const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_05";
let fetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE);
try {
const albumList = await media.getAlbums(fetchOp);
// check album length
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, 1);
if (!albumCountPass) return;
const album = albumList[0];
let fetchFileResult;
let fetchAllResult;
try {
fetchFileResult = await album.getFileAssets(null);
fetchAllResult = await album.getFileAssets(allFetchOp());
expect(fetchFileResult.getCount()).assertEqual(fetchAllResult.getCount());
} catch (error) {
console.info(`${testNum} getFileAssets fail, error: ${error}`);
expect(false).assertTrue();
}
fetchFileResult.close();
fetchAllResult.close();
done();
} catch (error) {
console.info(`${testNum}, error: ${error}`);
expect(false).assertTrue();
done();
}
});
}); });
} }
...@@ -87,6 +87,9 @@ export default function getThumbnailPromise(abilityContext) { ...@@ -87,6 +87,9 @@ export default function getThumbnailPromise(abilityContext) {
size = { width: 256, height: 256 }; size = { width: 256, height: 256 };
pixelmap = await asset.getThumbnail(); pixelmap = await asset.getThumbnail();
} else { } else {
if (size === undefined || size === null) {
size = { width: 256, height: 256 };
}
pixelmap = await asset.getThumbnail(size); pixelmap = await asset.getThumbnail(size);
} }
let info = await pixelmap.getImageInfo(); let info = await pixelmap.getImageInfo();
...@@ -242,6 +245,36 @@ export default function getThumbnailPromise(abilityContext) { ...@@ -242,6 +245,36 @@ export default function getThumbnailPromise(abilityContext) {
await testGetThumbnail(done, testNum, dOp, size); await testGetThumbnail(done, testNum, dOp, size);
}); });
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_08
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by undefined size
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_08", 0, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_08";
let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE);
let size = undefined;
await testGetThumbnail(done, testNum, dOp, size);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_09
* @tc.name : getThumbnail
* @tc.desc : getThumbnail(image) by null size
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_09", 0, async function (done) {
let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_09";
let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE);
let size = null;
await testGetThumbnail(done, testNum, dOp, size);
});
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_03 * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_03
* @tc.name : getThumbnail * @tc.name : getThumbnail
...@@ -302,20 +335,6 @@ export default function getThumbnailPromise(abilityContext) { ...@@ -302,20 +335,6 @@ export default function getThumbnailPromise(abilityContext) {
await testGetThumbnailError(done, testNum, dOp, size); 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.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_001_08
* @tc.name : getThumbnail * @tc.name : getThumbnail
...@@ -498,20 +517,6 @@ export default function getThumbnailPromise(abilityContext) { ...@@ -498,20 +517,6 @@ export default function getThumbnailPromise(abilityContext) {
await testGetThumbnailError(done, testNum, dOp, size); 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.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_002_08
* @tc.name : getThumbnail * @tc.name : getThumbnail
...@@ -694,20 +699,6 @@ export default function getThumbnailPromise(abilityContext) { ...@@ -694,20 +699,6 @@ export default function getThumbnailPromise(abilityContext) {
await testGetThumbnailError(done, testNum, dOp, size); 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.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_ERROR_003_08
* @tc.name : getThumbnail * @tc.name : getThumbnail
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册