提交 29b3d07a 编写于 作者: Y yangbo

fix bug 2.0

Signed-off-by: Nyangbo <yangbo258@huawei.com>
上级 3b353832
......@@ -94,11 +94,7 @@ export async function getPermission(name = 'ohos.acts.multimedia.photoaccess') :
const permissions = [
'ohos.permission.MEDIA_LOCATION',
'ohos.permission.READ_IMAGEVIDEO',
'ohos.permission.READ_AUDIO',
'ohos.permission.READ_DOCUMENT',
'ohos.permission.WRITE_IMAGEVIDEO',
'ohos.permission.WRITE_AUDIO',
'ohos.permission.WRITE_DOCUMENT',
];
const atManager = abilityAccessCtrl.createAtManager();
......
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 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
......
......@@ -118,7 +118,6 @@
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyPro06.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyPro07.mp4",
"chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
"hilog -p off",
"hilog -Q pidoff",
"hilog -Q domainoff",
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 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
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -39,8 +40,6 @@ export default function checkAlbumAttrTest () {
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
await album.addAssets([asset]);
expect(album.count).assertEqual(1);
expect(album.coverUri).assertEqual(asset.uri);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -109,38 +109,6 @@ export default function addAssetsTest () {
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ADD_ASSETS_0400
* @tc.name : addAssets_callback_004
* @tc.desc : add empty array to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('addAssets_callback_004', 2, async function (done) {
const testNum = 'addAssets_callback_004';
try {
const album = await helper.createAlbum(testNum);
album.addAssets([], async (err) => {
try {
if (err) {
console.info(`${testNum} err: ${err}`);
} else {
expect(false).assertTrue();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ADD_ASSETS_0500
* @tc.name : addAssets_callback_005
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -125,7 +125,7 @@ export default function albumCommitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_COMMITMODIFY_0300
* @tc.name : album_commitModify_callback_003
* @tc.desc : album commitModify with containing characters
* @tc.desc : album commitModify containing invalid characters
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -134,7 +134,7 @@ export default function albumCommitModifyTest () {
const testNum = 'album_commitModify_callback_003';
try {
const album = await helper.createAlbum(testNum);
const TITLE_REGEX_CHECK = '\.\\/:*?"\'`<>|{}\[\]';
const TITLE_REGEX_CHECK = '\\/:*?"\'`<>|{}\[\]';
let count = 0;
for (let i = 0; i < TITLE_REGEX_CHECK.length; i++) {
let invalidName = testNum + TITLE_REGEX_CHECK[i];
......@@ -250,13 +250,14 @@ export default function albumCommitModifyTest () {
const testNum = 'album_commitModify_promise_003';
try {
const album = await helper.createAlbum(testNum);
const TITLE_REGEX_CHECK = '\.\\/:*?"\'`<>|{}\[\]';
const TITLE_REGEX_CHECK = '\\/:*?"\'`<>|{}\[\]';
let count = 0;
for (let i = 0; i < TITLE_REGEX_CHECK.length; i++) {
let invalidName = testNum + TITLE_REGEX_CHECK[i];
album.albumName = invalidName;
try {
await album.commitModify();
console.info(`${testNum} commitModify suc: ${invalidName}`);
} catch (error) {
console.info(`${testNum} error: ${error}`);
count++;
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -43,6 +43,9 @@ export default function removeAssetsTest () {
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'removeCb01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
await album.addAssets([asset]);
const fetchResult = await album.getAssets(fetchOps);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.close()
album.removeAssets([asset], async (err) => {
try {
if (err) {
......@@ -86,6 +89,9 @@ export default function removeAssetsTest () {
const asset2 = await getFileAsset(testNum, fetchOps2);
assetList.push(asset2);
await album.addAssets(assetList);
const fetchResult = await album.getAssets(fetchAllOption());
expect(fetchResult.getCount()).assertEqual(2);
fetchResult.close()
album.removeAssets(assetList, async (err) => {
try {
if (err) {
......@@ -109,32 +115,6 @@ export default function removeAssetsTest () {
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_REMOVE_ASSETS_0300
* @tc.name : removeAssets_callback_003
* @tc.desc : user album remove empty array
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_callback_003', 2, async function (done) {
const testNum = 'removeAssets_callback_003';
try {
const album = await helper.createAlbum(testNum);
album.removeAssets([], async (err) => {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_REMOVE_ASSETS_0400
* @tc.name : removeAssets_callback_004
......@@ -164,7 +144,7 @@ export default function removeAssetsTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_REMOVE_ASSETS_0500
* @tc.name : removeAssets_callback_005
* @tc.desc : add deleted image asset to user album
* @tc.desc : user album image asset twice
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -196,7 +176,7 @@ export default function removeAssetsTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0000
* @tc.name : removeAssets_promise_000
* @tc.desc : add image asset to user album
* @tc.desc : user album remove image asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......@@ -209,8 +189,11 @@ export default function removeAssetsTest () {
const asset = await getFileAsset(testNum, fetchOps);
await album.addAssets([asset]);
let fetchResult = await album.getAssets(fetchOps);
console.info(`${testNum} count: ${fetchResult.getCount()}`);
expect(fetchResult.getCount()).assertEqual(1);
await album.removeAssets([asset]);
const fetchResult = await album.getAssets(fetchOps);
fetchResult = await album.getAssets(fetchOps);
console.info(`${testNum} count: ${fetchResult.getCount()}`);
expect(fetchResult.getCount()).assertEqual(0);
fetchResult.close();
......@@ -225,7 +208,7 @@ export default function removeAssetsTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0200
* @tc.name : removeAssets_promise_002
* @tc.desc : add image&video asset to user album
* @tc.desc : user album remove image&video asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -243,9 +226,10 @@ export default function removeAssetsTest () {
assetList.push(asset2);
await album.addAssets(assetList);
let fetchResult = await album.getAssets(fetchAllOption());
expect(fetchResult.getCount()).assertEqual(2);
await album.removeAssets(assetList);
console.info(`${testNum} album.count: ${album.count}`);
const fetchResult = await album.getAssets(fetchAllOption());
fetchResult = await album.getAssets(fetchAllOption());
expect(fetchResult.getCount()).assertEqual(0);
fetchResult.close();
done();
......@@ -259,7 +243,7 @@ export default function removeAssetsTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0300
* @tc.name : removeAssets_promise_003
* @tc.desc : add empty array to user album
* @tc.desc : user album remove empty array
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -280,7 +264,7 @@ export default function removeAssetsTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0400
* @tc.name : removeAssets_promise_004
* @tc.desc : add undefined array to user album
* @tc.desc : user album remove undefined array
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -301,7 +285,7 @@ export default function removeAssetsTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0500
* @tc.name : removeAssets_promise_005
* @tc.desc : add deleted image asset to user album
* @tc.desc : remove image asset twice
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -31,7 +31,7 @@ export default function albumCloseTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ALBUM_CLOSE_0000
* @tc.name : album_close_000
* @tc.desc : close
* @tc.desc : close system album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......@@ -49,50 +49,58 @@ export default function albumCloseTest () {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.close();
let testCount = 0;
let count = 0;
try {
testCount++;
fetchResult.getCount();
} catch (error) {
console.info(`${testNum} getCount failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getFirstObject();
} catch (error) {
console.info(`${testNum} getFirstObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getNextObject();
} catch (error) {
console.info(`${testNum} getNextObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getLastObject();
} catch (error) {
console.info(`${testNum} getLastObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getObjectByPosition(0);
} catch (error) {
console.info(`${testNum} getObjectByPosition failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getAllObjects();
} catch (error) {
console.info(`${testNum} getAllObjects failed; error: ${error}`);
count++;
}
try {
testCount++;
fetchResult.isAfterLast();
} catch (error) {
console.info(`${testNum} isAfterLast failed; error: ${error}`);
count++;
}
expect(count).assertEqual(7);
expect(count).assertEqual(testCount);
passCount++;
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
......@@ -109,7 +117,7 @@ export default function albumCloseTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ALBUM_CLOSE_0100
* @tc.name : album_close_001
* @tc.desc : close
* @tc.desc : close user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......@@ -122,50 +130,58 @@ export default function albumCloseTest () {
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.close();
let testCount = 0;
let count = 0;
try {
testCount++;
fetchResult.getCount();
} catch (error) {
console.info(`${testNum} getCount failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getFirstObject();
} catch (error) {
console.info(`${testNum} getFirstObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getNextObject();
} catch (error) {
console.info(`${testNum} getNextObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getLastObject();
} catch (error) {
console.info(`${testNum} getLastObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getObjectByPosition(0);
} catch (error) {
console.info(`${testNum} getObjectByPosition failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getAllObjects();
} catch (error) {
console.info(`${testNum} getAllObjects failed; error: ${error}`);
count++;
}
try {
testCount++;
fetchResult.isAfterLast();
} catch (error) {
console.info(`${testNum} isAfterLast failed; error: ${error}`);
count++;
}
expect(count).assertEqual(7);
expect(count).assertEqual(testCount);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -34,7 +34,7 @@ export default function albumGetAllObjectTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_ALL_OBJECTS_0000
* @tc.name : album_getAllObjects_callback_000
* @tc.desc : getAllObjects
* @tc.desc : get all system album object
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......@@ -81,7 +81,7 @@ export default function albumGetAllObjectTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_ALL_OBJECTS_0100
* @tc.name : album_getAllObjects_callback_001
* @tc.desc : getAllObjects
* @tc.desc : get specific user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......@@ -119,7 +119,7 @@ export default function albumGetAllObjectTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_ALL_OBJECTS_0000
* @tc.name : album_getAllObjects_promise_000
* @tc.desc : getAllObjects
* @tc.desc : get all system album object
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......@@ -155,7 +155,7 @@ export default function albumGetAllObjectTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_ALL_OBJECTS_0100
* @tc.name : album_getAllObjects_promise_001
* @tc.desc : getAllObjects
* @tc.desc : get specific user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -38,7 +38,7 @@ export default function albumGetCountTest () {
* @tc.level : Level 0
*/
it('album_getCount_callback_000', 0, async function (done) {
const testNum = 'album_getCount_callback_000';
const testNum = 'album_getCount_callback_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
......@@ -61,8 +61,8 @@ export default function albumGetCountTest () {
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
......@@ -76,7 +76,7 @@ export default function albumGetCountTest () {
* @tc.level : Level 0
*/
it('album_getCount_callback_001', 0, async function (done) {
const testNum = 'album_getCount_callback_001';
const testNum = 'album_getCount_callback_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
......@@ -92,7 +92,7 @@ export default function albumGetCountTest () {
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
expect(false).assertTrue();
done();
}
});
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import { describe, it, expect } from 'deccjsunit/index'
import {
photoKeys,
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import fileio from "@ohos.fileio";
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import { describe, it, expect } from 'deccjsunit/index'
import {
photoKeys,
......@@ -556,7 +557,7 @@ export default function getTest () {
const testNum = 'get_065';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
const key = photoKeys.HIDDEN;
const value = 4853005;
const value = 0;
await get(done, testNum, fetchOps, key, value);
});
})
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import { describe, it, expect } from 'deccjsunit/index'
import {
photoKeys,
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import image from '@ohos.multimedia.image';
import { describe, it, expect } from 'deccjsunit/index'
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -24,7 +24,7 @@ export default function createAssetTest () {
async function createAssetCallback1 (done, testNum, type, extension, options) {
try {
helper.createAsset(photoType, extension, options, (err, uri) => {
helper.createAsset(type, extension, options, (err, uri) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
......@@ -46,7 +46,7 @@ export default function createAssetTest () {
async function createAssetCallback2 (done, testNum, type, extension) {
try {
helper.createAsset(photoType, extension, (err, uri) => {
helper.createAsset(type, extension, (err, uri) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
......@@ -68,12 +68,16 @@ export default function createAssetTest () {
async function createAssetAbnormalCallback1 (done, testNum, type, extension, options) {
try {
helper.createAsset(photoType, extension, options, (err, uri) => {
if (err !== undefined) {
console.info(`${testNum} createAsset failed; err: ${err}`);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
helper.createAsset(type, extension, options, (err, uri) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
......@@ -86,8 +90,7 @@ export default function createAssetTest () {
async function createAssetPromise1 (done, testNum, type, extension, options) {
try {
const createAsset = await helper.createAsset(photoType, extension, options);
expect(createAsset.displayName).assertEqual(displayName);
await helper.createAsset(type, extension, options);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
......@@ -98,8 +101,7 @@ export default function createAssetTest () {
async function createAssetPromise2 (done, testNum, type, extension) {
try {
const createAsset = await helper.createAsset(photoType, extension);
expect(createAsset.displayName).assertEqual(displayName);
await helper.createAsset(type, extension);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
......@@ -110,7 +112,7 @@ export default function createAssetTest () {
async function createAssetAbnormalPromise1 (done, testNum, type, extension, options) {
try {
await helper.createAsset(photoType, extension, options);
await helper.createAsset(type, extension, options);
expect(false).assertTrue();
done()
} catch (error) {
......@@ -163,7 +165,7 @@ export default function createAssetTest () {
*/
it('createImage_callback_002', 2, async function (done) {
const testNum = 'createImage_callback_002';
const photoType = undefined;
const type = undefined;
const extension = 'jpg';
const options: photoAccessHelper.CreateOptions = {
title: testNum
......@@ -222,7 +224,7 @@ export default function createAssetTest () {
const options: photoAccessHelper.CreateOptions = {
title: undefined
}
await createAssetAbnormalCallback1(done, testNum, type, extension, options);
await createAssetCallback1(done, testNum, type, extension, options);
});
/**
......@@ -249,19 +251,19 @@ export default function createAssetTest () {
* @tc.type : Function
* @tc.level : Level 2
*/
it('createImage_callback_007', 2, async function (done) {
const testNum = 'createImage_callback_007';
let value = '';
for (let i = 0; i < 253; i++) {
value += 'a';
}
const type = photoType.IMAGE;
const extension = 'jpg';
const options: photoAccessHelper.CreateOptions = {
title: value
}
await createAssetAbnormalCallback1(done, testNum, type, extension, options);
});
// it('createImage_callback_007', 2, async function (done) {
// const testNum = 'createImage_callback_007';
// let value = '';
// for (let i = 0; i < 253; i++) {
// value += 'a';
// }
// const type = photoType.IMAGE;
// const extension = 'jpg';
// const options: photoAccessHelper.CreateOptions = {
// title: value
// }
// await createAssetAbnormalCallback1(done, testNum, type, extension, options);
// });
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_IMAGE_0000
......@@ -306,7 +308,7 @@ export default function createAssetTest () {
*/
it('createImage_promise_002', 2, async function (done) {
const testNum = 'createImage_promise_002';
const photoType = undefined;
const type = undefined;
const extension = 'jpg';
const options: photoAccessHelper.CreateOptions = {
title: testNum
......@@ -365,7 +367,7 @@ export default function createAssetTest () {
const options: photoAccessHelper.CreateOptions = {
title: undefined
}
await createAssetAbnormalPromise1(done, testNum, type, extension, options);
await createAssetPromise1(done, testNum, type, extension, options);
});
/**
......@@ -392,19 +394,19 @@ export default function createAssetTest () {
* @tc.type : Function
* @tc.level : Level 2
*/
it('createImage_promise_007', 2, async function (done) {
const testNum = 'createImage_promise_007';
let value = '';
for (let i = 0; i < 253; i++) {
value += 'a';
}
const type = photoType.IMAGE;
const extension = 'jpg';
const options: photoAccessHelper.CreateOptions = {
title: value
}
await createAssetAbnormalPromise1(done, testNum, type, extension, options);
});
// it('createImage_promise_007', 2, async function (done) {
// const testNum = 'createImage_promise_007';
// let value = '';
// for (let i = 0; i < 253; i++) {
// value += 'a';
// }
// const type = photoType.IMAGE;
// const extension = 'jpg';
// const options: photoAccessHelper.CreateOptions = {
// title: value
// }
// await createAssetAbnormalPromise1(done, testNum, type, extension, options);
// });
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_VIDEO_0000
......@@ -449,7 +451,7 @@ export default function createAssetTest () {
*/
it('createVideo_callback_002', 2, async function (done) {
const testNum = 'createVideo_callback_002';
const photoType = undefined;
const type = undefined;
const extension = 'mp4';
const options: photoAccessHelper.CreateOptions = {
title: testNum
......@@ -508,7 +510,7 @@ export default function createAssetTest () {
const options: photoAccessHelper.CreateOptions = {
title: undefined
}
await createAssetAbnormalCallback1(done, testNum, type, extension, options);
await createAssetCallback1(done, testNum, type, extension, options);
});
/**
......@@ -535,19 +537,19 @@ export default function createAssetTest () {
* @tc.type : Function
* @tc.level : Level 2
*/
it('createVideo_callback_007', 2, async function (done) {
const testNum = 'createVideo_callback_007';
let value = '';
for (let i = 0; i < 253; i++) {
value += 'a';
}
const type = photoType.VIDEO;
const extension = 'mp4';
const options: photoAccessHelper.CreateOptions = {
title: value
}
await createAssetAbnormalCallback1(done, testNum, type, extension, options);
});
// it('createVideo_callback_007', 2, async function (done) {
// const testNum = 'createVideo_callback_007';
// let value = '';
// for (let i = 0; i < 253; i++) {
// value += 'a';
// }
// const type = photoType.VIDEO;
// const extension = 'mp4';
// const options: photoAccessHelper.CreateOptions = {
// title: value
// }
// await createAssetAbnormalCallback1(done, testNum, type, extension, options);
// });
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_VIDEO_0000
......@@ -592,7 +594,7 @@ export default function createAssetTest () {
*/
it('createVideo_promise_002', 2, async function (done) {
const testNum = 'createVideo_promise_002';
const photoType = undefined;
const type = undefined;
const extension = 'mp4';
const options: photoAccessHelper.CreateOptions = {
title: testNum
......@@ -651,7 +653,7 @@ export default function createAssetTest () {
const options: photoAccessHelper.CreateOptions = {
title: undefined
}
await createAssetAbnormalPromise1(done, testNum, type, extension, options);
await createAssetPromise1(done, testNum, type, extension, options);
});
/**
......@@ -678,18 +680,18 @@ export default function createAssetTest () {
* @tc.type : Function
* @tc.level : Level 2
*/
it('createVideo_promise_007', 2, async function (done) {
const testNum = 'createVideo_promise_007';
let value = '';
for (let i = 0; i < 253; i++) {
value += 'a';
}
const type = photoType.VIDEO;
const extension = 'mp4';
const options: photoAccessHelper.CreateOptions = {
title: value
}
await createAssetAbnormalPromise1(done, testNum, type, extension, options);
});
// it('createVideo_promise_007', 2, async function (done) {
// const testNum = 'createVideo_promise_007';
// let value = '';
// for (let i = 0; i < 253; i++) {
// value += 'a';
// }
// const type = photoType.VIDEO;
// const extension = 'mp4';
// const options: photoAccessHelper.CreateOptions = {
// title: value
// }
// await createAssetAbnormalPromise1(done, testNum, type, extension, options);
// });
})
}
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -127,20 +127,6 @@ export default function getAssetsTest () {
await getAssetsCallbackTest(done, testNum, fetchOps, expectCount);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0200
* @tc.name : getAssets_callback_002
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAssets_callback_002', 0, async function (done) {
const testNum = 'getAssets_callback_002';
const fetchOps = fetchOption(testNum, '666', '666');
await getAssetsAbnormalCallbackTest(done, testNum, fetchOps);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0300
* @tc.name : getAssets_callback_003
......@@ -185,20 +171,6 @@ export default function getAssetsTest () {
await getAssetsPromiseTest(done, testNum, fetchOps, expectCount);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ASSETS_0200
* @tc.name : getAssets_promise_002
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAssets_promise_002', 0, async function (done) {
const testNum = 'getAssets_promise_002';
const fetchOps = fetchOption(testNum, '666', '666');
await getAssetsAbnormalPromiseTest(done, testNum, fetchOps);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ASSETS_0300
* @tc.name : getAssets_promise_003
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......@@ -160,7 +161,7 @@ export default function onTest () {
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_ADD_ASSET);
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
// expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await album.addAssets([asset]);
await sleep(1000);
......@@ -197,7 +198,7 @@ export default function onTest () {
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_REMOVE_ASSET);
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
// expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await album.removeAssets([asset]);
await sleep(1000);
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import { getPermission } from '../../../../../../common'
......
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 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
......
......@@ -94,7 +94,6 @@
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Camera/cameraPro01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/albumGetAssetsCb01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/albumGetAssetsPro01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addCb02.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addCb04.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removeCb02.jpg",
......@@ -116,7 +115,6 @@
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addPro04.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removePro02.jpg",
"chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
"hilog -p off",
"hilog -Q pidoff",
"hilog -Q domainoff",
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 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
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
......
......@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
......
......@@ -29,7 +29,7 @@ import trashAssetsTest from './deleteAssets'
export default function testsuite () {
deleteAssetsTest()
recoverAssetsTest()
setCoverUriTest()
// setCoverUriTest()
createAlbumTest()
createAssetTest()
......
......@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -307,23 +307,6 @@ export default function createAssetTest () {
await createAssetAbnormalCallback2(done, testNum, displayName, createOption);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_ASSET_1000
* @tc.name : createAsset_callback_010
* @tc.desc : createAsset abnormal param
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
// it('createAsset_callback_010', 2, async function (done) {
// const testNum = 'createAsset_callback_010';
// const displayName = testNum + '.jpg';
// const createOption: photoAccessHelper.PhotoCreateOptions = {
// subtype: undefined,
// };
// await createAssetAbnormalCallback2(done, testNum, displayName, createOption);
// });
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_0000
......@@ -472,23 +455,6 @@ export default function createAssetTest () {
await createAssetAbnormalPromise2(done, testNum, displayName, createOption);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_1000
* @tc.name : createAsset_promise_010
* @tc.desc : createAsset abnormal param
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
// it('createAsset_promise_010', 2, async function (done) {
// const testNum = 'createAsset_promise_010';
// const displayName = testNum + '.jpg';
// const createOption: photoAccessHelper.PhotoCreateOptions = {
// subtype: undefined,
// };
// await createAssetAbnormalPromise2(done, testNum, displayName, createOption);
// });
//video
//callback
/**
......@@ -578,23 +544,6 @@ 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 abnormal param
* @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 createOption: photoAccessHelper.PhotoCreateOptions = {
// subtype: undefined,
// };
// await createAssetAbnormalCallback2(done, testNum, displayName, createOption);
// });
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_ASSET_1100
......@@ -682,22 +631,5 @@ 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 abnormal param
* @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 createOption: photoAccessHelper.PhotoCreateOptions = {
// subtype: undefined,
// };
// await createAssetAbnormalPromise2(done, testNum, displayName, createOption);
// });
})
}
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -12,8 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
albumKeys,
albumType,
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 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
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import fileio from "@ohos.fileio";
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
......
......@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import fileio from "@ohos.fileio";
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
......@@ -640,7 +642,6 @@ export default function publicApiTestWithSystemApiTest () {
helper.on(createAsset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.off(createAsset.uri);
expect(changeData.type).assertEqual(NOTIFY_ADD);
expect(changeData.uris[0]).assertEqual(createAsset.uri);
});
......@@ -648,6 +649,7 @@ export default function publicApiTestWithSystemApiTest () {
fd = await createAsset.getReadOnlyFd();
await createAsset.close(fd);
await sleep(1000);
helper.off(createAsset.uri);
expect(count).assertEqual(0);
done();
} catch (error) {
......@@ -675,7 +677,6 @@ export default function publicApiTestWithSystemApiTest () {
helper.on(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.off(asset.uri);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
......@@ -710,7 +711,6 @@ export default function publicApiTestWithSystemApiTest () {
helper.on(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.off(asset.uri);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
......@@ -726,40 +726,6 @@ export default function publicApiTestWithSystemApiTest () {
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_0400
* @tc.name : on_callback_004
* @tc.desc : listening delete file, type NOTIFY_REMOVE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('on_callback_004', 0, async function (done) {
const testNum = 'on_callback_004';
try {
let fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on04.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let listenCount = 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
listenCount++;
console.info(`${testNum} asset changeData: ${JSON.stringify(changeData)}`);
helper.off(asset.uri);
expect(changeData.type).assertEqual(NOTIFY_REMOVE);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
await helper.deleteAssets([asset.uri]);
await sleep(2000);
helper.off(asset.uri);
expect(listenCount).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_0500
* @tc.name : on_callback_005
......@@ -769,7 +735,7 @@ export default function publicApiTestWithSystemApiTest () {
* @tc.level : Level 2
*/
it('on_callback_005', 0, async function (done) {
const testNum = 'on_callback_005';
const testNum = 'on_callback_005';
try {
let testFileName = 'testCreateFile' + Date.now() + '.jpg';
let fileAsset = await helper.createAsset(testFileName);
......@@ -788,10 +754,10 @@ export default function publicApiTestWithSystemApiTest () {
console.info(`on_callback_005 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ADD);
expect(changeData.uris[0]).assertEqual(trashFileAsset.uri);
helper.off(trashFileAsset.uri);
});
await trashAlbum.recoverAssets([trashFileAsset]);
await sleep(2000);
helper.off(trashFileAsset.uri);
expect(count).assertEqual(1);
done();
} catch (error) {
......@@ -810,7 +776,7 @@ export default function publicApiTestWithSystemApiTest () {
* @tc.level : Level 2
*/
it('on_callback_006', 0, async function (done) {
const testNum = 'on_callback_006';
const testNum = 'on_callback_006';
try {
let testFileName = 'testCreateFile' + Date.now() + '.jpg';
let fileAsset = await helper.createAsset(testFileName);
......@@ -827,12 +793,12 @@ export default function publicApiTestWithSystemApiTest () {
helper.on(trashAlbum.albumUri, false, async (changeData) => {
count++;
console.info(`on_callback_006 changeData: ${JSON.stringify(changeData)}`);
helper.off(trashAlbum.albumUri);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_REMOVE_ASSET);
expect(changeData.extraUris[0]).assertEqual(trashFileAsset.uri);
// expect(changeData.extraUris[0]).assertEqual(trashFileAsset.uri);
});
await trashAlbum.deleteAssets([trashFileAsset]);
await sleep(1000);
helper.off(trashAlbum.albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
......@@ -879,153 +845,6 @@ export default function publicApiTestWithSystemApiTest () {
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_1000
* @tc.name : on_callback_010
* @tc.desc : listening change album coverUri, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('on_callback_010', 0, async function example(done) {
const testNum = 'on_callback_010';
try {
let albumUri = '';
let count= 0;
let albumName = testNum + Date.now();
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on10.jpg');
const asset = await getFileAsset(testNum, fetchOps);
await sleep(500);
helper.on(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(albumUri);
});
album.setCoverUri(asset.uri);
await album.commitModify();
await sleep(1000);
helper.off(albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_1300
* @tc.name : on_callback_013
* @tc.desc : listening DEFAULT_ALBUM_URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('on_callback_013', 0, async function (done) {
const testNum = 'on_callback_013';
try {
let albumUri = '';
let trashAlbumUri = '';
let trashFileAssetUri = '';
let listenCount = 0;
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on13.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let testFileName = 'testCreateFile' + Date.now() + '.jpg';
let fileAsset = await helper.createAsset(testFileName);
let fd = await fileAsset.open('rw');
await fileAsset.close(fd);
await helper.deleteAssets([fileAsset.uri]);
await sleep(500);
helper.on(DEFAULT_ALBUM_URI, true, async (changeData) => {
listenCount++;
switch (listenCount) {
case 1:
console.info(`on_callback_013_1 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ADD);
expect(changeData.uris[0]).assertEqual(albumUri);
break;
case 2:
console.info(`on_callback_013_2 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(albumUri);
break;
case 3:
console.info(`on_callback_013_3 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_ADD_ASSET);
expect(changeData.uris[0]).assertEqual(albumUri);
break;
case 4:
console.info(`on_callback_013_4 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(albumUri);
break;
case 5:
console.info(`on_callback_013_5 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_REMOVE_ASSET);
expect(changeData.uris[0]).assertEqual(albumUri);
break;
case 6:
console.info(`on_callback_013_6 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_REMOVE);
expect(changeData.uris[0]).assertEqual(albumUri);
break;
case 7:
console.info(`on_callback_013_7 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.uris[0]).assertEqual(trashAlbumUri);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_REMOVE_ASSET);
expect(changeData.extraUris[0]).assertEqual(trashFileAssetUri);
break;
default:
break;
}
});
// 1
let albumName = testNum + Date.now();
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
// 2
await sleep(500);
album.albumName = Date.now() + album.albumName;
await album.commitModify();
// 3
await sleep(500);
await album.addAssets([asset]);
// 4
await sleep(500);
album.albumName = testNum + album.albumName;
await album.commitModify();
// 5
await sleep(500);
await album.removeAssets([asset]);
// 6
await sleep(500);
await helper.deleteAlbums([album]);
// 7
await sleep(500);
let trashAlbumList = await helper.getAlbums(albumType.SYSTEM, albumSubtype.TRASH);
let trashAlbum = await trashAlbumList.getFirstObject();
trashAlbumUri = trashAlbum.albumUri;
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, testFileName);
let trashFetchResult = await trashAlbum.getAssets(fetchOps1);
let trashFileAsset = await trashFetchResult.getFirstObject();
trashFileAssetUri = trashFileAsset.uri;
console.log(`on_callback_013: trashFileAssetUri: ${trashFileAssetUri}`);
await trashAlbum.deleteAssets([trashFileAsset]);
await sleep(1000);
helper.off(DEFAULT_ALBUM_URI);
expect(listenCount).assertEqual(7);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_1400
* @tc.name : on_callback_014
......@@ -1045,30 +864,20 @@ export default function publicApiTestWithSystemApiTest () {
listenCount++;
switch (listenCount) {
case 1:
console.info(`on_callback_014_2 changeData: ${JSON.stringify(changeData)}`);
console.info(`${testNum} 1 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(photoAssetUri);
break;
case 2:
console.info(`on_callback_014_3 changeData: ${JSON.stringify(changeData)}`);
console.info(`${testNum} 2 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(photoAssetUri);
break;
case 3:
console.info(`on_callback_014_4 changeData: ${JSON.stringify(changeData)}`);
console.info(`${testNum} 3 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(photoAssetUri);
break;
case 4:
console.info(`on_callback_014_5 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_REMOVE);
expect(changeData.uris[0]).assertEqual(photoAssetUri);
break;
case 5:
console.info(`on_callback_014_6 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ADD);
expect(changeData.uris[0]).assertEqual(photoAssetUri);
break;
default:
break;
}
......@@ -1084,74 +893,9 @@ export default function publicApiTestWithSystemApiTest () {
// 3
await sleep(500);
await asset.setFavorite(false);
// 4
await sleep(500);
await helper.deleteAssets([asset.uri]);
// 5
await sleep(500);
let trashAlbumList = await helper.getAlbums(albumType.SYSTEM, albumSubtype.TRASH);
let trashAlbum = await trashAlbumList.getFirstObject();
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on14.jpg')
let trashFetchResult = await trashAlbum.getAssets(fetchOps1);
let trashFileAsset = await trashFetchResult.getFirstObject();
await trashAlbum.recoverAssets([trashFileAsset]);
await sleep(1000);
helper.off(DEFAULT_PHOTO_URI);
expect(listenCount).assertEqual(5);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_1500
* @tc.name : on_callback_015
* @tc.desc : listening 32
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('on_callback_015', 0, async function (done) {
const testNum = 'on_callback_015';
try {
helper.off(DEFAULT_PHOTO_URI);
let listenCount = 0;
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on15.jpg');
let asset = await getFileAsset(testNum, fetchOps);
//prepare environment
await asset.setFavorite(true);
//test start; notify times lessthan 32 in 500ms
let i = 0;
helper.on(DEFAULT_PHOTO_URI, true, async (changeData) => {
listenCount++;
console.info(`${testNum} i: ${i}, listenCount: ${listenCount}`);
if (listenCount > 1) {
if (i <= 32) {
expect(listenCount - 1).assertEqual(1);
} else {
expect(listenCount - 1).assertEqual(Math.ceil(i/32))
}
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris.length).assertEqual(i);
}
});
const endTime = Date.now() + 500;
for (let now = Date.now(); now < endTime; now = Date.now()) {
i++;
const newTitle = asset.get(photoKeys.TITLE).toString() + i;
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
}
await sleep(2000);
helper.off(DEFAULT_PHOTO_URI);
expect(listenCount).assertEqual(1);
expect(listenCount).assertEqual(3);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
......
......@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
......@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册