提交 40dc8cc7 编写于 作者: Y yangbo

bugfix

Signed-off-by: Nyangbo <yangbo258@huawei.com>
上级 7465ed7f
......@@ -126,9 +126,18 @@ export function isNum(value) : boolean {
return typeof value === 'number' && !isNaN(value);
};
export function getId(uri) : string {
let index = uri.lastIndexOf('/');
export function getAssetId(uri) : string {
const tag = 'Photo/';
const index = uri.indexOf(tag);
let str = uri.substring(index + tag.length);
console.info(`getAssetId str: ${str}`);
return str;
}
export function getAlbumId(uri) : string {
const index = uri.lastIndexOf('/');
let str = uri.substring(index + 1);
console.info(`getAlbumId str: ${str}`);
return str;
}
......
......@@ -20,7 +20,7 @@ import {
albumSubtype,
fetchOption,
getFileAsset,
getId,
getAlbumId,
photoKeys
} from '../../../../../../../common'
......@@ -34,7 +34,7 @@ export default function checkAlbumAttrTest () {
expect(album.albumType).assertEqual(albumType.USER);
expect(album.albumSubtype).assertEqual(albumSubtype.USER_GENERIC);
expect(album.albumName).assertEqual(testNum);
const id = getId(album.albumUri);
const id = getAlbumId(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);
......
......@@ -45,7 +45,7 @@ export default function registerChangeTest () {
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
await sleep(550);
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
......@@ -53,6 +53,7 @@ export default function registerChangeTest () {
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
await sleep(550);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
......@@ -86,10 +87,11 @@ export default function registerChangeTest () {
changeDataUri = changeData.uris[0];
expect(changeData.type).assertEqual(NOTIFY_ADD);
});
await sleep(550);
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
let creatAlbumUri = album.albumUri;
await sleep(2000);
await sleep(1000);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
expect(creatAlbumUri).assertEqual(changeDataUri);
expect(listenCount).assertEqual(1);
......@@ -117,13 +119,14 @@ export default function registerChangeTest () {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
await sleep(550);
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);
});
await sleep(550);
album.albumName = Date.now() + album.albumName;
await album.commitModify();
await sleep(1000);
......@@ -153,7 +156,7 @@ export default function registerChangeTest () {
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on11.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
await sleep(550);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
......@@ -161,6 +164,7 @@ export default function registerChangeTest () {
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await sleep(550);
await album.addAssets([asset]);
await sleep(1000);
helper.unRegisterChange(album.albumUri);
......@@ -190,7 +194,7 @@ export default function registerChangeTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await album.addAssets([asset]);
await sleep(500);
await sleep(550);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
......@@ -198,6 +202,7 @@ export default function registerChangeTest () {
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await sleep(550);
await album.removeAssets([asset]);
await sleep(1000);
helper.unRegisterChange(album.albumUri);
......
......@@ -43,14 +43,14 @@ export default function unRegisterChangeTest () {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'off01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
await sleep(550);
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(asset.uri);
await sleep(100);
await sleep(550);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
......@@ -80,9 +80,9 @@ export default function unRegisterChangeTest () {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
await sleep(100);
await sleep(550);
let albumName = testNum + Date.now();
await helper.createAlbum(albumName);
await sleep(1000);
......@@ -111,14 +111,14 @@ export default function unRegisterChangeTest () {
let albumName = testNum + Date.now();
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
await sleep(550);
helper.registerChange(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(albumUri);
await sleep(100);
await sleep(550);
album.albumName = Date.now() + album.albumName;
await album.commitModify();
await sleep(1000);
......@@ -150,14 +150,14 @@ export default function unRegisterChangeTest () {
const asset = await getFileAsset(testNum, fetchOps);
albumUri = album.albumUri;
await album.addAssets([asset]);
await sleep(500);
await sleep(550);
helper.registerChange(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(albumUri);
await sleep(100);
await sleep(550);
album.albumName = testNum + album.albumName;
await album.commitModify();
await sleep(1000);
......@@ -186,14 +186,14 @@ export default function unRegisterChangeTest () {
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'off11.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
await sleep(550);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(album.albumUri);
await sleep(100);
await sleep(550);
await album.addAssets([asset]);
await sleep(1000);
expect(count).assertEqual(0);
......@@ -222,14 +222,14 @@ export default function unRegisterChangeTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await album.addAssets([asset]);
await sleep(500);
await sleep(550);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(album.albumUri);
await sleep(100);
await sleep(550);
await album.removeAssets([asset]);
await sleep(1000);
expect(count).assertEqual(0);
......@@ -255,7 +255,7 @@ export default function unRegisterChangeTest () {
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'off15.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let listenCount = 0;
await sleep(500);
await sleep(550);
helper.registerChange(asset.uri, false, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData1: ${JSON.stringify(changeData)}`);
......@@ -264,9 +264,9 @@ export default function unRegisterChangeTest () {
listenCount++;
console.info(`${testNum} changeData2: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(asset.uri);
await sleep(100);
await sleep(550);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
......@@ -295,7 +295,7 @@ export default function unRegisterChangeTest () {
const asset = await getFileAsset(testNum, fetchOps);
let listenCount1 = 0;
let listenCount2 = 0;
await sleep(500);
await sleep(550);
const callback1 = async (changeData) => {
listenCount1++;
console.info(`${testNum} callback1: ${JSON.stringify(changeData)}`);
......@@ -308,9 +308,9 @@ export default function unRegisterChangeTest () {
helper.registerChange(asset.uri, false, callback1);
helper.registerChange(asset.uri, false, callback2);
await sleep(100);
await sleep(550);
helper.unRegisterChange(asset.uri, callback1);
await sleep(100);
await sleep(550);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
......
......@@ -18,7 +18,7 @@ import {
photoKeys,
fetchOption,
getFileAsset,
getId,
getAssetId,
photoType
} from '../../../../../../../common'
......@@ -30,7 +30,7 @@ export default function checkAttrTest () {
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);
const id = getAssetId(asset.uri);
const expectUri = 'file://media/Photo/' + id;
const isIncludes = asset.uri.includes(expectUri);
expect(isIncludes).assertTrue();
......
......@@ -18,7 +18,7 @@ import {
photoKeys,
photoFetchOption,
getFileAsset,
getId,
getAssetId,
isNum,
photoType,
} from '../../../../../../../common'
......@@ -30,7 +30,7 @@ export default function getTest () {
let asset = await getFileAsset(testNum, fetchOps);
console.info(`${testNum} key: ${key}, value: ${value}, asset.key: ${asset.get(key)}`);
if (key === 'uri') {
const id = getId(asset.get(key));
const id = getAssetId(asset.get(key));
const expectUri = value + id;
const uri = asset.get(key).toString();
const isIncludes = uri.includes(expectUri);
......
......@@ -15,7 +15,7 @@
import fileio from "@ohos.fileio";
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import { describe, beforeAll, afterEach, it, expect } from 'deccjsunit/index'
import {
albumType,
albumSubtype,
......@@ -40,6 +40,10 @@ export default function publicApiTestWithSystemApiTest () {
await getPermission()
})
afterEach(async function () {
await sleep(550)
})
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0100
......@@ -277,13 +281,14 @@ export default function publicApiTestWithSystemApiTest () {
let fd = await createAsset.open('rw');
await createAsset.close(fd);
let count = 0;
await sleep(500);
await sleep(550);
helper.registerChange(createAsset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(550);
helper.unRegisterChange(createAsset.uri);
await sleep(100);
await sleep(550);
fd = await createAsset.getReadOnlyFd();
await createAsset.close(fd);
await sleep(1000);
......@@ -310,14 +315,14 @@ export default function publicApiTestWithSystemApiTest () {
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'off02.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count= 0;
await sleep(500);
await sleep(550);
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(asset.uri);
await sleep(100);
await sleep(550);
await asset.setFavorite(true);
await sleep(1000);
expect(count).assertEqual(0);
......@@ -344,14 +349,14 @@ export default function publicApiTestWithSystemApiTest () {
const asset = await getFileAsset(testNum, fetchOps);
await asset.setFavorite(true);
let count= 0;
await sleep(500);
await sleep(550);
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(asset.uri);
await sleep(100);
await sleep(550);
await asset.setFavorite(false);
await sleep(1000);
expect(count).assertEqual(0);
......@@ -377,16 +382,16 @@ export default function publicApiTestWithSystemApiTest () {
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'off04.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count= 0;
await sleep(500);
await sleep(550);
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} asset changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(asset.uri);
await sleep(100);
await sleep(550);
await helper.deleteAssets([asset.uri]);
await sleep(2000);
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
......@@ -418,18 +423,18 @@ export default function publicApiTestWithSystemApiTest () {
let trashFetchResult = await trashAlbum.getAssets(fetchOps);
const trashFileAsset = await trashFetchResult.getFirstObject();
let count= 0;
await sleep(500);
await sleep(550);
helper.registerChange(trashFileAsset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(false).assertTrue();
done();
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(trashFileAsset.uri);
await sleep(100);
await sleep(550);
await trashAlbum.recoverAssets([trashFileAsset]);
await sleep(2000);
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
......@@ -461,14 +466,14 @@ export default function publicApiTestWithSystemApiTest () {
let trashFetchResult = await trashAlbum.getAssets(fetchOps);
const trashFileAsset = await trashFetchResult.getFirstObject();
let count= 0;
await sleep(500);
await sleep(550);
helper.registerChange(trashAlbum.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(trashAlbum.albumUri);
await sleep(100);
await sleep(550);
await trashAlbum.deleteAssets([trashFileAsset]);
await sleep(1000);
expect(count).assertEqual(0);
......@@ -494,14 +499,14 @@ export default function publicApiTestWithSystemApiTest () {
let count= 0;
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
await sleep(500);
await sleep(550);
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
await sleep(100);
await sleep(550);
await helper.deleteAlbums([album]);
await sleep(1000);
expect(count).assertEqual(0);
......@@ -531,30 +536,30 @@ export default function publicApiTestWithSystemApiTest () {
let fd = await fileAsset.open('rw');
await fileAsset.close(fd);
await helper.deleteAssets([fileAsset.uri]);
await sleep(500);
await sleep(550);
let listenCount = 0;
helper.registerChange(DEFAULT_ALBUM_URI, true, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
await sleep(100);
await sleep(550);
// 1
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
// 2
await sleep(500);
await sleep(550);
album.albumName = 'hello';
await album.commitModify();
// 3
await sleep(500);
await sleep(550);
await album.addAssets([asset]);
// 5
await sleep(500);
await sleep(550);
await album.removeAssets([asset]);
// 6
await sleep(500);
await sleep(550);
await helper.deleteAlbums([album]);
// 7
let trashAlbumList = await helper.getAlbums(albumType.SYSTEM, albumSubtype.TRASH);
......@@ -587,32 +592,33 @@ export default function publicApiTestWithSystemApiTest () {
let listenCount = 0;
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'off14.jpg');
const asset = await getFileAsset(testNum, fetchOps);
await sleep(550);
helper.registerChange(DEFAULT_PHOTO_URI, true, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
});
await sleep(100);
await sleep(550);
helper.unRegisterChange(DEFAULT_PHOTO_URI);
await sleep(100);
await sleep(550);
// 1
let fd = await asset.open('rw');
await asset.close(fd);
// 2
await sleep(500);
await sleep(550);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
// 3
await sleep(500);
await sleep(550);
await asset.setFavorite(true);
// 4
await sleep(500);
await sleep(550);
await asset.setFavorite(false);
// 5
await sleep(500);
await sleep(550);
await helper.deleteAssets([asset.uri]);
// 6
await sleep(500);
await sleep(550);
let trashAlbumList = await helper.getAlbums(albumType.SYSTEM, albumSubtype.TRASH);
let trashAlbum = await trashAlbumList.getFirstObject();
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'off14.jpg')
......@@ -644,14 +650,14 @@ export default function publicApiTestWithSystemApiTest () {
const createAsset = await helper.createAsset(testNum + '.jpg');
uri = createAsset.uri;
let count = 0;
console.log(`${testNum}: uri: ${uri}`);
await sleep(550);
helper.registerChange(uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ADD);
expect(changeData.uris[0]).assertEqual(uri);
});
await sleep(100);
await sleep(550);
let fd = await createAsset.open('rw');
await fileio.write(fd, testNum);
await createAsset.close(fd);
......@@ -683,12 +689,14 @@ export default function publicApiTestWithSystemApiTest () {
const asset = await getFileAsset(testNum, fetchOps);
uri = asset.uri;
let count= 0;
await sleep(550);
helper.registerChange(uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(uri);
});
await sleep(550);
await asset.setFavorite(true);
await sleep(1000);
......@@ -720,13 +728,14 @@ export default function publicApiTestWithSystemApiTest () {
uri = asset.uri;
await asset.setFavorite(true);
let count= 0;
await sleep(500);
await sleep(550);
helper.registerChange(uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(uri);
});
await sleep(550);
await asset.setFavorite(false);
await sleep(1000);
......@@ -765,7 +774,7 @@ export default function publicApiTestWithSystemApiTest () {
const trashFileAsset = await trashFetchResult.getFirstObject();
uri = trashFileAsset.uri;
let count= 0;
await sleep(500);
await sleep(550);
console.log(`${testNum}: uri: ${uri}`);
helper.registerChange(uri, false, async (changeData) => {
count++;
......@@ -773,8 +782,9 @@ export default function publicApiTestWithSystemApiTest () {
expect(changeData.type).assertEqual(NOTIFY_ADD);
expect(changeData.uris[0]).assertEqual(uri);
});
await sleep(550);
await trashAlbum.recoverAssets([trashFileAsset]);
await sleep(2000);
await sleep(1000);
expect(count).assertEqual(1);
done();
......@@ -813,6 +823,7 @@ export default function publicApiTestWithSystemApiTest () {
const trashFileAsset = await trashFetchResult.getFirstObject();
console.info(`${testNum} trashFileAsset.uri: ${trashFileAsset.uri}`);
let count= 0;
await sleep(550);
helper.registerChange(uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
......@@ -820,6 +831,7 @@ export default function publicApiTestWithSystemApiTest () {
expect(changeData.uris[0]).assertEqual(uri);
expect(changeData.extraUris[0]).assertEqual(trashFileAsset.uri);
});
await sleep(550);
await trashAlbum.deleteAssets([trashFileAsset]);
await sleep(1000);
......@@ -851,7 +863,7 @@ export default function publicApiTestWithSystemApiTest () {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
await sleep(550);
uri = DEFAULT_ALBUM_URI;
helper.registerChange(uri, true, async (changeData) => {
listenCount++;
......@@ -860,10 +872,10 @@ export default function publicApiTestWithSystemApiTest () {
expect(changeData.uris[0]).assertEqual(albumUri);
done();
});
await sleep(550);
await helper.deleteAlbums([album]);
await sleep(1000);
expect(listenCount).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: $${error}`);
......@@ -897,7 +909,7 @@ export default function publicApiTestWithSystemApiTest () {
let fd = await fileAsset.open('rw');
await fileAsset.close(fd);
await helper.deleteAssets([fileAsset.uri]);
await sleep(500);
await sleep(550);
uri = DEFAULT_ALBUM_URI;
helper.registerChange(uri, true, async (changeData) => {
listenCount++;
......@@ -942,6 +954,7 @@ export default function publicApiTestWithSystemApiTest () {
break;
}
});
await sleep(550);
let testCount = 0;
// 1
testCount++;
......@@ -950,34 +963,34 @@ export default function publicApiTestWithSystemApiTest () {
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
// 2
await sleep(500);
await sleep(550);
testCount++;
console.info(`${testNum} testCount: ${testCount}`);
album.albumName = Date.now() + album.albumName;
await album.commitModify();
// 3
await sleep(500);
await sleep(550);
testCount++;
console.info(`${testNum} testCount: ${testCount}`);
await album.addAssets([asset]);
// 4
await sleep(500);
await sleep(550);
testCount++;
console.info(`${testNum} testCount: ${testCount}`);
album.albumName = testNum + album.albumName;
await album.commitModify();
// 5
await sleep(500);
await sleep(550);
testCount++;
console.info(`${testNum} testCount: ${testCount}`);
await album.removeAssets([asset]);
// 6
await sleep(500);
await sleep(550);
testCount++;
console.info(`${testNum} testCount: ${testCount}`);
await helper.deleteAlbums([album]);
// 7
await sleep(500);
await sleep(550);
testCount++;
console.info(`${testNum} testCount: ${testCount}`);
let trashAlbumList = await helper.getAlbums(albumType.SYSTEM, albumSubtype.TRASH);
......@@ -1018,6 +1031,7 @@ export default function publicApiTestWithSystemApiTest () {
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on14.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let photoAssetUri = asset.uri;
await sleep(550);
uri = DEFAULT_PHOTO_URI;
helper.registerChange(uri, true, async (changeData) => {
listenCount++;
......@@ -1042,15 +1056,15 @@ export default function publicApiTestWithSystemApiTest () {
}
});
// 1
await sleep(500);
await sleep(550);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
// 2
await sleep(500);
await sleep(550);
await asset.setFavorite(true);
// 3
await sleep(500);
await sleep(550);
await asset.setFavorite(false);
await sleep(1000);
......@@ -1080,6 +1094,7 @@ export default function publicApiTestWithSystemApiTest () {
let listenCount = 0;
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on15.jpg');
let asset = await getFileAsset(testNum, fetchOps);
await sleep(550);
//notify times lessthan 32 in 500ms
let i = 0;
......@@ -1100,6 +1115,7 @@ export default function publicApiTestWithSystemApiTest () {
}
});
await sleep(550);
const endTime = Date.now() + 500;
for (let now = Date.now(); now < endTime; now = Date.now()) {
i++;
......@@ -1107,7 +1123,7 @@ export default function publicApiTestWithSystemApiTest () {
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
}
await sleep(2000);
await sleep(1000);
done();
} catch (error) {
console.log(`${testNum}: tryError: ${error}`);
......@@ -1136,22 +1152,23 @@ export default function publicApiTestWithSystemApiTest () {
let fd = await asset.open('rw');
await asset.close(fd);
let listenCount = 0;
await sleep(500);
await sleep(550);
helper.registerChange(uri, false, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(uri);
});
await sleep(550);
for (let i = 0; i < 10; i++) {
if (i % 2 == 0) {
await asset.setFavorite(true);
} else {
await asset.setFavorite(false);
}
await sleep(500);
await sleep(550);
}
await sleep(2000);
await sleep(1000);
expect(listenCount).assertEqual(10);
done();
......@@ -1184,7 +1201,7 @@ export default function publicApiTestWithSystemApiTest () {
await fileio.write(fd, buf);
await fileAsset.close(fd);
let count= 0;
await sleep(1000);
await sleep(550);
uri = fileAsset.uri;
helper.registerChange(uri, false, async (changeData) => {
count++;
......@@ -1193,6 +1210,7 @@ export default function publicApiTestWithSystemApiTest () {
expect(changeData.uris[0]).assertEqual(uri);
done();
});
await sleep(550);
fd = await fileAsset.open('rw');
buf = new ArrayBuffer(1);
buf[0] = 0;
......@@ -1200,7 +1218,6 @@ export default function publicApiTestWithSystemApiTest () {
await fileAsset.close(fd);
await sleep(1000);
expect(count).assertEqual(1);
done();
} catch (error) {
console.log(`${testNum}: tryError: $${error}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册