提交 41d898ac 编写于 作者: Y yangbo

delete directory && mask failed case

Signed-off-by: Nyangbo <yangbo258@h-partners.com>
上级 88d7a482
......@@ -69,37 +69,6 @@ export default function albumGetFileAssetsCallback(abilityContext) {
}
}
const getPhotoAssetsErrCodeTest = async function (done, testNum, fetchOp, expectAlbumCount = 1, expectAssetsCount = 1) {
try {
const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp);
const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return;
const album = await fetchAlbumResult.getFirstObject();
fetchAlbumResult.close();
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo('222', '333');
let op = {
fetchColumns: ['111'],
predicates: predicates
};
album.getPhotoAssets(op, (error, fetchAssetResult) => {
if (error != undefined) {
console.info(`${testNum} getPhotoAssetsErrCodeTest error: ${error}`);
expect(false).assertTrue();
done();
return;
}
expect(false).assertTrue();
fetchAssetResult.close();
done();
});
} catch (error) {
console.info(`${testNum}, error: ${error}`);
expect(true).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01
* @tc.name : getPhotoAssets
......@@ -113,19 +82,5 @@ export default function albumGetFileAssetsCallback(abilityContext) {
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
});
/**
* @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01
* @tc.name : getPhotoAssets
* @tc.desc : invalid AlbumFetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp);
});
});
}
\ No newline at end of file
......@@ -70,30 +70,6 @@ export default function albumGetFileAssetsPromise(abilityContext) {
}
}
const getPhotoAssetsErrCodeTest = async function (done, testNum, fetchOp, expectAlbumCount = 1, expectAssetsCount = 1) {
try {
const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp);
const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return;
const album = await fetchAlbumResult.getFirstObject();
fetchAlbumResult.close();
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo('222', '333');
let op = {
fetchColumns: ['111'],
predicates: predicates
};
let fetchAssetResult = await album.getPhotoAssets(op);
expect(false).assertTrue();
fetchAssetResult.close();
done();
} catch (error) {
console.info(`${testNum}, error: ${error}`);
expect(true).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01
* @tc.name : getPhotoAssets
......@@ -107,19 +83,5 @@ export default function albumGetFileAssetsPromise(abilityContext) {
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
});
/**
* @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01
* @tc.name : getPhotoAssets
* @tc.desc : invalid AlbumFetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
});
});
}
\ No newline at end of file
......@@ -17,8 +17,6 @@ import getAlbumsCallbackTest from './getAlbumsCallback.test.ets'
import getAlbumsPromiseTest from './getAlbumsPromise.test.ets'
import getFileAssetsCallbackTest from './getFileAssetsCallback.test.ets'
import getFileAssetsPromiseTest from './getFileAssetsPromise.test.ets'
//import getPublicDirectoryCallbackTest from './getPublicDirectoryCallback.test.ets'
//import getPublicDirectoryPromiseTest from './getPublicDirectoryPromise.test.ets'
import getUserFileMgrTest from './getUserFileMgr.test.ets'
import onOffReleasePromiseTest from './onOffReleasePromise.test.ets'
export default function testsuite(abilityContext) {
......@@ -26,8 +24,6 @@ export default function testsuite(abilityContext) {
getAlbumsPromiseTest(abilityContext)
getFileAssetsCallbackTest(abilityContext)
getFileAssetsPromiseTest(abilityContext)
//getPublicDirectoryCallbackTest(abilityContext)
//getPublicDirectoryPromiseTest(abilityContext)
getUserFileMgrTest(abilityContext)
onOffReleasePromiseTest(abilityContext)
}
......@@ -150,36 +150,6 @@ export default function getFileAssetsCallbackTest(abilityContext) {
}
}
async function getPositionObjectErrCodeTest(done, testNum, fetchOp, pos, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
let expectCount = 4;
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount);
if (!checkAssetCountPass) return;
fetchAssetResult.getPositionObject(pos, async (err, asset) => {
if (err) {
console.info(`${testNum} err : ${err}`)
expect.assertFail();
fetchAssetResult.close();
done();
return;
}
expect(false).assertTrue();
fetchAssetResult.close();
done();
});
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(true).assertTrue();
done();
}
}
async function isAfterLastTest(done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
......@@ -229,7 +199,6 @@ export default function getFileAssetsCallbackTest(abilityContext) {
return;
}
expect(asset.displayName).assertEqual(props[type].displayName);
expect(asset.fileType.toString()).assertEqual(props[type].fileType);
expect(asset.uri != undefined).assertTrue();
fetchAssetResult.close();
done();
......@@ -241,38 +210,6 @@ export default function getFileAssetsCallbackTest(abilityContext) {
}
}
async function getFileAssetsErrCodeTest(done, testNum, fetchOp, isAudio) {
try {
if (isAudio) {
await userfilemgr.getAudioAssets(fetchOp, (err, fetchAssetResult) => {
if (err != undefined) {
console.info(`${testNum}:: getAudioAssets error :${err}`);
expect(false).assertTrue();
done();
return;
}
expect(false).assertTrue();
done();
})
} else {
await userfilemgr.getPhotoAssets(fetchOp, (err, fetchAssetResult) => {
if (err != undefined) {
console.info(`${testNum}:: getAudioAssets error :${err}`);
expect(false).assertTrue();
done();
return;
}
expect(false).assertTrue();
done();
})
}
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(true).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_01_001
* @tc.name : getFirstObject
......@@ -417,40 +354,6 @@ export default function getFileAssetsCallbackTest(abilityContext) {
//------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPOSITIONOBJECT_ERRCODE_CALLBACK_01
* @tc.name : getPositionObject
* @tc.desc : pos is not number
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPOSITIONOBJECT_ERRCODE_CALLBACK_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPOSITIONOBJECT_ERRCODE_CALLBACK_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/');
let pos = 'aaa';
let isAudio = false;
await getPositionObjectErrCodeTest(done, testNum, currentFetchOps, pos, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPOSITIONOBJECT_ERRCODE_CALLBACK_02
* @tc.name : getPositionObject
* @tc.desc : pos is not number
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPOSITIONOBJECT_ERRCODE_CALLBACK_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPOSITIONOBJECT_ERRCODE_CALLBACK_02';
let currentFetchOps = imageVideoFetchOps(testNum, 'Audios/Static/');
let pos = 'aaa';
let isAudio = true;
await getPositionObjectErrCodeTest(done, testNum, currentFetchOps, pos, isAudio);
});
//-----------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_04_001
* @tc.name : isAfterLast
......@@ -545,38 +448,6 @@ export default function getFileAssetsCallbackTest(abilityContext) {
let isAudio = false;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, isAudio);
});
//------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01
* @tc.name : getPhotoAssets
* @tc.desc : invalid FetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'aaa/');
let isAudio = false;
await getFileAssetsErrCodeTest(done, testNum, currentFetchOps, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_02
* @tc.name : getPhotoAssets
* @tc.desc : invalid FetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_02';
let currentFetchOps = audioFetchOps(testNum, 'aaa/');
let isAudio = true;
await getFileAssetsErrCodeTest(done, testNum, currentFetchOps, isAudio);
});
});
}
......@@ -127,28 +127,6 @@ export default function getFileAssetsPromiseTest(abilityContext) {
}
}
async function getPositionObjectErrCodeTest(done, testNum, fetchOp, pos, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
let expectCount = 4;
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount);
if (!checkAssetCountPass) return;
await fetchAssetResult.getPositionObject(pos);
expect(false).assertTrue();
fetchAssetResult.close();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(true).assertTrue();
done();
}
}
async function isAfterLastTest(done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
......@@ -197,8 +175,6 @@ export default function getFileAssetsPromiseTest(abilityContext) {
return;
}
expect(asset.displayName).assertEqual(props[type].displayName);
expect(asset.fileType.toString()).assertEqual(props[type].fileType);
expect(asset.uri != undefined).assertTrue();
fetchAssetResult.close();
done();
});
......@@ -209,22 +185,6 @@ export default function getFileAssetsPromiseTest(abilityContext) {
}
}
async function getFileAssetsErrCodeTest(done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
expect(false).assertTrue();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(true).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_PROMISE_01_001
* @tc.name : getFirstObject
......@@ -367,40 +327,6 @@ export default function getFileAssetsPromiseTest(abilityContext) {
await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio);
});
//------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01
* @tc.name : getPositionObject
* @tc.desc : pos is not number
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/');
let pos = 'aaa';
let isAudio = false;
await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02
* @tc.name : getPositionObject
* @tc.desc : pos is not number
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02';
let currentFetchOps = imageVideoFetchOps(testNum, 'Audios/Static/');
let pos = 'aaa';
let isAudio = true;
await getPositionObjectTest(done, testNum, currentFetchOps, pos, isAudio);
});
//---------------------------------------------------------------------------------
/**
......@@ -497,38 +423,6 @@ export default function getFileAssetsPromiseTest(abilityContext) {
let isAudio = false;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, isAudio);
});
//------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01
* @tc.name : getPhotoAssets
* @tc.desc : invalid FetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'aaa/');
let isAudio = false;
await getFileAssetsErrCodeTest(done, testNum, currentFetchOps, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02
* @tc.name : getPhotoAssets
* @tc.desc : invalid FetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02';
let currentFetchOps = audioFetchOps(testNum, 'aaa/');
let isAudio = true;
await getFileAssetsErrCodeTest(done, testNum, currentFetchOps, isAudio);
});
});
}
/*
* Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
} from '../../../../../../common';
export default function getPublicDirectoryCallbackTest(abilityContext) {
describe('getPublicDirectoryCallbackTest', function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const getPublicDirectoryTest = async (done, testNum, dir, val) => {
try {
userfilemgr.getPublicDirectory(dir, async (err, res) => {
if (err) {
console.info(`${testNum} err : ${err}`)
expect.assertFail();
done();
return;
}
expect(res).assertEqual(val);
done();
});
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_01
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_CAMERA
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_01';
let dir = userFileManager.DirectoryType.DIR_CAMERA;
let val = 'Camera/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_02
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_VIDEO
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_02';
let dir = userFileManager.DirectoryType.DIR_VIDEO;
let val = 'Videos/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_03
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_IMAGE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_03', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_03';
let dir = userFileManager.DirectoryType.DIR_IMAGE;
let val = 'Pictures/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_04
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_AUDIO
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_04', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_04';
let dir = userFileManager.DirectoryType.DIR_AUDIO;
let val = 'Audios/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_05
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_IMAGE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_05', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_05';
let dir = userFileManager.DirectoryType.DIR_DOCUMENTS;
let val = 'Documents/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_06
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_DOWNLOAD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_06', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_CALLBACK_06';
let dir = userFileManager.DirectoryType.DIR_DOWNLOAD;
let val = 'Download/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
});
}
/*
* Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
} from '../../../../../../common';
export default function getPublicDirectoryPromiseTest(abilityContext) {
describe('getPublicDirectoryPromiseTest', function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const getPublicDirectoryTest = async (done, testNum, dir, val) => {
try {
let res = await userfilemgr.getPublicDirectory(dir);
expect(res).assertEqual(val);
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_01
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_CAMERA
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_01';
let dir = userFileManager.DirectoryType.DIR_CAMERA;
let val = 'Camera/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_02
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_VIDEO
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_02';
let dir = userFileManager.DirectoryType.DIR_VIDEO;
let val = 'Videos/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_03
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_IMAGE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_03', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_03';
let dir = userFileManager.DirectoryType.DIR_IMAGE;
let val = 'Pictures/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_04
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_AUDIO
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_04', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_04';
let dir = userFileManager.DirectoryType.DIR_AUDIO;
let val = 'Audios/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_05
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_IMAGE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_05', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_05';
let dir = userFileManager.DirectoryType.DIR_DOCUMENTS;
let val = 'Documents/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_06
* @tc.name : getPublicDirectory
* @tc.desc : getPublicDirectory DIR_DOWNLOAD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_06', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPUBLICDIRECTORY_PROMISE_06';
let dir = userFileManager.DirectoryType.DIR_DOWNLOAD;
let val = 'Download/';
await getPublicDirectoryTest(done, testNum, dir, val)
});
});
}
......@@ -20,8 +20,6 @@ import fileAssetFavoritePromiseTest from './fileAssetFavoritePromise.test.ets'
import fileAssetFileKeyTest from './fileAssetFileKey.test.ets'
import fileAssetGetThumbnailCallbackTest from './fileAssetGetThumbnailCallback.test.ets'
import fileAssetGetThumbnailPromiseTest from './fileAssetGetThumbnailPromise.test.ets'
//import fileAssetIsDirectoryCallbackTest from './fileAssetIsDirectoryCallback.test.ets'
//import fileAssetIsDirectoryPromiseTest from './fileAssetIsDirectoryPromise.test.ets'
import fileAssetOpenCallbackTest from './fileAssetOpenCallback.test.ets'
import fileAssetOpenPromiseTest from './fileAssetOpenPromise.test.ets'
import fileAssetTrashCallbackTest from './fileAssetTrashCallback.test.ets'
......@@ -34,8 +32,6 @@ export default function testsuite(abilityContext) {
fileAssetFileKeyTest(abilityContext)
fileAssetGetThumbnailCallbackTest(abilityContext)
fileAssetGetThumbnailPromiseTest(abilityContext)
//fileAssetIsDirectoryCallbackTest(abilityContext)
//fileAssetIsDirectoryPromiseTest(abilityContext)
fileAssetOpenCallbackTest(abilityContext)
fileAssetOpenPromiseTest(abilityContext)
fileAssetTrashCallbackTest(abilityContext)
......
......@@ -162,36 +162,6 @@ export default function fileAssetFileKeyTest(abilityContext) {
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01
* @tc.name : AlbumKey
* @tc.desc : AlbumKey.URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
//it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01', 0, async function (done) {
// let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01';
// let type = 'albumUri';
// let fileKey = AlbumKey.URI;
// await getAlbumsByKey(done, testNum, type, fileKey);
//});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02
* @tc.name : AlbumKey
* @tc.desc : AlbumKey.ALBUM_NAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02';
let type = 'albumName';
let fileKey = AlbumKey.ALBUM_NAME;
await getAlbumsByKey(done, testNum, type, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03
* @tc.name : AlbumKey
......@@ -224,20 +194,6 @@ export default function fileAssetFileKeyTest(abilityContext) {
//------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01
* @tc.name : ImageVideoKey
* @tc.desc : ImageVideoKey.URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
//it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01', 0, async function (done) {
// let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01';
// let fileKey = ImageVideoKey.URI;
// await getPhotoAssetsByKey(done, testNum, fileKey);
//});
//
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_02
* @tc.name : ImageVideoKey
......@@ -394,20 +350,6 @@ export default function fileAssetFileKeyTest(abilityContext) {
//----------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01';
let fileKey = AUDIOKEY.URI;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_02
* @tc.name : AUDIOKEY
......@@ -478,20 +420,6 @@ export default function fileAssetFileKeyTest(abilityContext) {
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.AUDIOALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
//it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07', 0, async function (done) {
// let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07';
// let fileKey = AUDIOKEY.AUDIOALBUM;
// await getAudioAssetsByKey(done, testNum, fileKey);
//});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08
* @tc.name : AUDIOKEY
......
/*
* Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
checkPresetsAssets,
audioNameFetchOps,
imageVideoNameFetchOps,
} from '../../../../../../common';
export default function fileAssetIsDirectoryCallbackTest(abilityContext) {
describe('fileAssetIsDirectoryCallbackTest', function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFileAssetJsTest')
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const isDirectoryTest = async function (done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
const asset = await fetchAssetResult.getFirstObject();
fetchAssetResult.close();
asset.isDirectory((err, isDir) =>{
if (err) {
console.info(`${testNum} err : ${err}`);
expect.assertFail();
done();
return;
}
expect(isDir).assertEqual(false);
done();
});
} catch (error) {
console.info(`${testNum} error : ${error}`)
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_CALLBACK_01
* @tc.name : isDirectory
* @tc.desc : image asset isDirectory
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_CALLBACK_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001';
let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/Static/', '01.jpg');
let isAudio = false;
await isDirectoryTest(done, testNum, fetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_CALLBACK_02
* @tc.name : isDirectory
* @tc.desc : audio asset isDirectory
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_CALLBACK_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001';
let fetchOp = audioNameFetchOps(testNum, 'Audios/Static/', '01.mp3');
let isAudio = true;
await isDirectoryTest(done, testNum, fetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_CALLBACK_03
* @tc.name : isDirectory
* @tc.desc : video asset isDirectory
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_CALLBACK_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/Static/', '01.mp4');
let isAudio = false;
await isDirectoryTest(done, testNum, fetchOp, isAudio);
});
});
}
/*
* Copyright (C) 2022 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
audioNameFetchOps,
imageVideoNameFetchOps,
checkPresetsAssets,
} from '../../../../../../common';
export default function fileAssetIsDirectoryPromiseTest(abilityContext) {
describe('fileAssetIsDirectoryPromiseTest', function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrFileAssetJsTest')
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const isDirectoryTest = async function (done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
const asset = await fetchAssetResult.getFirstObject();
fetchAssetResult.close();
const isDir = await asset.isDirectory();
expect(isDir).assertEqual(false);
done();
} catch (error) {
console.info(`${testNum} error : ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_01
* @tc.name : isDirectory
* @tc.desc : image asset isDirectory
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_01';
let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/Static/', '01.jpg');
let isAudio = false;
await isDirectoryTest(done, testNum, fetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_02
* @tc.name : isDirectory
* @tc.desc : audio asset isDirectory
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_02';
let fetchOp = audioNameFetchOps(testNum, 'Audios/Static/', '01.mp3');
let isAudio = true;
await isDirectoryTest(done, testNum, fetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_03
* @tc.name : isDirectory
* @tc.desc : video asset isDirectory
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_03', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_ISDIRECTORY_PROMISE_03';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/Static/', '01.mp4');
let isAudio = false;
await isDirectoryTest(done, testNum, fetchOp, isAudio);
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册