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

!8894 新增photoAccessHelper模块xts

Merge pull request !8894 from yangbo/xts
......@@ -70,6 +70,8 @@ group("multimedia") {
"medialibrary/mediaLibrary_getThumbnail:mediaLibrary_getThumbnail_hap",
"medialibrary/mediaLibrary_mediafetchoptions:mediaLibrary_mediafetchoptions_hap",
"medialibrary/mediaLibrary_trash:mediaLibrary_trash_js_hap",
"photoAccess/photoAccess:photoAccess_js_hap",
"photoAccess/photoAccessSystem:photoAccess_system_js_hap",
]
} else {
deps = [
......
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import bundleManager from '@ohos.bundle.bundleManager';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
const photoType = photoAccessHelper.PhotoType;
const photoKeys = photoAccessHelper.PhotoKeys;
const albumKeys = photoAccessHelper.AlbumKeys;
const albumType = photoAccessHelper.AlbumType;
const albumSubtype = photoAccessHelper.AlbumSubtype;
const DEFAULT_SLEEP_TIME = 10;
export async function sleep(times = DEFAULT_SLEEP_TIME) : Promise<void> {
await new Promise(res => setTimeout(res, times));
};
export function fetchAllOption() : photoAccessHelper.FetchOptions {
const predicates = new dataSharePredicates.DataSharePredicates();
const ops : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates
};
return ops;
};
export function fetchOption(testNum, key, value) : photoAccessHelper.FetchOptions {
const predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(key, value);
const ops : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates
};
console.info(`${testNum} queryOps: ${key} = ${value}`);
return ops;
};
export function albumFetchOption(testNum, key, value) : photoAccessHelper.FetchOptions {
const predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(key, value);
const ops : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates
};
console.info(`${testNum} queryOps: ${key} = ${value}`);
return ops;
};
export function photoFetchOption(testNum, key, value) : photoAccessHelper.FetchOptions {
const predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(key, value);
const ops : photoAccessHelper.FetchOptions = {
fetchColumns: [
photoKeys.URI,
photoKeys.PHOTO_TYPE,
photoKeys.DISPLAY_NAME,
photoKeys.DATE_ADDED,
photoKeys.DATE_MODIFIED,
photoKeys.DURATION,
photoKeys.WIDTH,
photoKeys.HEIGHT,
photoKeys.DATE_TAKEN,
photoKeys.ORIENTATION,
photoKeys.FAVORITE,
photoKeys.SIZE,
photoKeys.TITLE,
photoKeys.POSITION,
photoKeys.DATE_TRASHED,
photoKeys.HIDDEN,
],
predicates: predicates
};
console.info(`${testNum} queryOps: ${key} = ${value}`);
return ops;
};
export async function getPermission(name = 'ohos.acts.multimedia.photoaccess') : Promise<void> {
try {
console.info('getPermission start', name);
let permissionState = new Map();
const permissions = [
'ohos.permission.MEDIA_LOCATION',
'ohos.permission.READ_IMAGEVIDEO',
'ohos.permission.WRITE_IMAGEVIDEO',
];
const atManager = abilityAccessCtrl.createAtManager();
const appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
const userId = 100;
const appInfo = await bundleManager.getApplicationInfo(name, appFlags, userId);
const tokenID = appInfo.accessTokenId;
for (const permission of permissions) {
console.info('getPermission permission: ' + permission);
try {
await atManager.grantUserGrantedPermission(tokenID, permission, 1);
} catch (error) {
console.info(`getPermission ${permission} failed`);
}
permissionState.set(permission, await atManager.verifyAccessToken(tokenID, permission));
}
permissionState.forEach((value, key, map) => {
if (value !== 0) {
console.info(`getPermission failed; permission: ${key}, state: ${value}`);
}
});
console.info('getPermission end');
} catch (error) {
console.info(`getPermission failed, error: ${error}`);
}
};
export function isNum(value) : boolean {
return typeof value === 'number' && !isNaN(value);
};
export function getId(uri) : string {
let index = uri.lastIndexOf('/');
let str = uri.substring(index + 1);
return str;
}
export function genRadomStr(len: number) : string {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let randomStr = '';
for (let i = 0; i < len; i++) {
randomStr += chars.charAt(Math.floor(Math.random() * chars.length));
}
return randomStr;
}
export async function createUserAlbum(testNum, albumName) : Promise<photoAccessHelper.Album> {
console.info(`${testNum} createUserAlbum albumName: ${albumName}`);
let album: photoAccessHelper.Album;
try {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
album = await helper.createAlbum(albumName);
console.info(`${testNum} createUserAlbum suc`);
} catch (error) {
console.info(`Failed to createUserAlbum! error: ${error}`);
throw error;
}
return new Promise((resolve, reject) => {
resolve(album);
});
}
//systemApi
export async function deleteAllUserAlbum(testNum) : Promise<void> {
try {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
let fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC);
let count = fetchResult.getCount();
console.info(`${testNum} deleteAllUserAlbum count: ${count}`);
if (count <= 0) {
return;
}
const albumList = await fetchResult.getAllObjects();
console.info(`${testNum} deleteAllUserAlbum getAllObjects: ${albumList.length}`);
await helper.deleteAlbums(albumList);
fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC);
if (fetchResult.getCount() === 0) {
console.info(`${testNum} deleteAllUserAlbum suc`);
} else {
console.info(`${testNum} deleteAllUserAlbum failed! fetchResult.getCount(): ${fetchResult.getCount()}`);
}
fetchResult.close();
} catch (error) {
console.info(`${testNum} deleteAllUserAlbum failed! error: ${error}`);
throw error;
}
};
export async function getFileAsset(testNum, fetchOps) : Promise<photoAccessHelper.PhotoAsset> {
let asset: photoAccessHelper.PhotoAsset;
try {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset>;
fetchResult = await helper.getAssets(fetchOps);
console.info(`${testNum} getFileAsset fetchResult: ${fetchResult.getCount()}`);
asset = await fetchResult.getFirstObject();
fetchResult.close();
} catch (error) {
console.info(`${testNum} getFileAsset error: ${error}`);
throw error;
}
return new Promise((resolve, reject) => {
resolve(asset);
});
}
export function getFileAssetFetchResult() : photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset>;
return fetchResult;
}
export function getAlbumFetchResult() : photoAccessHelper.FetchResult<photoAccessHelper.Album> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
return fetchResult;
}
export function checkUserAlbum(expect, testNum, album, expectedName, expectedCover) : void {
console.info(`${testNum} checkUserAlbum album.albumName: ${album.albumName}, expectedName: ${expectedName}`);
expect(album.albumType).assertEqual(albumType.USER);
expect(album.albumSubtype).assertEqual(albumSubtype.USER_GENERIC);
expect(album.albumName).assertEqual(expectedName);
if (expectedCover === '') {
expect(album.coverUri).assertEqual('');
} else {
expect(album.coverUri).assertEqual(expectedCover);
}
expect(album.albumUri !== '').assertEqual(true);
expect(album.count).assertEqual(0);
}
export function checkSystemAlbum(expect, testNum, album, expectedSubType) : void {
try {
console.info(`${testNum} checkSystemAlbum expectedSubType: ${expectedSubType}`);
expect(album.albumType).assertEqual(albumType.SYSTEM);
expect(album.albumSubtype).assertEqual(expectedSubType);
expect(album.albumName).assertEqual('');
expect(album.coverUri).assertEqual('');
expect(album.albumUri !== '').assertEqual(true);
expect(album.count).assertEqual(0);
} catch (error) {
console.info(`Failed to delete all user albums! error: ${error}`);
throw error;
}
}
export {
photoType,
photoKeys,
albumKeys,
albumType,
albumSubtype,
};
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.multimedia.photoaccess",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("photoAccess_js_hap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":photoAccess_js_assets",
":photoAccess_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsPhotoAccessTest"
part_name = "media_library"
subsystem_name = "multimedia"
}
ohos_app_scope("photoAccess_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("photoAccess_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("photoAccess_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":photoAccess_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for photoAccess Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "ohos.acts.multimedia.photoaccess",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"type": "ShellKit",
"pre-push": [],
"run-command": [
"rm -rf /storage/media/100/local/files/*",
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*",
"kill -9 `pidof com.ohos.medialibrary.medialibrarydata`",
"scanner",
"sleep 5",
"mkdir /storage/media/100/local/temp",
"param set persist.ace.testmode.enabled 1"
]
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/01.jpg",
"./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp/01.mp4"
]
},
{
"type": "ShellKit",
"run-command": [
"mkdir /storage/media/100/local/files/Pictures/Screenshots",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/01.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/01.mp4",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/albumGetAssetsCb01.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/albumGetAssetsCb01.mp4",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/albumGetAssetsPro01.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/albumGetAssetsPro01.mp4",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addCb01.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/addCb03.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addCb04.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/addCb01.mp4",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addPro01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addPro02.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addPro03.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/addPro04.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/addPro01.mp4",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removeCb01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removeCb02.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removeCb03.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removeCb04.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/removeCb01.mp4",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removePro01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removePro02.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removePro03.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/removePro04.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/removePro01.mp4",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off02.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off03.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off04.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off10.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off11.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off12.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off13.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off14.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/off15.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/offCb01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on02.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on03.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on04.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on10.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on11.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on12.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on13.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on14.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on15.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/on16.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyCb01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyCb02.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyCb03.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyCb04.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyCb05.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyCb06.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyCb07.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyCb01.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyCb02.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyCb03.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyCb04.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyCb05.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyCb06.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyCb07.mp4",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyPro01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyPro02.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyPro03.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyPro04.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyPro05.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyPro06.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/modifyPro07.jpg",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyPro01.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyPro02.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyPro03.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyPro04.mp4",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/modifyPro05.mp4",
"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/*",
"hilog -p off",
"hilog -Q pidoff",
"hilog -Q domainoff",
"hilog -b D -D 0xD002B70",
"scanner",
"sleep 5"
],
"teardown-command": [
"power-shell setmode 600"
]
},
{
"test-file-name": [
"ActsPhotoAccessTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() : void {
console.log("[Demo] MyAbilityStage onCreate");
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want, launchParam) : void {
// Ability is creating, initialize resources for this ability
console.log('[Demo] MainAbility onCreate');
globalThis.abilityWant = want;
}
onDestroy() : void {
// Ability is destroying, release resources for this ability
console.log('[Demo] MainAbility onDestroy');
}
onWindowStageCreate(windowStage) : void {
console.log('[Demo] MainAbility onWindowStageCreate windowStage=' + windowStage);
globalThis.windowStage = windowStage;
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, 'MainAbility/pages/index/index', null);
}
onWindowStageDestroy() : void {
//Main window is destroyed, release UI related resources
console.log('[Demo] MainAbility onWindowStageDestroy');
}
onForeground() : void {
// Ability has brought to foreground
console.log('[Demo] MainAbility onForeground');
}
onBackground() : void {
// Ability has back to background
console.log('[Demo] MainAbility onBackground');
}
};
\ No newline at end of file
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
export default class TestAbility extends Ability {
onCreate(want, launchParam) : void {
console.log('TestAbility onCreate');
}
onDestroy() : void {
console.log('TestAbility onDestroy');
}
onWindowStageCreate(windowStage) : void {
console.log('TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/index', (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
};
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() : void {
console.log('TestAbility onWindowStageDestroy');
}
onForeground() : void {
console.log('TestAbility onForeground');
}
onBackground() : void {
console.log('TestAbility onBackground');
}
};
\ No newline at end of file
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) : string {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`;
}
}
return targetParams.trim();
}
async function onAbilityCreateCallback() : Promise<void> {
console.log('onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err) : Promise<void> {
console.info('addAbilityMonitorCallback : ' + JSON.stringify(err));
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {};
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run');
let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
let cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
const debug = abilityDelegatorArguments.parameters['-D'];
if (debug === 'true')
{
cmd += ' -D';
}
console.info('cmd : ' + cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
});
console.info('OpenHarmonyTestRunner onRun end');
}
};
\ No newline at end of file
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
fetchOption,
getFileAsset,
getId,
photoKeys
} from '../../../../../../../common'
export default function checkAlbumAttrTest () {
describe('checkAlbumAttrTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
async function checkAssetAttr (done, testNum) {
try {
const album = await helper.createAlbum(testNum);
expect(album.albumType).assertEqual(albumType.USER);
expect(album.albumSubtype).assertEqual(albumSubtype.USER_GENERIC);
expect(album.albumName).assertEqual(testNum);
const id = getId(album.albumUri);
expect(album.albumUri).assertEqual('file://media/PhotoAlbum/' + id);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
await album.addAssets([asset]);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_0000
* @tc.name : album_000
* @tc.desc : chech album attr
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_000', 0, async function (done) {
const testNum = 'album_000';
await checkAssetAttr(done, testNum);
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
photoKeys,
fetchOption,
getFileAsset,
} from '../../../../../../../common'
export default function albumGetAssetsTest () {
describe('albumGetAssetsTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0000
* @tc.name : album_getAssets_callback_000
* @tc.desc : Video album getAssets
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getAssets_callback_000', 0, async function (done) {
const testNum = 'album_getAssets_callback_000';
try {
const fetchResult = await helper.getAlbums(albumType.SYSTEM, albumSubtype.VIDEO);
const album = await fetchResult.getFirstObject();
fetchResult.close();
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'albumGetAssetsCb01.mp4');
album.getAssets(fetchOps, async (err, fetchResult) => {
try {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.close();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ASSETS_0000
* @tc.name : album_getAssets_promise_000
* @tc.desc : Video album getAssets
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getAssets_promise_000', 0, async function (done) {
const testNum = 'album_getAssets_promise_000';
try {
const fetchResult = await helper.getAlbums(albumType.SYSTEM, albumSubtype.VIDEO);
const album = await fetchResult.getFirstObject();
fetchResult.close();
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'albumGetAssetsPro01.mp4');
const curFetchResult = await album.getAssets(fetchOps);
expect(curFetchResult.getCount()).assertEqual(1);
curFetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
photoKeys,
fetchOption,
fetchAllOption,
getFileAsset,
} from '../../../../../../../common'
export default function addAssetsTest () {
describe('addAssetsTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ADD_ASSETS_0100
* @tc.name : addAssets_callback_001
* @tc.desc : add image asset to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('addAssets_callback_001', 0, async function (done) {
const testNum = 'addAssets_callback_001';
try {
const album = await helper.createAlbum(testNum);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addCb01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
album.addAssets([asset], async (err) => {
try {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} album.count: ${album.count}`);
const fetchResult = await album.getAssets(fetchOps);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.close()
}
} 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_0300
* @tc.name : addAssets_callback_003
* @tc.desc : add image&video asset to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('addAssets_callback_003', 2, async function (done) {
const testNum = 'addAssets_callback_003';
try {
const album = await helper.createAlbum(testNum);
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addCb03.jpg');
const fetchOps2 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addCb01.mp4');
const assetList: Array<photoAccessHelper.PhotoAsset> = new Array();
const asset1 = await getFileAsset(testNum, fetchOps1);
assetList.push(asset1);
const asset2 = await getFileAsset(testNum, fetchOps2);
assetList.push(asset2);
album.addAssets(assetList, async (err) => {
try {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} album.count: ${album.count}`);
const fetchResult = await album.getAssets(fetchAllOption());
expect(fetchResult.getCount()).assertEqual(2);
fetchResult.close()
}
} 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
* @tc.desc : add undefined array to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('addAssets_callback_005', 2, async function (done) {
const testNum = 'addAssets_callback_005';
try {
const album = await helper.createAlbum(testNum);
album.addAssets(undefined, async (err) => {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
expect(false).assertTrue();
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ADD_ASSETS_0100
* @tc.name : addAssets_promise_001
* @tc.desc : add image asset to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('addAssets_promise_001', 0, async function (done) {
const testNum = 'addAssets_promise_001';
try {
const album = await helper.createAlbum(testNum);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addPro01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
await album.addAssets([asset]);
const fetchResult = await album.getAssets(fetchOps);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ADD_ASSETS_0300
* @tc.name : addAssets_promise_003
* @tc.desc : add image&video asset to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('addAssets_promise_003', 2, async function (done) {
const testNum = 'addAssets_promise_003';
try {
const album = await helper.createAlbum(testNum);
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addPro03.jpg');
const fetchOps2 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addPro01.mp4');
const assetList: Array<photoAccessHelper.PhotoAsset> = new Array();
const asset1 = await getFileAsset(testNum, fetchOps1);
assetList.push(asset1);
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();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ADD_ASSETS_0400
* @tc.name : addAssets_promise_004
* @tc.desc : add empty array to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('addAssets_promise_004', 2, async function (done) {
const testNum = 'addAssets_promise_004';
try {
const album = await helper.createAlbum(testNum);
await album.addAssets([]);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ADD_ASSETS_0500
* @tc.name : addAssets_promise_005
* @tc.desc : add undefined array to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('addAssets_promise_005', 2, async function (done) {
const testNum = 'addAssets_promise_005';
try {
const album = await helper.createAlbum(testNum);
await album.addAssets(undefined);
expect(false).assertTrue();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
genRadomStr,
fetchOption,
albumKeys,
sleep
} from '../../../../../../../common'
export default function albumCommitModifyTest () {
describe('albumCommitModifyTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_COMMITMODIFY_0000
* @tc.name : album_commitModify_callback_000
* @tc.desc : album change new name
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_commitModify_callback_000', 0, async function (done) {
const testNum = 'album_commitModify_callback_000';
try {
const album = await helper.createAlbum(testNum);
const newName = Date.now() + album.albumName;
album.albumName = newName;
album.commitModify(async (err) => {
try {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, newName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult.getCount()}`);
const album = await fetchResult.getFirstObject();
expect(album.albumName).assertEqual(newName);
fetchResult.close();
}
} 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_ALBUM_COMMITMODIFY_0100
* @tc.name : album_commitModify_callback_001
* @tc.desc : album commitModify with no change
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('album_commitModify_callback_001', 2, async function (done) {
const testNum = 'album_commitModify_callback_001';
try {
const album = await helper.createAlbum(testNum);
album.commitModify(async (err) => {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} suc`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_COMMITMODIFY_0200
* @tc.name : album_commitModify_callback_002
* @tc.desc : album commitModify with invalid long albumName
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('album_commitModify_callback_002', 2, async function (done) {
const testNum = 'album_commitModify_callback_002';
try {
const album = await helper.createAlbum(testNum);
const invalidName = genRadomStr(256);
album.albumName = invalidName;
album.commitModify(async (err) => {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
}
})
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_COMMITMODIFY_0300
* @tc.name : album_commitModify_callback_003
* @tc.desc : album commitModify containing invalid characters
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('album_commitModify_callback_003', 2, async function (done) {
const testNum = 'album_commitModify_callback_003';
try {
const album = await helper.createAlbum(testNum);
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;
album.commitModify((err) => {
try {
if (err) {
console.info(`${testNum} err: ${err}`);
count++;
} else {
console.info(`${testNum} album rename suc`);
expect(false).assertTrue();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
if (i + 1 === TITLE_REGEX_CHECK.length) {
expect(count).assertEqual(TITLE_REGEX_CHECK.length);
done();
}
})
await sleep(50);
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
}
})
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_RPOMISE_ALBUM_COMMITMODIFY_0000
* @tc.name : album_commitModify_promise_000
* @tc.desc : album change new name
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_commitModify_promise_000', 0, async function (done) {
const testNum = 'album_commitModify_promise_000';
try {
const album = await helper.createAlbum(testNum);
const newName = Date.now() + album.albumName;
album.albumName = newName;
await album.commitModify();
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, newName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult.getCount()}`);
const curAlbum = await fetchResult.getFirstObject();
expect(curAlbum.albumName).assertEqual(newName);
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_RPOMISE_ALBUM_COMMITMODIFY_0100
* @tc.name : album_commitModify_promise_001
* @tc.desc : album commitModify with no change
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('album_commitModify_promise_001', 2, async function (done) {
const testNum = 'album_commitModify_promise_001';
try {
const album = await helper.createAlbum(testNum);
await album.commitModify();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_RPOMISE_ALBUM_COMMITMODIFY_0200
* @tc.name : album_commitModify_promise_002
* @tc.desc : album commitModify with invalid long albumName
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('album_commitModify_promise_002', 2, async function (done) {
const testNum = 'album_commitModify_promise_002';
try {
const album = await helper.createAlbum(testNum);
const invalidName = genRadomStr(256);
album.albumName = invalidName;
await album.commitModify();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(true).assertTrue();
done();
}
})
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_RPOMISE_ALBUM_COMMITMODIFY_0300
* @tc.name : album_commitModify_promise_003
* @tc.desc : album commitModify with containing characters
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('album_commitModify_promise_003', 2, async function (done) {
const testNum = 'album_commitModify_promise_003';
try {
const album = await helper.createAlbum(testNum);
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++;
}
if (i + 1 === TITLE_REGEX_CHECK.length) {
expect(count).assertEqual(TITLE_REGEX_CHECK.length);
done();
}
}
await sleep(50);
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(true).assertTrue();
done();
}
})
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
photoKeys,
fetchOption,
fetchAllOption,
getFileAsset,
} from '../../../../../../../common'
export default function removeAssetsTest () {
describe('removeAssetsTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_REMOVE_ASSETS_0000
* @tc.name : removeAssets_callback_000
* @tc.desc : user album remove image asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('removeAssets_callback_000', 0, async function (done) {
const testNum = 'removeAssets_callback_000';
try {
const album = await helper.createAlbum(testNum);
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) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} album.count: ${album.count}`);
const fetchResult = await album.getAssets(fetchOps);
expect(fetchResult.getCount()).assertEqual(0);
fetchResult.close()
}
} 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_REMOVE_ASSETS_0200
* @tc.name : removeAssets_callback_002
* @tc.desc : user album remove image&video asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_callback_002', 2, async function (done) {
const testNum = 'removeAssets_callback_002';
try {
const album = await helper.createAlbum(testNum);
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'removeCb03.jpg');
const fetchOps2 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'removeCb01.mp4');
const assetList: Array<photoAccessHelper.PhotoAsset> = new Array();
const asset1 = await getFileAsset(testNum, fetchOps1);
assetList.push(asset1);
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) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} album.count: ${album.count}`);
const fetchResult = await album.getAssets(fetchAllOption());
expect(fetchResult.getCount()).assertEqual(0);
fetchResult.close()
}
} 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_REMOVE_ASSETS_0400
* @tc.name : removeAssets_callback_004
* @tc.desc : user album remove undefined array
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_callback_004', 2, async function (done) {
const testNum = 'removeAssets_callback_004';
try {
const album = await helper.createAlbum(testNum);
album.removeAssets(undefined, async (err) => {
if (err) {
console.info(`${testNum} err: ${err}`);
} else {
expect(false).assertTrue();
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_REMOVE_ASSETS_0500
* @tc.name : removeAssets_callback_005
* @tc.desc : user album image asset twice
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_callback_005', 2, async function (done) {
const testNum = 'removeAssets_callback_005';
try {
const album = await helper.createAlbum(testNum);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'removeCb04.jpg');
const asset = await getFileAsset(testNum, fetchOps);
await album.addAssets([asset]);
await album.removeAssets([asset]);
album.removeAssets([asset], 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();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0000
* @tc.name : removeAssets_promise_000
* @tc.desc : user album remove image asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('removeAssets_promise_000', 0, async function (done) {
const testNum = 'removeAssets_promise_000';
try {
const album = await helper.createAlbum(testNum);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'removePro01.jpg');
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]);
fetchResult = await album.getAssets(fetchOps);
console.info(`${testNum} count: ${fetchResult.getCount()}`);
expect(fetchResult.getCount()).assertEqual(0);
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0200
* @tc.name : removeAssets_promise_002
* @tc.desc : user album remove image&video asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_promise_002', 2, async function (done) {
const testNum = 'removeAssets_promise_002';
try {
const album = await helper.createAlbum(testNum);
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'removePro03.jpg');
const fetchOps2 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'removePro01.mp4');
const assetList: Array<photoAccessHelper.PhotoAsset> = new Array();
const asset1 = await getFileAsset(testNum, fetchOps1);
assetList.push(asset1);
const asset2 = await getFileAsset(testNum, fetchOps2);
assetList.push(asset2);
await album.addAssets(assetList);
let fetchResult = await album.getAssets(fetchAllOption());
expect(fetchResult.getCount()).assertEqual(2);
await album.removeAssets(assetList);
fetchResult = await album.getAssets(fetchAllOption());
expect(fetchResult.getCount()).assertEqual(0);
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0300
* @tc.name : removeAssets_promise_003
* @tc.desc : user album remove empty array
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_promise_003', 2, async function (done) {
const testNum = 'removeAssets_promise_003';
try {
const album = await helper.createAlbum(testNum);
await album.removeAssets([]);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0400
* @tc.name : removeAssets_promise_004
* @tc.desc : user album remove undefined array
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_promise_004', 2, async function (done) {
const testNum = 'removeAssets_promise_004';
try {
const album = await helper.createAlbum(testNum);
await album.removeAssets(undefined);
expect(false).assertTrue();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_REMOVE_ASSETS_0500
* @tc.name : removeAssets_promise_005
* @tc.desc : remove image asset twice
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_promise_005', 2, async function (done) {
const testNum = 'removeAssets_promise_005';
try {
const album = await helper.createAlbum(testNum);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'removePro04.jpg');
const asset = await getFileAsset(testNum, fetchOps);
await album.addAssets([asset]);
await album.removeAssets([asset]);
await album.removeAssets([asset]);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
getAlbumFetchResult,
fetchOption,
albumKeys
} from '../../../../../../../common'
export default function albumCloseTest () {
describe('albumCloseTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ALBUM_CLOSE_0000
* @tc.name : album_close_000
* @tc.desc : close system album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_close_000', 0, async function (done) {
const testNum = 'album_close_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult = getAlbumFetchResult();
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
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(testCount);
passCount++;
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ALBUM_CLOSE_0100
* @tc.name : album_close_001
* @tc.desc : close user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_close_001', 0, async function (done) {
const testNum = 'album_close_001';
try {
const album = await helper.createAlbum(testNum);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, album.albumName);
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(testCount);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
createUserAlbum,
genRadomStr,
fetchOption,
albumKeys,
sleep,
} from '../../../../../../../common'
export default function albumGetAllObjectTest () {
describe('albumGetAllObjectTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_ALL_OBJECTS_0000
* @tc.name : album_getAllObjects_callback_000
* @tc.desc : get all system album object
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getAllObjects_callback_000', 0, async function (done) {
const testNum = 'album_getAllObjects_callback_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.getAllObjects((err, allObj) => {
try {
if (err !== undefined) {
console.info(`${testNum} getAllObjects failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(allObj.length).assertEqual(1);
passCount++;
}
} catch (error) {
console.info(`${testNum} getAllObjects failed; error: ${error}`);
}
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
fetchResult.close();
done();
}
})
await sleep(50);
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_ALL_OBJECTS_0100
* @tc.name : album_getAllObjects_callback_001
* @tc.desc : get specific user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getAllObjects_callback_001', 0, async function (done) {
const testNum = 'album_getAllObjects_callback_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.getAllObjects(async (err, allObj) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
expect(allObj.length).assertEqual(1);
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
fetchResult.close();
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_ALL_OBJECTS_0000
* @tc.name : album_getAllObjects_promise_000
* @tc.desc : get all system album object
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getAllObjects_promise_000', 0, async function (done) {
const testNum = 'album_getAllObjects_promise_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
const allObj = await fetchResult.getAllObjects();
expect(allObj.length).assertEqual(1);
passCount++;
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
fetchResult.close();
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_ALL_OBJECTS_0100
* @tc.name : album_getAllObjects_promise_001
* @tc.desc : get specific user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getAllObjects_promise_001', 0, async function (done) {
const testNum = 'album_getAllObjects_promise_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
const allObj = await fetchResult.getAllObjects();
expect(allObj.length).assertEqual(1);
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
createUserAlbum,
genRadomStr,
fetchOption,
albumKeys
} from '../../../../../../../common'
export default function albumGetCountTest () {
describe('albumGetCountTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_COUNT_0000
* @tc.name : album_getCount_callback_000
* @tc.desc : getCount
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getCount_callback_000', 0, async function (done) {
const testNum = 'album_getCount_callback_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let count = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
try {
expect(fetchResult.getCount()).assertEqual(1);
count++;
} catch (error) {
console.info(`${testNum} getCount; error: ${error}`);
}
if (i + 1 === subTypes.length) {
expect(count).assertEqual(subTypes.length);
fetchResult.close();
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_COUNT_0100
* @tc.name : album_getCount_callback_001
* @tc.desc : getCount
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getCount_callback_001', 0, async function (done) {
const testNum = 'album_getCount_callback_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult}`);
try {
expect(fetchResult.getCount()).assertEqual(1);
} catch (error) {
console.info(`${testNum} getCount failed; error: ${error}`);
}
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
createUserAlbum,
genRadomStr,
fetchOption,
albumKeys,
sleep
} from '../../../../../../../common'
export default function albumGetFirstObjectTest () {
describe('albumGetFirstObjectTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_FIRST_OBJECT_0000
* @tc.name : album_getFirstObject_callback_000
* @tc.desc : getFirstObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getFirstObject_callback_000', 0, async function (done) {
const testNum = 'album_getFirstObject_callback_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.getFirstObject((err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getFirstObject failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
passCount++;
}
} catch (error) {
console.info(`${testNum} getFirstObject failed; error: ${error}`);
}
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
fetchResult.close();
done();
}
})
await sleep(50);
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_FIRST_OBJECT_0100
* @tc.name : album_getFirstObject_callback_001
* @tc.desc : getFirstObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getFirstObject_callback_001', 0, async function (done) {
const testNum = 'album_getFirstObject_callback_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} failed; fetchResult: ${typeof fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
console.info(`${testNum} failed; fetchResult.getCount(): ${fetchResult.getCount()}`);
fetchResult.getFirstObject(async (err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getFirstObject failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
}
} catch (error) {
console.info(`${testNum} getFirstObject failed; error: ${error}`);
}
fetchResult.close();
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_FIRST_OBJECT_0000
* @tc.name : album_getFirstObject_promise_000
* @tc.desc : getFirstObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getFirstObject_promise_000', 0, async function (done) {
const testNum = 'album_getFirstObject_promise_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
const asset = await fetchResult.getFirstObject();
expect(asset !== undefined).assertTrue();
passCount++;
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
fetchResult.close();
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_FIRST_OBJECT_0100
* @tc.name : album_getFirstObject_promise_001
* @tc.desc : getFirstObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getFirstObject_promise_001', 0, async function (done) {
const testNum = 'album_getFirstObject_promise_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
const asset = await fetchResult.getFirstObject();
console.info(`${testNum} asset: ${asset}`);
expect(asset !== undefined).assertTrue();
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
createUserAlbum,
genRadomStr,
fetchOption,
albumKeys,
sleep
} from '../../../../../../../common'
export default function albumGetLastObjectTest () {
describe('albumGetLastObjectTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_LAST_OBJECT_0000
* @tc.name : album_getLastObject_callback_000
* @tc.desc : getLastObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getLastObject_callback_000', 0, async function (done) {
const testNum = 'album_getLastObject_callback_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.getLastObject((err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getLastObject failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
passCount++;
}
} catch (error) {
console.info(`${testNum} getLastObject failed; error: ${error}`);
}
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
fetchResult.close();
done();
}
})
await sleep(50);
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_LAST_OBJECT_0100
* @tc.name : album_getLastObject_callback_001
* @tc.desc : getLastObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getLastObject_callback_001', 0, async function (done) {
const testNum = 'album_getLastObject_callback_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} failed; fetchResult: ${typeof fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
console.info(`${testNum} failed; fetchResult.getCount(): ${fetchResult.getCount()}`);
fetchResult.getLastObject(async (err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getLastObject failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
}
} catch (error) {
console.info(`${testNum} getLastObject failed; error: ${error}`);
}
fetchResult.close();
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_LAST_OBJECT_0000
* @tc.name : album_getLastObject_promise_000
* @tc.desc : getLastObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getLastObject_promise_000', 0, async function (done) {
const testNum = 'album_getLastObject_promise_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
const asset = await fetchResult.getLastObject();
expect(asset !== undefined).assertTrue();
passCount++;
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
fetchResult.close();
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_LAST_OBJECT_0100
* @tc.name : album_getLastObject_promise_001
* @tc.desc : getLastObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getLastObject_promise_001', 0, async function (done) {
const testNum = 'album_getLastObject_promise_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
const asset = await fetchResult.getLastObject();
console.info(`${testNum} asset: ${asset}`);
expect(asset !== undefined).assertTrue();
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
createUserAlbum,
genRadomStr,
fetchOption,
albumKeys,
sleep
} from '../../../../../../../common'
export default function albumGetNextObjectTest () {
describe('albumGetNextObjectTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_NEXT_OBJECT_0000
* @tc.name : album_getNextObject_callback_000
* @tc.desc : getNextObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getNextObject_callback_000', 0, async function (done) {
const testNum = 'album_getNextObject_callback_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.getNextObject((err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getNextObject failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
}
} catch (error) {
console.info(`${testNum} getNextObject failed; error: ${error}`);
}
fetchResult.close();
done();
})
await sleep(50);
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_NEXT_OBJECT_0100
* @tc.name : album_getNextObject_callback_001
* @tc.desc : getNextObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getNextObject_callback_001', 0, async function (done) {
const testNum = 'album_getNextObject_callback_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} failed; fetchResult: ${typeof fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
console.info(`${testNum} failed; fetchResult.getCount(): ${fetchResult.getCount()}`);
fetchResult.getNextObject(async (err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getNextObject failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
}
} catch (error) {
console.info(`${testNum} getNextObject failed; error: ${error}`);
}
fetchResult.close();
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_NEXT_OBJECT_0000
* @tc.name : album_getNextObject_promise_000
* @tc.desc : getNextObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getNextObject_promise_000', 0, async function (done) {
const testNum = 'album_getNextObject_promise_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let count = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
try {
await fetchResult.getNextObject();
count++;
} catch (error) {
console.info(`${testNum} getNextObject; error: ${error}`);
expect(false).assertTrue();
}
if (i + 1 === subTypes.length) {
expect(count).assertEqual(subTypes.length);
fetchResult.close();
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_NEXT_OBJECT_0100
* @tc.name : album_getNextObject_promise_001
* @tc.desc : getNextObject
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getNextObject_promise_001', 0, async function (done) {
const testNum = 'album_getNextObject_promise_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
const asset = await fetchResult.getNextObject();
console.info(`${testNum} asset: ${asset}`);
expect(asset !== undefined).assertTrue();
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
createUserAlbum,
genRadomStr,
fetchOption,
albumKeys,
sleep
} from '../../../../../../../common'
export default function albumGetPositionObjectTest () {
describe('albumGetPositionObjectTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_OBJECT_BY_POSITION_0000
* @tc.name : album_getObjectByPosition_callback_000
* @tc.desc : getObjectByPosition
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getObjectByPosition_callback_000', 0, async function (done) {
const testNum = 'album_getObjectByPosition_callback_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.getObjectByPosition(0, (err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getObjectByPosition failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
passCount++;
}
} catch (error) {
console.info(`${testNum} getObjectByPosition failed; error: ${error}`);
}
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
fetchResult.close();
done();
}
})
await sleep(50);
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ALBUM_GET_OBJECT_BY_POSITION_0100
* @tc.name : album_getObjectByPosition_callback_001
* @tc.desc : getObjectByPosition
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getObjectByPosition_callback_001', 0, async function (done) {
const testNum = 'album_getObjectByPosition_callback_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} failed; fetchResult: ${typeof fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
console.info(`${testNum} failed; fetchResult.getCount(): ${fetchResult.getCount()}`);
fetchResult.getObjectByPosition(0, async (err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getObjectByPosition failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
}
} catch (error) {
console.info(`${testNum} getObjectByPosition failed; error: ${error}`);
}
fetchResult.close();
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_OBJECT_BY_POSITION_0000
* @tc.name : album_getObjectByPosition_promise_000
* @tc.desc : getObjectByPosition
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getObjectByPosition_promise_000', 0, async function (done) {
const testNum = 'album_getObjectByPosition_promise_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let passCount = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
const asset = await fetchResult.getObjectByPosition(0);
expect(asset !== undefined).assertTrue();
passCount++;
if (i + 1 === subTypes.length) {
expect(passCount).assertEqual(subTypes.length);
fetchResult.close();
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_ALBUM_GET_OBJECT_BY_POSITION_0100
* @tc.name : album_getObjectByPosition_promise_001
* @tc.desc : getObjectByPosition
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_getObjectByPosition_promise_001', 0, async function (done) {
const testNum = 'album_getObjectByPosition_promise_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult}`);
expect(fetchResult.getCount()).assertEqual(1);
const asset = await fetchResult.getObjectByPosition(0);
console.info(`${testNum} asset: ${asset}`);
expect(asset !== undefined).assertTrue();
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumType,
albumSubtype,
createUserAlbum,
genRadomStr,
} from '../../../../../../../common'
export default function albumIsAfterLastTest () {
describe('albumIsAfterLastTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext);
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ALBUM_IS_AFTER_LAST_0000
* @tc.name : album_isAfterLast_000
* @tc.desc : isAfterLast
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_isAfterLast_000', 0, async function (done) {
const testNum = 'album_isAfterLast_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
let count = 0;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
expect(fetchResult.getCount()).assertEqual(1);
await fetchResult.getFirstObject();
try {
expect(fetchResult.isAfterLast()).assertTrue();
count++;
} catch (error) {
console.info(`${testNum} isAfterLast; error: ${error}`);
}
if (i + 1 === subTypes.length) {
expect(count).assertEqual(subTypes.length);
fetchResult.close();
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ALBUM_IS_AFTER_LAST_0100
* @tc.name : album_isAfterLast_001
* @tc.desc : isAfterLast
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('album_isAfterLast_001', 0, async function (done) {
const testNum = 'album_isAfterLast_001';
try {
await createUserAlbum(testNum, genRadomStr(10));
await createUserAlbum(testNum, genRadomStr(10));
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC);
let count = fetchResult.getCount();
console.info(`${testNum} count: ${count}`);
await fetchResult.getFirstObject();
for (let i = 1; i < count; i++) {
await fetchResult.getNextObject();
if (i + 1 === count) {
const result = fetchResult.isAfterLast();
expect(result).assertTrue();
fetchResult.close();
done();
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import checkAlbumAttrTest from './AbsAlbum/checkAttr'
import albumGetAssetsTest from './AbsAlbum/getAssets'
import addAssetsTest from './Album/addAssets'
import albumCommitModifyTest from './Album/commitModify'
import removeAssetsTest from './Album/removeAssets'
import getPhotoAccessHelperTest from './getPhotoAccessHelper'
import albumCloseTest from './AlbumFetchResult/close'
import albumGetAllObjectTest from './AlbumFetchResult/getAllObjects'
import albumGetCountTest from './AlbumFetchResult/getCount'
import albumGetFirstObjectTest from './AlbumFetchResult/getFirstObject'
import albumGetLastObjectTest from './AlbumFetchResult/getLastObject'
import albumGetNextObjectTest from './AlbumFetchResult/getNextObject'
import albumGetPositionObjectTest from './AlbumFetchResult/getObjectByPosition'
import albumIsAfterLastTest from './AlbumFetchResult/isAfterLast'
import assetCloseTest from './PhotoAssetFetchResult/close'
import assetGetAllObjectTest from './PhotoAssetFetchResult/getAllObjects'
import assetGetCountTest from './PhotoAssetFetchResult/getCount'
import assetGetFirstObjectTest from './PhotoAssetFetchResult/getFirstObject'
import assetGetLastObjectTest from './PhotoAssetFetchResult/getLastObject'
import assetGetNextObjectTest from './PhotoAssetFetchResult/getNextObject'
import assetGetPositionObjectTest from './PhotoAssetFetchResult/getObjectByPosition'
import assetIsAfterLastTest from './PhotoAssetFetchResult/isAfterLast'
import createAssetTest from './PhotoAccessHelper/createAsset'
import getAlbumsTest from './PhotoAccessHelper/getAlbums'
import getAssetsTest from './PhotoAccessHelper/getAssets'
import unRegisterChangeTest from './PhotoAccessHelper/unRegisterChange'
import registerChangeTest from './PhotoAccessHelper/registerChange'
import releaseTest from './PhotoAccessHelper/release'
import checkAttrTest from './PhotoAsset/checkAttr'
import closeTest from './PhotoAsset/close'
import commitModifyTest from './PhotoAsset/commitModify'
import getTest from './PhotoAsset/get'
import getReadOnlyFdTest from './PhotoAsset/getReadOnlyFd'
import getThumbnailTest from './PhotoAsset/getThumbnail'
export default function testsuite () {
getPhotoAccessHelperTest()
checkAlbumAttrTest()
albumGetAssetsTest()
addAssetsTest()
albumCommitModifyTest()
removeAssetsTest()
albumCloseTest()
albumGetAllObjectTest()
albumGetCountTest()
albumGetFirstObjectTest()
albumGetLastObjectTest()
albumGetNextObjectTest()
albumGetPositionObjectTest()
albumIsAfterLastTest()
assetCloseTest()
assetGetAllObjectTest()
assetGetCountTest()
assetGetFirstObjectTest()
assetGetLastObjectTest()
assetGetNextObjectTest()
assetGetPositionObjectTest()
assetIsAfterLastTest()
createAssetTest()
getAlbumsTest()
getAssetsTest()
unRegisterChangeTest()
registerChangeTest()
releaseTest()
checkAttrTest()
closeTest()
commitModifyTest()
getTest()
getReadOnlyFdTest()
getThumbnailTest()
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
albumKeys,
albumType,
albumSubtype,
fetchOption,
checkUserAlbum,
checkSystemAlbum,
sleep,
} from '../../../../../../../common'
export default function getAlbumsTest () {
describe('getAlbumsTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ALBUMS_0000
* @tc.name : getAlbums_callback_000
* @tc.desc : get an user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAlbums_callback_000', 0, async function (done) {
const testNum = 'getAlbums_callback_000';
try {
let albumNames = [
'getAlbums_callback_000_01',
'getAlbums_callback_000_02',
'getAlbums_callback_000_03',
'getAlbums_callback_000_04',
'getAlbums_callback_000_05'
];
const beforeResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC);
const count = beforeResult.getCount();
beforeResult.close();
// Firstly, create some albums
for (let i = 0; i < albumNames.length; i++) {
await helper.createAlbum(albumNames[i]);
}
// Secondly, get albums and check
helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, async (err, fetchResult) => {
try {
if (err !== undefined) {
console.info(`${testNum} getAlbums failed, err: ${err}`);
expect(false).assertTrue();
} else {
const totalCount = fetchResult.getCount();
expect(totalCount).assertEqual(count + albumNames.length);
let albumList = await fetchResult.getAllObjects();
fetchResult.close();
for (let i = count; i < totalCount; i++) {
checkUserAlbum(expect, testNum, albumList[i], albumNames[i - count], '');
}
}
} catch (error) {
console.info(`${testNum} getAlbums failed, error: ${error}`);
}
done()
})
} catch (error) {
console.info(`${testNum} failed, error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ALBUMS_0100
* @tc.name : getAlbums_callback_001
* @tc.desc : get user albums by albumName
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getAlbums_callback_001', 0, async function (done) {
const testNum = 'getAlbums_callback_001';
try {
// Firstly, create an album
let albumName = testNum;
const album = await helper.createAlbum(albumName);
checkUserAlbum(expect, testNum, album, albumName, '');
// Secondly, query the newly created album by albumName, the fetch count should be 1
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps, async (err, fetchResult) => {
try {
if (err != undefined) {
console.info(`${testNum} getAlbums failed, err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} fetchResult: ${fetchResult.getCount()}`);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.close();
}
} catch (error) {
console.info(`${testNum} getAlbums failed, error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed, error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ALBUMS_0200
* @tc.name : getAlbums_callback_002
* @tc.desc : get system albums by albumType
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ALBUM_003', 0, async function (done) {
const testNum = 'getAlbums_callback_002';
try {
let subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let count = 0;
for (let i = 0; i < subTypes.length; i++) {
helper.getAlbums(albumType.SYSTEM, subTypes[i], async (err, fetchResult) => {
try {
if (err !== undefined) {
console.info(`${testNum} getAlbums Failed! err: ${err}`);
expect(false).assertTrue();
} else {
const album = await fetchResult.getFirstObject();
fetchResult.close()
checkSystemAlbum(expect, testNum, album, subTypes[i]);
count++;
}
} catch (error) {
console.info(`${testNum} getAlbums Failed! error: ${error}`);
}
if (i + 1 === subTypes.length) {
expect(count === subTypes.length);
done();
}
})
await sleep(50);
}
} catch (error) {
console.info(`${testNum} failed, error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
}
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ALBUMS_0000
* @tc.name : getAlbums_promise_000
* @tc.desc : get an user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAlbums_promise_000', 0, async function (done) {
const testNum = 'getAlbums_promise_000';
try {
let albumNames = [
'getAlbums_promise_000_01',
'getAlbums_promise_000_02',
'getAlbums_promise_000_03',
'getAlbums_promise_000_04',
'getAlbums_promise_000_05'
];
const beforeResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC);
const count = beforeResult.getCount();
beforeResult.close();
// Firstly, create some albums
for (let i = 0; i < albumNames.length; i++) {
await helper.createAlbum(albumNames[i]);
}
// Secondly, get albums and check
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC);
const totalCount = fetchResult.getCount();
expect(totalCount).assertEqual(count + albumNames.length);
let albumList = await fetchResult.getAllObjects();
fetchResult.close();
for (let i = count; i < totalCount; i++) {
checkUserAlbum(expect, testNum, albumList[i], albumNames[i - count], '');
}
done();
} catch (error) {
console.info(`${testNum} failed, error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ALBUMS_0100
* @tc.name : getAlbums_promise_001
* @tc.desc : get user albums by albumName
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getAlbums_promise_001', 0, async function (done) {
const testNum = 'getAlbums_promise_001';
try {
// Firstly, create an album
let albumName = testNum;
const album = await helper.createAlbum(albumName);
checkUserAlbum(expect, testNum, album, albumName, '');
// Secondly, query the newly created album by albumName, the fetch count should be 1
const fetchOps = fetchOption(testNum, albumKeys.ALBUM_NAME, albumName);
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
expect(fetchResult.getCount()).assertEqual(1);
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed, error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ALBUMS_0200
* @tc.name : getAlbums_promise_002
* @tc.desc : get system albums by albumType
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_PHOTOACCESS_HELPER_PROMISE_GET_ALBUM_003', 0, async function (done) {
const testNum = 'getAlbums_promise_002';
try {
let subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
albumSubtype.FAVORITE,
];
let count = 0;
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album>;
for (let i = 0; i < subTypes.length; i++) {
fetchResult = await helper.getAlbums(albumType.SYSTEM, subTypes[i]);
const album = await fetchResult.getFirstObject();
checkSystemAlbum(expect, testNum, album, subTypes[i]);
count++;
}
fetchResult.close();
expect(count === subTypes.length);
done();
} catch (error) {
console.info(`${testNum} failed, error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
photoKeys,
fetchOption,
} from '../../../../../../../common'
export default function getAssetsTest () {
describe('getAssetsTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
function getAssetsCallbackTest (done, testNum, fetchOps, expectCount) {
try {
helper.getAssets(fetchOps, (err, fetchResult) => {
try {
if (err !== undefined) {
console.info(`${testNum} getAssets failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(fetchResult.getCount()).assertEqual(expectCount);
fetchResult.close();
}
} catch (error) {
console.info(`${testNum} getAssets failed; error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
}
function getAssetsAbnormalCallbackTest (done, testNum, fetchOps) {
try {
helper.getAssets(fetchOps, (err, fetchResult) => {
try {
if (err !== undefined) {
console.info(`${testNum} getAssets failed; err: ${err}`);
expect(true).assertTrue();
} else {
console.info(`${testNum} getAssets suc; fetchResult: ${fetchResult.getCount()}`);
fetchResult.close();
expect(false).assertTrue();
}
} catch (error) {
console.info(`${testNum} getAssets failed; error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
}
}
async function getAssetsPromiseTest (done, testNum, fetchOps, expectCount) {
try {
const fetchResult = await helper.getAssets(fetchOps);
expect(fetchResult.getCount()).assertEqual(expectCount);
fetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
}
async function getAssetsAbnormalPromiseTest (done, testNum, fetchOps) {
try {
await helper.getAssets(fetchOps);
expect(false).assertTrue();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
}
}
//image
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0000
* @tc.name : getAssets_callback_000
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAssets_callback_000', 0, async function (done) {
const testNum = 'getAssets_callback_000';
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
const expectCount = 1;
await getAssetsCallbackTest(done, testNum, fetchOps, expectCount);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0100
* @tc.name : getAssets_callback_001
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAssets_callback_001', 0, async function (done) {
const testNum = 'getAssets_callback_001';
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, '666');
const expectCount = 0;
await getAssetsCallbackTest(done, testNum, fetchOps, expectCount);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0300
* @tc.name : getAssets_callback_003
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getAssets_callback_003', 2, async function (done) {
const testNum = 'getAssets_callback_003';
await getAssetsAbnormalCallbackTest(done, testNum, undefined);
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ASSETS_0000
* @tc.name : getAssets_promise_000
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAssets_promise_000', 0, async function (done) {
const testNum = 'getAssets_promise_000';
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
const expectCount = 1;
await getAssetsPromiseTest(done, testNum, fetchOps, expectCount);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ASSETS_0100
* @tc.name : getAssets_promise_001
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAssets_promise_001', 0, async function (done) {
const testNum = 'getAssets_promise_001';
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, '666');
const expectCount = 0;
await getAssetsPromiseTest(done, testNum, fetchOps, expectCount);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ASSETS_0300
* @tc.name : getAssets_promise_003
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getAssets_promise_003', 2, async function (done) {
const testNum = 'getAssets_promise_003';
await getAssetsAbnormalPromiseTest(done, testNum, undefined);
});
//video
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0400
* @tc.name : getAssets_callback_004
* @tc.desc : getAssets video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAssets_callback_004', 0, async function (done) {
const testNum = 'getAssets_callback_004';
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
const expectCount = 1;
await getAssetsCallbackTest(done, testNum, fetchOps, expectCount);
});
//promise
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ASSETS_0400
* @tc.name : getAssets_promise_004
* @tc.desc : getAssets video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getAssets_promise_004', 0, async function (done) {
const testNum = 'getAssets_promise_004';
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
const expectCount = 1;
await getAssetsPromiseTest(done, testNum, fetchOps, expectCount);
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
sleep,
fetchOption,
photoKeys,
getFileAsset,
photoFetchOption,
photoType,
} from '../../../../../../../common'
export default function registerChangeTest () {
describe('registerChangeTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
const { NOTIFY_ADD, NOTIFY_UPDATE, NOTIFY_REMOVE, NOTIFY_ALBUM_ADD_ASSET, NOTIFY_ALBUM_REMOVE_ASSET } =
photoAccessHelper.NotifyType;
const DEFAULT_PHOTO_URI = photoAccessHelper.DefaultChangeUri.DEFAULT_PHOTO_URI;
const DEFAULT_ALBUM_URI = photoAccessHelper.DefaultChangeUri.DEFAULT_ALBUM_URI;
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_0100
* @tc.name : on_callback_001
* @tc.desc : listening motify file displayName, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('on_callback_001', 0, async function (done) {
const testNum = 'on_callback_001';
try {
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.unRegisterChange(asset.uri);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
await sleep(1000);
expect(count).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_0700
* @tc.name : on_callback_007
* @tc.desc : listening create album, type NOTIFY_ADD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('on_callback_007', 0, async function (done) {
const testNum = 'on_callback_007';
try {
let changeDataUri = '';
let listenCount = 0;
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
changeDataUri = changeData.uris[0];
expect(changeData.type).assertEqual(NOTIFY_ADD);
});
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
let creatAlbumUri = album.albumUri;
await sleep(2000);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
expect(creatAlbumUri).assertEqual(changeDataUri);
expect(listenCount).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_0800
* @tc.name : on_callback_008
* @tc.desc : listening change albumName, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('on_callback_008', 0, async function (done) {
const testNum = 'on_callback_008';
try {
let albumUri = '';
let count = 0;
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
helper.registerChange(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.albumName = Date.now() + album.albumName;
await album.commitModify();
await sleep(1000);
helper.unRegisterChange(albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_1100
* @tc.name : on_callback_011
* @tc.desc : listening album removeAssets, type NOTIFY_ALBUM_ADD_ASSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('on_callback_011', 0, async function (done) {
const testNum = 'on_callback_011';
try {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on11.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
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);
});
await album.addAssets([asset]);
await sleep(1000);
helper.unRegisterChange(album.albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_1200
* @tc.name : on_callback_012
* @tc.desc : listening album removeAssets, type NOTIFY_ALBUM_REMOVE_ASSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('on_callback_012', 0, async function (done) {
const testNum = 'on_callback_012';
try {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on12.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await album.addAssets([asset]);
await sleep(500);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
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);
});
await album.removeAssets([asset]);
await sleep(1000);
helper.unRegisterChange(album.albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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'
export default function releaseTest () {
describe('releaseTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_RELEASE_0000
* @tc.name : release_callback_000
* @tc.desc : Release photoAccessHelper instance
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('release_callback_000', 0, async function (done) {
const testNum = 'release_callback_000'
try {
await helper.release((err) => {
if (err !== undefined) {
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_PROMISE_RELEASE_0000
* @tc.name : release_promise_000
* @tc.desc : Release photoAccessHelper instance
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('release_promise_000', 0, async function (done) {
const testNum = 'release_promise_000'
try {
await helper.release()
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue()
done();
}
})
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 {
sleep,
fetchOption,
photoKeys,
getFileAsset,
photoFetchOption,
photoType,
albumType,
albumSubtype
} from '../../../../../../../common'
export default function unRegisterChangeTest () {
describe('unRegisterChangeTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
const DEFAULT_PHOTO_URI = photoAccessHelper.DefaultChangeUri.DEFAULT_PHOTO_URI;
const DEFAULT_ALBUM_URI = photoAccessHelper.DefaultChangeUri.DEFAULT_ALBUM_URI;
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_OFF_0100
* @tc.name : off_001
* @tc.desc : off listening motify file displayName, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('off_001', 0, async function (done) {
const testNum = 'off_001';
try {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'off01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.unRegisterChange(asset.uri);
await sleep(100);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_OFF_0700
* @tc.name : off_007
* @tc.desc : off listening create album, type NOTIFY_ADD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('off_007', 0, async function (done) {
const testNum = 'off_007';
try {
let count = 0;
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
await sleep(100);
let albumName = testNum + Date.now();
await helper.createAlbum(albumName);
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_OFF_0800
* @tc.name : off_008
* @tc.desc : off listening create album, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('off_008', 0, async function (done) {
const testNum = 'off_008';
try {
let albumUri = '';
let count = 0;
let albumName = testNum + Date.now();
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
helper.registerChange(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.unRegisterChange(albumUri);
await sleep(100);
album.albumName = Date.now() + album.albumName;
await album.commitModify();
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_OFF_1000
* @tc.name : off_010
* @tc.desc : off listening change album overUri, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('off_010', 0, async function example(done) {
const testNum = 'off_010';
try {
let albumUri = '';
let count = 0;
let albumName = testNum + Date.now();
let album = await helper.createAlbum(albumName);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'off10.jpg');
const asset = await getFileAsset(testNum, fetchOps);
albumUri = album.albumUri;
await album.addAssets([asset]);
await sleep(500);
helper.registerChange(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.unRegisterChange(albumUri);
await sleep(100);
album.albumName = testNum + album.albumName;
await album.commitModify();
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_OFF_1100
* @tc.name : off_011
* @tc.desc : off listening album removeAssets, type NOTIFY_ALBUM_ADD_ASSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('off_011', 0, async function (done) {
const testNum = 'off_011';
try {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'off11.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.unRegisterChange(album.albumUri);
await sleep(100);
await album.addAssets([asset]);
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_OFF_1200
* @tc.name : off_012
* @tc.desc : off listening album removeAssets, type NOTIFY_ALBUM_REMOVE_ASSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('off_012', 0, async function (done) {
const testNum = 'off_012';
try {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'off12.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await album.addAssets([asset]);
await sleep(500);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.unRegisterChange(album.albumUri);
await sleep(100);
await album.removeAssets([asset]);
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_OFF_1500
* @tc.name : off_015
* @tc.desc : off remove all listening
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('off_015', 0, async function (done) {
const testNum = 'off_015';
try {
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'off15.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let listenCount = 0;
await sleep(500);
helper.registerChange(asset.uri, false, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData1: ${JSON.stringify(changeData)}`);
});
helper.registerChange(asset.uri, false, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData2: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.unRegisterChange(asset.uri);
await sleep(100);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
await sleep(1000);
expect(listenCount).assertEqual(0);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_OFF_CALLBACK_0000
* @tc.name : off_callback_000
* @tc.desc : off remove specified callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('off_callback_000', 0, async function (done) {
const testNum = 'off_callback_000';
try {
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'offCb01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let listenCount1 = 0;
let listenCount2 = 0;
await sleep(500);
const callback1 = async (changeData) => {
listenCount1++;
console.info(`${testNum} callback1: ${JSON.stringify(changeData)}`);
};
const callback2 = async (changeData) => {
listenCount2++;
console.info(`${testNum} callback2: ${JSON.stringify(changeData)}`);
helper.unRegisterChange(asset.uri, callback2);
};
helper.registerChange(asset.uri, false, callback1);
helper.registerChange(asset.uri, false, callback2);
await sleep(100);
helper.unRegisterChange(asset.uri, callback1);
await sleep(100);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
await sleep(1000);
expect(listenCount1).assertEqual(0);
expect(listenCount2).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import { describe, it, expect } from 'deccjsunit/index'
import {
photoKeys,
fetchOption,
getFileAsset,
getId,
photoType
} from '../../../../../../../common'
export default function checkAttrTest () {
describe('checkAttrTest', function () {
async function checkAssetAttr (done, testNum, displayName, mediaType) {
try {
let key = photoKeys.DISPLAY_NAME;
let uri = 'file://media/Photo/';
const fetchOps = fetchOption(testNum, key, displayName);
const asset = await getFileAsset(testNum, fetchOps);
console.info(`${testNum} uri: ${asset.uri} filetype: ${asset.photoType} displayName: ${asset.displayName}`)
const id = getId(asset.uri);
expect(asset.uri).assertEqual(uri + id);
expect(asset.photoType).assertEqual(mediaType);
expect(asset.displayName).assertEqual(displayName);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
done();
expect(false).assertTrue();
}
}
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_FILE_ASSET_CHECK_ASSET_ATTR_0000
* @tc.name : photoAsset_000
* @tc.desc : check image uri displayName photoType
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('photoAsset_000', 0, async function (done) {
const testNum = 'photoAsset_000';
const displayName = '01.jpg';
const mediaType = photoType.IMAGE;
await checkAssetAttr(done, testNum, displayName, mediaType);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_FILE_ASSET_CHECK_ASSET_ATTR_0100
* @tc.name : photoAsset_001
* @tc.desc : check video uri displayName photoType
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('photoAsset_001', 0, async function (done) {
const testNum = 'photoAsset_001';
const displayName = '01.mp4';
const mediaType = photoType.VIDEO;
await checkAssetAttr(done, testNum, displayName, mediaType);
});
})
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsPhotoAccessTest"
},
{
"name": "form_description",
"value": "photoAccess"
},
{
"name": "serviceability_description",
"value": "photoAccess"
},
{
"name": "description_application",
"value": "photoAccess test"
},
{
"name": "app_name",
"value": "ActsPhotoAccessTest"
}
]
}
\ No newline at end of file
{
"src": [
"MainAbility/pages/index/index"
]
}
\ No newline at end of file
文件已添加
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部