diff --git a/multimedia/photoAccess/common.ts b/multimedia/photoAccess/common.ts index 5bbb9e496ef459c417515c9e6342ab5dfc0445c1..4ca722e543a97c60328b536696b47936aaee8871 100644 --- a/multimedia/photoAccess/common.ts +++ b/multimedia/photoAccess/common.ts @@ -80,6 +80,7 @@ export function photoFetchOption(testNum, key, value) : photoAccessHelper.FetchO photoKeys.POSITION, photoKeys.DATE_TRASHED, photoKeys.HIDDEN, + photoKeys.CAMERA_SHOT_KEY, ], predicates: predicates }; @@ -161,7 +162,7 @@ export async function createUserAlbum(testNum, albumName) : Promise { resolve(album); }); diff --git a/multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets b/multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets index 238d1e847ecb506861a4f2da85e284253478c640..8e07e6f5f8ece1396c6628f5ebd6d8f9cb189913 100644 --- a/multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets +++ b/multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets @@ -32,7 +32,7 @@ export default function unRegisterChangeTest () { /** * @tc.number : SUB_PHOTOACCESS_UNREGISTERCHANGE_0100 * @tc.name : unRegisterChange_001 - * @tc.desc : unRegister listening motify file displayName + * @tc.desc : unRegister listening motify file title * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 diff --git a/multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/createAsset.ets b/multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/createAsset.ets index db1e595a547ec26ceb9a9a1f4188ab2b7702b8b7..2d71d4709d3ae9eec14b055301778c4152677316 100644 --- a/multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/createAsset.ets +++ b/multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/createAsset.ets @@ -17,6 +17,9 @@ import photoAccessHelper from '@ohos.file.photoAccessHelper' import { describe, beforeAll, it, expect } from 'deccjsunit/index' import { + photoKeys, + photoFetchOption, + getFileAsset, getPermission } from '../../../../../../common' @@ -30,7 +33,7 @@ export default function createAssetTest () { async function createAssetCallback1 (done, testNum, displayName) { try { - helper.createAsset(displayName, (err, createAsset) => { + helper.createAsset(displayName, (err, createAsset) => { try { if (err !== undefined) { console.info(`${testNum} createAsset failed; err: ${err}`); @@ -44,21 +47,49 @@ export default function createAssetTest () { done(); }) } catch (error) { - console.info(`${testNum} failed; error: ${error}`); - expect(false).assertTrue(); - done(); + console.info(`${testNum} failed; error: ${error}`); + expect(false).assertTrue(); + done(); } } async function createAssetCallback2 (done, testNum, displayName, createOption) { try { - helper.createAsset(displayName, createOption, (err, createAsset) => { + helper.createAsset(displayName, createOption, (err, createAsset) => { + try { + if (err !== undefined) { + console.info(`${testNum} createAsset failed; err: ${err}`); + expect(false).assertTrue(); + } else { + expect(createAsset.displayName).assertEqual(displayName); + } + } catch (error) { + console.info(`${testNum} createAsset failed; error: ${error}`); + } + done(); + }) + } catch (error) { + console.info(`${testNum} failed; error: ${error}`); + expect(false).assertTrue(); + done(); + } + } + + async function createAssetCallback3 (done, testNum, displayName, createOption, fetchOps) { + let asset: photoAccessHelper.PhotoAsset; + try { + helper.createAsset(displayName, createOption, async(err, createAsset) => { try { if (err !== undefined) { console.info(`${testNum} createAsset failed; err: ${err}`); expect(false).assertTrue(); } else { + let fd = await createAsset.open("rw"); + await createAsset.close(fd); expect(createAsset.displayName).assertEqual(displayName); + asset = await getFileAsset(testNum, fetchOps); + console.info(`${testNum} createAsset displayName: ${asset.displayName}`); + expect(asset.displayName).assertEqual(displayName); } } catch (error) { console.info(`${testNum} createAsset failed; error: ${error}`); @@ -66,15 +97,15 @@ export default function createAssetTest () { done(); }) } catch (error) { - console.info(`${testNum} failed; error: ${error}`); - expect(false).assertTrue(); - done(); + console.info(`${testNum} failed; error: ${error}`); + expect(false).assertTrue(); + done(); } } async function createAssetAbnormalCallback1 (done, testNum, displayName) { try { - helper.createAsset(displayName, (err, createAsset) => { + helper.createAsset(displayName, (err, createAsset) => { if (err !== undefined) { console.info(`${testNum} createAsset failed; err: ${err}`); expect(true).assertTrue(); @@ -84,27 +115,32 @@ export default function createAssetTest () { done(); }) } catch (error) { - console.info(`${testNum} failed; error: ${error}`); - expect(true).assertTrue(); - done(); + console.info(`${testNum} failed; error: ${error}`); + expect(true).assertTrue(); + done(); } } async function createAssetAbnormalCallback2 (done, testNum, displayName, createOption) { try { - helper.createAsset(displayName, createOption, (err, createAsset) => { - if (err !== undefined) { - console.info(`${testNum} createAsset failed; err: ${err}`); - expect(true).assertTrue(); - } else { - expect(false).assertTrue(); + helper.createAsset(displayName, createOption, (err, createAsset) => { + try { + if (err !== undefined) { + console.info(`${testNum} createAsset failed; err: ${err}`); + expect(true).assertTrue(); + } else { + console.info(`${testNum} createAsset success`); + expect(false).assertTrue(); + } + } catch(error) { + console.info(`${testNum} error: ${error}`); } done(); }) } catch (error) { - console.info(`${testNum} failed; error: ${error}`); - expect(true).assertTrue(); - done(); + console.info(`${testNum} failed; error: ${error}`); + expect(true).assertTrue(); + done(); } } @@ -115,9 +151,9 @@ export default function createAssetTest () { expect(createAsset.displayName).assertEqual(displayName); done(); } catch (error) { - console.info(`${testNum} failed; error: ${error}`); - expect(false).assertTrue(); - done(); + console.info(`${testNum} failed; error: ${error}`); + expect(false).assertTrue(); + done(); } } @@ -128,33 +164,53 @@ export default function createAssetTest () { expect(createAsset.displayName).assertEqual(displayName); done(); } catch (error) { - console.info(`${testNum} failed; error: ${error}`); - expect(false).assertTrue(); - done(); + console.info(`${testNum} failed; error: ${error}`); + expect(false).assertTrue(); + done(); + } + } + + async function createAssetPromise3 (done, testNum, displayName, createOption, fetchOps) { + try { + let createAsset : photoAccessHelper.PhotoAsset; + createAsset = await helper.createAsset(displayName, createOption); + expect(createAsset.displayName).assertEqual(displayName); + let fd = await createAsset.open("rw"); + await createAsset.close(fd); + expect(createAsset.displayName).assertEqual(displayName); + let asset: photoAccessHelper.PhotoAsset; + asset = await getFileAsset(testNum, fetchOps); + console.info(`${testNum} createAsset displayName: ${asset.displayName}`); + expect(asset.displayName).assertEqual(displayName); + done(); + } catch (error) { + console.info(`${testNum} failed; error: ${error}`); + expect(false).assertTrue(); + done(); } } async function createAssetAbnormalPromise1 (done, testNum, displayName) { try { await helper.createAsset(displayName); - expect(false).assertTrue(); + expect(false).assertTrue(); done() } catch (error) { - console.info(`${testNum} failed; error: ${error}`); - expect(true).assertTrue(); - done(); + console.info(`${testNum} failed; error: ${error}`); + expect(true).assertTrue(); + done(); } } async function createAssetAbnormalPromise2 (done, testNum, displayName, createOption) { try { await helper.createAsset(displayName, createOption); - expect(false).assertTrue(); + expect(false).assertTrue(); done() } catch (error) { - console.info(`${testNum} failed; error: ${error}`); - expect(true).assertTrue(); - done(); + console.info(`${testNum} failed; error: ${error}`); + expect(true).assertTrue(); + done(); } } @@ -163,15 +219,15 @@ export default function createAssetTest () { /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_0000 * @tc.name : createAsset_callback_000 - * @tc.desc : createAsset + * @tc.desc : createAsset by displayname * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ it('createAsset_callback_000', 0, async function (done) { - const testNum = 'createAsset_callback_000'; + const testNum = 'createAsset_callback_000'; const displayName = testNum + '.jpg'; - await createAssetCallback1(done, testNum, displayName); + await createAssetCallback1(done, testNum, displayName); }); /** @@ -183,12 +239,12 @@ export default function createAssetTest () { * @tc.level : Level 2 */ it('createAsset_callback_001', 2, async function (done) { - const testNum = 'createAsset_callback_001'; + const testNum = 'createAsset_callback_001'; const displayName = testNum + '.jpg'; const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.DEFAULT, }; - await createAssetCallback2(done, testNum, displayName, createOption); + await createAssetCallback2(done, testNum, displayName, createOption); }); /** @@ -200,126 +256,240 @@ export default function createAssetTest () { * @tc.level : Level 2 */ it('createAsset_callback_002', 2, async function (done) { - const testNum = 'createAsset_callback_002'; + const testNum = 'createAsset_callback_002'; const displayName = testNum + '.jpg'; const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, }; - await createAssetCallback2(done, testNum, displayName, createOption); + await createAssetCallback2(done, testNum, displayName, createOption); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_0400 * @tc.name : createAsset_callback_004 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname is undefined and no createoption * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_callback_004', 2, async function (done) { - const testNum = 'createAsset_callback_004'; - await createAssetAbnormalCallback1(done, testNum, undefined); + const testNum = 'createAsset_callback_004'; + await createAssetAbnormalCallback1(done, testNum, undefined); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_0500 * @tc.name : createAsset_callback_005 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname is not has extension and no createoption * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_callback_005', 2, async function (done) { - const testNum = 'createAsset_callback_005'; + const testNum = 'createAsset_callback_005'; const displayName = testNum; - await createAssetAbnormalCallback1(done, testNum, displayName); + await createAssetAbnormalCallback1(done, testNum, displayName); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_0600 * @tc.name : createAsset_callback_006 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset with too long displayname * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_callback_006', 2, async function (done) { - const testNum = 'createAsset_callback_006'; + const testNum = 'createAsset_callback_006'; let value = ''; for (let i = 0; i < 253; i++) { value += 'a'; } const displayName = value + '.jpg'; - await createAssetAbnormalCallback1(done, testNum, displayName); + await createAssetAbnormalCallback1(done, testNum, displayName); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_0700 * @tc.name : createAsset_callback_007 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset with undefined displayname * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_callback_007', 2, async function (done) { - const testNum = 'createAsset_callback_007'; + const testNum = 'createAsset_callback_007'; const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.DEFAULT, }; - await createAssetAbnormalCallback2(done, testNum, undefined, createOption); + await createAssetAbnormalCallback2(done, testNum, undefined, createOption); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_0800 * @tc.name : createAsset_callback_008 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname is not has extension and subtype is DEFAULT * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_callback_008', 2, async function (done) { - const testNum = 'createAsset_callback_008'; + const testNum = 'createAsset_callback_008'; const displayName = testNum; - const createOption: photoAccessHelper.PhotoCreateOptions = { + const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.DEFAULT, }; - await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_0900 * @tc.name : createAsset_callback_009 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset with too long displayname and subtype is DEFAULT * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_callback_009', 2, async function (done) { - const testNum = 'createAsset_callback_009'; + const testNum = 'createAsset_callback_009'; let value = ''; for (let i = 0; i < 253; i++) { value += 'a'; } const displayName = value + '.jpg'; - const createOption: photoAccessHelper.PhotoCreateOptions = { + const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.DEFAULT, }; - await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_01000 + * @tc.name : createAsset_callback_0010 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and subtype is DEFAULT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_0010', 2, async function (done) { + const testNum = 'createAsset_callback_0010'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_callback_0010aaaaa'; + const fetchOps = photoFetchOption(testNum, photoKeys.CAMERA_SHOT_KEY, cameraShotKey); + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + cameraShotKey: cameraShotKey, + }; + await createAssetCallback3(done, testNum, displayName, createOption, fetchOps); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_01100 + * @tc.name : createAsset_callback_0011 + * @tc.desc : createAsset with cameraShotKey.length is greater than or equal to 30 and has no subtype + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_0011', 2, async function (done) { + const testNum = 'createAsset_callback_0011'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_callback_0011aaaaa'; + const fetchOps = photoFetchOption(testNum, photoKeys.CAMERA_SHOT_KEY, cameraShotKey); + const createOption: photoAccessHelper.PhotoCreateOptions = { + cameraShotKey: cameraShotKey, + }; + await createAssetCallback3(done, testNum, displayName, createOption, fetchOps); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_01200 + * @tc.name : createAsset_callback_0012 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and subtype is SCREENSHOT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_0012', 2, async function (done) { + const testNum = 'createAsset_callback_0012'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_callback_0012aaaaa'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_01300 + * @tc.name : createAsset_callback_0013 + * @tc.desc : createAsset with abnormal cameraShotKey.length is less than 30 and has no subtype + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_0013', 2, async function (done) { + const testNum = 'createAsset_callback_0013'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_callback_0013a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_01400 + * @tc.name : createAsset_callback_0014 + * @tc.desc : createAsset with abnormal cameraShotKey.length is less than 30 and subtype is DEFAULT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_0014', 2, async function (done) { + const testNum = 'createAsset_callback_0014'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_callback_0014a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_01500 + * @tc.name : createAsset_callback_0015 + * @tc.desc : createAsset with abnormal cameraShotKey.length is less than 30 and subtype is SCREENSHOT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_0015', 2, async function (done) { + const testNum = 'createAsset_callback_0015'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_callback_0015a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); }); //promise /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0000 * @tc.name : createAsset_promise_000 - * @tc.desc : createAsset + * @tc.desc : createAsset by displayname * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ it('createAsset_promise_000', 0, async function (done) { - const testNum = 'createAsset_promise_000'; + const testNum = 'createAsset_promise_000'; const displayName = testNum + '.jpg'; - await createAssetPromise1(done, testNum, displayName); + await createAssetPromise1(done, testNum, displayName); }); /** @@ -331,128 +501,242 @@ export default function createAssetTest () { * @tc.level : Level 2 */ it('createAsset_promise_001', 2, async function (done) { - const testNum = 'createAsset_promise_001'; + const testNum = 'createAsset_promise_001'; const displayName = testNum + '.jpg'; const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.DEFAULT, }; - await createAssetPromise2(done, testNum, displayName, createOption); + await createAssetPromise2(done, testNum, displayName, createOption); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0200 * @tc.name : createAsset_promise_002 - * @tc.desc : createAsset with createOption(PhotoSubtype.SCREENSHOT) + * @tc.desc : createAsset by displayname with createOption(PhotoSubtype.SCREENSHOT) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_promise_002', 2, async function (done) { - const testNum = 'createAsset_promise_002'; + const testNum = 'createAsset_promise_002'; const displayName = testNum + '.jpg'; const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, }; - await createAssetPromise2(done, testNum, displayName, createOption); + await createAssetPromise2(done, testNum, displayName, createOption); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0400 * @tc.name : createAsset_promise_004 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname has no extension * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_promise_004', 2, async function (done) { - const testNum = 'createAsset_promise_004'; - await createAssetAbnormalPromise1(done, testNum, undefined); + const testNum = 'createAsset_promise_004'; + await createAssetAbnormalPromise1(done, testNum, undefined); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0500 * @tc.name : createAsset_promise_005 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname has no extension * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_promise_005', 2, async function (done) { - const testNum = 'createAsset_promise_005'; + const testNum = 'createAsset_promise_005'; const displayName = testNum; - await createAssetAbnormalPromise1(done, testNum, displayName); + await createAssetAbnormalPromise1(done, testNum, displayName); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0600 * @tc.name : createAsset_promise_006 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname is too long * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_promise_006', 2, async function (done) { - const testNum = 'createAsset_promise_006'; + const testNum = 'createAsset_promise_006'; let value = ''; for (let i = 0; i < 253; i++) { value += 'a'; } const displayName = value + '.jpg'; - await createAssetAbnormalPromise1(done, testNum, displayName); + await createAssetAbnormalPromise1(done, testNum, displayName); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0700 * @tc.name : createAsset_promise_007 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset with undefined displayname * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_promise_007', 2, async function (done) { - const testNum = 'createAsset_promise_007'; + const testNum = 'createAsset_promise_007'; const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.DEFAULT, }; - await createAssetAbnormalPromise2(done, testNum, undefined, createOption); + await createAssetAbnormalPromise2(done, testNum, undefined, createOption); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0800 * @tc.name : createAsset_promise_008 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname has no extension * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_promise_008', 2, async function (done) { - const testNum = 'createAsset_promise_008'; + const testNum = 'createAsset_promise_008'; const displayName = testNum; - const createOption: photoAccessHelper.PhotoCreateOptions = { + const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.DEFAULT, }; - await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); }); /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0900 * @tc.name : createAsset_promise_009 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname is too long with subtype is DEFAULT * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ it('createAsset_promise_009', 2, async function (done) { - const testNum = 'createAsset_promise_009'; + const testNum = 'createAsset_promise_009'; let value = ''; for (let i = 0; i < 253; i++) { value += 'a'; } const displayName = value + '.jpg'; - const createOption: photoAccessHelper.PhotoCreateOptions = { + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + }; + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_01000 + * @tc.name : createAsset_promise_0010 + * @tc.desc : createAsset with normal cameraShotKey.length is is greater than or equal to 30 and has no subtype + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_0010', 2, async function (done) { + const testNum = 'createAsset_promise_0010'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_promise_0010aaaaaa'; + const fetchOps = photoFetchOption(testNum, photoKeys.CAMERA_SHOT_KEY, cameraShotKey); + const createOption: photoAccessHelper.PhotoCreateOptions = { + cameraShotKey: cameraShotKey, + }; + await createAssetPromise3(done, testNum, displayName, createOption, fetchOps); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_01100 + * @tc.name : createAsset_promise_0011 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and subtype is DEFAULT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_0011', 2, async function (done) { + const testNum = 'createAsset_promise_0011'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_promise_0011aaaaaa'; + const fetchOps = photoFetchOption(testNum, photoKeys.CAMERA_SHOT_KEY, cameraShotKey); + const createOption: photoAccessHelper.PhotoCreateOptions = { subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + cameraShotKey: cameraShotKey, + }; + await createAssetPromise3(done, testNum, displayName, createOption, fetchOps); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_01200 + * @tc.name : createAsset_promise_0012 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and subtype is SCREENSHOT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_0012', 2, async function (done) { + const testNum = 'createAsset_promise_0012'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_promise_0012aaaaaa'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, + cameraShotKey: cameraShotKey, }; - await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_01300 + * @tc.name : createAsset_promise_0013 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and subtype is SCREENSHOT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_0013', 2, async function (done) { + const testNum = 'createAsset_promise_0013'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_promise_0013a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_01400 + * @tc.name : createAsset_promise_0014 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and subtype is DEFAULT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_0014', 2, async function (done) { + const testNum = 'createAsset_promise_0014'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_promise_0014a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_01500 + * @tc.name : createAsset_promise_0015 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and has no subtype + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_0015', 2, async function (done) { + const testNum = 'createAsset_promise_0015'; + const displayName = testNum + '.jpg'; + const cameraShotKey = 'createAsset_promise_0015a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); }); //video @@ -460,7 +744,7 @@ export default function createAssetTest () { /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_1100 * @tc.name : createAsset_callback_011 - * @tc.desc : createAsset + * @tc.desc : createAsset by displayname * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 @@ -508,7 +792,7 @@ export default function createAssetTest () { /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_1500 * @tc.name : createAsset_callback_015 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset with displayname is too long * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 @@ -526,7 +810,7 @@ export default function createAssetTest () { /** * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_1600 * @tc.name : createAsset_callback_016 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset with displayname is too long and subtype is DEFAULT * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 @@ -544,11 +828,125 @@ export default function createAssetTest () { await createAssetAbnormalCallback2(done, testNum, displayName, createOption); }); + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_1700 + * @tc.name : createAsset_callback_017 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and subtype is DEFAULT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_017', 2, async function (done) { + const testNum = 'createAsset_callback_017'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_callback_0170aaaaa'; + const fetchOps = photoFetchOption(testNum, photoKeys.CAMERA_SHOT_KEY, cameraShotKey); + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + cameraShotKey: cameraShotKey, + }; + await createAssetCallback3(done, testNum, displayName, createOption, fetchOps); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_1800 + * @tc.name : createAsset_callback_0180 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and has no subtype + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_018', 2, async function (done) { + const testNum = 'createAsset_callback_018'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_callback_0180aaaaa'; + const fetchOps = photoFetchOption(testNum, photoKeys.CAMERA_SHOT_KEY, cameraShotKey); + const createOption: photoAccessHelper.PhotoCreateOptions = { + cameraShotKey: cameraShotKey, + }; + await createAssetCallback3(done, testNum, displayName, createOption, fetchOps); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_1900 + * @tc.name : createAsset_callback_019 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and subtype is SCREENSHOT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_019', 2, async function (done) { + const testNum = 'createAsset_callback_019'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_callback_0190aaaaa'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_2000 + * @tc.name : createAsset_callback_020 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and has no subtype + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_020', 2, async function (done) { + const testNum = 'createAsset_callback_020'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_callback_020a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_2100 + * @tc.name : createAsset_callback_021 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and subtype is DEFAULT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_021', 2, async function (done) { + const testNum = 'createAsset_callback_021'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_callback_021a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_2200 + * @tc.name : createAsset_callback_022 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and subtype is SCREENSHOT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_callback_022', 2, async function (done) { + const testNum = 'createAsset_callback_022'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_callback_022a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalCallback2(done, testNum, displayName, createOption); + }); + //promise /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_1100 * @tc.name : createAsset_promise_011 - * @tc.desc : createAsset + * @tc.desc : createAsset by displayname * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 @@ -596,7 +994,7 @@ export default function createAssetTest () { /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_1500 * @tc.name : createAsset_promise_015 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset with displayname is too long * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 @@ -614,7 +1012,7 @@ export default function createAssetTest () { /** * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_1600 * @tc.name : createAsset_promise_016 - * @tc.desc : createAsset abnormal param + * @tc.desc : createAsset displayname is too long with subtype is DEFAULT * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 @@ -631,5 +1029,119 @@ export default function createAssetTest () { }; await createAssetAbnormalPromise2(done, testNum, displayName, createOption); }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_1700 + * @tc.name : createAsset_promise_017 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and has no subtype + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_017', 2, async function (done) { + const testNum = 'createAsset_promise_017'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_promise_0170aaaaaa'; + const fetchOps = photoFetchOption(testNum, photoKeys.CAMERA_SHOT_KEY, cameraShotKey); + const createOption: photoAccessHelper.PhotoCreateOptions = { + cameraShotKey: cameraShotKey, + }; + await createAssetPromise3(done, testNum, displayName, createOption, fetchOps); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_1800 + * @tc.name : createAsset_promise_018 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and subtype is DEFAULT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_018', 2, async function (done) { + const testNum = 'createAsset_promise_018'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_promise_0180aaaaaa'; + const fetchOps = photoFetchOption(testNum, photoKeys.CAMERA_SHOT_KEY, cameraShotKey); + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + cameraShotKey: cameraShotKey, + }; + await createAssetPromise3(done, testNum, displayName, createOption, fetchOps); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_1900 + * @tc.name : createAsset_promise_019 + * @tc.desc : createAsset with normal cameraShotKey.length is greater than or equal to 30 and subtype is SCREENSHOT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_019', 2, async function (done) { + const testNum = 'createAsset_promise_019'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_promise_0190aaaaa'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_2000 + * @tc.name : createAsset_promise_020 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and subtype is SCREENSHOT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_020', 2, async function (done) { + const testNum = 'createAsset_promise_020'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_promise_0200a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.SCREENSHOT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_2100 + * @tc.name : createAsset_promise_021 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and subtype is DEFAULT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_021', 2, async function (done) { + const testNum = 'createAsset_promise_021'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_promise_0210a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + subtype: photoAccessHelper.PhotoSubtype.DEFAULT, + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + }); + + /** + * @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_2200 + * @tc.name : createAsset_promise_022 + * @tc.desc : createAsset with cameraShotKey.length is less than 30 and no subtype + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('createAsset_promise_022', 2, async function (done) { + const testNum = 'createAsset_promise_022'; + const displayName = testNum + '.mp4'; + const cameraShotKey = 'createAsset_promise_0220a'; + const createOption: photoAccessHelper.PhotoCreateOptions = { + cameraShotKey: cameraShotKey, + }; + await createAssetAbnormalPromise2(done, testNum, displayName, createOption); + }); }) }