提交 95a4e0f3 编写于 作者: Y yangbo

fixbug 3.0

Signed-off-by: Nyangbo <yangbo258@huawei.com>
上级 29b3d07a
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import bundleManager from '@ohos.bundle.bundleManager';
......
......@@ -35,12 +35,12 @@ import assetGetLastObjectTest from './PhotoAssetFetchResult/getLastObject'
import assetGetNextObjectTest from './PhotoAssetFetchResult/getNextObject'
import assetGetPositionObjectTest from './PhotoAssetFetchResult/getObjectByPosition'
import assetIsAfterLastTest from './PhotoAssetFetchResult/isAfterLast'
import createAssetTest from './UserFileManager/createAsset'
import getAlbumsTest from './UserFileManager/getAlbums'
import getAssetsTest from './UserFileManager/getAssets'
import offTest from './UserFileManager/off'
import onTest from './UserFileManager/on'
import releaseTest from './UserFileManager/release'
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'
......@@ -74,8 +74,8 @@ export default function testsuite () {
createAssetTest()
getAlbumsTest()
getAssetsTest()
offTest()
onTest()
unRegisterChangeTest()
registerChangeTest()
releaseTest()
checkAttrTest()
closeTest()
......
......@@ -133,9 +133,9 @@ export default function getAssetsTest () {
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('getAssets_callback_003', 0, async function (done) {
it('getAssets_callback_003', 2, async function (done) {
const testNum = 'getAssets_callback_003';
await getAssetsAbnormalCallbackTest(done, testNum, undefined);
});
......@@ -177,9 +177,9 @@ export default function getAssetsTest () {
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('getAssets_promise_003', 0, async function (done) {
it('getAssets_promise_003', 2, async function (done) {
const testNum = 'getAssets_promise_003';
await getAssetsAbnormalPromiseTest(done, testNum, undefined);
});
......
......@@ -25,8 +25,8 @@ import {
photoType,
} from '../../../../../../../common'
export default function onTest () {
describe('onTest', function () {
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;
......@@ -48,10 +48,10 @@ export default function onTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
......@@ -81,10 +81,10 @@ export default function onTest () {
try {
let changeDataUri = '';
let listenCount = 0;
helper.on(DEFAULT_ALBUM_URI, true, async (changeData) => {
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.off(DEFAULT_ALBUM_URI);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
changeDataUri = changeData.uris[0];
expect(changeData.type).assertEqual(NOTIFY_ADD);
});
......@@ -92,7 +92,7 @@ export default function onTest () {
let album = await helper.createAlbum(albumName);
let creatAlbumUri = album.albumUri;
await sleep(2000);
helper.off(DEFAULT_ALBUM_URI);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
expect(creatAlbumUri).assertEqual(changeDataUri);
expect(listenCount).assertEqual(1);
done();
......@@ -120,7 +120,7 @@ export default function onTest () {
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
helper.on(albumUri, false, async (changeData) => {
helper.registerChange(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
......@@ -129,7 +129,7 @@ export default function onTest () {
album.albumName = Date.now() + album.albumName;
await album.commitModify();
await sleep(1000);
helper.off(albumUri);
helper.unRegisterChange(albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
......@@ -156,16 +156,16 @@ export default function onTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.on(album.albumUri, false, async (changeData) => {
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);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await album.addAssets([asset]);
await sleep(1000);
helper.off(album.albumUri);
helper.unRegisterChange(album.albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
......@@ -193,16 +193,16 @@ export default function onTest () {
let count = 0;
await album.addAssets([asset]);
await sleep(500);
helper.on(album.albumUri, false, async (changeData) => {
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);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await album.removeAssets([asset]);
await sleep(1000);
helper.off(album.albumUri);
helper.unRegisterChange(album.albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
......
......@@ -27,8 +27,8 @@ import {
albumSubtype
} from '../../../../../../../common'
export default function offTest () {
describe('offTest', function () {
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;
......@@ -48,12 +48,12 @@ export default function offTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
await sleep(100);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
......@@ -80,12 +80,12 @@ export default function offTest () {
const testNum = 'off_007';
try {
let count = 0;
helper.on(DEFAULT_ALBUM_URI, true, async (changeData) => {
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(DEFAULT_ALBUM_URI);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
await sleep(100);
let albumName = testNum + Date.now();
await helper.createAlbum(albumName);
......@@ -116,12 +116,12 @@ export default function offTest () {
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
helper.on(albumUri, false, async (changeData) => {
helper.registerChange(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(albumUri);
helper.unRegisterChange(albumUri);
await sleep(100);
album.albumName = Date.now() + album.albumName;
await album.commitModify();
......@@ -155,12 +155,12 @@ export default function offTest () {
albumUri = album.albumUri;
await album.addAssets([asset]);
await sleep(500);
helper.on(albumUri, false, async (changeData) => {
helper.registerChange(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(albumUri);
helper.unRegisterChange(albumUri);
await sleep(100);
album.albumName = testNum + album.albumName;
await album.commitModify();
......@@ -191,12 +191,12 @@ export default function offTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.on(album.albumUri, false, async (changeData) => {
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(album.albumUri);
helper.unRegisterChange(album.albumUri);
await sleep(100);
await album.addAssets([asset]);
await sleep(1000);
......@@ -227,12 +227,12 @@ export default function offTest () {
let count = 0;
await album.addAssets([asset]);
await sleep(500);
helper.on(album.albumUri, false, async (changeData) => {
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(album.albumUri);
helper.unRegisterChange(album.albumUri);
await sleep(100);
await album.removeAssets([asset]);
await sleep(1000);
......@@ -260,16 +260,16 @@ export default function offTest () {
const asset = await getFileAsset(testNum, fetchOps);
let listenCount = 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData1: ${JSON.stringify(changeData)}`);
});
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData2: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
await sleep(100);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
......@@ -307,13 +307,13 @@ export default function offTest () {
const callback2 = async (changeData) => {
listenCount2++;
console.info(`${testNum} callback2: ${JSON.stringify(changeData)}`);
helper.off(asset.uri, callback2);
helper.unRegisterChange(asset.uri, callback2);
};
helper.on(asset.uri, false, callback1);
helper.on(asset.uri, false, callback2);
helper.registerChange(asset.uri, false, callback1);
helper.registerChange(asset.uri, false, callback2);
await sleep(100);
helper.off(asset.uri, callback1);
helper.unRegisterChange(asset.uri, callback1);
await sleep(100);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
......
......@@ -117,14 +117,14 @@ export default function commitModifyTest () {
it('photoAsset_commitModify_callback_000', 0, async function (done) {
const testNum = 'photoAsset_commitModify_callback_000';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyCb01.jpg');
const newTitle = new Date().getTime() + '.jpg';
const newTitle = new Date().getTime() + testNum;
await commitModifyCallback(done, testNum, fetchOps, newTitle);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0100
* @tc.name : photoAsset_commitModify_callback_001
* @tc.desc : modify image displayName '中中...' (83)
* @tc.desc : modify image displayName '一...' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -133,10 +133,9 @@ export default function commitModifyTest () {
const testNum = 'photoAsset_commitModify_callback_001';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyCb02.jpg');
let newTitle = '';
for (let i = 0; i < 83; i++) {
newTitle += '';
for (let i = 0; i < 84; i++) {
newTitle += '';
}
newTitle += '.jpg';
await commitModifyCallback(done, testNum, fetchOps, newTitle);
});
......@@ -155,7 +154,6 @@ export default function commitModifyTest () {
for (let i = 0; i < 251; i++) {
newTitle += 'a';
}
newTitle += '.jpg';
await commitModifyCallback(done, testNum, fetchOps, newTitle);
});
......@@ -194,7 +192,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0500
* @tc.name : photoAsset_commitModify_callback_005
* @tc.desc : modify image displayName '中中....jpg' (84)
* @tc.desc : modify image displayName '二二....jpg' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -205,7 +203,7 @@ export default function commitModifyTest () {
const type = 'displayName';
let value = '';
for (let i = 0; i < 84; i++) {
value += '';
value += '';
}
value += '.jpg';
await commitModifyAbnormalCallback(done, testNum, fetchOps, type, value);
......@@ -214,7 +212,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0600
* @tc.name : photoAsset_commitModify_callback_006
* @tc.desc : modify image displayName 'aaaaaaa...' (252)
* @tc.desc : modify image displayName 'bbbbbbb...' (252)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -225,7 +223,7 @@ export default function commitModifyTest () {
const type = 'displayName';
let value = '';
for (let i = 0; i < 252; i++) {
value += 'a';
value += 'b';
}
value += '.jpg';
await commitModifyAbnormalCallback(done, testNum, fetchOps, type, value);
......@@ -243,14 +241,14 @@ export default function commitModifyTest () {
it('photoAsset_commitModify_callback_007', 0, async function (done) {
const testNum = 'photoAsset_commitModify_callback_007';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyCb01.mp4');
const newTitle = new Date().getTime() + '.mp4';
const newTitle = new Date().getTime() + testNum;
await commitModifyCallback(done, testNum, fetchOps, newTitle);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0800
* @tc.name : photoAsset_commitModify_callback_008
* @tc.desc : modify video displayName '中中...' (83)
* @tc.desc : modify video displayName '三三...' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -259,17 +257,16 @@ export default function commitModifyTest () {
const testNum = 'photoAsset_commitModify_callback_008';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyCb02.mp4');
let newTitle = '';
for (let i = 0; i < 83; i++) {
newTitle += '';
for (let i = 0; i < 84; i++) {
newTitle += '';
}
newTitle += '.mp4';
await commitModifyCallback(done, testNum, fetchOps, newTitle);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0900
* @tc.name : photoAsset_commitModify_callback_009
* @tc.desc : modify image displayName 'aaaaaaa...' (251)
* @tc.desc : modify image displayName 'ccccccc...' (251)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -279,9 +276,8 @@ export default function commitModifyTest () {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyCb03.mp4');
let newTitle = '';
for (let i = 0; i < 251; i++) {
newTitle += 'a';
newTitle += 'c';
}
newTitle += '.mp4';
await commitModifyCallback(done, testNum, fetchOps, newTitle);
});
......@@ -320,7 +316,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_1200
* @tc.name : photoAsset_commitModify_callback_012
* @tc.desc : modify image displayName '中中...' (84)
* @tc.desc : modify image displayName '四四...' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -331,7 +327,7 @@ export default function commitModifyTest () {
const type = 'displayName';
let value = '';
for (let i = 0; i < 84; i++) {
value += '';
value += '';
}
value += '.mp4';
await commitModifyAbnormalCallback(done, testNum, fetchOps, type, value);
......@@ -340,7 +336,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_1300
* @tc.name : photoAsset_commitModify_callback_013
* @tc.desc : modify image displayName 'aaaaaaa...' (252)
* @tc.desc : modify image displayName 'ddddddd...' (252)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -351,7 +347,7 @@ export default function commitModifyTest () {
const type = 'displayName';
let value = '';
for (let i = 0; i < 252; i++) {
value += 'a';
value += 'd';
}
value += '.mp4';
await commitModifyAbnormalCallback(done, testNum, fetchOps, type, value);
......@@ -377,7 +373,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0100
* @tc.name : photoAsset_commitModify_promise_001
* @tc.desc : modify image displayName '中中...' (83)
* @tc.desc : modify image displayName '五五...' (83)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -387,16 +383,15 @@ export default function commitModifyTest () {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyPro02.jpg');
let newTitle = '';
for (let i = 0; i < 83; i++) {
newTitle += '';
newTitle += '';
}
newTitle += '.jpg';
await commitModifyPromise(done, testNum, fetchOps, newTitle);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0200
* @tc.name : photoAsset_commitModify_promise_002
* @tc.desc : modify image displayName 'aaaaaaa...' (251)
* @tc.desc : modify image displayName 'eeeeeee...' (251)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -406,9 +401,8 @@ export default function commitModifyTest () {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyPro03.jpg');
let newTitle = '';
for (let i = 0; i < 251; i++) {
newTitle += 'a';
newTitle += 'e';
}
newTitle += '.jpg';
await commitModifyPromise(done, testNum, fetchOps, newTitle);
});
......@@ -447,7 +441,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0500
* @tc.name : photoAsset_commitModify_promise_005
* @tc.desc : modify image displayName '中中....jpg' (84)
* @tc.desc : modify image displayName '六六....jpg' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -458,7 +452,7 @@ export default function commitModifyTest () {
const type = 'displayName';
let value = '';
for (let i = 0; i < 84; i++) {
value += '';
value += '';
}
value += '.jpg';
await commitModifyAbnormalPromise(done, testNum, fetchOps, type, value);
......@@ -467,7 +461,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0600
* @tc.name : photoAsset_commitModify_promise_006
* @tc.desc : modify image displayName 'aaaaaaa...' (252)
* @tc.desc : modify image displayName 'fffffff...' (252)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -478,7 +472,7 @@ export default function commitModifyTest () {
const type = 'displayName';
let value = '';
for (let i = 0; i < 252; i++) {
value += 'a';
value += 'f';
}
value += '.jpg';
await commitModifyAbnormalPromise(done, testNum, fetchOps, type, value);
......@@ -503,7 +497,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0800
* @tc.name : photoAsset_commitModify_promise_008
* @tc.desc : modify video displayName '中中...' (83)
* @tc.desc : modify video displayName '七七...' (83)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -513,16 +507,15 @@ export default function commitModifyTest () {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyPro02.mp4');
let newTitle = '';
for (let i = 0; i < 83; i++) {
newTitle += '';
newTitle += '';
}
newTitle += '.mp4';
await commitModifyPromise(done, testNum, fetchOps, newTitle);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0900
* @tc.name : photoAsset_commitModify_promise_009
* @tc.desc : modify image displayName 'aaaaaaa...' (251)
* @tc.desc : modify image displayName 'ggggggg...' (251)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -532,9 +525,8 @@ export default function commitModifyTest () {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'modifyPro03.mp4');
let newTitle = '';
for (let i = 0; i < 251; i++) {
newTitle += 'a';
newTitle += 'g';
}
newTitle += '.mp4';
await commitModifyPromise(done, testNum, fetchOps, newTitle);
});
......@@ -573,7 +565,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_1200
* @tc.name : photoAsset_commitModify_promise_012
* @tc.desc : modify image displayName '中中...' (84)
* @tc.desc : modify image displayName '八八...' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -584,7 +576,7 @@ export default function commitModifyTest () {
const type = 'displayName';
let value = '';
for (let i = 0; i < 84; i++) {
value += '';
value += '';
}
value += '.mp4';
await commitModifyAbnormalPromise(done, testNum, fetchOps, type, value);
......@@ -593,7 +585,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_1300
* @tc.name : photoAsset_commitModify_promise_013
* @tc.desc : modify image displayName 'aaaaaaa...' (252)
* @tc.desc : modify image displayName 'hhhhhhh...' (252)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -604,7 +596,7 @@ export default function commitModifyTest () {
const type = 'displayName';
let value = '';
for (let i = 0; i < 252; i++) {
value += 'a';
value += 'h';
}
value += '.mp4';
await commitModifyAbnormalPromise(done, testNum, fetchOps, type, value);
......
......@@ -14,6 +14,7 @@
*/
// @ts-nocheck
import fileio from "@ohos.fileio";
import { describe, it, expect } from 'deccjsunit/index'
import {
photoKeys,
......@@ -34,7 +35,12 @@ export default function getReadOnlyFdTest () {
expect(false).assertTrue();
} else {
console.info(`${testNum} fd: ${fd}`);
expect(isNum(fd)).assertTrue();
try {
await fileio.write(fd, testNum);
expect(false).assertTrue();
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
}
done();
})
......@@ -50,11 +56,11 @@ export default function getReadOnlyFdTest () {
const asset = await getFileAsset(testNum, fetchOps);
const fd = await asset.getReadOnlyFd();
console.info(`${testNum} fd: ${fd}`);
expect(isNum(fd)).assertTrue();
await fileio.write(fd, testNum);
expect(false).assertTrue();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
}
......
......@@ -31,50 +31,58 @@ export default function assetCloseTest () {
let fetchResult = await helper.getAssets(fetchOps);
expect(fetchResult.getCount() > 0).assertTrue();
fetchResult.close();
let testCount = 0;
let count = 0;
try {
testCount++;
fetchResult.getCount();
} catch (error) {
console.info(`${testNum} getCount failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getFirstObject();
} catch (error) {
console.info(`${testNum} getFirstObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getNextObject();
} catch (error) {
console.info(`${testNum} getNextObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getLastObject();
} catch (error) {
console.info(`${testNum} getLastObject failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getObjectByPosition(0);
} catch (error) {
console.info(`${testNum} getObjectByPosition failed; error: ${error}`);
count++;
}
try {
testCount++;
await fetchResult.getAllObjects();
} catch (error) {
console.info(`${testNum} getAllObjects failed; error: ${error}`);
count++;
}
try {
testCount++;
fetchResult.isAfterLast();
} catch (error) {
console.info(`${testNum} isAfterLast failed; error: ${error}`);
count++;
}
expect(count).assertEqual(7);
expect(count).assertEqual(testCount);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
......
......@@ -37,6 +37,8 @@ export default function assetGetLastObjectTest () {
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
const ret = fetchResult.isAfterLast();
expect(ret).assertTrue();
}
} catch (error) {
console.info(`${testNum} getLastObject failed; error: ${error}`);
......@@ -56,8 +58,10 @@ export default function assetGetLastObjectTest () {
let fetchResult = await helper.getAssets(fetchOps);
expect(fetchResult.getCount() > 0).assertTrue();
const asset = await fetchResult.getLastObject();
fetchResult.close();
expect(asset !== undefined).assertTrue();
const ret = fetchResult.isAfterLast();
fetchResult.close();
expect(ret).assertTrue();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
......
......@@ -30,13 +30,14 @@ export default function assetGetPositionObjectTest () {
try {
let fetchResult = await helper.getAssets(fetchOps);
expect(fetchResult.getCount() > 0).assertTrue();
const firAsset = await fetchResult.getFirstObject();
fetchResult.getObjectByPosition(0, (err, asset) => {
try {
if (err !== undefined) {
console.info(`${testNum} getObjectByPosition failed; err: ${err}`);
expect(false).assertTrue();
} else {
expect(asset !== undefined).assertTrue();
expect(asset.displayName).assertEqual(firAsset.displayName);
}
} catch (error) {
console.info(`${testNum} getObjectByPosition failed; error: ${error}`);
......@@ -55,9 +56,10 @@ export default function assetGetPositionObjectTest () {
try {
let fetchResult = await helper.getAssets(fetchOps);
expect(fetchResult.getCount() > 0).assertTrue();
const firAsset = await fetchResult.getFirstObject();
const asset = await fetchResult.getObjectByPosition(0);
fetchResult.close();
expect(asset !== undefined).assertTrue();
expect(asset.displayName).assertEqual(firAsset.displayName);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
......
......@@ -17,8 +17,8 @@ ohos_js_hap_suite("photoAccess_system_js_hap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":photoAccess_js_assets",
":photoAccess_resources",
":photoAccessSystem_js_assets",
":photoAccessSystem_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
......@@ -27,17 +27,17 @@ ohos_js_hap_suite("photoAccess_system_js_hap") {
subsystem_name = "multimedia"
}
ohos_app_scope("photoAccess_app_profile") {
ohos_app_scope("photoAccessSystem_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("photoAccess_js_assets") {
ohos_js_assets("photoAccessSystem_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("photoAccess_resources") {
ohos_resources("photoAccessSystem_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":photoAccess_app_profile" ]
deps = [ ":photoAccessSystem_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
......@@ -273,11 +273,11 @@ export default function publicApiTestWithSystemApiTest () {
await createAsset.close(fd);
let count = 0;
await sleep(500);
helper.on(createAsset.uri, false, async (changeData) => {
helper.registerChange(createAsset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
helper.off(createAsset.uri);
helper.unRegisterChange(createAsset.uri);
await sleep(100);
fd = await createAsset.getReadOnlyFd();
await createAsset.close(fd);
......@@ -306,12 +306,12 @@ export default function publicApiTestWithSystemApiTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count= 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
await sleep(100);
await asset.setFavorite(true);
await sleep(1000);
......@@ -340,12 +340,12 @@ export default function publicApiTestWithSystemApiTest () {
await asset.setFavorite(true);
let count= 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
await sleep(100);
await asset.setFavorite(false);
await sleep(1000);
......@@ -373,12 +373,12 @@ export default function publicApiTestWithSystemApiTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count= 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} asset changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
await sleep(100);
await helper.deleteAssets([asset.uri]);
await sleep(2000);
......@@ -414,14 +414,14 @@ export default function publicApiTestWithSystemApiTest () {
const trashFileAsset = await trashFetchResult.getFirstObject();
let count= 0;
await sleep(500);
helper.on(trashFileAsset.uri, false, async (changeData) => {
helper.registerChange(trashFileAsset.uri, false, async (changeData) => {
count++;
console.info(`off_005 changeData: ${JSON.stringify(changeData)}`);
expect(false).assertTrue();
done();
});
await sleep(100);
helper.off(trashFileAsset.uri);
helper.unRegisterChange(trashFileAsset.uri);
await sleep(100);
await trashAlbum.recoverAssets([trashFileAsset]);
await sleep(2000);
......@@ -457,12 +457,12 @@ export default function publicApiTestWithSystemApiTest () {
const trashFileAsset = await trashFetchResult.getFirstObject();
let count= 0;
await sleep(500);
helper.on(trashAlbum.albumUri, false, async (changeData) => {
helper.registerChange(trashAlbum.albumUri, false, async (changeData) => {
count++;
console.info(`off_006 changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(trashAlbum.albumUri);
helper.unRegisterChange(trashAlbum.albumUri);
await sleep(100);
await trashAlbum.deleteAssets([trashFileAsset]);
await sleep(1000);
......@@ -489,12 +489,12 @@ export default function publicApiTestWithSystemApiTest () {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
await sleep(500);
helper.on(DEFAULT_ALBUM_URI, true, async (changeData) => {
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
count++;
console.info(`off_009 changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(DEFAULT_ALBUM_URI);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
await sleep(100);
await helper.deleteAlbums([album]);
await sleep(1000);
......@@ -527,12 +527,12 @@ export default function publicApiTestWithSystemApiTest () {
await helper.deleteAssets([fileAsset.uri]);
await sleep(500);
let listenCount = 0;
helper.on(DEFAULT_ALBUM_URI, true, async (changeData) => {
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(DEFAULT_ALBUM_URI);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
await sleep(100);
// 1
let albumName = 'testAlbum' + Date.now();
......@@ -581,12 +581,12 @@ export default function publicApiTestWithSystemApiTest () {
let listenCount = 0;
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'off14.jpg');
const asset = await getFileAsset(testNum, fetchOps);
helper.on(DEFAULT_PHOTO_URI, true, async (changeData) => {
helper.registerChange(DEFAULT_PHOTO_URI, true, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
helper.off(DEFAULT_PHOTO_URI);
helper.unRegisterChange(DEFAULT_PHOTO_URI);
await sleep(100);
// 1
let fd = await asset.open('rw');
......@@ -639,7 +639,7 @@ export default function publicApiTestWithSystemApiTest () {
await createAsset.close(fd);
let count = 0;
await sleep(500);
helper.on(createAsset.uri, false, async (changeData) => {
helper.registerChange(createAsset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ADD);
......@@ -649,7 +649,7 @@ export default function publicApiTestWithSystemApiTest () {
fd = await createAsset.getReadOnlyFd();
await createAsset.close(fd);
await sleep(1000);
helper.off(createAsset.uri);
helper.unRegisterChange(createAsset.uri);
expect(count).assertEqual(0);
done();
} catch (error) {
......@@ -674,7 +674,7 @@ export default function publicApiTestWithSystemApiTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count= 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
......@@ -682,7 +682,7 @@ export default function publicApiTestWithSystemApiTest () {
});
await asset.setFavorite(true);
await sleep(1000);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
expect(count).assertEqual(1);
done();
} catch (error) {
......@@ -708,7 +708,7 @@ export default function publicApiTestWithSystemApiTest () {
await asset.setFavorite(true);
let count= 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
......@@ -716,7 +716,7 @@ export default function publicApiTestWithSystemApiTest () {
});
await asset.setFavorite(false);
await sleep(1000);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
expect(count).assertEqual(1);
done();
} catch (error) {
......@@ -749,7 +749,7 @@ export default function publicApiTestWithSystemApiTest () {
const trashFileAsset = await trashFetchResult.getFirstObject();
let count= 0;
await sleep(500);
helper.on(trashFileAsset.uri, false, async (changeData) => {
helper.registerChange(trashFileAsset.uri, false, async (changeData) => {
count++;
console.info(`on_callback_005 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ADD);
......@@ -757,7 +757,7 @@ export default function publicApiTestWithSystemApiTest () {
});
await trashAlbum.recoverAssets([trashFileAsset]);
await sleep(2000);
helper.off(trashFileAsset.uri);
helper.unRegisterChange(trashFileAsset.uri);
expect(count).assertEqual(1);
done();
} catch (error) {
......@@ -790,15 +790,15 @@ export default function publicApiTestWithSystemApiTest () {
const trashFileAsset = await trashFetchResult.getFirstObject();
let count= 0;
await sleep(500);
helper.on(trashAlbum.albumUri, false, async (changeData) => {
helper.registerChange(trashAlbum.albumUri, false, async (changeData) => {
count++;
console.info(`on_callback_006 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_REMOVE_ASSET);
// expect(changeData.extraUris[0]).assertEqual(trashFileAsset.uri);
expect(changeData.extraUris[0]).assertEqual(trashFileAsset.uri);
});
await trashAlbum.deleteAssets([trashFileAsset]);
await sleep(1000);
helper.off(trashAlbum.albumUri);
helper.unRegisterChange(trashAlbum.albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
......@@ -824,7 +824,7 @@ export default function publicApiTestWithSystemApiTest () {
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
helper.on(DEFAULT_ALBUM_URI, true, async (changeData) => {
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
listenCount++;
if (listenCount < 2) {
console.info(`on_callback_009 changeData: ${JSON.stringify(changeData)}`);
......@@ -836,7 +836,7 @@ export default function publicApiTestWithSystemApiTest () {
await helper.deleteAlbums([album]);
await sleep(1000);
expect(listenCount).assertEqual(1);
helper.off(DEFAULT_ALBUM_URI);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
done();
} catch (error) {
console.log(`on_callback_009: tryError: $${error}`);
......@@ -860,7 +860,7 @@ export default function publicApiTestWithSystemApiTest () {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on14.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let photoAssetUri = asset.uri;
helper.on(DEFAULT_PHOTO_URI, true, async (changeData) => {
helper.registerChange(DEFAULT_PHOTO_URI, true, async (changeData) => {
listenCount++;
switch (listenCount) {
case 1:
......@@ -894,7 +894,7 @@ export default function publicApiTestWithSystemApiTest () {
await sleep(500);
await asset.setFavorite(false);
await sleep(1000);
helper.off(DEFAULT_PHOTO_URI);
helper.unRegisterChange(DEFAULT_PHOTO_URI);
expect(listenCount).assertEqual(3);
done();
} catch (error) {
......@@ -921,7 +921,7 @@ export default function publicApiTestWithSystemApiTest () {
await asset.close(fd);
let listenCount = 0;
await sleep(500);
helper.on(asset.uri, false, async (changeData) => {
helper.registerChange(asset.uri, false, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
......@@ -936,7 +936,7 @@ export default function publicApiTestWithSystemApiTest () {
await sleep(500);
}
await sleep(2000);
helper.off(asset.uri);
helper.unRegisterChange(asset.uri);
expect(listenCount).assertEqual(10);
done();
} catch (error) {
......@@ -965,7 +965,7 @@ export default function publicApiTestWithSystemApiTest () {
await fileAsset.close(fd);
let count= 0;
await sleep(1000);
helper.on(fileAsset.uri, false, async (changeData) => {
helper.registerChange(fileAsset.uri, false, async (changeData) => {
count++;
console.info(`on_callback_017 changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
......@@ -979,7 +979,7 @@ export default function publicApiTestWithSystemApiTest () {
await fileAsset.close(fd);
await sleep(1000);
expect(count).assertEqual(1);
helper.off(fileAsset.uri);
helper.unRegisterChange(fileAsset.uri);
done();
} catch (error) {
console.log(`on_callback_017: tryError: $${error}`);
......
......@@ -14,15 +14,15 @@
},
{
"name": "form_description",
"value": "photoAccess"
"value": "photoAccessSystem"
},
{
"name": "serviceability_description",
"value": "photoAccess"
"value": "photoAccessSystem"
},
{
"name": "description_application",
"value": "photoAccess test"
"value": "photoAccessSystem test"
},
{
"name": "app_name",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册